java.lang.Object
gov.nih.mipav.view.renderer.J3D.model.structures.ModelClodMesh

public class ModelClodMesh extends Object
A triangle mesh that represents a level surface. The mesh is stored in its highest level of detail. The mesh also has an associated sequence of collapse records that store incremental changes in the vertex quantity, the triangle quantity, and the triangle connectivity array. These records are used to dynamically change the level of detail of the mesh. The surface viewer creates a Shape3D object whose geometry can be objects generated from an ModelClodMesh object. The surface color is provided by attaching to the Shape3D object an appearance that contains a material. The vertex normals in ModelClodMesh are used by the lighting system in conjunction with the surface material to produce the surface color.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static float[]
    DOCUMENT ME!
    private static int[]
    Java3D supports limiting the vertices to be processed by the call setValidVertexCount(int).
    private int[]
    DOCUMENT ME!
    the incremental changes representing the decimation.
    private javax.vecmath.Point3f[]
    the highest level of detail data.
    private int
    current level of detail record, 0 invalid input: '<'= m_iCurrentRecord invalid input: '<'= m_akRecord.length-1.
    the triangle mesh corresponding to the current level of detail.
    private static float[]
    DOCUMENT ME!
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelClodMesh(javax.vecmath.Point3f[] akVertex, int[] aiConnect, ModelCollapseRecord[] akRecord)
    A triangle mesh whose vertices have a common vertex color and vertex normal vectors that are computed from the geometry of the mesh itself.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    DOCUMENT ME!
    int
    The current level of detail C with 0 invalid input: '<'= C invalid input: '<'= getMaximumLOD().
    int
    The maximum level of detail supported by the mesh.
    Accessor for the triangle mesh that corresponds to the current level of detail in the ModelClodMesh.
    static float[]
    DOCUMENT ME!
    loadCMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int piece)
    Load the clod mesh from a binary file.
    loadCMesh(RandomAccessFile kIn, JProgressBar pBar, int added, int piece)
    Load the clod mesh from a binary file.
    protected void
    Internal support for 'void print (String)' and 'void print (String, ModelTriangleMesh[])'.
    void
    print(String kName)
    Save the triangle mesh to a text file.
    static void
    print(String kName, ModelClodMesh[] akComponent)
    Save an array of triangle meshes to a text file.
    protected void
    save(RandomAccessFile kOut, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
    Internal support for 'void save (String)' and 'void save (String, ModelTriangleMesh[])'.
    static void
    save(String kName, ModelClodMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix)
    Save an array of triangle meshes to a binary file.
    void
    setLOD(int iLOD)
    Set the current level of detail to C with 0 invalid input: '<'= C invalid input: '<'= getMaximumLOD().
    void
    setVerticies(javax.vecmath.Point3f[] verticies)
    Accessor to reset the verticies associated with this clod.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • direction

      private static int[] direction
      Java3D supports limiting the vertices to be processed by the call setValidVertexCount(int). However, there is no equivalent call that supports limiting the triangles [setValidIndexCount(int) is needed]. The dynamic edge collapse partially depends on changing the number of active triangles. Since this is not supported, the setLOD(int) method is designed to create an ModelTriangleMesh object on each change. Not very efficient. Better would be to just allow us to change the valid index count.
    • startLocation

      private static float[] startLocation
      DOCUMENT ME!
    • box

      private static float[] box
      DOCUMENT ME!
    • m_aiConnect

      private int[] m_aiConnect
      DOCUMENT ME!
    • m_akRecord

      private ModelCollapseRecord[] m_akRecord
      the incremental changes representing the decimation.
    • m_akVertex

      private javax.vecmath.Point3f[] m_akVertex
      the highest level of detail data.
    • m_iCurrentRecord

      private int m_iCurrentRecord
      current level of detail record, 0 invalid input: '<'= m_iCurrentRecord invalid input: '<'= m_akRecord.length-1.
    • m_kMesh

      private ModelTriangleMesh m_kMesh
      the triangle mesh corresponding to the current level of detail.
  • Constructor Details

    • ModelClodMesh

      public ModelClodMesh(javax.vecmath.Point3f[] akVertex, int[] aiConnect, ModelCollapseRecord[] akRecord)
      A triangle mesh whose vertices have a common vertex color and vertex normal vectors that are computed from the geometry of the mesh itself. The collapse records form a sequence of incremental changes that are used to dynamically change the level of detail by incrementing or decrementing vertex and triangle quantities.
      Parameters:
      akVertex - Array of vertices in the mesh.
      aiConnect - Connectivity array for the triangles. Each triple of indices represents one triangle. The triangle is counterclockwise ordered as viewed by an observer outside the mesh.
      akRecord - Array of collapse records that are computed by ModelSurfaceDecimator.
  • Method Details

    • getDirection

      public static int[] getDirection()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getStartLocation

      public static float[] getStartLocation()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • loadCMesh

      public static ModelClodMesh loadCMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int piece) throws IOException
      Load the clod mesh from a binary file. The caller must have already opened the file and read the mesh type (0 = ModelTriangleMesh, 1 = ModelClodMesh) and the number of meshes in the file. The caller then calls this function for each mesh. The format for a mesh is
             int vCount;  // number of vertices
             Point3f vertices[vCount];
             Point3f normals[vCount];
             int iCount;  // number of indices in the connectivity array
             int indices[iCount];
             int rCount;
             ModelCollapseRecord collapses[rCount];
       
      with 4-byte quantities stored in Big Endian format.
      Parameters:
      kIn - the file from which the triangle mesh is loaded
      progress - DOCUMENT ME!
      added - param piece
      piece - DOCUMENT ME!
      Returns:
      the loaded triangle mesh
      Throws:
      IOException - if there is an error reading from the file
    • loadCMesh

      public static ModelClodMesh loadCMesh(RandomAccessFile kIn, JProgressBar pBar, int added, int piece) throws IOException
      Load the clod mesh from a binary file. The caller must have already opened the file and read the mesh type (0 = ModelTriangleMesh, 1 = ModelClodMesh) and the number of meshes in the file. The caller then calls this function for each mesh. The format for a mesh is
             int vCount;  // number of vertices
             Point3f vertices[vCount];
             Point3f normals[vCount];
             int iCount;  // number of indices in the connectivity array
             int indices[iCount];
             int rCount;
             ModelCollapseRecord collapses[rCount];
       
      with 4-byte quantities stored in Big Endian format.
      Parameters:
      kIn - the file from which the triangle mesh is loaded
      pBar - DOCUMENT ME!
      added - DOCUMENT ME!
      piece - DOCUMENT ME!
      Returns:
      the loaded triangle mesh
      Throws:
      IOException - if there is an error reading from the file
    • print

      public static void print(String kName, ModelClodMesh[] akComponent) throws IOException
      Save an array of triangle meshes to a text file. The format for the file is
             int type;  // 0 = ModelTriangleMesh, 1 = ModelClodMesh
             int aCount;  // number of array elements
             array of 'aCount' meshes, each of the form:
             int vCount;  // number of vertices
             vertex[0].x vertex[0].y vertex[0].z;
             :
             normal[0].x normal[0].y normal[0].z;
             :
             int tCount;  // number of triangles
             index[0] index[1] index[2]
             :
             index[3*(tCount-1)] index[3*(tCount-1)+1] index[3*(tCount-1)+2]
       
      Parameters:
      kName - the name of the file to which the components are saved
      akComponent - the array of mesh components to save
      Throws:
      IOException - if the specified file could not be opened for writing
    • save

      public static void save(String kName, ModelClodMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) throws IOException
      Save an array of triangle meshes to a binary file. The format for the file is
             int type;  // 0 = ModelTriangleMesh, 1 = ModelClodMesh
             int aCount;  // number of array elements
             array of 'aCount' meshes, each of the form:
             int vCount;  // number of vertices
             Point3f vertices[vCount];
             Point3f normals[vCount];
             int iCount;  // number of indices in the connectivity array
             int indices[iCount];
       
      with 4-byte quantities stored in Big Endian format.
      Parameters:
      kName - the name of the file to which the components are saved
      akComponent - the array of mesh components to be saved
      flip - if the y axis should be flipped - true in extract and in save of JDialogSurface To have proper orientations in surface file if flip is true flip y and z on reading.
      direction - 1 or -1 for each axis
      startLocation - DOCUMENT ME!
      box - (dim-1)*res
      inverseDicomMatrix -
      Throws:
      IOException - if there is an error writing to the file
    • getLOD

      public int getLOD()
      The current level of detail C with 0 invalid input: '<'= C invalid input: '<'= getMaximumLOD().
      Returns:
      DOCUMENT ME!
    • getMaximumLOD

      public int getMaximumLOD()
      The maximum level of detail supported by the mesh. The minimum level of detail is always zero (the first collapse record).
      Returns:
      DOCUMENT ME!
    • getMesh

      public ModelTriangleMesh getMesh()
      Accessor for the triangle mesh that corresponds to the current level of detail in the ModelClodMesh.
      Returns:
      the triangle mesh managed by the clod mesh
    • print

      public void print(String kName) throws IOException
      Save the triangle mesh to a text file. The format for the file is
             int type;  // 0 = ModelTriangleMesh, 1 = ModelClodMesh
             int aCount;  // 1, write the entire mesh as a single component
             int vCount;  // number of vertices
             vertex[0].x vertex[0].y vertex[0].z;
             :
             normal[0].x normal[0].y normal[0].z;
             :
             int tCount;  // number of triangles
             index[0] index[1] index[2]
             :
             index[3*(tCount-1)] index[3*(tCount-1)+1] index[3*(tCount-1)+2]
       
      Parameters:
      kName - the name of file to which the triangle mesh is saved
      Throws:
      IOException - if the specified file could not be opened for writing
    • setLOD

      public void setLOD(int iLOD)
      Set the current level of detail to C with 0 invalid input: '<'= C invalid input: '<'= getMaximumLOD().
      Parameters:
      iLOD - the desired index of the active collapse record
    • setVerticies

      public void setVerticies(javax.vecmath.Point3f[] verticies)
      Accessor to reset the verticies associated with this clod. Used for smoothing.
      Parameters:
      verticies - New vertices for clod mesh.
    • print

      protected void print(PrintWriter kOut) throws IOException
      Internal support for 'void print (String)' and 'void print (String, ModelTriangleMesh[])'. ModelTriangleMesh uses this function to print vertices, normals, and connectivity indices to the file. ModelClodMesh overrides this to additionally print collapse records to the file in the form:
             int rCount;  // number of collapse records
             r[0].keep r[0].throw r[0].vCount r[0].tcount r[0].iCount indices...
             :
       
      Parameters:
      kOut - the file to which the clod mesh is saved
      Throws:
      IOException - if there is an error writing to the file
    • save

      protected void save(RandomAccessFile kOut, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) throws IOException
      Internal support for 'void save (String)' and 'void save (String, ModelTriangleMesh[])'. ModelTriangleMesh uses this function to write vertices, normals, and connectivity indices to the file. ModelClodMesh overrides this to additionally write collapse records to the file in the form:
             int rCount;
             ModelCollapseRecord collapses[rCount];
       
      with 4-byte quantities stored in Big Endian format.
      Parameters:
      kOut - the file to which the clod mesh is saved
      flip - if the y axis should be flipped - true in extract and in save of JDialogSurface To have proper orientations in surface file if flip is true flip y and z on reading.
      direction - 1 or -1 for each axis
      startLocation - DOCUMENT ME!
      box - (dim-1)*res
      inverseDicomMatrix - DOCUMENT ME!
      Throws:
      IOException - if there is an error writing to the file