All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
SurgSim::DataStructures::TriangleMesh Class Reference

A TriangleMesh stores normal information for the triangles. More...

#include <SurgSim/DataStructures/TriangleMesh.h>

Inheritance diagram for SurgSim::DataStructures::TriangleMesh:
Inheritance graph
[legend]
Collaboration diagram for SurgSim::DataStructures::TriangleMesh:
Collaboration graph
[legend]

Public Member Functions

 TriangleMesh ()
 Constructor. More...
 
template<class VertexDataSource , class EdgeDataSource , class TriangleDataSource >
 TriangleMesh (const TriangleMeshBase< VertexDataSource, EdgeDataSource, TriangleDataSource > &mesh)
 Templated constructor this lets us convert one mesh class into another mesh class. More...
 
const SurgSim::Math::Vector3dgetNormal (size_t triangleId)
 Get normal for triangle. More...
 
void calculateNormals ()
 Calculate normals for all triangles. More...
 
void copyWithTransform (const SurgSim::Math::RigidTransform3d &pose, const TriangleMesh &source)
 Sets the mesh's vertices and normals by transforming a similar mesh. More...
 
- Public Member Functions inherited from SurgSim::Framework::Asset
 Asset ()
 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::DataStructures::TriangleMeshBase< EmptyData, EmptyData, NormalData >
 TriangleMeshBase ()
 Constructor. The mesh is initially empty (no vertices, no edges, no triangles). More...
 
 TriangleMeshBase (const TriangleMeshBase< VertexDataSource, EdgeDataSource, TriangleDataSource > &mesh)
 Copy constructor. More...
 
virtual ~TriangleMeshBase ()
 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 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 EdgeTypegetEdge (size_t id) const
 Retrieve a specific edge. More...
 
EdgeTypegetEdge (size_t id)
 Retrieve a specific edge (non const version) More...
 
const TriangleTypegetTriangle (size_t id) const
 Retrieve a specific triangle. More...
 
TriangleTypegetTriangle (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 TriangleMeshBase is valid (valid vertex Ids used in all MeshElements) More...
 
- Public Member Functions inherited from SurgSim::DataStructures::Vertices< EmptyData >
 Vertices ()
 Constructor. The mesh is initially empty (no vertices). More...
 
virtual ~Vertices ()
 Destructor. More...
 
void clear ()
 Clear mesh to return to an empty state (no vertices). More...
 
void 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 VertexTypegetVertex (size_t id) const
 Returns the specified vertex. More...
 
VertexTypegetVertex (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::Vector3dgetVertexPosition (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...
 
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 doUpdate () override
 Performs any updates that are required when the vertices are modified. More...
 
virtual bool doLoad (const std::string &fileName) override
 Derived classes will overwrite this method to do actual loading. More...
 
- Protected Member Functions inherited from SurgSim::Framework::Asset
void serializeFileName (SurgSim::Framework::Accessible *accessible)
 Derived classes (which also inherit from SurgSim::Framework::Accessible) should call this function with 'this' pointer as the parameter in their constructors to register file name property for serialization. More...
 
- Protected Member Functions inherited from SurgSim::DataStructures::TriangleMeshBase< EmptyData, EmptyData, NormalData >
virtual void doClearEdges ()
 Remove all edges from the mesh. More...
 
virtual void doClearTriangles ()
 Remove all triangles from the mesh. More...
 
virtual bool isEqual (const Vertices< EmptyData > &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< EmptyData >
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...
 

Friends

class SurgSim::Math::MeshShape
 

Additional Inherited Members

- Public Types inherited from SurgSim::DataStructures::TriangleMeshBase< EmptyData, EmptyData, NormalData >
typedef MeshElement< 2, EmptyDataEdgeType
 Edge type for convenience (Ids of the 2 vertices) More...
 
typedef MeshElement
< 3, NormalData
TriangleType
 Triangle type for convenience (Ids of the 3 vertices) More...
 
- Public Types inherited from SurgSim::DataStructures::Vertices< EmptyData >
typedef Vertex< EmptyDataVertexType
 Vertex type for convenience. More...
 

Detailed Description

A TriangleMesh stores normal information for the triangles.

Constructor & Destructor Documentation

SurgSim::DataStructures::TriangleMesh::TriangleMesh ( )

Constructor.

template<class VertexDataSource , class EdgeDataSource , class TriangleDataSource >
SurgSim::DataStructures::TriangleMesh::TriangleMesh ( const TriangleMeshBase< VertexDataSource, EdgeDataSource, TriangleDataSource > &  mesh)
explicit

Templated constructor this lets us convert one mesh class into another mesh class.

Template Parameters
VertexDataSourceType of extra data stored in each vertex
EdgeDataSourceType of extra data stored in each edge
TriangleDataSourceType of extra data stored in each triangle
Parameters
meshThe mesh to be copied from. Vertex, edge and triangle data will be emptied.
See also
TriangleMeshBase

Member Function Documentation

void SurgSim::DataStructures::TriangleMesh::calculateNormals ( )

Calculate normals for all triangles.

Note
Normals will be normalized.
void SurgSim::DataStructures::TriangleMesh::copyWithTransform ( const SurgSim::Math::RigidTransform3d pose,
const TriangleMesh source 
)

Sets the mesh's vertices and normals by transforming a similar mesh.

The two meshes must have the same number of vertices, edges, and triangles.

Parameters
posethe transformation to be applied to the vertices and norms
sourcethe mesh suppling the vertices and norms
bool SurgSim::DataStructures::TriangleMesh::doLoad ( const std::string &  filePath)
overrideprotectedvirtual

Derived classes will overwrite this method to do actual loading.

Note
This method is not required to do any check on the validity or the existence of the file.
Parameters
filePathAbsolute path to the file.
Returns
True if loading is successful; Otherwise, false.

Implements SurgSim::Framework::Asset.

void SurgSim::DataStructures::TriangleMesh::doUpdate ( )
overrideprotectedvirtual

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.

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

const SurgSim::Math::Vector3d & SurgSim::DataStructures::TriangleMesh::getNormal ( size_t  triangleId)

Get normal for triangle.

Parameters
triangleIdThe triangle to get normal.
Returns
The normal for the triangle with given ID.

Friends And Related Function Documentation

friend class SurgSim::Math::MeshShape
friend

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