示例#1
0
 protected void setBoundingBox(Point3f pt, float margin) {
   if (xyzMin == null) {
     xyzMin = new Point3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
     xyzMax = new Point3f(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
   }
   BoxInfo.addPoint(pt, xyzMin, xyzMax, margin);
 }
示例#2
0
  public boolean slabPolygons(Object[] slabObject, boolean allowCap) {
    if (polygonCount0 < 0) return false; // disabled for some surface types
    int slabType = ((Integer) slabObject[0]).intValue();
    if (slabType == T.none || slabType == T.brillouin) {
      if (bsSlabDisplay != null && (polygonCount0 != 0 || vertexCount0 != 0)) {
        pc = polygonCount0;
        vc = vertexCount0;
        polygonCount0 = vertexCount0 = 0;
        normixCount = (isTriangleSet ? pc : vc);
        bsSlabDisplay.setBits(0, (pc == 0 ? vc : pc));
        slabOptions = new SB().append(meshType + " slab none");
        bsSlabGhost = null;
        slabMeshType = T.none;
      }
      if (slabType == T.none) return false;
    }
    Object slabbingObject = slabObject[1];
    boolean andCap = ((Boolean) slabObject[2]).booleanValue() && !(slabType == T.brillouin);
    if (andCap && !allowCap) return false;
    Object[] colorData = (Object[]) slabObject[3];
    boolean isGhost = (colorData != null);
    if (bsSlabDisplay == null || polygonCount0 == 0 && vertexCount0 == 0) {
      polygonCount0 = pc;
      vertexCount0 = vc;
      bsSlabDisplay = BSUtil.setAll(pc == 0 ? vc : pc);
      bsSlabGhost = null;
      if (pc == 0 && vc == 0) return false;
    } else if (isMerged) {
      if (pc == 0) bsSlabDisplay.setBits(mergeVertexCount0, vc);
      else bsSlabDisplay.setBits(mergePolygonCount0, pc);
    }

    if (isGhost) {
      if (bsSlabGhost == null) bsSlabGhost = new BS();
      slabMeshType = ((Integer) colorData[0]).intValue();
      slabColix = ((Short) colorData[1]).shortValue();
      // if (C.isColixColorInherited(slabColix))
      // slabColix = C.copyColixTranslucency(slabColix, colix);
      andCap = false;
      colix = C.getColixTranslucent3(colix, false, 0);
    }

    SB sb = new SB();
    sb.append(andCap ? " cap " : " slab ");
    if (isGhost) {
      sb.append("translucent ").appendF(C.getColixTranslucencyFractional(slabColix)).append(" ");
      String s = C.getHexCode(slabColix);
      if (s != null) sb.append(s).append(" ");
      if (slabMeshType == T.mesh) sb.append("mesh ");
    }
    switch (slabType) {
      case T.brillouin:
        sb.append("brillouin");
        slabBrillouin((P3[]) slabbingObject);
        break;
      case T.decimal:
        getIntersection(
            0,
            null,
            null,
            null,
            null,
            (BS) slabbingObject,
            null,
            andCap,
            false,
            T.decimal,
            isGhost);
        break;
      case T.plane:
        P4 plane = (P4) slabbingObject;
        sb.append(Escape.eP4(plane));
        getIntersection(0, plane, null, null, null, null, null, andCap, false, T.plane, isGhost);
        break;
      case T.unitcell:
      case T.boundbox:
        P3[] box = (P3[]) slabbingObject;
        sb.append("within ").append(Escape.eAP(box));
        P4[] faces = BoxInfo.getFacesFromCriticalPoints(box);
        for (int i = 0; i < faces.length; i++) {
          getIntersection(
              0, faces[i], null, null, null, null, null, andCap, false, T.plane, isGhost);
        }
        break;
      case T.data:
        getIntersection(
            0,
            null,
            null,
            null,
            (float[]) slabbingObject,
            null,
            null,
            false,
            false,
            T.min,
            isGhost);
        break;
      case T.within:
      case T.range:
      case T.mesh:
        Object[] o = (Object[]) slabbingObject;
        float distance = ((Float) o[0]).floatValue();
        switch (slabType) {
          case T.within:
            P3[] points = (P3[]) o[1];
            BS bs = (BS) o[2];
            sb.append("within ")
                .appendF(distance)
                .append(bs == null ? Escape.e(points) : Escape.e(bs));
            getIntersection(
                distance,
                null,
                points,
                null,
                null,
                null,
                null,
                andCap,
                false,
                (distance > 0 ? T.distance : T.sphere),
                isGhost);
            break;
          case T.range:
            // isosurface slab within range x.x y.y
            // if y.y < x.x then this effectively means "NOT within range y.y x.x"
            if (vvs == null) return false;
            float distanceMax = ((Float) o[1]).floatValue();
            sb.append("within range ").appendF(distance).append(" ").appendF(distanceMax);
            bs = (distanceMax < distance ? BSUtil.copy(bsSlabDisplay) : null);
            getIntersection(
                distance, null, null, null, null, null, null, andCap, false, T.min, isGhost);
            BS bsA = (bs == null ? null : BSUtil.copy(bsSlabDisplay));
            BSUtil.copy2(bs, bsSlabDisplay);
            getIntersection(
                distanceMax, null, null, null, null, null, null, andCap, false, T.max, isGhost);
            if (bsA != null) bsSlabDisplay.or(bsA);
            break;
          case T.mesh:
            // NOT IMPLEMENTED
            MeshSurface mesh = (MeshSurface) o[1];
            // distance = -1;
            getIntersection(
                0,
                null,
                null,
                null,
                null,
                null,
                mesh,
                andCap,
                false,
                distance < 0 ? T.min : T.max,
                isGhost);
            // TODO: unresolved how exactly to store this in the state
            // -- must indicate exact set of triangles to slab and how!
            break;
        }
        break;
    }
    String newOptions = sb.toString();
    if (slabOptions == null) slabOptions = new SB();
    if (slabOptions.indexOf(newOptions) < 0)
      slabOptions.append(slabOptions.length() > 0 ? "; " : "").append(meshType).append(newOptions);
    return true;
  }