SurgSim::DataStructures::Vertices< VertexData > Class Template Reference

Base class for mesh structures, handling basic vertex functionality. More...

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

Inheritance diagram for SurgSim::DataStructures::Vertices< VertexData >:

## Public Types

typedef Vertex< VertexData > | VertexType
| Vertex type for convenience. More...

## Public Member Functions

| 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 | doClearVertices ()
| Remove all vertices from the mesh. More...
virtual bool | isEqual (const Vertices &mesh) const
| Internal comparison of meshes of the same type: returns true if equal, false if not equal. More...

## Private Member Functions

virtual void | doClear ()
| Clear mesh to return to an empty state (no vertices). More...
virtual bool | doUpdate ()
| Performs any updates that are required when the vertices are modified. More...

## Private Attributes

std::vector< VertexType > | m_vertices
| Vertices. More...

## Detailed Description

### template<class VertexData>
class SurgSim::DataStructures::Vertices< VertexData >

Base class for mesh structures, handling basic vertex functionality.

Vertices is to be used purely as a data structure and not provide implementation of algorithms. For example, a physics FEM is not a subclass of Vertices, but may use a Mesh for storing the structure of the FEM.

Subclasses of this class should handle the elements required for a specific type of mesh (as simple as just a generic triangle mesh or as specific as a triangle mesh for collision detection, which might also specify the data types for the vertex and elements).

It is recommended that subclasses of this class also provide convenience methods for creation of vertices and elements, and the data each contains. A method such as createVertex(position, other data...) simplifies the creation of vertices and the data required. This method would use the addVertex() method to add the created vertices to the Mesh.

Template Parameters

  VertexData | Type of extra data stored in each vertex (void for no data)

See also
  Vertex
  MeshElement

## Member Typedef Documentation

## VertexType

template<class VertexData>

typedef Vertex<VertexData> SurgSim::DataStructures::Vertices< VertexData >::VertexType

Vertex type for convenience.

## Constructor & Destructor Documentation

## Vertices() [1/2]

template<class VertexData >

SurgSim::DataStructures::Vertices< VertexData >::Vertices | ( |  | ) |

Constructor.

## Vertices() [2/2]

template<class VertexData >
template<class V >

SurgSim::DataStructures::Vertices< VertexData >::Vertices | ( | const Vertices< V > & | other | ) |

explicit

Copy constructor when the template data is a different type In this case, no data will be copied.

Template Parameters

  V | type of data stored in the other Vertices

Parameters

  other | the Vertices to copy from

## ~Vertices()

template<class VertexData >

SurgSim::DataStructures::Vertices< VertexData >::~Vertices | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## addVertex()

template<class VertexData >

size_t SurgSim::DataStructures::Vertices< VertexData >::addVertex | ( | const VertexType & | vertex | ) |

Adds a vertex to the mesh.

Recommend that subclasses with a specific purpose (such as for use in collision detection), have a createVertex(position, other data...) method which performs any checking desired and sets up the vertex data based on the other parameters.

Parameters

  vertex | Vertex to add to the mesh

Returns
  Unique ID of the new vertex.

## clear()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::clear | ( |  | ) |

Clear mesh to return to an empty state (no vertices).

## doClear()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::doClear | ( |  | ) |

private virtual

Clear mesh to return to an empty state (no vertices).

Reimplemented in SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, TriangleData >, SurgSim::DataStructures::TriangleMesh< VertexData, SurgSim::DataStructures::EmptyData, SurgSim::DataStructures::EmptyData >, SurgSim::DataStructures::TriangleMesh< SurgSim::DataStructures::EmptyData, SurgSim::DataStructures::EmptyData, SurgSim::DataStructures::NormalData >, SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >, SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >, and SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >.

## doClearVertices()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::doClearVertices | ( |  | ) |

protected virtual

Remove all vertices from the mesh.

## doUpdate()

template<class VertexData >

bool SurgSim::DataStructures::Vertices< VertexData >::doUpdate | ( |  | ) |

private virtual

Performs any updates that are required when the vertices are modified.

Override this method to implement update functionality. For example, this could be overridden to calculate normals for each Vertex.

Returns
  true on success.

Reimplemented in SurgSim::Math::MeshShape, SurgSim::Math::ParticlesShape, and SurgSim::Math::SegmentMeshShape.

## getNumVertices()

template<class VertexData >

size_t SurgSim::DataStructures::Vertices< VertexData >::getNumVertices | ( |  | ) | const

Returns the number of vertices in this mesh.

## getVertex() [1/2]

template<class VertexData >

const Vertices< VertexData >::VertexType & SurgSim::DataStructures::Vertices< VertexData >::getVertex | ( | size_t | id | ) | const

Returns the specified vertex.

## getVertex() [2/2]

template<class VertexData >

Vertices< VertexData >::VertexType & SurgSim::DataStructures::Vertices< VertexData >::getVertex | ( | size_t | id | ) |

Returns the specified vertex (non const version).

## getVertexPosition()

template<class VertexData >

const SurgSim::Math::Vector3d & SurgSim::DataStructures::Vertices< VertexData >::getVertexPosition | ( | size_t | id | ) | const

Returns the position of a vertex.

Parameters

  id | Unique ID of the vertex

Returns
  Position of the vertex

## getVertices() [1/2]

template<class VertexData >

const std::vector< typename Vertices< VertexData >::VertexType > & SurgSim::DataStructures::Vertices< VertexData >::getVertices | ( |  | ) | const

Returns a vector containing the position of each vertex.

## getVertices() [2/2]

template<class VertexData >

std::vector< typename Vertices< VertexData >::VertexType > & SurgSim::DataStructures::Vertices< VertexData >::getVertices | ( |  | ) |

Returns a vector containing the position of each vertex (non const version).

## isEqual()

template<class VertexData >

bool SurgSim::DataStructures::Vertices< VertexData >::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. Base Mesh implementation compares vertices: the order of vertices must also match to be considered equal.

Parameters

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

Reimplemented in SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, TriangleData >, SurgSim::DataStructures::TriangleMesh< VertexData, SurgSim::DataStructures::EmptyData, SurgSim::DataStructures::EmptyData >, SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >, and SurgSim::DataStructures::TetrahedronMesh< VertexData, EdgeData, TriangleData, TetrahedronData >.

## operator!=()

template<class VertexData >

bool SurgSim::DataStructures::Vertices< VertexData >::operator!= | ( | const Vertices< VertexData > & | mesh | ) | const

Compares the mesh with another one (inequality)

Parameters

  mesh | The Vertices to compare it to

Returns
  False if the two vertices are equals, True otherwise

## operator=()

template<class VertexData >
template<class V >

Vertices< VertexData > & SurgSim::DataStructures::Vertices< VertexData >::operator= | ( | const Vertices< V > & | other | ) |

Assignment when the template data is a different type In this case, no data will be copied.

Template Parameters

  V | type of data stored in the other Vertices

Parameters

  other | the Vertices to copy from

## operator==()

template<class VertexData >

bool SurgSim::DataStructures::Vertices< VertexData >::operator== | ( | const Vertices< VertexData > & | mesh | ) | const

Compares the mesh with another one (equality)

Parameters

  mesh | The Vertices to compare it to

Returns
  True if the two vertices are equals, False otherwise

## setVertexPosition()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::setVertexPosition | ( | size_t | id,
|  | const SurgSim::Math::Vector3d & | position
| ) |  |

Sets the position of a vertex.

Parameters

  id | Unique ID of the vertex
  position | Position of the vertex

## setVertexPositions()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::setVertexPositions | ( | const std::vector< SurgSim::Math::Vector3d > & | positions,
|  | bool | doUpdate = `true`
| ) |  |

Sets the position of each vertex.

Parameters

  positions | Vector containing new position for each vertex
  doUpdate | True to perform an update after setting the vertices, false to skip update; default is true.

## transform()

template<class VertexData >

void SurgSim::DataStructures::Vertices< VertexData >::transform | ( | const Math::RigidTransform3d & | pose | ) |

Apply a rigid transform to each vertex.

Parameters

  pose | the rigid transform to apply

## update()

template<class VertexData >

bool SurgSim::DataStructures::Vertices< VertexData >::update | ( |  | ) |

Performs any updates that are required when the vertices are modified.

Calls doUpdate() to perform the updates.

Returns
  true on success.

## Member Data Documentation

## m_vertices

template<class VertexData>

std::vector<VertexType> SurgSim::DataStructures::Vertices< VertexData >::m_vertices

private

Vertices.

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

- SurgSim/DataStructures/Vertices.h
- SurgSim/DataStructures/Vertices-inl.h