SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData > Class Template Reference

Class to hold the type of a SegmentMesh. More...

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

Inheritance diagram for SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >:

## Public Types

typedef TriangleMesh< VertexData, EdgeData, SegmentEmptyData > | TriangleMeshType
| TriangleMesh type for convenience. More...
typedef TriangleMeshType::EdgeType | EdgeType
| Edge type for convenience (Ids of the 2 vertices) More...
typedef TriangleMeshType::TriangleType | TriangleType
| Triangle type for convenience (Ids of the 3 vertices) More...
Public Types inherited from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >
typedef MeshElement< 2, EdgeData > | EdgeType
| Edge type for convenience (Ids of the 2 vertices) More...
typedef MeshElement< 3, SegmentEmptyData > | TriangleType
| Triangle type for convenience (Ids of the 3 vertices) More...
Public Types inherited from SurgSim::DataStructures::Vertices< VertexData >
typedef Vertex< VertexData > | VertexType
| Vertex type for convenience. More...
Public Types inherited from SurgSim::Framework::Accessible
typedef std::function< boost::any(void)> | GetterType
typedef std::function< void(boost::any)> | SetterType
typedef std::function< YAML::Node(void)> | EncoderType
typedef std::function< void(const YAML::Node *)> | DecoderType
Public Types inherited from SurgSim::Framework::FactoryBase< Asset >
typedef ObjectFactory< Asset > | FactoryType

## Public Member Functions

| SegmentMesh ()
| Constructor. The mesh is initially empty (no vertices, no edges). More...
| SegmentMesh (const SegmentMesh< VertexData, EdgeData > &other)
| Copy constructor when the template data is the same type. More...
template<class V , class E >
| SegmentMesh (const SegmentMesh< V, E > &other)
| Copy constructor when the template data is a different type. More...
virtual | ~SegmentMesh ()
| Destructor. More...
| SegmentMesh (SegmentMesh &&other)
| Move Constructor. More...
SegmentMesh< VertexData, EdgeData > & | operator= (const SegmentMesh< VertexData, EdgeData > &other)
| Copy Assignment. More...
SegmentMesh< VertexData, EdgeData > & | operator= (SegmentMesh< VertexData, EdgeData > &&other)
| Move Assignment. More...
void | createDefaultEdges ()
| Creates edges for all vertices in the mesh connecting all the points consecutively. More...
bool | save (const std::string &fileName, bool asPhysics=true, double radius=0.0001, double massDensity=900, double poissonRatio=0.45, double youngsModulus=1.75e9)
| Save the current structure to a ply file. More...
size_t | addTriangle (const TriangleType &triangle)
size_t | getNumTriangles () const
const std::vector< TriangleType > & | getTriangles () const
std::vector< TriangleType > & | getTriangles ()
const TriangleType & | getTriangle (size_t id) const
TriangleType & | getTriangle (size_t id)
void | removeTriangle (size_t id)
std::array< SurgSim::Math::Vector3d, 3 > | getTrianglePositions (size_t id) const
void | doClearTriangles () override
Public Member Functions inherited from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >
| TriangleMesh ()
| Constructor. The mesh is initially empty (no vertices, no edges, no triangles). More...
| TriangleMesh (const TriangleMesh< VertexData, EdgeData, SegmentEmptyData > &other)
| Copy constructor when the template data is the same type. More...
| TriangleMesh (const TriangleMesh< V, E, T > &other)
| Copy constructor when the template data is a different type. More...
| TriangleMesh (TriangleMesh &&other)
| Move Constructor. More...
virtual | ~TriangleMesh ()
| Destructor. More...
TriangleMesh< VertexData, EdgeData, SegmentEmptyData > & | operator= (const TriangleMesh< VertexData, EdgeData, SegmentEmptyData > &other)
| Copy Assignment. More...
TriangleMesh< VertexData, EdgeData, SegmentEmptyData > & | operator= (TriangleMesh< VertexData, EdgeData, SegmentEmptyData > &&other)
| Move Assignment. More...
std::string | getClassName () const override
| Support serialization with a classname. 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 | getNumEdges () const
| Get the number of edges. More...
size_t | getNumTriangles () const
| Get the number of triangles. More...
const std::vector< EdgeType > & | getEdges () const
| Retrieve all edges. More...
std::vector< EdgeType > & | getEdges ()
| Retrieve all edges (non const version) More...
const std::vector< TriangleType > & | getTriangles () const
| Retrieve all triangles. More...
std::vector< TriangleType > & | getTriangles ()
| Retrieve all triangles (non const version) More...
const EdgeType & | getEdge (size_t id) const
| Retrieve a specific edge. More...
EdgeType & | getEdge (size_t id)
| Retrieve a specific edge (non const version) More...
std::array< SurgSim::Math::Vector3d, 2 > | getEdgePositions (size_t id) const
| Returns an array of the edge's vertices' positions. More...
const TriangleType & | getTriangle (size_t id) const
| Retrieve a specific triangle. More...
TriangleType & | getTriangle (size_t id)
| Retrieve a specific triangle (non const version) More...
void | removeTriangle (size_t id)
| Marks a triangle as invalid, the triangle cannot be accessed via getTriangle anymore. More...
std::array< SurgSim::Math::Vector3d, 3 > | getTrianglePositions (size_t id) const
| Returns an array of the triangle's vertices' positions. More...
bool | isValid () const
| Test if the TriangleMesh is valid (valid vertex Ids used in all MeshElements) More...
void | save (const std::string &fileName)
| Save the triangle mesh in the ply format. 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...
Public Member Functions inherited from SurgSim::Framework::Asset
| Asset ()
| Constructor. More...
| Asset (const Asset &rhs)
| Copy Constructor. More...
virtual | ~Asset ()
| Destructor. More...
void | load (const std::string &fileName, const SurgSim::Framework::ApplicationData &data)
| Load a file with given name using 'data' as look up path(s). More...
void | load (const std::string &fileName)
| Overloaded function using SurgSim::Framework::Runtime::getApplicationData() as look up path(s). More...
std::string | getFileName () const
| Return the name of file loaded by this class. More...
Public Member Functions inherited from SurgSim::Framework::Accessible
| Accessible ()
| Default Constructor. More...
| ~Accessible ()
| Destructor. More...
template<class T >
T | getValue (const std::string &name) const
| Retrieves the value with the name by executing the getter if it is found and tries to convert it to the given type. More...
boost::any | getValue (const std::string &name) const
| Retrieves the value with the name by executing the getter if it is found. More...
template<class T >
bool | getValue (const std::string &name, T *value) const
| Retrieves the value with the name by executing the getter if it is found, and converts it to the type of the output parameter. More...
void | setValue (const std::string &name, const boost::any &value)
| Sets a value of a property that has setter. More...
bool | isReadable (const std::string &name) const
| Check whether a property is readable. More...
bool | isWriteable (const std::string &name) const
| Check whether a property is writable. More...
void | setGetter (const std::string &name, GetterType func)
| Sets a getter for a given property. More...
void | setSetter (const std::string &name, SetterType func)
| Sets a setter for a given property. More...
void | setAccessors (const std::string &name, GetterType getter, SetterType setter)
| Sets the accessors getter and setter in one function. More...
void | removeAccessors (const std::string &name)
| Removes all the accessors (getter and setter) for a given property. More...
void | forwardProperty (const std::string &name, const Accessible &target, const std::string &targetProperty)
| Adds a property with the given name that uses the targets accessors, in effect forwarding the value to the target. More...
void | setSerializable (const std::string &name, EncoderType encoder, DecoderType decoder)
| Sets the functions used to convert data from and to a YAML::Node. More...
void | setDecoder (const std::string &name, DecoderType decoder)
| Sets the functions used to convert data from a YAML::Node. More...
YAML::Node | encode () const
| Encode this Accessible to a YAML::Node. More...
void | decode (const YAML::Node &node, const std::vector< std::string > &ignoredProperties=std::vector< std::string >())
| Decode this Accessible from a YAML::Node, will throw an exception if the data type cannot be converted. More...
template<>
boost::any | getValue (const std::string &name) const

## Private Member Functions

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

## Additional Inherited Members

Static Public Member Functions inherited from SurgSim::Framework::FactoryBase< Asset >
static FactoryType & | getFactory ()
Protected Member Functions inherited from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >
std::string | m_className
std::string | m_className
virtual void | doClearEdges ()
| Remove all edges 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...
bool | doLoad (const std::string &fileName) override
| Derived classes will overwrite this method to do actual loading. More...
Protected Member Functions inherited from SurgSim::DataStructures::Vertices< VertexData >
virtual void | doClearVertices ()
| Remove all vertices from the mesh. More...
Static Protected Attributes inherited from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >
static std::string | m_className

## Detailed Description

### template<class VertexData, class EdgeData>
class SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >

Class to hold the type of a SegmentMesh.

Template Parameters

  VertexData | Type of extra data stored in each vertex
  EdgeData | Type of extra data stored in each edge

See also
  TriangleMesh

## Member Typedef Documentation

## EdgeType

template<class VertexData, class EdgeData>

typedef TriangleMeshType::EdgeType SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::EdgeType

Edge type for convenience (Ids of the 2 vertices)

## TriangleMeshType

template<class VertexData, class EdgeData>

typedef TriangleMesh<VertexData, EdgeData, SegmentEmptyData> SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::TriangleMeshType

TriangleMesh type for convenience.

## TriangleType

template<class VertexData, class EdgeData>

typedef TriangleMeshType::TriangleType SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::TriangleType

Triangle type for convenience (Ids of the 3 vertices)

## Constructor & Destructor Documentation

## SegmentMesh() [1/4]

template<class VertexData , class EdgeData >

SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::SegmentMesh | ( |  | ) |

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

## SegmentMesh() [2/4]

template<class VertexData , class EdgeData >

SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::SegmentMesh | ( | const SegmentMesh< VertexData, EdgeData > & | other | ) |

Copy constructor when the template data is the same type.

Parameters

  other | the mesh to copy from

## SegmentMesh() [3/4]

template<class VertexData , class EdgeData >
template<class V , class E >

SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::SegmentMesh | ( | const SegmentMesh< V, E > & | other | ) |

explicit

Copy constructor when the template data is a different type.

Template Parameters

  V | Type of extra data stored in each vertex
  E | Type of extra data stored in each edge

Parameters

  other | The mesh to be copied from. Vertex and edge data will not be copied

Note
  : Data of the input mesh, i.e. VertexDataSource, EdgeDataSource will not be copied.

## ~SegmentMesh()

template<class VertexData , class EdgeData >

SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::~SegmentMesh | ( |  | ) |

virtual

Destructor.

## SegmentMesh() [4/4]

template<class VertexData , class EdgeData >

SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::SegmentMesh | ( | SegmentMesh< VertexData, EdgeData > && | other | ) |

Move Constructor.

Parameters

  other | Constructor source

## Member Function Documentation

## addTriangle()

template<class VertexData , class EdgeData >

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

Functions that need to assert, because they deal with triangles.

## createDefaultEdges()

template<class VertexData , class EdgeData >

void SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::createDefaultEdges | ( |  | ) |

Creates edges for all vertices in the mesh connecting all the points consecutively.

Note
  This will clear all the current edges

## doClear()

template<class VertexData , class EdgeData >

void SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::doClear | ( |  | ) |

override private virtual

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

Reimplemented from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >.

## doClearTriangles()

template<class VertexData , class EdgeData >

void SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::doClearTriangles | ( |  | ) |

override virtual

Functions that need to assert, because they deal with triangles.

Reimplemented from SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >.

## getNumTriangles()

template<class VertexData , class EdgeData >

size_t SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::getNumTriangles | ( |  | ) | const

Functions that need to assert, because they deal with triangles.

## getTriangle() [1/2]

template<class VertexData , class EdgeData >

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

Functions that need to assert, because they deal with triangles.

## getTriangle() [2/2]

template<class VertexData , class EdgeData >

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

Functions that need to assert, because they deal with triangles.

## getTrianglePositions()

template<class VertexData , class EdgeData >

std::array< SurgSim::Math::Vector3d, 3 > SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::getTrianglePositions | ( | size_t | id | ) | const

Functions that need to assert, because they deal with triangles.

## getTriangles() [1/2]

template<class VertexData , class EdgeData >

const std::vector< typename SegmentMesh< VertexData, EdgeData >::TriangleType > & SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::getTriangles | ( |  | ) | const

Functions that need to assert, because they deal with triangles.

## getTriangles() [2/2]

template<class VertexData , class EdgeData >

std::vector< typename SegmentMesh< VertexData, EdgeData >::TriangleType > & SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::getTriangles | ( |  | ) |

Functions that need to assert, because they deal with triangles.

## operator=() [1/2]

template<class VertexData , class EdgeData >

SegmentMesh< VertexData, EdgeData > & SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::operator= | ( | const SegmentMesh< VertexData, EdgeData > & | other | ) |

Copy Assignment.

Parameters

  other | Assignment source

## operator=() [2/2]

template<class VertexData , class EdgeData >

SegmentMesh< VertexData, EdgeData > & SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::operator= | ( | SegmentMesh< VertexData, EdgeData > && | other | ) |

Move Assignment.

Parameters

  other | Assignment source

## removeTriangle()

template<class VertexData , class EdgeData >

void SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::removeTriangle | ( | size_t | id | ) |

Functions that need to assert, because they deal with triangles.

## save()

template<class VertexData , class EdgeData >

bool SurgSim::DataStructures::SegmentMesh< VertexData, EdgeData >::save | ( | const std::string & | fileName,
|  | bool | asPhysics = `true`,
|  | double | radius = `0.0001`,
|  | double | massDensity = `900`,
|  | double | poissonRatio = `0.45`,
|  | double | youngsModulus = `1.75e9`
| ) |  |

Save the current structure to a ply file.

Parameters

  fileName | Name of the file for writing
  asPhysics | Format the file to be used as a physics file, otherwise the file will be ply format with 'edge' as the edge element
  radius | if asPhysics is true, this will be used as the radius for the ply file
  massDensity | if asPhysics is true, this will be used as the massDensity for the ply file
  poissonRatio | if asPhysics is true, this will be used as the poissonRatio for the ply file
  youngsModulus | if asPhysics is true, this will be used as the youngsModulus for the ply file

Returns
  true if the file was written successfully

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

- SurgSim/DataStructures/SegmentMesh.h
- SurgSim/DataStructures/SegmentMesh-inl.h