Package WildMagic.LibFoundation.Meshes
Class VETMesh
- java.lang.Object
-
- WildMagic.LibFoundation.Meshes.VETMesh
-
- All Implemented Interfaces:
java.io.Serializable
public class VETMesh extends java.lang.Object implements java.io.Serializable
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.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
VETMesh.Edge
A representation of an edge for the vertex-edge-triangle table.protected class
VETMesh.EdgeAttribute
The attributes associated with an edge.static class
VETMesh.Statistics
For debugging and testing.class
VETMesh.Triangle
A representation of a triangle for the vertex-edge-triangle table.protected class
VETMesh.TriangleAttribute
The attributes associated with a triangle.class
VETMesh.Vertex
A representation of a vertex for the vertex-edge-triangle table.protected class
VETMesh.VertexAttribute
The attributes associated with a vertex.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<VETMesh.Edge,VETMesh.EdgeAttribute>
m_kEMap
map of. protected java.util.HashMap<VETMesh.Triangle,VETMesh.TriangleAttribute>
m_kTMap
map of. protected java.util.HashMap<VETMesh.Vertex,VETMesh.VertexAttribute>
m_kVMap
map of. private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description VETMesh()
The default constructor whose job is solely to allocate the hashmaps for the vertex-edge-triangle table.VETMesh(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad)
Creates a new VETMesh object.VETMesh(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad, int[] aiConnect)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VETMesh
Create()
A factory that is used for operations that create new meshes from the current one.void
GetComponents(java.util.Vector<VETMesh> kComponents)
Construct the connected components of the mesh.boolean
GetConsistentComponents(java.util.Vector<VETMesh> kComponents)
Construct the connected components of the mesh.java.lang.Object
GetData(VETMesh.Edge kE)
Get the attribute data associated with the specified edge.java.lang.Object
GetData(VETMesh.Triangle kT)
Get the attribute data associated with the specified triangle.java.lang.Object
GetData(VETMesh.Vertex kV)
Get the attribute data associated with the specified vertex.java.util.HashMap<VETMesh.Edge,VETMesh.EdgeAttribute>
GetEdgeMap()
Access the hash map of edges.int
GetEdgeQuantity()
The number of edges currently in the table.VETMesh
GetReversedOrderMesh()
Reverse the order of each triangle in the mesh.java.util.HashMap<VETMesh.Triangle,VETMesh.TriangleAttribute>
GetTriangleMap()
Access the hash map of triangles.int
GetTriangleQuantity()
The number of triangles currently in the table.int[]
GetTriangles()
java.util.HashMap<VETMesh.Vertex,VETMesh.VertexAttribute>
GetVertexMap()
Access the hash map of vertices.int
GetVertexQuantity()
The number of vertices currently in the table.void
InsertTriangle(int iV0, int iV1, int iV2)
Insert triangleinto the mesh. void
InsertTriangle(VETMesh.Triangle kT)
Convenience function for inserting triangles into the mesh.boolean
IsClosed()
boolean
IsConnected()
Determine if the triangle mesh is connected.boolean
IsManifold()
Determine if the triangle mesh is manifold (closed).void
OnEdgeInsert(VETMesh.Edge kE, boolean bCreate, VETMesh.EdgeAttribute kEAttr)
Stub provided for overriding in derived classes.void
OnEdgeRemove(VETMesh.Edge kE, boolean bDestroy, VETMesh.EdgeAttribute kEAttr)
Stub provided for overriding in derived classes.void
OnTriangleInsert(VETMesh.Triangle kT, boolean bCreate, VETMesh.TriangleAttribute kTAttr)
Stub provided for overriding in derived classes.void
OnTriangleRemove(VETMesh.Triangle kT, boolean bDestroy, VETMesh.TriangleAttribute kTAttr)
Stub provided for overriding in derived classes.void
OnVertexInsert(VETMesh.Vertex kV, boolean bCreate, VETMesh.VertexAttribute kVAttr)
Stub provided for overriding in derived classes.void
OnVertexRemove(VETMesh.Vertex kV, boolean bDestroy, VETMesh.VertexAttribute kVAttr)
Stub provided for overriding in derived classes.int
RemoveComponent(int iOffset, int[] aiConnect)
Extract a connected component from the mesh and remove all the triangles of the component from the mesh.void
RemoveTriangle(int iV0, int iV1, int iV2)
Remove trianglefrom the mesh. void
RemoveTriangle(VETMesh.Triangle kT)
Convenience function for removing triangles from the mesh.void
SetData(VETMesh.Edge kE, java.lang.Object kData)
Set the attribute data associated with the specified edge.void
SetData(VETMesh.Triangle kT, java.lang.Object kData)
Set the attribute data associated with the specified triangle.void
SetData(VETMesh.Vertex kV, java.lang.Object kData)
Set the attribute data associated with the specified vertex.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_kEMap
protected java.util.HashMap<VETMesh.Edge,VETMesh.EdgeAttribute> m_kEMap
map of.
-
m_kTMap
protected java.util.HashMap<VETMesh.Triangle,VETMesh.TriangleAttribute> m_kTMap
map of.
-
m_kVMap
protected java.util.HashMap<VETMesh.Vertex,VETMesh.VertexAttribute> m_kVMap
map of.
-
-
Constructor Detail
-
VETMesh
public VETMesh()
The default constructor whose job is solely to allocate the hashmaps for the vertex-edge-triangle table.
-
VETMesh
public VETMesh(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad)
Creates a new VETMesh 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)
-
VETMesh
public VETMesh(int iVCapacity, float fVLoad, int iECapacity, float fELoad, int iTCapacity, float fTLoad, int[] aiConnect)
-
-
Method Detail
-
Create
public VETMesh 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
public void GetComponents(java.util.Vector<VETMesh> kComponents)
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.- Parameters:
kComponents
- an array of components, each entry of type VETMesh
-
GetConsistentComponents
public boolean GetConsistentComponents(java.util.Vector<VETMesh> kComponents)
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 VETMesh
-
GetData
public java.lang.Object GetData(VETMesh.Edge kE)
Get the attribute data associated with the specified edge.- Parameters:
kE
- the edge whose attribute data will be retrieved- Returns:
- the attribute data
-
GetData
public java.lang.Object GetData(VETMesh.Triangle kT)
Get the attribute data associated with the specified triangle.- Parameters:
kT
- the triangle whose attribute data will be retrieved- Returns:
- the attribute data
-
GetData
public java.lang.Object GetData(VETMesh.Vertex kV)
Get the attribute data associated with the specified vertex.- Parameters:
kV
- the vertex whose attribute data will be retrieved- Returns:
- the attribute data
-
GetEdgeMap
public java.util.HashMap<VETMesh.Edge,VETMesh.EdgeAttribute> 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
public VETMesh GetReversedOrderMesh()
Reverse the order of each triangle in the mesh. If a triangle in the mesh is, the returned vertex-edge-table contains a corresponding triangle . - Returns:
- the vertex-edge-table containing the reversed order triangles
-
GetTriangleMap
public java.util.HashMap<VETMesh.Triangle,VETMesh.TriangleAttribute> 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
-
GetTriangles
public int[] GetTriangles()
-
GetVertexMap
public java.util.HashMap<VETMesh.Vertex,VETMesh.VertexAttribute> 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
public void InsertTriangle(int iV0, int iV1, int iV2)
Insert triangleinto the mesh. The ordering of the indices is relevant. Triangle is considered to be a different triangle (reversed ordering from ). - Parameters:
iV0
- index of triangleiV1
- index of triangleiV2
- index of triangle
-
InsertTriangle
public void InsertTriangle(VETMesh.Triangle kT)
Convenience function for inserting triangles into the mesh.- Parameters:
kT
- the triangle to be inserted
-
IsClosed
public boolean IsClosed()
-
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 (closed). Each edge must have exactly two triangles sharing it- Returns:
- true iff the mesh is closed
-
OnEdgeInsert
public void OnEdgeInsert(VETMesh.Edge kE, boolean bCreate, VETMesh.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(VETMesh.Edge kE, boolean bDestroy, VETMesh.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(VETMesh.Triangle kT, boolean bCreate, VETMesh.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(VETMesh.Triangle kT, boolean bDestroy, VETMesh.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(VETMesh.Vertex kV, boolean bCreate, VETMesh.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(VETMesh.Vertex kV, boolean bDestroy, VETMesh.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
-
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 isVETMesh 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 < 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 <= C <= 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
public void RemoveTriangle(int iV0, int iV1, int iV2)
Remove trianglefrom the mesh. The ordering of the indices is relevant. Triangle is considered to be a different triangle (reversed ordering from ). - Parameters:
iV0
- index of triangleiV1
- index of triangleiV2
- index of triangle
-
RemoveTriangle
public void RemoveTriangle(VETMesh.Triangle kT)
Convenience function for removing triangles from the mesh.- Parameters:
kT
- the triangle to be removed
-
SetData
public void SetData(VETMesh.Edge kE, java.lang.Object kData)
Set the attribute data associated with the specified edge.- Parameters:
kE
- the edge whose attribute data will be setkData
- the attribute data
-
SetData
public void SetData(VETMesh.Triangle kT, java.lang.Object kData)
Set the attribute data associated with the specified triangle.- Parameters:
kT
- the triangle whose attribute data will be setkData
- the attribute data
-
SetData
public void SetData(VETMesh.Vertex kV, java.lang.Object kData)
Set the attribute data associated with the specified vertex.- Parameters:
kV
- the vertex whose attribute data will be setkData
- the attribute data
-
-