Vertices.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_VERTICES_H
#define SURGSIM_DATASTRUCTURES_VERTICES_H
#include <vector>
#include "SurgSim/DataStructures/EmptyData.h"
#include "SurgSim/DataStructures/Vertex.h"
#include "SurgSim/Math/RigidTransform.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace DataStructures
{
template <class VertexData>
class Vertices
{
public:
typedef Vertex<VertexData> VertexType;
Vertices();
template <class V>
explicit Vertices(const Vertices<V>& other);
template <class V>
Vertices<VertexData>& operator=(const Vertices<V>& other);
virtual ~Vertices();
void clear();
bool update();
size_t addVertex(const VertexType& vertex);
size_t getNumVertices() const;
const VertexType& getVertex(size_t id) const;
VertexType& getVertex(size_t id);
const std::vector<VertexType>& getVertices() const;
std::vector<VertexType>& getVertices();
void setVertexPosition(size_t id, const SurgSim::Math::Vector3d& position);
const SurgSim::Math::Vector3d& getVertexPosition(size_t id) const;
void setVertexPositions(const std::vector<SurgSim::Math::Vector3d>& positions, bool doUpdate = true);
void transform(const Math::RigidTransform3d& pose);
bool operator==(const Vertices& mesh) const;
bool operator!=(const Vertices& mesh) const;
protected:
virtual void doClearVertices();
virtual bool isEqual(const Vertices& mesh) const;
private:
virtual void doClear();
virtual bool doUpdate();
std::vector<VertexType> m_vertices;
};
typedef Vertices<EmptyData> VerticesPlain;
}; // namespace DataStructures
}; // namespace SurgSim
#include "SurgSim/DataStructures/Vertices-inl.h"
#endif // SURGSIM_DATASTRUCTURES_VERTICES_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::Vertices::transform
void transform(const Math::RigidTransform3d &pose)
Apply a rigid transform to each vertex.
Definition: Vertices-inl.h:157
SurgSim::DataStructures::Vertices::m_vertices
std::vector< VertexType > m_vertices
Vertices.
Definition: Vertices.h:158
SurgSim::DataStructures::Vertices::getNumVertices
size_t getNumVertices() const
Returns the number of vertices in this mesh.
Definition: Vertices-inl.h:99
SurgSim::DataStructures::Vertices::~Vertices
virtual ~Vertices()
Destructor.
Definition: Vertices-inl.h:75
SurgSim::DataStructures::Vertices::operator=
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
SurgSim::DataStructures::Vertices::operator==
bool operator==(const Vertices &mesh) const
Compares the mesh with another one (equality)
Definition: Vertices-inl.h:166
SurgSim::DataStructures::Vertices::Vertices
Vertices()
Constructor.
Definition: Vertices-inl.h:30
SurgSim::DataStructures::Vertices::doUpdate
virtual bool doUpdate()
Performs any updates that are required when the vertices are modified.
Definition: Vertices-inl.h:196
SurgSim::DataStructures::VerticesPlain
Vertices< EmptyData > VerticesPlain
Definition: Vertices.h:161
SurgSim::DataStructures::Vertices::update
bool update()
Performs any updates that are required when the vertices are modified.
Definition: Vertices-inl.h:86
SurgSim::DataStructures::Vertices::getVertex
const VertexType & getVertex(size_t id) const
Returns the specified vertex.
Definition: Vertices-inl.h:105
SurgSim::DataStructures::Vertices::setVertexPositions
void setVertexPositions(const std::vector< SurgSim::Math::Vector3d > &positions, bool doUpdate=true)
Sets the position of each vertex.
Definition: Vertices-inl.h:141
SurgSim::DataStructures::Vertex
Vertex structure for meshes.
Definition: Vertex.h:44
SurgSim::DataStructures::Vertices::getVertices
const std::vector< VertexType > & getVertices() const
Returns a vector containing the position of each vertex.
Definition: Vertices-inl.h:117
Vertices-inl.h
SurgSim::DataStructures::Vertices::setVertexPosition
void setVertexPosition(size_t id, const SurgSim::Math::Vector3d &position)
Sets the position of a vertex.
Definition: Vertices-inl.h:129
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
Vertex.h
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
Vector.h
Definitions of small fixed-size vector types.
SurgSim::DataStructures::Vertices::addVertex
size_t addVertex(const VertexType &vertex)
Adds a vertex to the mesh.
Definition: Vertices-inl.h:92
SurgSim::DataStructures::Vertices::clear
void clear()
Clear mesh to return to an empty state (no vertices).
Definition: Vertices-inl.h:80
SurgSim::DataStructures::Vertices::VertexType
Vertex< VertexData > VertexType
Vertex type for convenience.
Definition: Vertices.h:55
SurgSim::DataStructures::Vertices::isEqual
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
SurgSim::DataStructures::Vertices::doClearVertices
virtual void doClearVertices()
Remove all vertices from the mesh.
Definition: Vertices-inl.h:178
SurgSim::DataStructures::Vertices::getVertexPosition
const SurgSim::Math::Vector3d & getVertexPosition(size_t id) const
Returns the position of a vertex.
Definition: Vertices-inl.h:135
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::DataStructures::Vertices
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
SurgSim::DataStructures::Vertices::doClear
virtual void doClear()
Clear mesh to return to an empty state (no vertices).
Definition: Vertices-inl.h:190
SurgSim::DataStructures::Vertices::operator!=
bool operator!=(const Vertices &mesh) const
Compares the mesh with another one (inequality)
Definition: Vertices-inl.h:172
EmptyData.h