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)
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)
161 vertex.position = pose * vertex.position;
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>
186 return m_vertices == mesh.m_vertices;
189 template <
class VertexData>
195 template <
class VertexData>
204 #endif //SURGSIM_DATASTRUCTURES_VERTICES_INL_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
void transform(const Math::RigidTransform3d &pose)
Apply a rigid transform to each vertex.
Definition: Vertices-inl.h:157
size_t getNumVertices() const
Returns the number of vertices in this mesh.
Definition: Vertices-inl.h:99
virtual ~Vertices()
Destructor.
Definition: Vertices-inl.h:75
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
Vertices()
Constructor.
Definition: Vertices-inl.h:30
bool update()
Performs any updates that are required when the vertices are modified.
Definition: Vertices-inl.h:86
const VertexType & getVertex(size_t id) const
Returns the specified vertex.
Definition: Vertices-inl.h:105
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
void setVertexPositions(const std::vector< SurgSim::Math::Vector3d > &positions, bool doUpdate=true)
Sets the position of each vertex.
Definition: Vertices-inl.h:141
Vertex structure for meshes.
Definition: Vertex.h:44
const std::vector< VertexType > & getVertices() const
Returns a vector containing the position of each vertex.
Definition: Vertices-inl.h:117
void setVertexPosition(size_t id, const SurgSim::Math::Vector3d &position)
Sets the position of a vertex.
Definition: Vertices-inl.h:129
The header that provides the assertion API.
size_t addVertex(const VertexType &vertex)
Adds a vertex to the mesh.
Definition: Vertices-inl.h:92
void clear()
Clear mesh to return to an empty state (no vertices).
Definition: Vertices-inl.h:80
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
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
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
bool operator!=(const Vertices &mesh) const
Compares the mesh with another one (inequality)
Definition: Vertices-inl.h:172