Class ModelClodMesh


  • public class ModelClodMesh
    extends java.lang.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[] box
      DOCUMENT ME!
      private static int[] direction
      Java3D supports limiting the vertices to be processed by the call setValidVertexCount(int).
      private int[] m_aiConnect
      DOCUMENT ME!
      private ModelCollapseRecord[] m_akRecord
      the incremental changes representing the decimation.
      private javax.vecmath.Point3f[] m_akVertex
      the highest level of detail data.
      private int m_iCurrentRecord
      current level of detail record, 0 <= m_iCurrentRecord <= m_akRecord.length-1.
      private ModelTriangleMesh m_kMesh
      the triangle mesh corresponding to the current level of detail.
      private static float[] startLocation
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] getDirection()
      DOCUMENT ME!
      int getLOD()
      The current level of detail C with 0 <= C <= getMaximumLOD().
      int getMaximumLOD()
      The maximum level of detail supported by the mesh.
      ModelTriangleMesh getMesh()
      Accessor for the triangle mesh that corresponds to the current level of detail in the ModelClodMesh.
      static float[] getStartLocation()
      DOCUMENT ME!
      static ModelClodMesh loadCMesh​(java.io.RandomAccessFile kIn, ViewJProgressBar progress, int added, int piece)
      Load the clod mesh from a binary file.
      static ModelClodMesh loadCMesh​(java.io.RandomAccessFile kIn, javax.swing.JProgressBar pBar, int added, int piece)
      Load the clod mesh from a binary file.
      protected void print​(java.io.PrintWriter kOut)
      Internal support for 'void print (String)' and 'void print (String, ModelTriangleMesh[])'.
      void print​(java.lang.String kName)
      Save the triangle mesh to a text file.
      static void print​(java.lang.String kName, ModelClodMesh[] akComponent)
      Save an array of triangle meshes to a text file.
      protected void save​(java.io.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​(java.lang.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 <= C <= 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 Detail

      • 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 <= m_iCurrentRecord <= m_akRecord.length-1.
      • m_kMesh

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

      • 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 Detail

      • 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​(java.io.RandomAccessFile kIn,
                                              ViewJProgressBar progress,
                                              int added,
                                              int piece)
                                       throws java.io.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:
        java.io.IOException - if there is an error reading from the file
      • loadCMesh

        public static ModelClodMesh loadCMesh​(java.io.RandomAccessFile kIn,
                                              javax.swing.JProgressBar pBar,
                                              int added,
                                              int piece)
                                       throws java.io.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:
        java.io.IOException - if there is an error reading from the file
      • print

        public static void print​(java.lang.String kName,
                                 ModelClodMesh[] akComponent)
                          throws java.io.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:
        java.io.IOException - if the specified file could not be opened for writing
      • save

        public static void save​(java.lang.String kName,
                                ModelClodMesh[] akComponent,
                                boolean flip,
                                int[] direction,
                                float[] startLocation,
                                float[] box,
                                TransMatrix inverseDicomMatrix)
                         throws java.io.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:
        java.io.IOException - if there is an error writing to the file
      • getLOD

        public int getLOD()
        The current level of detail C with 0 <= C <= 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​(java.lang.String kName)
                   throws java.io.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:
        java.io.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 <= C <= 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​(java.io.PrintWriter kOut)
                      throws java.io.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:
        java.io.IOException - if there is an error writing to the file
      • save

        protected void save​(java.io.RandomAccessFile kOut,
                            boolean flip,
                            int[] direction,
                            float[] startLocation,
                            float[] box,
                            TransMatrix inverseDicomMatrix)
                     throws java.io.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:
        java.io.IOException - if there is an error writing to the file