16 #ifndef SURGSIM_DATASTRUCTURES_TRIANGLEMESH_H 17 #define SURGSIM_DATASTRUCTURES_TRIANGLEMESH_H 22 #include "SurgSim/DataStructures/EmptyData.h" 23 #include "SurgSim/DataStructures/MeshElement.h" 24 #include "SurgSim/DataStructures/NormalData.h" 25 #include "SurgSim/DataStructures/TriangleMeshPlyReaderDelegate.h" 26 #include "SurgSim/DataStructures/Vertices.h" 27 #include "SurgSim/Framework/Asset.h" 31 namespace DataStructures
61 template <
class VertexData,
class EdgeData,
class TriangleData>
63 public std::enable_shared_from_this<TriangleMesh<VertexData, EdgeData, TriangleData>>
84 template <
class V,
class E,
class T>
114 size_t addEdge(
const EdgeType& edge);
137 const std::vector<EdgeType>&
getEdges()
const;
162 const EdgeType&
getEdge(
size_t id)
const;
204 void save(
const std::string& fileName);
220 bool doLoad(
const std::string& fileName)
override;
224 static std::string m_className;
229 virtual void doClear();
232 std::vector<EdgeType> m_edges;
235 std::vector<TriangleType> m_triangles;
238 std::vector<size_t> m_freeTriangles;
254 #include "SurgSim/DataStructures/TriangleMesh-inl.h" 256 #endif // SURGSIM_DATASTRUCTURES_TRIANGLEMESH_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
This class is used to facilitate file loading.
Definition: Asset.h:39
const TriangleType & getTriangle(size_t id) const
Retrieve a specific triangle.
Definition: TriangleMesh-inl.h:179
size_t addTriangle(const TriangleType &triangle)
Adds a triangle to the mesh.
Definition: TriangleMesh-inl.h:88
std::array< SurgSim::Math::Vector3d, 2 > getEdgePositions(size_t id) const
Returns an array of the edge's vertices' positions.
Definition: TriangleMesh-inl.h:165
bool isValid() const
Test if the TriangleMesh is valid (valid vertex Ids used in all MeshElements)
Definition: TriangleMesh-inl.h:223
virtual void doClearTriangles()
Remove all triangles from the mesh.
Definition: TriangleMesh-inl.h:265
Vertex structure for meshes.
Definition: Vertex.h:44
void removeTriangle(size_t id)
Marks a triangle as invalid, the triangle cannot be accessed via getTriangle anymore.
Definition: TriangleMesh-inl.h:197
const std::vector< TriangleType > & getTriangles() const
Retrieve all triangles.
Definition: TriangleMesh-inl.h:137
virtual bool isEqual(const Vertices< VertexData > &mesh) const
Internal comparison of meshes of the same type: returns true if equal, false if not equal...
Definition: TriangleMesh-inl.h:272
virtual void doClearEdges()
Remove all edges from the mesh.
Definition: TriangleMesh-inl.h:259
std::array< SurgSim::Math::Vector3d, 3 > getTrianglePositions(size_t id) const
Returns an array of the triangle's vertices' positions.
Definition: TriangleMesh-inl.h:209
void save(const std::string &fileName)
Save the triangle mesh in the ply format.
Definition: TriangleMesh-inl.h:346
TriangleMesh()
Constructor. The mesh is initially empty (no vertices, no edges, no triangles).
Definition: TriangleMesh-inl.h:28
MeshElement< 3, TriangleData > TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: TriangleMesh.h:69
virtual ~TriangleMesh()
Destructor.
Definition: TriangleMesh-inl.h:69
const EdgeType & getEdge(size_t id) const
Retrieve a specific edge.
Definition: TriangleMesh-inl.h:151
TriangleMesh< VertexData, EdgeData, TriangleData > & operator=(const TriangleMesh< VertexData, EdgeData, TriangleData > &other)
Copy Assignment.
Definition: TriangleMesh-inl.h:322
MeshElement< 2, EdgeData > EdgeType
Edge type for convenience (Ids of the 2 vertices)
Definition: TriangleMesh.h:67
size_t addEdge(const EdgeType &edge)
Adds an edge to the mesh.
Definition: TriangleMesh-inl.h:81
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMesh.h:62
Element structure for meshes.
Definition: MeshElement.h:44
const std::vector< EdgeType > & getEdges() const
Retrieve all edges.
Definition: TriangleMesh-inl.h:123
size_t getNumTriangles() const
Get the number of triangles.
Definition: TriangleMesh-inl.h:116
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
bool doLoad(const std::string &fileName) override
Derived classes will overwrite this method to do actual loading.
Definition: TriangleMesh-inl.h:280
std::string getClassName() const override
Support serialization with a classname.
Definition: TriangleMesh-inl.h:74
size_t getNumEdges() const
Get the number of edges.
Definition: TriangleMesh-inl.h:110