Class ModelTriangleMesh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA representation of an edge for the vertex-edge-triangle table.classDOCUMENT ME! -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static float[]DOCUMENT ME!protected double[][]support for vtkprivate HashSet[]used in smoothing.private static int[]DOCUMENT ME!(package private) IntegerDOCUMENT ME!(package private) float[]DOCUMENT ME!(package private) ModelTriangleMesh.UnorderedSetInt[]DOCUMENT ME!(package private) javax.vecmath.Vector3f[]DOCUMENT ME!(package private) javax.vecmath.Vector3f[]DOCUMENT ME!(package private) javax.vecmath.Vector3f[]DOCUMENT ME!(package private) javax.vecmath.Vector3f[]DOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!private floatstore the mesh transparency:private javax.vecmath.Color4f[]Store the mesh colors:private javax.vecmath.Vector3fDOCUMENT ME!private javax.vecmath.Vector3fDOCUMENT ME!(package private) HashMapDOCUMENT ME!private ObjectThe ModelClodMesh object that generated the ModelTriangleMesh object, null otherwise.private javax.media.j3d.Materialstore the Material properties of the mesh:private javax.vecmath.Vector3fDOCUMENT ME!private javax.vecmath.Point3ftemporary variables to avoid 'new' calls.private javax.vecmath.Point3ftemporary variables to avoid 'new' calls.private javax.vecmath.Point3ftemporary variables to avoid 'new' calls.private javax.vecmath.Point3ftemporary variables to avoid 'new' calls.private javax.vecmath.Color4f[]Per vertex color array, which store the color data saved in .sur file.private static float[]DOCUMENT ME!protected double[][]support for vtkFields inherited from class javax.media.j3d.IndexedGeometryArray
ALLOW_COLOR_INDEX_READ, ALLOW_COLOR_INDEX_WRITE, ALLOW_COORDINATE_INDEX_READ, ALLOW_COORDINATE_INDEX_WRITE, ALLOW_NORMAL_INDEX_READ, ALLOW_NORMAL_INDEX_WRITE, ALLOW_TEXCOORD_INDEX_READ, ALLOW_TEXCOORD_INDEX_WRITE, ALLOW_VERTEX_ATTR_INDEX_READ, ALLOW_VERTEX_ATTR_INDEX_WRITEFields inherited from class javax.media.j3d.GeometryArray
ALLOW_COLOR_READ, ALLOW_COLOR_WRITE, ALLOW_COORDINATE_READ, ALLOW_COORDINATE_WRITE, ALLOW_COUNT_READ, ALLOW_COUNT_WRITE, ALLOW_FORMAT_READ, ALLOW_NORMAL_READ, ALLOW_NORMAL_WRITE, ALLOW_REF_DATA_READ, ALLOW_REF_DATA_WRITE, ALLOW_TEXCOORD_READ, ALLOW_TEXCOORD_WRITE, ALLOW_VERTEX_ATTR_READ, ALLOW_VERTEX_ATTR_WRITE, BY_REFERENCE, BY_REFERENCE_INDICES, COLOR_3, COLOR_4, COORDINATES, INTERLEAVED, NORMALS, TEXTURE_COORDINATE_2, TEXTURE_COORDINATE_3, TEXTURE_COORDINATE_4, USE_COORD_INDEX_ONLY, USE_NIO_BUFFER, VERTEX_ATTRIBUTESFields inherited from class javax.media.j3d.Geometry
ALLOW_INTERSECT -
Constructor Summary
ConstructorsConstructorDescriptionCopies a ModelTriangleMesh by copying it's components.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, int[] aiConnect) A triangle mesh whose vertex normal vectors are computed from the geometry of the mesh itself.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, int[] aiConnect, javax.vecmath.Color4f[] vertexColor) A triangle mesh whose vertex normal vectors have been precomputed.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, javax.vecmath.TexCoord3f[] akTexCoord, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.TexCoord3f[] akTexCoord, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.ModelTriangleMesh(WildMagic.LibFoundation.Mathematics.Vector3f[] akVertex, int[] aiConnect) A triangle mesh whose vertex normal vectors are computed from the geometry of the mesh itself. -
Method Summary
Modifier and TypeMethodDescriptionvoidaffineTransform(double[][] aafH) The input 4x4 homogeneous matrix H is assumed to multiply vectors V as H*V where V = (x,y,z,1).voidaffineTransform(float[][] afRot, float[] afTrn, float[] afScale) Rotation R is 3x3, translation T is 3x1, and scale S is 3x1.floatarea()Calculate the surface mesh area.private voidBuilds a list of cross-references, so that connections[i] contains all the verticies that are connected to vertex at i.javax.vecmath.Point3fcenter()Calculates and returns the center point of the Mesh:private voidCompute the average length of all the edges in the triangle mesh.voidA normal vector at a vertex is computed by averaging the triangle normals for all triangles sharing the vertex.private voidLet V[i] be a vertex in the triangle mesh.private voidCompute the vertex normals of the triangle mesh.double[][]javax.vecmath.Color4f[]Make a copy of the colors of a triangle mesh.voidgetColorLocal(int index, javax.vecmath.Color4f kColor) Gets the stored local color.Construct the connected components of the triangle mesh.voidConstruct the connected components of the triangle mesh.voidgetCopies(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, javax.vecmath.TexCoord3f[] akTexCoord) Copies the components of a ModelTriangleMesh into the parameters.static int[]DOCUMENT ME!Support for regenerating an ModelTriangleMesh from an ModelClodMesh whenever the level of detail is changed for the ModelClodMesh.int[]Make a copy of the connectivity array of a triangle mesh.javax.media.j3d.MaterialGets the material properties of the mesh:javax.vecmath.Vector3f[]Make a copy of the normals of a triangle mesh.javax.vecmath.Color4f[]static float[]DOCUMENT ME!javax.vecmath.TexCoord3f[]Make a copy of the texture coordinates of a triangle mesh.floatGets the mesh transparency.javax.vecmath.Point3f[]Make a copy of the vertices of a triangle mesh.WildMagic.LibFoundation.Mathematics.Vector3f[]Make a copy of the vertices of a triangle mesh.double[][]double[]getVertexData(int i) private voidinit()Initializes capabilities and temporary variables.voidInvert the mesh z-coord, reorder the triangles, and recompute the normals:static ModelTriangleMeshloadTMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean isVisible) Load the triangle mesh from a binary file.static ModelTriangleMeshloadTMesh(RandomAccessFile kIn, JProgressBar pBar, int added, int total) Load the triangle mesh from a binary file.static ModelTriangleMeshloadVRMLMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag) Load the triangle mesh from a VRML file specifically written by MIPAV!.static ModelTriangleMeshloadVTKLegacyMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag, String fileName) static ModelTriangleMeshloadVTKXMLMesh(String absPath, ViewJProgressBar progress, int added, int total, boolean flag, String fileName, String dir) static intParses the VRML to see how many surfaces there are.protected voidprint(PrintWriter kOut) Internal support for 'void print (String)' and 'void print (String, ModelTriangleMesh[])'.protected voidprintSMFAscii(PrintWriter kOut) protected voidprintSTLAscii(PrintWriter kOut) Print the STL file format in ASCII.protected voidPrint the STL file format in binary ( little endian ).protected voidsave(RandomAccessFile kOut, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix, javax.vecmath.Color4f[] perVertexColorArray) Internal support for 'void save (String)' and 'void save (String, ModelTriangleMesh[])'.voidsave(String kName, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) Save the triangle mesh to a binary file.static voidsave(String kName, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix, javax.vecmath.Color4f[][] perVertexColorArray) Save an array of triangle meshes to a binary file.voidsaveAsPlyFile(String kName) protected voidsaveAsPortableVRML(PrintWriter kOut, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format.voidsaveAsPortableVRML(PrintWriter kOut, boolean flip, int numberOfShapes, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).static voidsaveAsPortableVRML(PrintWriter kOut, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).voidsaveAsSMFAsciiFile(String kName) Sate the SMF ACII file format.voidsaveAsSTLAsciiFile(String kName) Sate the STIL ACII file format.voidsaveAsSTLBinaryFile(String kName) Sate the STIL Binary file format.voidsaveAsTextFile(String kName) Save the triangle mesh to a text file.static voidsaveAsTextFile(String kName, ModelTriangleMesh[] akComponent) Save an array of triangle meshes to a text file.protected voidsaveAsVRML(PrintWriter kOut, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format.voidsaveAsVRML(String kName, boolean flip, int numberOfShapes, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).static voidsaveAsVRML(String kName, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).voidsaveAsVTKLegacy(String kName) Saves the triangle mesh to VTK Legacy formatvoidsaveAsVTKXML(String fileName) saves thr triangle mesh to VTK XML formatprotected voidInternal support for 'void save (String)' and 'void save (String, ModelTriangleMesh[])'.voidsaveXMLHeader(String kName) voidsetCellData(double[][] cellData) voidsetColor(int index, javax.vecmath.Color4f kColor) Sets the color and stores the color update information in a local copy.voidsetColorDelay(int index, javax.vecmath.Color4f kColor) Used for fast color update while painting the triangle mesh, stores the color update information for later loading into the surface.voidUsed for fast color update while painting.voidsetGenerator(Object kGenerator) Support for regenerating an ModelTriangleMesh from an ModelClodMesh whenever the level of detail is changed for the ModelClodMesh.voidsetMaterial(javax.media.j3d.Material kMaterial) Sets the material properties of the mesh.voidsetTransparency(float transparency) Sets the mesh transparency.voidsetVertexData(double[][] data) voidsetVertexData(int i, double val) voidsetVertexData(int i, double[] array) voidsetVertexData(int i, int j, double val) voidsetVerticies(javax.vecmath.Point3f[] akVertex) Replace the verticies with a new set.voidsmoothMesh(int iteration, float alpha, boolean volumeLimit, float volumePercent, boolean pVisible) Smooth mesh.voidsmoothThree(int iteration, float lambda, float mu, boolean pVisible) Smooth mesh.voidsmoothTwo(int iterations, float m_fStiffness, boolean volumeLimit, float volumePercent, boolean pVisible) Derived from the first 2 of the 3 components of AlgorithmBrainExtraction Note that m_fStiffness does not increase and then decrease as in AlgorithmBrainExtraction but instead remains constant.private floatupdate2(int i) Compute the coefficient of the surface normal for the update of the mesh vertex V[i] in the SNormal[i] direction.private voidThe heart of the segmentation.floatvolume()Calculates volume of triangle mesh.Methods inherited from class javax.media.j3d.IndexedTriangleArray
cloneNodeComponentMethods inherited from class javax.media.j3d.IndexedGeometryArray
getColorIndex, getColorIndices, getCoordinateIndex, getCoordinateIndices, getCoordIndicesRef, getIndexCount, getInitialIndexIndex, getNormalIndex, getNormalIndices, getTextureCoordinateIndex, getTextureCoordinateIndex, getTextureCoordinateIndices, getTextureCoordinateIndices, getValidIndexCount, getVertexAttrIndex, getVertexAttrIndices, setColorIndex, setColorIndices, setCoordinateIndex, setCoordinateIndices, setCoordIndicesRef, setInitialColorIndex, setInitialCoordIndex, setInitialIndexIndex, setInitialNormalIndex, setInitialTexCoordIndex, setInitialVertexAttrIndex, setInitialVertexIndex, setNormalIndex, setNormalIndices, setTextureCoordinateIndex, setTextureCoordinateIndex, setTextureCoordinateIndices, setTextureCoordinateIndices, setValidIndexCount, setValidVertexCount, setVertexAttrIndex, setVertexAttrIndicesMethods inherited from class javax.media.j3d.GeometryArray
getColor, getColor, getColor, getColor, getColor, getColor, getColorRef3b, getColorRef3f, getColorRef4b, getColorRef4f, getColorRefBuffer, getColorRefByte, getColorRefFloat, getColors, getColors, getColors, getColors, getColors, getColors, getCoordinate, getCoordinate, getCoordinate, getCoordinate, getCoordinates, getCoordinates, getCoordinates, getCoordinates, getCoordRef3d, getCoordRef3f, getCoordRefBuffer, getCoordRefDouble, getCoordRefFloat, getInitialColorIndex, getInitialCoordIndex, getInitialNormalIndex, getInitialTexCoordIndex, getInitialVertexAttrIndex, getInitialVertexIndex, getInterleavedVertexBuffer, getInterleavedVertices, getNormal, getNormal, getNormalRef3f, getNormalRefBuffer, getNormalRefFloat, getNormals, getNormals, getTexCoordRef2f, getTexCoordRef3f, getTexCoordRefBuffer, getTexCoordRefFloat, getTexCoordSetCount, getTexCoordSetMap, getTexCoordSetMapLength, getTextureCoordinate, getTextureCoordinate, getTextureCoordinate, getTextureCoordinate, getTextureCoordinate, getTextureCoordinate, getTextureCoordinate, getTextureCoordinates, getTextureCoordinates, getTextureCoordinates, getTextureCoordinates, getTextureCoordinates, getTextureCoordinates, getTextureCoordinates, getValidVertexCount, getVertexAttr, getVertexAttr, getVertexAttr, getVertexAttr, getVertexAttrCount, getVertexAttrRefBuffer, getVertexAttrRefFloat, getVertexAttrs, getVertexAttrs, getVertexAttrs, getVertexAttrs, getVertexAttrSizes, getVertexCount, getVertexFormat, setColor, setColor, setColor, setColor, setColor, setColorRef3b, setColorRef3f, setColorRef4b, setColorRef4f, setColorRefBuffer, setColorRefByte, setColorRefFloat, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setColors, setCoordinate, setCoordinate, setCoordinate, setCoordinate, setCoordinates, setCoordinates, setCoordinates, setCoordinates, setCoordinates, setCoordinates, setCoordinates, setCoordinates, setCoordRef3d, setCoordRef3f, setCoordRefBuffer, setCoordRefDouble, setCoordRefFloat, setInterleavedVertexBuffer, setInterleavedVertices, setNormal, setNormal, setNormalRef3f, setNormalRefBuffer, setNormalRefFloat, setNormals, setNormals, setNormals, setNormals, setTexCoordRef2f, setTexCoordRef3f, setTexCoordRefBuffer, setTexCoordRefFloat, setTextureCoordinate, setTextureCoordinate, setTextureCoordinate, setTextureCoordinate, setTextureCoordinate, setTextureCoordinate, setTextureCoordinate, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setTextureCoordinates, setVertexAttr, setVertexAttr, setVertexAttr, setVertexAttr, setVertexAttrRefBuffer, setVertexAttrRefFloat, setVertexAttrs, setVertexAttrs, setVertexAttrs, setVertexAttrs, setVertexAttrs, setVertexAttrs, setVertexAttrs, setVertexAttrs, updateDataMethods inherited from class javax.media.j3d.NodeComponent
cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTreeMethods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
Field Details
-
direction
private static int[] directionDOCUMENT ME! -
startLocation
private static float[] startLocationDOCUMENT ME! -
box
private static float[] boxDOCUMENT ME! -
kInvalid
Integer kInvalidDOCUMENT ME! -
m_afCurvature
float[] m_afCurvatureDOCUMENT ME! -
m_akAdjacent
ModelTriangleMesh.UnorderedSetInt[] m_akAdjacentDOCUMENT ME! -
m_akSNormal
javax.vecmath.Vector3f[] m_akSNormalDOCUMENT ME! -
m_akSTangent
javax.vecmath.Vector3f[] m_akSTangentDOCUMENT ME! -
m_akVMean
javax.vecmath.Vector3f[] m_akVMeanDOCUMENT ME! -
m_akVNormal
javax.vecmath.Vector3f[] m_akVNormalDOCUMENT ME! -
m_fEParam
float m_fEParamDOCUMENT ME! -
m_fFParam
float m_fFParamDOCUMENT ME! -
m_fMeanEdgeLength
float m_fMeanEdgeLengthDOCUMENT ME! -
m_fStiffness
float m_fStiffnessDOCUMENT ME! -
m_kEMap
HashMap m_kEMapDOCUMENT ME! -
connections
used in smoothing. -
m_kE0
private javax.vecmath.Vector3f m_kE0DOCUMENT ME! -
m_kE1
private javax.vecmath.Vector3f m_kE1DOCUMENT ME! -
m_kN
private javax.vecmath.Vector3f m_kNDOCUMENT ME! -
m_kGenerator
The ModelClodMesh object that generated the ModelTriangleMesh object, null otherwise. -
m_kV0
private javax.vecmath.Point3f m_kV0temporary variables to avoid 'new' calls. -
m_kV1
private javax.vecmath.Point3f m_kV1temporary variables to avoid 'new' calls. -
m_kV2
private javax.vecmath.Point3f m_kV2temporary variables to avoid 'new' calls. -
m_kV3
private javax.vecmath.Point3f m_kV3temporary variables to avoid 'new' calls. -
m_kMaterial
private javax.media.j3d.Material m_kMaterialstore the Material properties of the mesh: -
m_fTransparency
private float m_fTransparencystore the mesh transparency: -
m_kColors
private javax.vecmath.Color4f[] m_kColorsStore the mesh colors: -
perVertexColor
private javax.vecmath.Color4f[] perVertexColorPer vertex color array, which store the color data saved in .sur file. -
vertexData
protected double[][] vertexDatasupport for vtk -
cellData
protected double[][] cellDatasupport for vtk
-
-
Constructor Details
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, int[] aiConnect) A triangle mesh whose vertex normal vectors are computed from the geometry of the mesh itself. The normal at a vertex is the normalized average of normals of the triangles that share the vertex.- Parameters:
akVertex- array of vertices in the meshaiConnect- 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.
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.- Parameters:
akVertex- array of vertices in the meshakNormal- array of vertex normals for the meshaiConnect- 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.
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, int[] aiConnect, javax.vecmath.Color4f[] vertexColor) A triangle mesh whose vertex normal vectors have been precomputed.- Parameters:
akVertex- array of vertices in the meshakNormal- array of vertex normals for the meshaiConnect- 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.
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.- Parameters:
akVertex- array of vertices in the meshakNormal- array of vertex normals for the meshakColor- array of vertex colorsaiConnect- 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.
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.TexCoord3f[] akTexCoord, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.- Parameters:
akVertex- array of vertices in the meshakNormal- array of vertex normals for the meshakTexCoord- array of Texture CoordinatesaiConnect- 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.akColor- array of vertex colors
-
ModelTriangleMesh
public ModelTriangleMesh(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, javax.vecmath.TexCoord3f[] akTexCoord, int[] aiConnect) A triangle mesh whose vertex normal vectors have been precomputed.- Parameters:
akVertex- array of vertices in the meshakNormal- array of vertex normals for the meshakColor- array of vertex colorsakTexCoord- array of Texture CoordinatesaiConnect- 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.
-
ModelTriangleMesh
Copies a ModelTriangleMesh by copying it's components.- Parameters:
ModelTriangleMesh- ModelTriangleMesh to copy
-
ModelTriangleMesh
public ModelTriangleMesh(WildMagic.LibFoundation.Mathematics.Vector3f[] akVertex, int[] aiConnect) A triangle mesh whose vertex normal vectors are computed from the geometry of the mesh itself. The normal at a vertex is the normalized average of normals of the triangles that share the vertex.- Parameters:
akVertex- array of vertices in the meshaiConnect- 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.
-
-
Method Details
-
init
private void init()Initializes capabilities and temporary variables. -
getPerVertexColor
public javax.vecmath.Color4f[] getPerVertexColor() -
getVertexData
public double[][] getVertexData() -
getVertexData
public double[] getVertexData(int i) -
setVertexData
public void setVertexData(double[][] data) -
setVertexData
public void setVertexData(int i, double val) -
setVertexData
public void setVertexData(int i, int j, double val) -
setVertexData
public void setVertexData(int i, double[] array) -
setCellData
public void setCellData(double[][] cellData) -
getCellData
public double[][] getCellData() -
getDirection
public static int[] getDirection()DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
getStartLocation
public static float[] getStartLocation()DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
loadTMesh
public static ModelTriangleMesh loadTMesh(RandomAccessFile kIn, JProgressBar pBar, int added, int total) throws IOException Load the triangle 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 isint 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:
kIn- the file from which the triangle mesh is loadedpBar- DOCUMENT ME!added- DOCUMENT ME!total- DOCUMENT ME!- Returns:
- the loaded triangle mesh
- Throws:
IOException- if there is an error reading from the file
-
loadTMesh
public static ModelTriangleMesh loadTMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean isVisible) throws IOException Load the triangle 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 isint 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:
kIn- the file from which the triangle mesh is loadedprogress- DOCUMENT ME!added- DOCUMENT ME!total- DOCUMENT ME!isVisible- DOCUMENT ME!- Returns:
- the loaded triangle mesh
- Throws:
IOException- if there is an error reading from the file
-
save
public static void save(String kName, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix, javax.vecmath.Color4f[][] perVertexColorArray) throws IOException Save an array of triangle meshes to a binary file. The format for the file isint 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 savedakComponent- the array of mesh components to be savedflip- if the y and z axes 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- either 1 or -1 for each axisstartLocation- DOCUMENT ME!box- (dim-1)*resinverseDicomMatrix- dicom transformperVertexColorArray- color per vertex array.- Throws:
IOException- if there is an error writing to the file
-
loadVRMLMesh
public static ModelTriangleMesh loadVRMLMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag) throws IOException Load the triangle mesh from a VRML file specifically written by MIPAV!. The caller must have already opened the file. Must be made more robust to better parse the file. It only reads VRML 2.0 that MIPAV has written.- Parameters:
kIn- the file from which the triangle mesh is loadedprogress- DOCUMENT ME!added- DOCUMENT ME!total- DOCUMENT ME!flag- DOCUMENT ME!- Returns:
- the loaded triangle mesh
- Throws:
IOException- if there is an error reading from the file
-
loadVTKLegacyMesh
public static ModelTriangleMesh loadVTKLegacyMesh(RandomAccessFile kIn, ViewJProgressBar progress, int added, int total, boolean flag, String fileName) throws IOException - Parameters:
kIn-progress-added-total-flag-- Returns:
- Throws:
IOException
-
loadVTKXMLMesh
public static ModelTriangleMesh loadVTKXMLMesh(String absPath, ViewJProgressBar progress, int added, int total, boolean flag, String fileName, String dir) throws IOException - Parameters:
progress-added-total-flag-fileName-kIn-- Returns:
- Throws:
IOException
-
parseVRMLMesh
Parses the VRML to see how many surfaces there are.- Parameters:
kIn- the file to parse- Returns:
- DOCUMENT ME!
- Throws:
IOException- DOCUMENT ME!NoSuchElementException- DOCUMENT ME!
-
saveAsPortableVRML
public static void saveAsPortableVRML(PrintWriter kOut, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).- Parameters:
kOut- the name of file to which the triangle mesh is savedakComponent- DOCUMENT ME!flip- if the y and z axes 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 axisstartLocation- DOCUMENT ME!box- (dim-1)*resolutioncolor- DOCUMENT ME!- Throws:
IOException- if the specified file could not be opened for writing
-
saveAsTextFile
Save an array of triangle meshes to a text file. The format for the file isint 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 savedakComponent- the array of mesh components to save- Throws:
IOException- if the specified file could not be opened for writing
-
saveAsVRML
public static void saveAsVRML(String kName, ModelTriangleMesh[] akComponent, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).- Parameters:
kName- the name of file to which the triangle mesh is savedakComponent- DOCUMENT ME!flip- if the y and z axes 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. param direction 1 or -1 for each axis param startLocation param box (dim-1)*resolutiondirection- DOCUMENT ME!startLocation- DOCUMENT ME!box- DOCUMENT ME!color- DOCUMENT ME!- Throws:
IOException- if the specified file could not be opened for writing
-
affineTransform
public void affineTransform(double[][] aafH) The input 4x4 homogeneous matrix H is assumed to multiply vectors V as H*V where V = (x,y,z,1). Let the upper left 3x3 block of H be A. Let the upper right 3x1 block of H be B. The last row is [0 0 0 1]. Let the upper 3x1 block of V be X. The lower 1x1 block is 1. The product H*V = A*X + B.- Parameters:
aafH- Affine transformation matrix.
-
affineTransform
public void affineTransform(float[][] afRot, float[] afTrn, float[] afScale) Rotation R is 3x3, translation T is 3x1, and scale S is 3x1. The product with 3x1 vector X is Diag(S)*R*X + T where Diag(S) is the diagonal matrix whose diagonal entries are the values of S. As a homogeneous matrix (see notation above), A = diag(S)*R and B = T.- Parameters:
afRot- Affine rotation matrix.afTrn- Affine translation matrix.afScale- Affine scale matrix.
-
area
public float area()Calculate the surface mesh area. Each surface mesh is composed of triangles. Calculate the surface area from the summation of the each triangle area. Based on the Area by Stokes' Theorem. Area(S) = 1/2 * Normal dot ( Sum from i = 0 to n-1 of ( V1 cross V2) ) ==> Area(S) = 1/2 * ( Sum from i = 0 to n-1 of ( Normal dot ( V1 cross V2) ) )- Returns:
- float
-
center
public javax.vecmath.Point3f center()Calculates and returns the center point of the Mesh:- Returns:
- DOCUMENT ME!
-
computeNormals
public void computeNormals()A normal vector at a vertex is computed by averaging the triangle normals for all triangles sharing the vertex. This routine computes all vertex normals. -
getComponents
Construct the connected components of the triangle mesh.- Returns:
- An array of connected components of the triangle mesh. Each component has its own vertex and connectivity index arrays.
-
getConsistentComponents
public void getConsistentComponents()Construct the connected components of the triangle mesh. -
getGenerator
Support for regenerating an ModelTriangleMesh from an ModelClodMesh whenever the level of detail is changed for the ModelClodMesh. If the mesh was generated from an ModelClodMesh, the generator member refers to that ModelClodMesh object. If the mesh was not generated from an ModelClodMesh, the generator member is null.- Returns:
- the generator of this mesh
-
getIndexCopy
public int[] getIndexCopy()Make a copy of the connectivity array of a triangle mesh.- Returns:
- A copy of the array of connectivity indices of the triangle mesh.
-
getNormalCopy
public javax.vecmath.Vector3f[] getNormalCopy()Make a copy of the normals of a triangle mesh.- Returns:
- A copy of the array of normals of the triangle mesh.
-
getVertexCopy
public javax.vecmath.Point3f[] getVertexCopy()Make a copy of the vertices of a triangle mesh.- Returns:
- A copy of the array of vertices of the triangle mesh.
-
getVertexCopyAsVector3f
public WildMagic.LibFoundation.Mathematics.Vector3f[] getVertexCopyAsVector3f()Make a copy of the vertices of a triangle mesh.- Returns:
- A copy of the array of vertices of the triangle mesh.
-
getColorCopy
public javax.vecmath.Color4f[] getColorCopy()Make a copy of the colors of a triangle mesh.- Returns:
- A copy of the array of colors of the triangle mesh.
-
getCopies
public void getCopies(javax.vecmath.Point3f[] akVertex, javax.vecmath.Vector3f[] akNormal, javax.vecmath.Color4f[] akColor, javax.vecmath.TexCoord3f[] akTexCoord) Copies the components of a ModelTriangleMesh into the parameters. More efficient than copying the components individually.- Parameters:
akVertex- the array of coordinates to copy into.akNormal- the array of normals to copy into.akColor- the array of colors to copy into.akTexCoord- the array of texture coordinates to copy into.
-
getTexCoordCopy
public javax.vecmath.TexCoord3f[] getTexCoordCopy()Make a copy of the texture coordinates of a triangle mesh.- Returns:
- A copy of the array of texture coordinates of the triangle mesh.
-
setColorDelay
public void setColorDelay(int index, javax.vecmath.Color4f kColor) Used for fast color update while painting the triangle mesh, stores the color update information for later loading into the surface.- Parameters:
index- the vertex index to set the color forkColor- the new color
-
setColor
public void setColor(int index, javax.vecmath.Color4f kColor) Sets the color and stores the color update information in a local copy.- Overrides:
setColorin classjavax.media.j3d.GeometryArray- Parameters:
index- the vertex index to set the color forkColor- the new color
-
getColorLocal
public void getColorLocal(int index, javax.vecmath.Color4f kColor) Gets the stored local color.- Parameters:
index- the vertex index to get the color for.kColor- the stored local color.
-
setColorUpdate
public void setColorUpdate()Used for fast color update while painting. After paint operations, set the color of the triangle mesh with the stored colors. -
save
public void save(String kName, boolean flip, int[] direction, float[] startLocation, float[] box, TransMatrix inverseDicomMatrix) throws IOException Save the triangle mesh to a binary file. The format for the file isint type; // 0 = ModelTriangleMesh, 1 = ModelClodMesh int aCount; // 1, write the entire mesh as a single component 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 triangle mesh is savedflip- if the y and z axes 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- equal 1 or -1 for each axisstartLocation- DOCUMENT ME!box- (dim-1)*resinverseDicomMatrix- DOCUMENT ME!- Throws:
IOException- if the specified file could not be opened for writing
-
saveXMLHeader
-
saveAsPortableVRML
public void saveAsPortableVRML(PrintWriter kOut, boolean flip, int numberOfShapes, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).- Parameters:
kOut- the name of file to which the triangle mesh is savedflip- if the y and z axes 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.numberOfShapes- DOCUMENT ME!direction- 1 or -1 for each axisstartLocation- DOCUMENT ME!box- (dimension-1)*resolutioncolor- DOCUMENT ME!- Throws:
IOException- if the specified file could not be opened for writing
-
saveAsVTKLegacy
Saves the triangle mesh to VTK Legacy format- Parameters:
kName-- Throws:
IOException
-
saveAsVTKXML
saves thr triangle mesh to VTK XML format- Parameters:
kName-- Throws:
IOException
-
saveAsTextFile
Save the triangle mesh to a text file. The format for the file isint type; // 0 = ModelTriangleMesh, 1 = ModelClodMesh, 2 = ModelQuadMesh 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
-
saveAsPlyFile
- Throws:
IOException
-
saveAsSMFAsciiFile
Sate the SMF ACII file format.- Parameters:
kName- file name- Throws:
IOException
-
saveAsSTLAsciiFile
Sate the STIL ACII file format.- Parameters:
kName- file name- Throws:
IOException
-
saveAsSTLBinaryFile
Sate the STIL Binary file format.- Parameters:
kName- file name- Throws:
IOException
-
saveAsVRML
public void saveAsVRML(String kName, boolean flip, int numberOfShapes, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format (text format).- Parameters:
kName- the name of file to which the triangle mesh is savedflip- if the y and z axes 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.numberOfShapes- DOCUMENT ME!direction- 1 or -1 for each axisstartLocation- DOCUMENT ME!box- (dimension-1)*resolutioncolor- DOCUMENT ME!- Throws:
IOException- if the specified file could not be opened for writing
-
setGenerator
Support for regenerating an ModelTriangleMesh from an ModelClodMesh whenever the level of detail is changed for the ModelClodMesh. If the mesh was generated from an ModelClodMesh, the generator member refers to that ModelClodMesh object. If the mesh was not generated from an ModelClodMesh, the generator member is null.- Parameters:
kGenerator- the generator of this mesh
-
setVerticies
public void setVerticies(javax.vecmath.Point3f[] akVertex) Replace the verticies with a new set.- Parameters:
akVertex- DOCUMENT ME!
-
smoothMesh
public void smoothMesh(int iteration, float alpha, boolean volumeLimit, float volumePercent, boolean pVisible) Smooth mesh. The formula can be found in "The Visualization Toolkit" by Will Schoeder, Ken Martin, and Bill Lorensen, p. 389. Mesh smoothing moves the verticies of the mesh closer to an average of the points. Each point is moved so that it is the average of the points around it. The formula is:xi+1 = xi + (alpha * (Sum from j=0 to n of {xj - xi}))where xi+1 is the new point, xi is the orginal point, and the xjs are points that are connected to xi. Alpha is some smoothing factor between .01 and .10. This formula is run for a number of iterations to obtain a smooth mesh. Usually the iterations will be between 50 and 100.- Parameters:
iteration- Number of times to run smoothing formula on data set.alpha- Smoothing factor.volumeLimit- if true stop iterations when the present volume is volumePercent or more different from the initialvolumePercent- percentage from initial volume for stopping iterationspVisible- if true display progress bar
-
smoothThree
public void smoothThree(int iteration, float lambda, float mu, boolean pVisible) Smooth mesh. This method smoothes without shrinking by 2 Gaussian smoothing steps. First, a Gaussian smoothing is performed with a positive scale factor lambda. Second, a Gaussian smoothing is performed with a negative scale factor mu, which is greater in magnitude than lambda. To produce a significant smoothing, these steps must be repeated a number of times. 3 references for this smoothing: 1.) Curve and Surface Smoothing Without Shrinkage by Gabriel Taubin, Technical Report RC-19536, IBM Research, April, 1994. (also in Proceedings, Fifth International Conference on Computer Vision, pages 852-857, June, 1995). 2.) A Signal Processing Approach to Fair Surface Design by Gabriel Taubin, Computer Graphics, pages 351-358, August, 1995 (Proceedings SIGGRAPH '95). 3.) Optimal Surface Smoothing as Filter Design by Gabriel Taubin, Tong Zhang, and Gene Golub, IBM Research Report RC-20404 (#90237). Usually the iterations will be between 30 and 100.- Parameters:
iteration- Number of times to run smoothing formula on data set.lambda- positive scale factormu- negative scale factorpVisible- if true display progress bar Require: 0 invalid input: '<' lambda invalid input: '<' -mu (1/lambda) + (1/mu) invalid input: '<' 2
-
smoothTwo
public void smoothTwo(int iterations, float m_fStiffness, boolean volumeLimit, float volumePercent, boolean pVisible) Derived from the first 2 of the 3 components of AlgorithmBrainExtraction Note that m_fStiffness does not increase and then decrease as in AlgorithmBrainExtraction but instead remains constant. This is because the change in m_fStiffness only applies to the third component of AlgorithmBrainExtraction which uses image intensities.- Parameters:
iterations- DOCUMENT ME!m_fStiffness- DOCUMENT ME!volumeLimit- if true stop iterations when the present volume is volumePercent or more different from the initialvolumePercent- percentage from initial volume for stopping iterationspVisible- if true display progress bar
-
volume
public float volume()Calculates volume of triangle mesh. The mesh consists of triangle faces and encloses a bounded region. Face j, 0 invalid input: '<'= j invalid input: '<'= n-1 has verticies P0, P1, and P2. The order of the verticies is counterclockwise as you view the face from outside the bounded region. The mesh is closed and manifold in the sense that each edge is shared by exactly two triangles. The volume of the bounded region is:
V = 1/6 (Sum from j=0 to n-1 of {P0 dot P1 cross P2})The terms of the summation can be positive, negative, or zero. The term is positive if the face is counterclockwise when viewed from the zero vector, or zero if the face appears to be a line segment when viewed from the zero vector. NOTICE THAT THERE ARE 2 DIFFERENT DEFINITIONS OF COUNTERCLOCKWISE, COUNTERCLOCKWISE AS VIEWED FROM OUTSIDE THE BOUNDED REGION AND COUNTERCLOCKWISE AS VIEWED FROM THE ZERO VECTOR.A 3D image on a rectangular lattice contains points (i0, i1, i2) where 0 invalid input: '<'= ik invalid input: '<' Bk for specified dimension bounds Bk. These are just indicies. The actual physical measurements are provided by scaling factors Dk > 0. For example, a 256x256x256 MRI has B0 = B1 = B2 = 256. If each voxel is 1 mm in x, 1 mm in y, and 5 mm in z, then D0 = D1 = 1 and D2 = 5. The 3D image encloses a rectangular region [0,C0] x [0,C1] x [0,C2] in physical space where Ck = Dk*Bk. In the example, C0 = D0*B0 = 256 mm in x, C1 = D1*B1 = 256 mm in y, and C2 = D2*B2 = 1280 mm in z. Volume calculations are required to use physical measurements. In the example, volume will be in cubic millimeters.
The surface extraction is performed by mapping [0,C0] x [0,C1] x [0,C2] into [-1,1] x [-1,1] x [-1,1] using uniform scaling. This is done to keep the floating point values within order 1 to avoid the floating point errors that occur if you were to use the index values themselves. The topology of a level surface is invariant under any scaling (not just uniform), but the continuous level of detail algorithm for triangle decimation does edge collapses based on various geometric measurements of the mesh representing the level surface. The geometric measurements are not invariant under nonuniform scaling. Map the image into a cube using uniform scaling so that the triangle collapse order is invariant. The uniform scaling is done so that the largest image dimension [0,M] is mapped to [-1,1]. The other ranges are mapped to intervals of the form [-L,L) where L invalid input: '<' 1. If (i0,i1,i2) is in [0,B0) x [0,B1) x [0,B2), the corresponding (x0,x1,x2) in [-1,1) is:
2*Dk*ik - Ck xk = ------------ max{C0,C1,C2}However, we want to map from [0,Bk) to an inclusive interval [-Rk,Rk], where 0 invalid input: '<' Rk invalid input: '<' 1 and Rk = 1 - Dk/max{C0,C1,C2}. This ensures that surfaces begin in the center of a voxel rather than at the (0,0,0) corner of the voxel. The problem is easiest to see in the Z direction: a surface that should cover the full Z range will end before the last slice. Therefore, the formula should be:
2*Dk*ik - Ck + Dk xk = ----------------- max{C0,C1,C2}Once a closed manifold triangle mesh is extracted, the problem is now to compute its volume in physical space. Note that ik are indicies in the original image, but the true physical length that is measured (relative to other index locations) is yk = Dk*ik. Any triangle mesh (x0,x1,x2) must be mapped to (y0,y1,y2) before the volume calculation. The mapping is:
max{C0,C1,C2}*xk + Ck - Dk yk = -------------------------- 2The volume calculations use the previously mentioned formula where the P points are the (y0,y1,y2) values.
- Returns:
- The volume of the surface.
-
print
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- Parameters:
kOut- the file to which the triangle mesh is saved- Throws:
IOException- if there is an error writing to the file
-
printSMFAscii
- Throws:
IOException
-
printSTLAscii
Print the STL file format in ASCII. STLA Examples: solid MYSOLID facet normal 0.4 0.4 0.2 outerloop vertex 1.0 2.1 3.2 vertex 2.1 3.7 4.5 vertex 3.1 4.5 6.7 endloop endfacet ... facet normal 0.2 0.2 0.4 outerloop vertex 2.0 2.3 3.4 vertex 3.1 3.2 6.5 vertex 4.1 5.5 9.0 endloop endfacet endsolid MYSOLID- Parameters:
kOut-- Throws:
IOException
-
printSTLBinary
Print the STL file format in binary ( little endian ). STLB Example: 80 byte string = header containing nothing in particular 4 byte int = number of faces For each face: 3 4-byte floats = components of normal vector to face; 3 4-byte floats = coordinates of first node; 3 4-byte floats = coordinates of second node; 3 4-byte floats = coordinates of third and final node; 2-byte int = attribute, whose value is 0.- Parameters:
kOut- binary file output- Throws:
IOException
-
saveAsXML
Internal support for 'void save (String)' and 'void save (String, ModelTriangleMesh[])'. ModelTriangleMesh uses this function to write vertices, normals, and connectivity indices to the XML file. ModelClodMesh overrides this to additionally write collapse records to the file- Parameters:
fileName- the file to which the triangle mesh is saveddirection- either 1 or -1 for each axisstartLocation- image origin coordinatebox- (dim-1)*res- 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, javax.vecmath.Color4f[] perVertexColorArray) 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- Parameters:
kOut- the file to which the triangle mesh is savedflip- if the y and z axes should be flipped - true in extraction algorithms and in JDialogSurface. To have proper orientations in surface file if flip is true flip y and z on reading.direction- either 1 or -1 for each axisstartLocation- DOCUMENT ME!box- (dim-1)*resperVertexColorArray- color per vertex array.inverseDicomArray- DOCUMENT ME!- Throws:
IOException- if there is an error writing to the file
-
saveAsPortableVRML
protected void saveAsPortableVRML(PrintWriter kOut, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format. File name should end with ".wrl"- Parameters:
kOut- the file to which the triangle mesh is savedflip- if the y and z axes 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 axisstartLocation- DOCUMENT ME!box- (dimension-1)*resolutioncolor- DOCUMENT ME!- Throws:
IOException- if there is an error writing to the file
-
saveAsVRML
protected void saveAsVRML(PrintWriter kOut, boolean flip, int[] direction, float[] startLocation, float[] box, javax.vecmath.Color3f color) throws IOException Saves the triangle mesh in VRML97 (VRML 2.0) format. File name should end with ".wrl"- Parameters:
kOut- the file to which the triangle mesh is savedflip- if the y and z axes 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 axisstartLocation- DOCUMENT ME!box- (dimension-1)*resolutioncolor- DOCUMENT ME!- Throws:
IOException- if there is an error writing to the file
-
buildConnections
private void buildConnections()Builds a list of cross-references, so that connections[i] contains all the verticies that are connected to vertex at i. -
computeMeanEdgeLength
private void computeMeanEdgeLength()Compute the average length of all the edges in the triangle mesh. -
computeVertexInformation
private void computeVertexInformation()Let V[i] be a vertex in the triangle mesh. This function computes VMean[i], the average of the immediate neighbors of V[i]. Define S[i] = VMean[i] - V[i]. The function also computes a surface normal SNormal[i], the component of S[i] in the vertex normal direction. STangent[i] = S[i] - SNormal[i] is computed as an approximation to a tangent to the surface. Finally, Curvature[i] is an approximation of the surface curvature at V[i]. -
computeVertexNormals
private void computeVertexNormals()Compute the vertex normals of the triangle mesh. Each vertex normal is the unitized average of the non-unit triangle normals for those triangles sharing the vertex. -
update2
private float update2(int i) Compute the coefficient of the surface normal for the update of the mesh vertex V[i] in the SNormal[i] direction. See BrainExtraction.pdf for a description of the update.- Parameters:
i- the index of the vertex to update- Returns:
- the coefficient of SNormal[i] for the update
-
updateMesh
private void updateMesh()The heart of the segmentation. This function is responsible for the evolution of the triangle mesh that approximates the brain surface. The update has a tangential component, a surface normal component, and a vertex normal component for each vertex in the mesh. The first two components control the geometry of the mesh. The last component is based on the MRI data itself. See BrainExtraction.pdf for a detailed description of the update terms. -
invertMesh
public void invertMesh()Invert the mesh z-coord, reorder the triangles, and recompute the normals: -
setMaterial
public void setMaterial(javax.media.j3d.Material kMaterial) Sets the material properties of the mesh.- Parameters:
kMaterial- new material properties.
-
getMaterial
public javax.media.j3d.Material getMaterial()Gets the material properties of the mesh:- Returns:
- material properties.
-
setTransparency
public void setTransparency(float transparency) Sets the mesh transparency.- Parameters:
transparency- mesh transparency
-
getTransparency
public float getTransparency()Gets the mesh transparency.- Returns:
- mesh transparency.
-