예제 #1
0
 @Override
 protected BS getVoxelBitSet(int nPoints) throws Exception {
   if (bsVoxelBitSet != null) return bsVoxelBitSet;
   BS bs = new BS();
   int bsVoxelPtr = 0;
   if (surfaceDataCount <= 0) return bs; // unnecessary -- probably a plane or color density
   int nThisValue = 0;
   while (bsVoxelPtr < nPoints) {
     nThisValue = parseInt();
     if (nThisValue == Integer.MIN_VALUE) {
       readLine();
       // note -- does not allow for empty lines;
       // must be a continuous block of numbers.
       if (line == null || (nThisValue = parseIntStr(line)) == Integer.MIN_VALUE) {
         if (!endOfData) Logger.error("end of file in JvxlReader?" + " line=" + line);
         endOfData = true;
         nThisValue = 10000;
         // throw new NullPointerException();
       }
     }
     thisInside = !thisInside;
     ++jvxlNSurfaceInts;
     if (thisInside) bs.setBits(bsVoxelPtr, bsVoxelPtr + nThisValue);
     bsVoxelPtr += nThisValue;
   }
   return bs;
 }
예제 #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;
  }