SegmentMesh.h
Go to the documentation of this file.
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_SEGMENTMESH_H
17 #define SURGSIM_DATASTRUCTURES_SEGMENTMESH_H
18 
21 
22 namespace SurgSim
23 {
24 namespace DataStructures
25 {
26 
32 template <class VertexData, class EdgeData>
33 class SegmentMesh : public TriangleMesh<VertexData, EdgeData, SegmentEmptyData>
34 {
35 public:
42 
44  SegmentMesh();
45 
49 
55  template <class V, class E>
56  explicit SegmentMesh(const SegmentMesh<V, E>& other);
57 
59  virtual ~SegmentMesh();
60 
63  SegmentMesh(SegmentMesh&& other);
64 
69 
74 
77  void createDefaultEdges();
78 
88  bool save(const std::string& fileName,
89  bool asPhysics = true,
90  double radius = 0.0001,
91  double massDensity = 900,
92  double poissonRatio = 0.45,
93  double youngsModulus = 1.75e9);
94 
101 
104  size_t addTriangle(const TriangleType& triangle);
105  size_t getNumTriangles() const;
106  const std::vector<TriangleType>& getTriangles() const;
107  std::vector<TriangleType>& getTriangles();
108  const TriangleType& getTriangle(size_t id) const;
109  TriangleType& getTriangle(size_t id);
110  void removeTriangle(size_t id);
111  std::array<SurgSim::Math::Vector3d, 3> getTrianglePositions(size_t id) const;
112  void doClearTriangles() override;
114 
115 private:
117  void doClear() override;
118 };
119 
121 
122 } // namespace DataStructures
123 } // namespace SurgSim
124 
126 
127 #endif // SURGSIM_DATASTRUCTURES_SEGMENTMESH_H
SurgSim::DataStructures::SegmentMesh::getNumTriangles
size_t getNumTriangles() const
Definition: SegmentMesh-inl.h:79
SurgSim::DataStructures::TriangleMesh
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality.
Definition: TriangleMesh.h:64
SurgSim::DataStructures::SegmentMesh::createDefaultEdges
void createDefaultEdges()
Creates edges for all vertices in the mesh connecting all the points consecutively.
Definition: SegmentMesh-inl.h:154
SurgSim::DataStructures::SegmentMesh::TriangleMeshType
TriangleMesh< VertexData, EdgeData, SegmentEmptyData > TriangleMeshType
TriangleMesh type for convenience.
Definition: SegmentMesh.h:37
SurgSim::DataStructures::SegmentMesh::TriangleType
TriangleMeshType::TriangleType TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: SegmentMesh.h:41
SurgSim::DataStructures::SegmentMeshPlain
SegmentMesh< EmptyData, EmptyData > SegmentMeshPlain
Definition: SegmentMesh.h:120
SurgSim::DataStructures::SegmentMesh::getTriangle
const TriangleType & getTriangle(size_t id) const
Definition: SegmentMesh-inl.h:103
SegmentMesh-inl.h
SurgSim::DataStructures::MeshElement
Element structure for meshes.
Definition: MeshElement.h:45
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >::TriangleType
MeshElement< 3, SegmentEmptyData > TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: TriangleMesh.h:69
SegmentEmptyData.h
TriangleMesh.h
SurgSim::DataStructures::SegmentMesh::addTriangle
size_t addTriangle(const TriangleType &triangle)
Definition: SegmentMesh-inl.h:72
SurgSim::DataStructures::SegmentMesh::operator=
SegmentMesh< VertexData, EdgeData > & operator=(const SegmentMesh< VertexData, EdgeData > &other)
Copy Assignment.
Definition: SegmentMesh-inl.h:58
SurgSim::DataStructures::SegmentMesh::SegmentMesh
SegmentMesh()
Constructor. The mesh is initially empty (no vertices, no edges).
Definition: SegmentMesh-inl.h:28
SurgSim::DataStructures::SegmentMesh::save
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.
Definition: SegmentMesh-inl.h:167
SurgSim::DataStructures::SegmentMesh::~SegmentMesh
virtual ~SegmentMesh()
Destructor.
Definition: SegmentMesh-inl.h:47
SurgSim::DataStructures::SegmentMesh::removeTriangle
void removeTriangle(size_t id)
Definition: SegmentMesh-inl.h:118
SurgSim::DataStructures::SegmentMesh::getTriangles
const std::vector< TriangleType > & getTriangles() const
Definition: SegmentMesh-inl.h:87
SurgSim::DataStructures::SegmentMesh::EdgeType
TriangleMeshType::EdgeType EdgeType
Edge type for convenience (Ids of the 2 vertices)
Definition: SegmentMesh.h:39
SurgSim::DataStructures::SegmentMesh
Class to hold the type of a SegmentMesh.
Definition: SegmentMesh.h:34
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::DataStructures::SegmentMesh::doClearTriangles
void doClearTriangles() override
Definition: SegmentMesh-inl.h:141
SurgSim::DataStructures::SegmentMesh::getTrianglePositions
std::array< SurgSim::Math::Vector3d, 3 > getTrianglePositions(size_t id) const
Definition: SegmentMesh-inl.h:125
SurgSim::DataStructures::SegmentMesh::doClear
void doClear() override
Clear mesh to return to an empty state (no vertices, no edges).
Definition: SegmentMesh-inl.h:147