16 #ifndef SURGSIM_DATASTRUCTURES_SEGMENTMESH_INL_H 17 #define SURGSIM_DATASTRUCTURES_SEGMENTMESH_INL_H 24 namespace DataStructures
27 template <
class VertexData,
class EdgeData>
32 template <
class VertexData,
class EdgeData>
39 template <
class VertexData,
class EdgeData>
40 template <
class V,
class E>
46 template <
class VertexData,
class EdgeData>
51 template <
class VertexData,
class EdgeData>
57 template <
class VertexData,
class EdgeData>
64 template <
class VertexData,
class EdgeData>
71 template <
class VertexData,
class EdgeData>
75 return static_cast<size_t>(0);
78 template <
class VertexData,
class EdgeData>
82 return static_cast<size_t>(0);
85 template <
class VertexData,
class EdgeData>
86 const std::vector<typename SegmentMesh<VertexData, EdgeData>::TriangleType>&
93 template <
class VertexData,
class EdgeData>
94 std::vector<typename SegmentMesh<VertexData, EdgeData>::TriangleType>&
101 template <
class VertexData,
class EdgeData>
109 template <
class VertexData,
class EdgeData>
117 template <
class VertexData,
class EdgeData>
123 template <
class VertexData,
class EdgeData>
124 std::array<SurgSim::Math::Vector3d, 3>
129 std::array<Vector3d, 3> result =
140 template <
class VertexData,
class EdgeData>
146 template <
class VertexData,
class EdgeData>
153 template <
class VertexData,
class EdgeData>
159 std::array<size_t, 2> vertices = { i, i + 1 };
166 template <
class VertexData,
class EdgeData>
172 double youngsModulus)
174 std::fstream out(fileName, std::ios::out);
178 out <<
"ply" << std::endl;
179 out <<
"format ascii 1.0" << std::endl;
180 out <<
"comment Created by OpenSurgSim, www.opensurgsim.org" << std::endl;
182 out <<
"property float x\nproperty float y\nproperty float z" << std::endl;
185 out <<
"element 1d_element " <<
getNumEdges() << std::endl;
186 out <<
"property list uint uint vertex_indices" << std::endl;
187 out <<
"element radius 1" << std::endl;
188 out <<
"property double value" << std::endl;
189 out <<
"element material 1" << std::endl;
190 out <<
"property double mass_density" << std::endl;
191 out <<
"property double poisson_ratio" << std::endl;
192 out <<
"property double young_modulus" << std::endl;
193 out <<
"element boundary_condition 0" << std::endl;
194 out <<
"property uint vertex_index" << std::endl;
198 out <<
"element edge " <<
getNumEdges() << std::endl;
199 out <<
"property uint vertex1" << std::endl;
200 out <<
"property uint vertex2" << std::endl;
202 out <<
"end_header" << std::endl;
205 out << vertex.position[0] <<
" " << vertex.position[1] <<
" " << vertex.position[2] << std::endl;
214 out << edge.verticesId[0] <<
" " << edge.verticesId[1] << std::endl;
218 out << radius << std::endl;
219 out << massDensity <<
" " << poissonRatio <<
" " << youngsModulus << std::endl;
225 <<
"There was a problem writing " << fileName;
233 <<
"Could not open " << fileName <<
" for writing.";
243 #endif // SURGSIM_DATASTRUCTURES_SEGMENTMESH_INL_H Definition: CompoundShapeToGraphics.cpp:29
const TriangleType & getTriangle(size_t id) const
Retrieve a specific triangle.
Definition: TriangleMesh-inl.h:179
size_t addTriangle(const TriangleType &triangle)
Definition: SegmentMesh-inl.h:72
size_t getNumVertices() const
Returns the number of vertices in this mesh.
Definition: Vertices-inl.h:99
void doClearTriangles() override
Definition: SegmentMesh-inl.h:141
#define SURGSIM_LOG_WARNING(logger)
Logs a message to the specified logger at the WARNING level.
Definition: LogMacros.h:96
virtual ~SegmentMesh()
Destructor.
Definition: SegmentMesh-inl.h:47
SegmentMesh()
Constructor. The mesh is initially empty (no vertices, no edges).
Definition: SegmentMesh-inl.h:28
#define SURGSIM_FAILURE()
Report that something very bad has happened and abort program execution.
Definition: Assert.h:95
The convenience header that provides the entirety of the logging API.
const std::vector< VertexType > & getVertices() const
Returns a vector containing the position of each vertex.
Definition: Vertices-inl.h:117
void removeTriangle(size_t id)
Definition: SegmentMesh-inl.h:118
const std::vector< TriangleType > & getTriangles() const
Retrieve all triangles.
Definition: TriangleMesh-inl.h:137
Class to hold the type of a SegmentMesh.
Definition: SegmentMesh.h:33
virtual void doClearEdges()
Remove all edges from the mesh.
Definition: TriangleMesh-inl.h:259
void doClear() override
Clear mesh to return to an empty state (no vertices, no edges).
Definition: SegmentMesh-inl.h:147
size_t getNumTriangles() const
Definition: SegmentMesh-inl.h:79
void createDefaultEdges()
Creates edges for all vertices in the mesh connecting all the points consecutively.
Definition: SegmentMesh-inl.h:154
TriangleMesh< VertexData, EdgeData, SegmentEmptyData > & operator=(const TriangleMesh< VertexData, EdgeData, SegmentEmptyData > &other)
Copy Assignment.
Definition: TriangleMesh-inl.h:322
size_t addEdge(const EdgeType &edge)
Adds an edge to the mesh.
Definition: TriangleMesh-inl.h:81
Element structure for meshes.
Definition: MeshElement.h:44
std::array< SurgSim::Math::Vector3d, 3 > getTrianglePositions(size_t id) const
Definition: SegmentMesh-inl.h:125
static std::shared_ptr< Logger > getDefaultLogger()
Get default logger.
Definition: Logger.h:116
virtual void doClearVertices()
Remove all vertices from the mesh.
Definition: Vertices-inl.h:178
const TriangleType & getTriangle(size_t id) const
Definition: SegmentMesh-inl.h:103
const std::vector< EdgeType > & getEdges() const
Retrieve all edges.
Definition: TriangleMesh-inl.h:123
SegmentMesh< VertexData, EdgeData > & operator=(const SegmentMesh< VertexData, EdgeData > &other)
Copy Assignment.
Definition: SegmentMesh-inl.h:58
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
TriangleMeshType::TriangleType TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: SegmentMesh.h:41
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
const std::vector< TriangleType > & getTriangles() const
Definition: SegmentMesh-inl.h:87
size_t getNumEdges() const
Get the number of edges.
Definition: TriangleMesh-inl.h:110