SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData > Class Template Reference

Basic class for storing Tetrahedron Meshes, handling basic vertex, edge, triangle and tetrahedron functionality. More...

`#include <SurgSim/DataStructures/TetrahedronMesh.h>`

Inheritance diagram for SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >:

## Public Types

typedef MeshElement< 2, EdgeData > | EdgeType
| Edge type for convenience (Ids of the 2 vertices) More...
typedef MeshElement< 3, TriangleData > | TriangleType
| Triangle type for convenience (Ids of the 3 vertices) More...
typedef MeshElement< 4, TetrahedronData > | TetrahedronType
| Tetrahedron type for convenience (Ids of the 4 vertices) More...
Public Types inherited from SurgSim::DataStructures::Vertices< VertexData >
typedef Vertex< VertexData > | VertexType
| Vertex type for convenience. More...

## Public Member Functions

| TetrahedronMesh ()
| Constructor. The mesh is initially empty (no vertices, no edges, no triangles, no tetrahedrons). More...
virtual | ~TetrahedronMesh ()
| Destructor. More...
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...
Public Member Functions inherited from SurgSim::DataStructures::Vertices< VertexData >
| Vertices ()
| Constructor. More...
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. More...
void | clear ()
| Clear mesh to return to an empty state (no vertices). More...
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. More...
const VertexType & | getVertex (size_t id) const
| Returns the specified vertex. More...
VertexType & | getVertex (size_t id)
| Returns the specified vertex (non const version). More...
const std::vector< VertexType > & | getVertices () const
| Returns a vector containing the position of each vertex. More...
std::vector< VertexType > & | getVertices ()
| Returns a vector containing the position of each vertex (non const version). More...
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. More...
virtual void | doClearTriangles ()
| Remove all triangles from the mesh. More...
virtual void | doClearTetrahedrons ()
| Remove all tetrahedrons from the mesh. More...
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...
Protected Member Functions inherited from SurgSim::DataStructures::Vertices< VertexData >
virtual void | doClearVertices ()
| Remove all vertices from the mesh. More...

## Private Member Functions

virtual void | doClear ()
| Clear mesh to return to an empty state (no vertices, no edges, no triangles, no m_tetrahedrons). More...

## Private Attributes

std::vector< EdgeType > | m_edges
| Edges. More...
std::vector< TriangleType > | m_triangles
| Triangles. More...
std::vector< TetrahedronType > | m_tetrahedrons
| Tetrahedrons. More...

## Detailed Description

### template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>
class SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >

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.

Template Parameters

  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

See also
  Vertices
  MeshElement

## Member Typedef Documentation

## EdgeType

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

typedef MeshElement<2, EdgeData> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType

Edge type for convenience (Ids of the 2 vertices)

## TetrahedronType

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

typedef MeshElement<4, TetrahedronData> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType

Tetrahedron type for convenience (Ids of the 4 vertices)

## TriangleType

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

typedef MeshElement<3, TriangleData> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType

Triangle type for convenience (Ids of the 3 vertices)

## Constructor & Destructor Documentation

## TetrahedronMesh()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronMesh | ( |  | ) |

Constructor. The mesh is initially empty (no vertices, no edges, no triangles, no tetrahedrons).

## ~TetrahedronMesh()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::~TetrahedronMesh | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## addEdge()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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.

Parameters

  edge | Edge to add to the mesh

Returns
  Unique ID of the new edge.

## addTetrahedron()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::addTetrahedron | ( | const TetrahedronType & | tetrahedron | ) |

Adds a tetrahedron to the mesh.

Parameters

  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.

Returns
  Unique ID of the new tetrahedron.

## addTriangle()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::addTriangle | ( | const TriangleType & | triangle | ) |

Adds a triangle to the mesh.

Parameters

  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.

Returns
  Unique ID of the new triangle.

## doClear()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

void SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::doClear | ( |  | ) |

private virtual

Clear mesh to return to an empty state (no vertices, no edges, no triangles, no m_tetrahedrons).

Reimplemented from SurgSim::DataStructures::Vertices< VertexData >.

## doClearEdges()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

void SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::doClearEdges | ( |  | ) |

protected virtual

Remove all edges from the mesh.

## doClearTetrahedrons()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

void SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::doClearTetrahedrons | ( |  | ) |

protected virtual

Remove all tetrahedrons from the mesh.

## doClearTriangles()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

void SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::doClearTriangles | ( |  | ) |

protected virtual

Remove all triangles from the mesh.

## getEdge() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdge | ( | size_t | id | ) | const

Returns the specified edge.

Parameters

  id | The edge's id

Returns
  The edge id

Note
  No check is performed on the id

## getEdge() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::EdgeType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getEdge | ( | size_t | id | ) |

Returns the specified edge (non const version).

Parameters

  id | The edge's id

Returns
  The edge id

Note
  No check is performed on the id

## getEdges() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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.

Returns
  The vector containing all edges

## getEdges() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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).

Returns
  The vector containing all edges

## getNumEdges()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumEdges | ( |  | ) | const

Returns the number of edges in this mesh.

Returns
  The number of edges

## getNumTetrahedrons()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumTetrahedrons | ( |  | ) | const

Returns the number of tetrahedrons in this mesh.

Returns
  The number of tetrahedrons

## getNumTriangles()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

size_t SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getNumTriangles | ( |  | ) | const

Returns the number of triangles in this mesh.

Returns
  The number of triangles

## getTetrahedron() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedron | ( | size_t | id | ) | const

Returns the specified tetrahedron.

Parameters

  id | The tetrahedron's id

Returns
  The tetrahedron id

Note
  No check is performed on the id

## getTetrahedron() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TetrahedronType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTetrahedron | ( | size_t | id | ) |

Returns the specified tetrahedron (non const version).

Parameters

  id | The tetrahedron's id

Returns
  The tetrahedron id

Note
  No check is performed on the id

## getTetrahedrons() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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.

Returns
  The vector containing all tetrahedrons

## getTetrahedrons() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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).

Returns
  The vector containing all tetrahedrons

## getTriangle() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

const TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangle | ( | size_t | id | ) | const

Returns the specified triangle.

Parameters

  id | The triangle's id

Returns
  The triangle id

Note
  No check is performed on the id

## getTriangle() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::TriangleType & SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::getTriangle | ( | size_t | id | ) |

Returns the specified triangle (non const version).

Parameters

  id | The triangle's id

Returns
  The triangle id

Note
  No check is performed on the id

## getTriangles() [1/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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.

Returns
  The vector containing all triangles

## getTriangles() [2/2]

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

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).

Returns
  The vector containing all triangles

## isEqual()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

bool SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::isEqual | ( | const Vertices< VertexData > & | mesh | ) | const

protected virtual

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.

Parameters

  mesh | Mesh must be of the same type as that which it is compared against

Reimplemented from SurgSim::DataStructures::Vertices< VertexData >.

## isValid()

template<class VertexData , class EdgeData , class TriangleData , class TetrahedronData >

bool SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::isValid | ( |  | ) | const

Test if the TetrahedronMesh is valid (valid vertex Ids used in all MeshElements)

Returns
  True if the TetrahedronMesh is valid, False otherwise (the topology is then broken)

## Member Data Documentation

## m_edges

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

std::vector<EdgeType> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::m_edges

private

Edges.

## m_tetrahedrons

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

std::vector<TetrahedronType> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::m_tetrahedrons

private

Tetrahedrons.

## m_triangles

template<class VertexData, class EdgeData, class TriangleData, class TetrahedronData>

std::vector<TriangleType> SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >::m_triangles

private

Triangles.

The documentation for this class was generated from the following files:

- SurgSim/DataStructures/TetrahedronMesh.h
- SurgSim/DataStructures/TetrahedronMesh-inl.h