SegmentMesh.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_SEGMENTMESH_H
#define SURGSIM_DATASTRUCTURES_SEGMENTMESH_H
#include "SurgSim/DataStructures/SegmentEmptyData.h"
#include "SurgSim/DataStructures/TriangleMesh.h"
namespace SurgSim
{
namespace DataStructures
{
template <class VertexData, class EdgeData>
class SegmentMesh : public TriangleMesh<VertexData, EdgeData, SegmentEmptyData>
{
public:
typedef TriangleMesh<VertexData, EdgeData, SegmentEmptyData> TriangleMeshType;
typedef typename TriangleMeshType::EdgeType EdgeType;
typedef typename TriangleMeshType::TriangleType TriangleType;
SegmentMesh();
SegmentMesh(const SegmentMesh<VertexData, EdgeData>& other);
template <class V, class E>
explicit SegmentMesh(const SegmentMesh<V, E>& other);
virtual ~SegmentMesh();
SegmentMesh(SegmentMesh&& other);
SegmentMesh<VertexData, EdgeData>& operator=(
const SegmentMesh<VertexData, EdgeData>& other);
SegmentMesh<VertexData, EdgeData>& operator=(
SegmentMesh<VertexData, EdgeData>&& other);
void createDefaultEdges();
bool save(const std::string& fileName,
bool asPhysics = true,
double radius = 0.0001,
double massDensity = 900,
double poissonRatio = 0.45,
double youngsModulus = 1.75e9);
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::addEdge;
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::doClearEdges;
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::getNumEdges;
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::getNumVertices;
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::getEdges;
using TriangleMesh<VertexData, EdgeData, SegmentEmptyData>::getVertices;
size_t addTriangle(const TriangleType& triangle);
size_t getNumTriangles() const;
const std::vector<TriangleType>& getTriangles() const;
std::vector<TriangleType>& getTriangles();
const TriangleType& getTriangle(size_t id) const;
TriangleType& getTriangle(size_t id);
void removeTriangle(size_t id);
std::array<SurgSim::Math::Vector3d, 3> getTrianglePositions(size_t id) const;
void doClearTriangles() override;
private:
void doClear() override;
};
typedef SegmentMesh<EmptyData, EmptyData> SegmentMeshPlain;
} // namespace DataStructures
} // namespace SurgSim
#include "SurgSim/DataStructures/SegmentMesh-inl.h"
#endif // SURGSIM_DATASTRUCTURES_SEGMENTMESH_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::SegmentMeshPlain
SegmentMesh< EmptyData, EmptyData > SegmentMeshPlain
Definition: SegmentMesh.h:120
SurgSim::DataStructures::SegmentMesh::addTriangle
size_t addTriangle(const TriangleType &triangle)
Definition: SegmentMesh-inl.h:72
SegmentEmptyData.h
SurgSim::DataStructures::SegmentMesh::doClearTriangles
void doClearTriangles() override
Definition: SegmentMesh-inl.h:141
SurgSim::DataStructures::SegmentMesh::~SegmentMesh
virtual ~SegmentMesh()
Destructor.
Definition: SegmentMesh-inl.h:47
SurgSim::DataStructures::SegmentMesh::SegmentMesh
SegmentMesh()
Constructor. The mesh is initially empty (no vertices, no edges).
Definition: SegmentMesh-inl.h:28
SurgSim::DataStructures::SegmentMesh::removeTriangle
void removeTriangle(size_t id)
Definition: SegmentMesh-inl.h:118
SurgSim::DataStructures::SegmentMesh::TriangleMeshType
TriangleMesh< VertexData, EdgeData, SegmentEmptyData > TriangleMeshType
TriangleMesh type for convenience.
Definition: SegmentMesh.h:37
SurgSim::DataStructures::SegmentMesh
Class to hold the type of a SegmentMesh.
Definition: SegmentMesh.h:33
SurgSim::DataStructures::SegmentMesh::doClear
void doClear() override
Clear mesh to return to an empty state (no vertices, no edges).
Definition: SegmentMesh-inl.h:147
SurgSim::DataStructures::SegmentMesh::getNumTriangles
size_t getNumTriangles() const
Definition: SegmentMesh-inl.h:79
SurgSim::DataStructures::TriangleMesh< VertexData, EdgeData, SegmentEmptyData >::TriangleType
MeshElement< 3, SegmentEmptyData > TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: TriangleMesh.h:69
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::TriangleMesh
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMesh.h:62
SurgSim::DataStructures::MeshElement
Element structure for meshes.
Definition: MeshElement.h:44
SurgSim::DataStructures::SegmentMesh::getTrianglePositions
std::array< SurgSim::Math::Vector3d, 3 > getTrianglePositions(size_t id) const
Definition: SegmentMesh-inl.h:125
SurgSim::DataStructures::SegmentMesh::getTriangle
const TriangleType & getTriangle(size_t id) const
Definition: SegmentMesh-inl.h:103
SurgSim::DataStructures::SegmentMesh::operator=
SegmentMesh< VertexData, EdgeData > & operator=(const SegmentMesh< VertexData, EdgeData > &other)
Copy Assignment.
Definition: SegmentMesh-inl.h:58
SurgSim::DataStructures::SegmentMesh::TriangleType
TriangleMeshType::TriangleType TriangleType
Triangle type for convenience (Ids of the 3 vertices)
Definition: SegmentMesh.h:41
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::getTriangles
const std::vector< TriangleType > & getTriangles() const
Definition: SegmentMesh-inl.h:87
TriangleMesh.h
SegmentMesh-inl.h
SurgSim::DataStructures::SegmentMesh::EdgeType
TriangleMeshType::EdgeType EdgeType
Edge type for convenience (Ids of the 2 vertices)
Definition: SegmentMesh.h:39