opensurgsim
|
Basic class for storing Tetrahedron Meshes, handling basic vertex, edge, triangle and tetrahedron functionality. More...
#include <TetrahedronMesh.h>
Public Types | |
typedef MeshElement< 2, EdgeData > | EdgeType |
Edge type for convenience (Ids of the 2 vertices) | |
typedef MeshElement< 3, TriangleData > | TriangleType |
Triangle type for convenience (Ids of the 3 vertices) | |
typedef MeshElement< 4, TetrahedronData > | TetrahedronType |
Tetrahedron type for convenience (Ids of the 4 vertices) | |
![]() | |
typedef Vertex< VertexData > | VertexType |
Vertex type for convenience. | |
Public Member Functions | |
TetrahedronMesh () | |
Constructor. The mesh is initially empty (no vertices, no edges, no triangles, no tetrahedrons). | |
virtual | ~TetrahedronMesh () |
Destructor. | |
size_t | addEdge (const EdgeType &edge) |
Adds an edge to the mesh. More... | |
size_t | addTriangle (const TriangleType &triangle) |
Adds a triangle to the mesh. More... | |
size_t | addTetrahedron (const TetrahedronType &tetrahedron) |
Adds a tetrahedron to the mesh. More... | |
size_t | getNumEdges () const |
Returns the number of edges in this mesh. More... | |
size_t | getNumTriangles () const |
Returns the number of triangles in this mesh. More... | |
size_t | getNumTetrahedrons () const |
Returns the number of tetrahedrons in this mesh. More... | |
const std::vector< EdgeType > & | getEdges () const |
Returns a vector containing the position of each edge. More... | |
std::vector< EdgeType > & | getEdges () |
Returns a vector containing the position of each edge (non const version). More... | |
const std::vector< TriangleType > & | getTriangles () const |
Returns a vector containing the position of each triangle. More... | |
std::vector< TriangleType > & | getTriangles () |
Returns a vector containing the position of each triangle (non const version). More... | |
const std::vector< TetrahedronType > & | getTetrahedrons () const |
Returns a vector containing the position of each tetrahedron. More... | |
std::vector< TetrahedronType > & | getTetrahedrons () |
Returns a vector containing the position of each tetrahedron (non const version). More... | |
const EdgeType & | getEdge (size_t id) const |
Returns the specified edge. More... | |
EdgeType & | getEdge (size_t id) |
Returns the specified edge (non const version). More... | |
const TriangleType & | getTriangle (size_t id) const |
Returns the specified triangle. More... | |
TriangleType & | getTriangle (size_t id) |
Returns the specified triangle (non const version). More... | |
const TetrahedronType & | getTetrahedron (size_t id) const |
Returns the specified tetrahedron. More... | |
TetrahedronType & | getTetrahedron (size_t id) |
Returns the specified tetrahedron (non const version). More... | |
bool | isValid () const |
Test if the TetrahedronMesh is valid (valid vertex Ids used in all MeshElements) More... | |
![]() | |
Vertices () | |
Constructor. | |
template<class V > | |
Vertices (const Vertices< V > &other) | |
Copy constructor when the template data is a different type In this case, no data will be copied. More... | |
template<class V > | |
Vertices< VertexData > & | operator= (const Vertices< V > &other) |
Assignment when the template data is a different type In this case, no data will be copied. More... | |
virtual | ~Vertices () |
Destructor. | |
void | clear () |
Clear mesh to return to an empty state (no vertices). | |
bool | update () |
Performs any updates that are required when the vertices are modified. More... | |
size_t | addVertex (const VertexType &vertex) |
Adds a vertex to the mesh. More... | |
size_t | getNumVertices () const |
Returns the number of vertices in this mesh. | |
const VertexType & | getVertex (size_t id) const |
Returns the specified vertex. | |
VertexType & | getVertex (size_t id) |
Returns the specified vertex (non const version). | |
const std::vector< VertexType > & | getVertices () const |
Returns a vector containing the position of each vertex. | |
std::vector< VertexType > & | getVertices () |
Returns a vector containing the position of each vertex (non const version). | |
void | setVertexPosition (size_t id, const SurgSim::Math::Vector3d &position) |
Sets the position of a vertex. More... | |
const SurgSim::Math::Vector3d & | getVertexPosition (size_t id) const |
Returns the position of a vertex. More... | |
void | setVertexPositions (const std::vector< SurgSim::Math::Vector3d > &positions, bool doUpdate=true) |
Sets the position of each vertex. More... | |
void | transform (const Math::RigidTransform3d &pose) |
Apply a rigid transform to each vertex. More... | |
bool | operator== (const Vertices &mesh) const |
Compares the mesh with another one (equality) More... | |
bool | operator!= (const Vertices &mesh) const |
Compares the mesh with another one (inequality) More... | |
Protected Member Functions | |
virtual void | doClearEdges () |
Remove all edges from the mesh. | |
virtual void | doClearTriangles () |
Remove all triangles from the mesh. | |
virtual void | doClearTetrahedrons () |
Remove all tetrahedrons from the mesh. | |
virtual bool | isEqual (const Vertices< VertexData > &mesh) const |
Internal comparison of meshes of the same type: returns true if equal, false if not equal. More... | |
![]() | |
virtual void | doClearVertices () |
Remove all vertices from the mesh. | |
Basic class for storing Tetrahedron Meshes, handling basic vertex, edge, triangle and tetrahedron functionality.
TetrahedronMesh is to be used purely as a data structure and not provide implementation of algorithms. For example, a physics 3D FEM is not a subclass of TetrahedronMesh, but may use a TetrahedronMesh for storing the structure of the FEM.
It is recommended that subclasses with a specific purpose (such as for use in collision detection) provide convenience methods for creation of vertices, edges, triangles, tetrahedrons and the data each contains. Methods such as createVertex(position, other data...), createEdge(vertices, other data...), createTriangle(vertices, other data...) and createTetrahedron(vertices, other data...) simplify the creation of vertices and elements and the data required. These methods would use the addVertex(), addEdge(), addTriangle() and addTetrahedron() methods to add the created vertices and elements to the TetrahedronMesh.
Overriding isEqual(const Mesh&) is necessary to do more than just basic list comparison of the vertices, edges, triangles and tetrahedrons which is dependent on order in the list.
Override doUpdate() to provide update functionality when vertices are changed, such as recalculating surface normals.
A subclass that is designed for a specific use (such as collision detection) may also specify the VertexData, EdgeData, TriangleData and TetrahedronData to what is required.
VertexData | Type of extra data stored in each vertex |
EdgeData | Type of extra data stored in each edge |
TriangleData | Type of extra data stored in each triangle |
TetrahedronData | Type of extra data stored in each tetrahedron |
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::addEdge | ( | const EdgeType & | edge | ) |
Adds an edge to the mesh.
No checking on the edge's vertices is performed. Recommend that subclasses with a specific purpose (such as for use in collision detection) have a createEdge(vertices, other data...) method which performs any checking desired and sets up the edge data based on the vertices and other parameters.
edge | Edge to add to the mesh |
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::addTetrahedron | ( | const TetrahedronType & | tetrahedron | ) |
Adds a tetrahedron to the mesh.
tetrahedron | Tetrahedron to add to the mesh Recommend that subclasses with a specific purpose (such as for use in collision detection) have a createTetrahedron(vertices, other data...) method which performs any checking desired and sets up the tetrahedron data based on the vertices and other parameters. |
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::addTriangle | ( | const TriangleType & | triangle | ) |
Adds a triangle to the mesh.
triangle | Triangle to add to the mesh Recommend that subclasses with a specific purpose (such as for use in collision detection) have a createTriangle(vertices, other data...) method which performs any checking desired and sets up the triangle data based on the vertices and other parameters. |
const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdge | ( | size_t | id | ) | const |
Returns the specified edge.
id | The edge's id |
TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdge | ( | size_t | id | ) |
Returns the specified edge (non const version).
id | The edge's id |
const std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdges | ( | ) | const |
Returns a vector containing the position of each edge.
std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdges | ( | ) |
Returns a vector containing the position of each edge (non const version).
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumEdges | ( | ) | const |
Returns the number of edges in this mesh.
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumTetrahedrons | ( | ) | const |
Returns the number of tetrahedrons in this mesh.
size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumTriangles | ( | ) | const |
Returns the number of triangles in this mesh.
const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedron | ( | size_t | id | ) | const |
Returns the specified tetrahedron.
id | The tetrahedron's id |
TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedron | ( | size_t | id | ) |
Returns the specified tetrahedron (non const version).
id | The tetrahedron's id |
const std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedrons | ( | ) | const |
Returns a vector containing the position of each tetrahedron.
std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedrons | ( | ) |
Returns a vector containing the position of each tetrahedron (non const version).
const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangle | ( | size_t | id | ) | const |
Returns the specified triangle.
id | The triangle's id |
TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangle | ( | size_t | id | ) |
Returns the specified triangle (non const version).
id | The triangle's id |
const std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangles | ( | ) | const |
Returns a vector containing the position of each triangle.
std::vector< typename TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType > & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangles | ( | ) |
Returns a vector containing the position of each triangle (non const version).
|
protectedvirtual |
Internal comparison of meshes of the same type: returns true if equal, false if not equal.
Override this method to provide custom comparison. Basic TriangleMesh implementation compares vertices, edges and triangles: the order of vertices, edges, and triangles must also match to be considered equal.
mesh | Mesh must be of the same type as that which it is compared against |
Reimplemented from SurgSim::DataStructures::Vertices< VertexData >.
bool SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::isValid | ( | ) | const |
Test if the TetrahedronMesh is valid (valid vertex Ids used in all MeshElements)