Go to the documentation of this file.
16 #ifndef SURGSIM_DATASTRUCTURES_VERTICES_INL_H
17 #define SURGSIM_DATASTRUCTURES_VERTICES_INL_H
26 namespace DataStructures
29 template <
class VertexData>
34 template <
class VertexData>
45 template <
class VertexData>
51 if (otherVertices.size() < m_vertices.size())
53 m_vertices.resize(otherVertices.size());
57 m_vertices.reserve(otherVertices.size());
60 auto vertex = m_vertices.begin();
61 auto otherVertex = otherVertices.begin();
62 for (; vertex != m_vertices.end(); ++vertex, ++otherVertex)
64 *vertex = *otherVertex;
66 for (; otherVertex != otherVertices.end(); ++otherVertex)
68 addVertex(VertexType(*otherVertex));
74 template <
class VertexData>
79 template <
class VertexData>
85 template <
class VertexData>
91 template <
class VertexData>
94 m_vertices.push_back(vertex);
95 return m_vertices.size() - 1;
98 template <
class VertexData>
101 return m_vertices.size();
104 template <
class VertexData>
107 return m_vertices[id];
110 template <
class VertexData>
113 return m_vertices[id];
116 template <
class VertexData>
122 template <
class VertexData>
128 template <
class VertexData>
131 m_vertices[id].position = position;
134 template <
class VertexData>
137 return m_vertices[id].position;
140 template <
class VertexData>
143 SURGSIM_ASSERT(m_vertices.size() == positions.size()) <<
"Number of positions must match number of vertices.";
145 for (
size_t i = 0; i < m_vertices.size(); ++i)
147 m_vertices[i].position = positions[i];
156 template <
class VertexData>
159 for (
auto& vertex : m_vertices)
165 template <
class VertexData>
168 return (
typeid(*
this) ==
typeid(mesh)) && isEqual(mesh);
171 template <
class VertexData>
174 return (
typeid(*
this) !=
typeid(mesh)) || ! isEqual(mesh);
177 template <
class VertexData>
183 template <
class VertexData>
189 template <
class VertexData>
195 template <
class VertexData>
204 #endif //SURGSIM_DATASTRUCTURES_VERTICES_INL_H
Vertices()
Constructor.
Definition: Vertices-inl.h:30
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
std::vector< VertexType > m_vertices
Vertices.
Definition: Vertices.h:158
bool update()
Performs any updates that are required when the vertices are modified.
Definition: Vertices-inl.h:86
virtual bool doUpdate()
Performs any updates that are required when the vertices are modified.
Definition: Vertices-inl.h:196
virtual ~Vertices()
Destructor.
Definition: Vertices-inl.h:75
void transform(const Math::RigidTransform3d &pose)
Apply a rigid transform to each vertex.
Definition: Vertices-inl.h:157
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:52
void setVertexPositions(const std::vector< SurgSim::Math::Vector3d > &positions, bool doUpdate=true)
Sets the position of each vertex.
Definition: Vertices-inl.h:141
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
const VertexType & getVertex(size_t id) const
Returns the specified vertex.
Definition: Vertices-inl.h:105
The header that provides the assertion API.
const std::vector< VertexType > & getVertices() const
Returns a vector containing the position of each vertex.
Definition: Vertices-inl.h:117
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
void clear()
Clear mesh to return to an empty state (no vertices).
Definition: Vertices-inl.h:80
Definition: CompoundShapeToGraphics.cpp:30
Vertex structure for meshes.
Definition: Vertex.h:45
void setVertexPosition(size_t id, const SurgSim::Math::Vector3d &position)
Sets the position of a vertex.
Definition: Vertices-inl.h:129
bool operator!=(const Vertices &mesh) const
Compares the mesh with another one (inequality)
Definition: Vertices-inl.h:172
virtual void doClear()
Clear mesh to return to an empty state (no vertices).
Definition: Vertices-inl.h:190
virtual bool isEqual(const Vertices &mesh) const
Internal comparison of meshes of the same type: returns true if equal, false if not equal.
Definition: Vertices-inl.h:184
size_t addVertex(const VertexType &vertex)
Adds a vertex to the mesh.
Definition: Vertices-inl.h:92
virtual void doClearVertices()
Remove all vertices from the mesh.
Definition: Vertices-inl.h:178
const SurgSim::Math::Vector3d & getVertexPosition(size_t id) const
Returns the position of a vertex.
Definition: Vertices-inl.h:135
size_t getNumVertices() const
Returns the number of vertices in this mesh.
Definition: Vertices-inl.h:99
SurgSim::Math::Vector3d position
Position of the vertex.
Definition: Vertex.h:82
Vertices< VertexData > & operator=(const Vertices< V > &other)
Assignment when the template data is a different type In this case, no data will be copied.
Definition: Vertices-inl.h:47
bool operator==(const Vertices &mesh) const
Compares the mesh with another one (equality)
Definition: Vertices-inl.h:166