opensurgsim
TetrahedronMesh.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
17 #define SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
18 
19 #include <vector>
20 
21 #include "SurgSim/DataStructures/MeshElement.h"
22 #include "SurgSim/DataStructures/Vertices.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace DataStructures
28 {
29 
59 template <class VertexData, class EdgeData, class TriangleData, class TetrahedronData>
60 class TetrahedronMesh : public Vertices<VertexData>
61 {
62 public:
69 
72 
74  virtual ~TetrahedronMesh();
75 
83  size_t addEdge(const EdgeType& edge);
84 
91  size_t addTriangle(const TriangleType& triangle);
92 
99  size_t addTetrahedron(const TetrahedronType& tetrahedron);
100 
103  size_t getNumEdges() const;
104 
107  size_t getNumTriangles() const;
108 
111  size_t getNumTetrahedrons() const;
112 
115  const std::vector<EdgeType>& getEdges() const;
118  std::vector<EdgeType>& getEdges();
119 
122  const std::vector<TriangleType>& getTriangles() const;
125  std::vector<TriangleType>& getTriangles();
126 
129  const std::vector<TetrahedronType>& getTetrahedrons() const;
132  std::vector<TetrahedronType>& getTetrahedrons();
133 
138  const EdgeType& getEdge(size_t id) const;
143  EdgeType& getEdge(size_t id);
144 
149  const TriangleType& getTriangle(size_t id) const;
154  TriangleType& getTriangle(size_t id);
155 
160  const TetrahedronType& getTetrahedron(size_t id) const;
165  TetrahedronType& getTetrahedron(size_t id);
166 
169  bool isValid() const;
170 
171 protected:
173  virtual void doClearEdges();
174 
176  virtual void doClearTriangles();
177 
179  virtual void doClearTetrahedrons();
180 
185  virtual bool isEqual(const Vertices<VertexData>& mesh) const;
186 private:
187 
189  virtual void doClear();
190 
192  std::vector<EdgeType> m_edges;
193 
195  std::vector<TriangleType> m_triangles;
196 
198  std::vector<TetrahedronType> m_tetrahedrons;
199 };
200 
201 }; // namespace DataStructures
202 
203 }; // namespace SurgSim
204 
205 #include "SurgSim/DataStructures/TetrahedronMesh-inl.h"
206 
207 #endif // SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
const std::vector< EdgeType > & getEdges() const
Returns a vector containing the position of each edge.
Definition: TetrahedronMesh-inl.h:91
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
MeshElement< 4, TetrahedronData > TetrahedronType
Tetrahedron type for convenience (Ids of the 4 vertices)
Definition: TetrahedronMesh.h:68
Basic class for storing Tetrahedron Meshes, handling basic vertex, edge, triangle and tetrahedron fun...
Definition: TetrahedronMesh.h:60
bool isValid() const
Test if the TetrahedronMesh is valid (valid vertex Ids used in all MeshElements)
Definition: TetrahedronMesh-inl.h:187
virtual void doClearEdges()
Remove all edges from the mesh.
Definition: TetrahedronMesh-inl.h:246
size_t getNumEdges() const
Returns the number of edges in this mesh.
Definition: TetrahedronMesh-inl.h:67
size_t addTriangle(const TriangleType &triangle)
Adds a triangle to the mesh.
Definition: TetrahedronMesh-inl.h:49
virtual void doClearTriangles()
Remove all triangles from the mesh.
Definition: TetrahedronMesh-inl.h:254
size_t getNumTetrahedrons() const
Returns the number of tetrahedrons in this mesh.
Definition: TetrahedronMesh-inl.h:83
const std::vector< TetrahedronType > & getTetrahedrons() const
Returns a vector containing the position of each tetrahedron.
Definition: TetrahedronMesh-inl.h:123
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: TetrahedronMesh-inl.h:270
size_t addEdge(const EdgeType &edge)
Adds an edge to the mesh.
Definition: TetrahedronMesh-inl.h:40
virtual void doClearTetrahedrons()
Remove all tetrahedrons from the mesh.
Definition: TetrahedronMesh-inl.h:262
MeshElement< 2, EdgeData > EdgeType
Edge type for convenience (Ids of the 2 vertices)
Definition: TetrahedronMesh.h:64
size_t addTetrahedron(const TetrahedronType &tetrahedron)
Adds a tetrahedron to the mesh.
Definition: TetrahedronMesh-inl.h:58
virtual ~TetrahedronMesh()
Destructor.
Definition: TetrahedronMesh-inl.h:33
TetrahedronMesh()
Constructor. The mesh is initially empty (no vertices, no edges, no triangles, no tetrahedrons)...
Definition: TetrahedronMesh-inl.h:27
Element structure for meshes.
Definition: MeshElement.h:44
MeshElement< 3, TriangleData > TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: TetrahedronMesh.h:66
const TetrahedronType & getTetrahedron(size_t id) const
Returns the specified tetrahedron.
Definition: TetrahedronMesh-inl.h:171
const TriangleType & getTriangle(size_t id) const
Returns the specified triangle.
Definition: TetrahedronMesh-inl.h:155
const std::vector< TriangleType > & getTriangles() const
Returns a vector containing the position of each triangle.
Definition: TetrahedronMesh-inl.h:107
const EdgeType & getEdge(size_t id) const
Returns the specified edge.
Definition: TetrahedronMesh-inl.h:139
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
size_t getNumTriangles() const
Returns the number of triangles in this mesh.
Definition: TetrahedronMesh-inl.h:75