Exemplo n.º 1
0
  void colorIsosurface() {
    if (params.isSquared && volumeData != null) volumeData.filterData(true, Float.NaN);
    /*    if (params.isContoured && marchingSquares == null) {
          //    if (params.isContoured && !(jvxlDataIs2dContour || params.thePlane != null)) {
          Logger.error("Isosurface error: Cannot contour this type of data.");
          return;
        }
    */
    if (meshDataServer != null) {
      meshDataServer.fillMeshData(meshData, MeshData.MODE_GET_VERTICES, null);
    }

    jvxlData.saveVertexCount = 0;
    if (params.isContoured && marchingSquares != null) {
      initializeMapping();
      params.setMapRanges(this, false);
      marchingSquares.setMinMax(params.valueMappedToRed, params.valueMappedToBlue);
      jvxlData.saveVertexCount = marchingSquares.contourVertexCount;
      contourVertexCount =
          marchingSquares.generateContourData(
              jvxlDataIs2dContour, (params.isSquared ? 1e-8f : 1e-4f));
      jvxlData.contourValuesUsed = marchingSquares.getContourValues();
      minMax = marchingSquares.getMinMax();
      if (meshDataServer != null) meshDataServer.notifySurfaceGenerationCompleted();
      finalizeMapping();
    }

    applyColorScale();
    jvxlData.nContours = (params.contourFromZero ? params.nContours : -1 - params.nContours);
    jvxlData.jvxlFileMessage =
        "mapped: min = " + params.valueMappedToRed + "; max = " + params.valueMappedToBlue;
  }
Exemplo n.º 2
0
  public int getSurfacePointIndexAndFraction(
      float cutoff,
      boolean isCutoffAbsolute,
      int x,
      int y,
      int z,
      Point3i offset,
      int vA,
      int vB,
      float valueA,
      float valueB,
      Point3f pointA,
      Vector3f edgeVector,
      boolean isContourType,
      float[] fReturn) {
    float thisValue =
        getSurfacePointAndFraction(
            cutoff,
            isCutoffAbsolute,
            valueA,
            valueB,
            pointA,
            edgeVector,
            x,
            y,
            z,
            vA,
            vB,
            fReturn,
            ptTemp);
    /*
     * from MarchingCubes
     *
     * In the case of a setup for a Marching Squares calculation,
     * we are collecting just the desired type of intersection for the 2D marching
     * square contouring -- x, y, or z. In the case of a contoured f(x,y) surface,
     * we take every point.
     *
     */

    if (marchingSquares != null && params.isContoured)
      return marchingSquares.addContourVertex(ptTemp, cutoff);
    int assocVertex =
        (assocCutoff > 0
            ? (fReturn[0] < assocCutoff
                ? vA
                : fReturn[0] > 1 - assocCutoff ? vB : MarchingSquares.CONTOUR_POINT)
            : MarchingSquares.CONTOUR_POINT);
    if (assocVertex >= 0) assocVertex = marchingCubes.getLinearOffset(x, y, z, assocVertex);
    int n = addVertexCopy(ptTemp, thisValue, assocVertex);
    if (n >= 0 && params.iAddGridPoints) {
      marchingCubes.calcVertexPoint(x, y, z, vB, ptTemp);
      addVertexCopy(valueA < valueB ? pointA : ptTemp, Float.NaN, MarchingSquares.EDGE_POINT);
      addVertexCopy(valueA < valueB ? ptTemp : pointA, Float.NaN, MarchingSquares.EDGE_POINT);
    }
    return n;
  }
Exemplo n.º 3
0
 public int addTriangleCheck(
     int iA, int iB, int iC, int check, int check2, boolean isAbsolute, int color) {
   if (marchingSquares != null && params.isContoured) {
     if (color == 0) // from marching cubes
     return marchingSquares.addTriangle(iA, iB, iC, check, check2);
     color = 0; // from marchingSquares
   }
   return (meshDataServer != null
       ? meshDataServer.addTriangleCheck(iA, iB, iC, check, check2, isAbsolute, color)
       : isAbsolute && !MeshData.checkCutoff(iA, iB, iC, meshData.vertexValues)
           ? -1
           : meshData.addTriangleCheck(iA, iB, iC, check, check2, color));
 }
Exemplo n.º 4
0
  private void generateSurfaceData() {
    edgeData = "";
    if (vertexDataOnly) {
      try {
        readSurfaceData(false);
      } catch (Exception e) {
        e.printStackTrace();
        Logger.error("Exception in SurfaceReader::readSurfaceData: " + e.getMessage());
      }
      return;
    }
    contourVertexCount = 0;
    int contourType = -1;
    marchingSquares = null;

    if (params.thePlane != null || params.isContoured) {
      marchingSquares =
          new MarchingSquares(
              this,
              volumeData,
              params.thePlane,
              params.contoursDiscrete,
              params.nContours,
              params.thisContour,
              params.contourFromZero);
      contourType = marchingSquares.getContourType();
      marchingSquares.setMinMax(params.valueMappedToRed, params.valueMappedToBlue);
    }
    params.contourType = contourType;
    params.isXLowToHigh = isXLowToHigh;
    marchingCubes = new MarchingCubes(this, volumeData, params, jvxlVoxelBitSet);
    String data = marchingCubes.getEdgeData();
    if (params.thePlane == null) edgeData = data;
    jvxlData.setSurfaceInfoFromBitSet(marchingCubes.getBsVoxels(), params.thePlane);
    jvxlData.jvxlExcluded = params.bsExcluded;
    if (isJvxl) edgeData = jvxlEdgeDataRead;
    postProcessVertices();
  }