TetrahedronMesh.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
#define SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
#include <vector>
#include "SurgSim/DataStructures/MeshElement.h"
#include "SurgSim/DataStructures/Vertices.h"
namespace SurgSim
{
namespace DataStructures
{
template <class VertexData, class EdgeData, class TriangleData, class TetrahedronData>
class TetrahedronMesh : public Vertices<VertexData>
{
public:
typedef MeshElement<2, EdgeData> EdgeType;
typedef MeshElement<3, TriangleData> TriangleType;
typedef MeshElement<4, TetrahedronData> TetrahedronType;
TetrahedronMesh();
virtual ~TetrahedronMesh();
size_t addEdge(const EdgeType& edge);
size_t addTriangle(const TriangleType& triangle);
size_t addTetrahedron(const TetrahedronType& tetrahedron);
size_t getNumEdges() const;
size_t getNumTriangles() const;
size_t getNumTetrahedrons() const;
const std::vector<EdgeType>& getEdges() const;
std::vector<EdgeType>& getEdges();
const std::vector<TriangleType>& getTriangles() const;
std::vector<TriangleType>& getTriangles();
const std::vector<TetrahedronType>& getTetrahedrons() const;
std::vector<TetrahedronType>& getTetrahedrons();
const EdgeType& getEdge(size_t id) const;
EdgeType& getEdge(size_t id);
const TriangleType& getTriangle(size_t id) const;
TriangleType& getTriangle(size_t id);
const TetrahedronType& getTetrahedron(size_t id) const;
TetrahedronType& getTetrahedron(size_t id);
bool isValid() const;
protected:
virtual void doClearEdges();
virtual void doClearTriangles();
virtual void doClearTetrahedrons();
virtual bool isEqual(const Vertices<VertexData>& mesh) const;
private:
virtual void doClear();
std::vector<EdgeType> m_edges;
std::vector<TriangleType> m_triangles;
std::vector<TetrahedronType> m_tetrahedrons;
};
}; // namespace DataStructures
}; // namespace SurgSim
#include "SurgSim/DataStructures/TetrahedronMesh-inl.h"
#endif // SURGSIM_DATASTRUCTURES_TETRAHEDRONMESH_H
SurgSim::DataStructures::TetrahedronMesh::getEdges
const std::vector< EdgeType > & getEdges() const
Returns a vector containing the position of each edge.
Definition: TetrahedronMesh-inl.h:91
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
Vertices.h
SurgSim::DataStructures::TetrahedronMesh::TetrahedronType
MeshElement< 4, TetrahedronData > TetrahedronType
Tetrahedron type for convenience (Ids of the 4 vertices)
Definition: TetrahedronMesh.h:68
SurgSim::DataStructures::TetrahedronMesh
Basic class for storing Tetrahedron Meshes, handling basic vertex, edge, triangle and tetrahedron fun...
Definition: TetrahedronMesh.h:60
SurgSim::DataStructures::TetrahedronMesh::isValid
bool isValid() const
Test if the TetrahedronMesh is valid (valid vertex Ids used in all MeshElements)
Definition: TetrahedronMesh-inl.h:187
SurgSim::DataStructures::TetrahedronMesh::m_tetrahedrons
std::vector< TetrahedronType > m_tetrahedrons
Tetrahedrons.
Definition: TetrahedronMesh.h:198
SurgSim::DataStructures::TetrahedronMesh::doClearEdges
virtual void doClearEdges()
Remove all edges from the mesh.
Definition: TetrahedronMesh-inl.h:246
SurgSim::DataStructures::TetrahedronMesh::getNumEdges
size_t getNumEdges() const
Returns the number of edges in this mesh.
Definition: TetrahedronMesh-inl.h:67
SurgSim::DataStructures::TetrahedronMesh::addTriangle
size_t addTriangle(const TriangleType &triangle)
Adds a triangle to the mesh.
Definition: TetrahedronMesh-inl.h:49
SurgSim::DataStructures::TetrahedronMesh::m_edges
std::vector< EdgeType > m_edges
Edges.
Definition: TetrahedronMesh.h:192
MeshElement.h
SurgSim::DataStructures::TetrahedronMesh::doClearTriangles
virtual void doClearTriangles()
Remove all triangles from the mesh.
Definition: TetrahedronMesh-inl.h:254
SurgSim::DataStructures::TetrahedronMesh::getNumTetrahedrons
size_t getNumTetrahedrons() const
Returns the number of tetrahedrons in this mesh.
Definition: TetrahedronMesh-inl.h:83
SurgSim::DataStructures::TetrahedronMesh::getTetrahedrons
const std::vector< TetrahedronType > & getTetrahedrons() const
Returns a vector containing the position of each tetrahedron.
Definition: TetrahedronMesh-inl.h:123
SurgSim::DataStructures::TetrahedronMesh::m_triangles
std::vector< TriangleType > m_triangles
Triangles.
Definition: TetrahedronMesh.h:195
SurgSim::DataStructures::TetrahedronMesh::isEqual
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
SurgSim::DataStructures::TetrahedronMesh::doClear
virtual void doClear()
Clear mesh to return to an empty state (no vertices, no edges, no triangles, no m_tetrahedrons).
Definition: TetrahedronMesh-inl.h:280
SurgSim::DataStructures::TetrahedronMesh::addEdge
size_t addEdge(const EdgeType &edge)
Adds an edge to the mesh.
Definition: TetrahedronMesh-inl.h:40
SurgSim::DataStructures::TetrahedronMesh::doClearTetrahedrons
virtual void doClearTetrahedrons()
Remove all tetrahedrons from the mesh.
Definition: TetrahedronMesh-inl.h:262
SurgSim::DataStructures::TetrahedronMesh::EdgeType
MeshElement< 2, EdgeData > EdgeType
Edge type for convenience (Ids of the 2 vertices)
Definition: TetrahedronMesh.h:64
SurgSim::DataStructures::TetrahedronMesh::addTetrahedron
size_t addTetrahedron(const TetrahedronType &tetrahedron)
Adds a tetrahedron to the mesh.
Definition: TetrahedronMesh-inl.h:58
TetrahedronMesh-inl.h
SurgSim::DataStructures::TetrahedronMesh::~TetrahedronMesh
virtual ~TetrahedronMesh()
Destructor.
Definition: TetrahedronMesh-inl.h:33
SurgSim::DataStructures::TetrahedronMesh::TetrahedronMesh
TetrahedronMesh()
Constructor. The mesh is initially empty (no vertices, no edges, no triangles, no tetrahedrons)...
Definition: TetrahedronMesh-inl.h:27
SurgSim::DataStructures::MeshElement
Element structure for meshes.
Definition: MeshElement.h:44
SurgSim::DataStructures::TetrahedronMesh::TriangleType
MeshElement< 3, TriangleData > TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: TetrahedronMesh.h:66
SurgSim::DataStructures::TetrahedronMesh::getTetrahedron
const TetrahedronType & getTetrahedron(size_t id) const
Returns the specified tetrahedron.
Definition: TetrahedronMesh-inl.h:171
SurgSim::DataStructures::TetrahedronMesh::getTriangle
const TriangleType & getTriangle(size_t id) const
Returns the specified triangle.
Definition: TetrahedronMesh-inl.h:155
SurgSim::DataStructures::TetrahedronMesh::getTriangles
const std::vector< TriangleType > & getTriangles() const
Returns a vector containing the position of each triangle.
Definition: TetrahedronMesh-inl.h:107
SurgSim::DataStructures::TetrahedronMesh::getEdge
const EdgeType & getEdge(size_t id) const
Returns the specified edge.
Definition: TetrahedronMesh-inl.h:139
SurgSim::DataStructures::Vertices
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
SurgSim::DataStructures::TetrahedronMesh::getNumTriangles
size_t getNumTriangles() const
Returns the number of triangles in this mesh.
Definition: TetrahedronMesh-inl.h:75