Class ModelSurfaceTopology
java.lang.Object
gov.nih.mipav.view.renderer.J3D.model.structures.ModelSurfaceTopology
- Direct Known Subclasses:
ModelSurfaceDecimator
This is an implementation of a vertex-edge-triangle table. It uses hash maps for storing the mesh components. Basic
operations are supported including insertion and removal of triangles and accessing the mesh components and their
adjacent components. More complex operations are also supported including determination if the mesh is connected,
closed, or manifold, and allows for computing the connected components of a mesh. With additional computation time,
the connected components can be created so that the triangles within each component are consistely ordered. See the
document Level Set Extraction for more details on vertex-edge-triangle
tables.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA representation of an edge for the vertex-edge-triangle table.protected classThe attributes associated with an edge.static classFor debugging and testing.classA representation of a triangle for the vertex-edge-triangle table.protected classThe attributes associated with a triangle.classA representation of a vertex for the vertex-edge-triangle table.protected classThe attributes associated with a vertex. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor whose job is solely to allocate the hashmaps for the vertex-edge-triangle table.ModelSurfaceTopology(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad) Creates a new ModelSurfaceTopology object. -
Method Summary
Modifier and TypeMethodDescriptionCreate()A factory that is used for operations that create new meshes from the current one.Construct the connected components of the mesh.int[]getComponents(Vector kIndex) Construct the connected components of the mesh by factoring the connectivity array into disjoint subarrays.Construct the connected components of the mesh.Get the attribute data associated with the specified edge.Get the attribute data associated with the specified triangle.Get the attribute data associated with the specified vertex.Access the hash map of edges.intThe number of edges currently in the table.Reverse the order of each triangle in the mesh.Access the hash map of triangles.intThe number of triangles currently in the table.Access the hash map of vertices.intThe number of vertices currently in the table.voidinsertTriangle(int iV0, int iV1, int iV2) Insert triangle invalid input: '<'V0,V1,V2> into the mesh.voidConvenience function for inserting triangles into the mesh.booleanisClosed()Determine if the triangle mesh is closed.booleanDetermine if the triangle mesh is connected.booleanDetermine if the triangle mesh is manifold.voidOnEdgeInsert(ModelSurfaceTopology.Edge kE, boolean bCreate, ModelSurfaceTopology.EdgeAttribute kEAttr) Stub provided for overriding in derived classes.voidOnEdgeRemove(ModelSurfaceTopology.Edge kE, boolean bDestroy, ModelSurfaceTopology.EdgeAttribute kEAttr) Stub provided for overriding in derived classes.voidOnTriangleInsert(ModelSurfaceTopology.Triangle kT, boolean bCreate, ModelSurfaceTopology.TriangleAttribute kTAttr) Stub provided for overriding in derived classes.voidOnTriangleRemove(ModelSurfaceTopology.Triangle kT, boolean bDestroy, ModelSurfaceTopology.TriangleAttribute kTAttr) Stub provided for overriding in derived classes.voidOnVertexInsert(ModelSurfaceTopology.Vertex kV, boolean bCreate, ModelSurfaceTopology.VertexAttribute kVAttr) Stub provided for overriding in derived classes.voidOnVertexRemove(ModelSurfaceTopology.Vertex kV, boolean bDestroy, ModelSurfaceTopology.VertexAttribute kVAttr) Stub provided for overriding in derived classes.voidPrint the vertex-edge-triangle table to a text file.intremoveComponent(int iOffset, int[] aiConnect) Extract a connected component from the mesh and remove all the triangles of the component from the mesh.voidremoveTriangle(int iV0, int iV1, int iV2) Remove triangle invalid input: '<'V0,V1,V2> from the mesh.voidConvenience function for removing triangles from the mesh.voidsetData(ModelSurfaceTopology.Edge kE, Object kData) Set the attribute data associated with the specified edge.voidsetData(ModelSurfaceTopology.Triangle kT, Object kData) Set the attribute data associated with the specified triangle.voidsetData(ModelSurfaceTopology.Vertex kV, Object kData) Set the attribute data associated with the specified vertex.
-
Field Details
-
m_kEMap
map of invalid input: '<'Edge,EdgeAttribute>. -
m_kTMap
map of invalid input: '<'Triangle,TriangleAttribute>. -
m_kVMap
map of invalid input: '<'Vertex,VertexAttribute>.
-
-
Constructor Details
-
ModelSurfaceTopology
public ModelSurfaceTopology()The default constructor whose job is solely to allocate the hashmaps for the vertex-edge-triangle table. -
ModelSurfaceTopology
public ModelSurfaceTopology(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad) Creates a new ModelSurfaceTopology object.- Parameters:
iVCapacity- the initial number of buckets in the vertex hashmapfVLoad- the load factor for the vertex hash map, in (0,1)iECapacity- the initial number of buckets in the edge hash mapfELoad- the load factor for the edge hash map, in (0,1)iTCapacity- the initial number of buckets in the triangle hashmapfTLoad- the load factor for the triangle hash map, in (0,1)
-
-
Method Details
-
Create
A factory that is used for operations that create new meshes from the current one. This allows derived class construction within the base class operations.- Returns:
- a new vertex-edge-triangle table of the correct derived-class type
-
getComponents
Construct the connected components of the mesh. The triangle ordering within a single component is not guaranteed to be consistent. That is, it is possible for a triangle to be counterclockwise ordered, but an adjacent triangle to be clockwise ordered.- Returns:
- an array of components, each entry of type ModelSurfaceTopology
-
getComponents
Construct the connected components of the mesh by factoring the connectivity array into disjoint subarrays. The triangle ordering within a single component is not guaranteed to be consistent. That is, it is possible for a triangle to be counterclockwise ordered, but an adjacent triangle to be clockwise ordered.- Parameters:
kIndex- - An array whose entries indicate the starting point of each subarray in the returned integer array. Each entry is of type Integer. kIndex[0] always has value 0 since the first subarray always starts at the beginning. The next subarray is at kIndex[1]. The number of elements in the first subarray is kIndex[1]-kIndex[0]. The last entry kIndex[kIndex.size()-1] stores the total length of the returned array, so there are only kIndex.size()-1 subarrays.- Returns:
- An array of indices that contain the disjoint subarrays in contiguous order.
-
getConsistentComponents
Construct the connected components of the mesh. The triangle ordering within a single component is guaranteed to be consistent. That is, all triangles in the component are counterclockwise ordered, or all are clockwise ordered. It is not possible to make ordering between two components consistent since this requires geometric information about how the components are placed in space relative to each other (requires specification of an eye point).- Returns:
- an array of components (triangles), each entry of type ModelSurfaceTopology
-
getData
Get the attribute data associated with the specified vertex.- Parameters:
kV- the vertex whose attribute data will be retrieved- Returns:
- the attribute data
-
getData
Get the attribute data associated with the specified edge.- Parameters:
kE- the edge whose attribute data will be retrieved- Returns:
- the attribute data
-
getData
Get the attribute data associated with the specified triangle.- Parameters:
kT- the triangle whose attribute data will be retrieved- Returns:
- the attribute data
-
getEdgeMap
Access the hash map of edges. This is useful for allowing an application to iterate over the edge/attribute pairs.- Returns:
- the hash map of edges
-
getEdgeQuantity
public int getEdgeQuantity()The number of edges currently in the table.- Returns:
- the number of edges
-
getReversedOrderMesh
Reverse the order of each triangle in the mesh. If a triangle in the mesh is invalid input: '<'V0,V1,V2>, the returned vertex-edge-table contains a corresponding triangle invalid input: '<'V0,V2,V1>.- Returns:
- the vertex-edge-table containing the reversed order triangles
-
getTriangleMap
Access the hash map of triangles. This is useful for allowing an application to iterate over the triangle/attribute pairs.- Returns:
- the hash map of triangles
-
getTriangleQuantity
public int getTriangleQuantity()The number of triangles currently in the table.- Returns:
- the number of triangles
-
getVertexMap
Access the hash map of vertices. This is useful for allowing an application to iterate over the vertex/attribute pairs.- Returns:
- the hash map of vertices
-
getVertexQuantity
public int getVertexQuantity()The number of vertices currently in the table.- Returns:
- the number of vertices
-
insertTriangle
Convenience function for inserting triangles into the mesh.- Parameters:
kT- the triangle to be inserted
-
insertTriangle
public void insertTriangle(int iV0, int iV1, int iV2) Insert triangle invalid input: '<'V0,V1,V2> into the mesh. The ordering of the indices is relevant. Triangle invalid input: '<'V0,V2,V1> is considered to be a different triangle (reversed ordering from invalid input: '<'V0,V1,V2>).- Parameters:
iV0- index of triangleiV1- index of triangleiV2- index of triangle
-
isClosed
public boolean isClosed()Determine if the triangle mesh is closed. Each edge must have exactly two triangles sharing it- Returns:
- true iff the mesh is closed
-
isConnected
public boolean isConnected()Determine if the triangle mesh is connected.- Returns:
- true iff the mesh is connected
-
isManifold
public boolean isManifold()Determine if the triangle mesh is manifold. An edge is a manifold edge if it has at most two triangles sharing it.- Returns:
- true iff the mesh is manifold
-
OnEdgeInsert
public void OnEdgeInsert(ModelSurfaceTopology.Edge kE, boolean bCreate, ModelSurfaceTopology.EdgeAttribute kEAttr) Stub provided for overriding in derived classes. Each time an edge is attempted to be inserted into a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kE- the edge that was attempted to be inserted into the mapbCreate- true if the edge did not exist in the map before insertion (it is a brand new edge), false if the edge already existed.kEAttr- the attribute for the edge
-
OnEdgeRemove
public void OnEdgeRemove(ModelSurfaceTopology.Edge kE, boolean bDestroy, ModelSurfaceTopology.EdgeAttribute kEAttr) Stub provided for overriding in derived classes. Each time an edge is attempted to be removed from a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kE- the edge that was attempted to be removed from the mapbDestroy- true if the edge did exist in the map before the attempted removal and no other mesh components are referencing the edge, false if the edge does exist in the map, but other mesh components are referencing it.kEAttr- the attribute for the edge
-
OnTriangleInsert
public void OnTriangleInsert(ModelSurfaceTopology.Triangle kT, boolean bCreate, ModelSurfaceTopology.TriangleAttribute kTAttr) Stub provided for overriding in derived classes. Each time a triangle is attempted to be inserted into a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kT- the triangle that was attempted to be inserted into the mapbCreate- true if the triangle did not exist in the map before insertion (it is a brand new triangle), false if the triangle already existed.kTAttr- the attribute for the triangle
-
OnTriangleRemove
public void OnTriangleRemove(ModelSurfaceTopology.Triangle kT, boolean bDestroy, ModelSurfaceTopology.TriangleAttribute kTAttr) Stub provided for overriding in derived classes. Each time a triangle is attempted to be removed from a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kT- the triangle that was attempted to be removed from the mapbDestroy- true if the triangle did exist in the map before the attempted removal and no other mesh components are referencing the triangle, false if the triangle does exist in the map, but other mesh components are referencing it.kTAttr- the attribute for the triangle
-
OnVertexInsert
public void OnVertexInsert(ModelSurfaceTopology.Vertex kV, boolean bCreate, ModelSurfaceTopology.VertexAttribute kVAttr) Stub provided for overriding in derived classes. Each time a vertex is attempted to be inserted into a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kV- the vertex that was attempted to be inserted into the mapbCreate- true if the vertex did not exist in the map before insertion (it is a brand new vertex), false if the vertex already existed.kVAttr- the attribute for the vertex
-
OnVertexRemove
public void OnVertexRemove(ModelSurfaceTopology.Vertex kV, boolean bDestroy, ModelSurfaceTopology.VertexAttribute kVAttr) Stub provided for overriding in derived classes. Each time a vertex is attempted to be removed from a map, this function is called so that the derived class can perform actions specific to the application.- Parameters:
kV- the vertex that was attempted to be removed from the mapbDestroy- true if the vertex did exist in the map before the attempted removal and no other mesh components are referencing the vertex, false if the vertex does exist in the map, but other mesh components are referencing it.kVAttr- the attribute for the vertex
-
print
Print the vertex-edge-triangle table to a text file. This function is provided for debugging support and is not needed by the triangle decimation scheme or surface visualizer.- Parameters:
kFilename- the name of the file to which the table should be printed- Throws:
IOException- if the specified file could not be opened for writing
-
removeComponent
public int removeComponent(int iOffset, int[] aiConnect) Extract a connected component from the mesh and remove all the triangles of the component from the mesh. This is useful for computing the components in a very large mesh that uses a lot of memory. The intention is that the function is called until all components are found. The typical code isModelSurfaceTopology kTopo =
; Vector kIndex = new Vector(); // vector of kIndex.add(new Integer(0)); int iITotalQuantity = 3*kTopo.getTriangleQuantity(); int[] aiConnect = new int[iITotalQuantity]; int iNumComponents = 0; for (int iIQuantity = 0; iIQuantity invalid input: '<' iITotalQuantity; ) { int iComponentIQuantity = kTopo.removeComponent(iIQuantity,aiConnect); iIQuantity += iComponentIQuantity; kIndex.add(new Integer(iQuantity)); iNumComponents++; } The components are stored contiguously in aiConnect. The starting index for component C is stored in the kIndex[C] for 0 invalid input: '<'= C invalid input: '<'= iNumComponents. kIndex[iNumComponents+1] stores the length of the connectivity array.
- Parameters:
iOffset- the starting index in aiConnect where the next component is to be storedaiConnect- the array of connectivity indices that will store all the components- Returns:
- the number of indices in the just-extracted component
-
removeTriangle
Convenience function for removing triangles from the mesh.- Parameters:
kT- the triangle to be removed
-
removeTriangle
public void removeTriangle(int iV0, int iV1, int iV2) Remove triangle invalid input: '<'V0,V1,V2> from the mesh. The ordering of the indices is relevant. Triangle invalid input: '<'V0,V2,V1> is considered to be a different triangle (reversed ordering from invalid input: '<'V0,V1,V2>).- Parameters:
iV0- index of triangleiV1- index of triangleiV2- index of triangle
-
setData
Set the attribute data associated with the specified vertex.- Parameters:
kV- the vertex whose attribute data will be setkData- the attribute data
-
setData
Set the attribute data associated with the specified edge.- Parameters:
kE- the edge whose attribute data will be setkData- the attribute data
-
setData
Set the attribute data associated with the specified triangle.- Parameters:
kT- the triangle whose attribute data will be setkData- the attribute data
-