Vertex.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_VERTEX_H
#define SURGSIM_DATASTRUCTURES_VERTEX_H
#include "SurgSim/Math/Vector.h"
#include <memory>
namespace SurgSim
{
namespace DataStructures
{
template <class Data>
struct Vertex
{
Vertex()
{
}
explicit Vertex(const SurgSim::Math::Vector3d& position, const Data& data = Data()) :
position(position),
data(data)
{
}
template <class T>
explicit Vertex(const Vertex<T>& other) :
position(other.position)
{
}
template <class T>
Vertex<Data>& operator=(const Vertex<T>& other)
{
position = other.position;
return *this;
}
SurgSim::Math::Vector3d position;
Data data;
bool operator==(const Vertex<Data>& vertex) const
{
return data == vertex.data && position == vertex.position;
}
bool operator!=(const Vertex<Data>& vertex) const
{
return ! ((*this) == vertex);
}
};
template <>
struct Vertex<void>
{
explicit Vertex(const SurgSim::Math::Vector3d& position) : position(position)
{
}
SurgSim::Math::Vector3d position;
bool operator==(const Vertex<void>& vertex) const
{
return position == vertex.position;
}
bool operator!=(const Vertex<void>& vertex) const
{
return ! ((*this) == vertex);
}
};
}; // namespace DataStructures
}; // namespace SurgSim
#endif // SURGSIM_DATASTRUCTURES_VERTEX_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::Vertex::position
SurgSim::Math::Vector3d position
Position of the vertex.
Definition: Vertex.h:82
SurgSim::DataStructures::Vertex::operator=
Vertex< Data > & operator=(const Vertex< T > &other)
Assignment when the template data is a different type In this case, no data will be copied...
Definition: Vertex.h:75
SurgSim::DataStructures::Vertex< void >::operator==
bool operator==(const Vertex< void > &vertex) const
Compare the vertex to another one (equality)
Definition: Vertex.h:120
SurgSim::DataStructures::Vertex::operator==
bool operator==(const Vertex< Data > &vertex) const
Compare the vertex to another one (equality)
Definition: Vertex.h:89
SurgSim::DataStructures::Vertex< void >
Specialization of Vertex with no data.
Definition: Vertex.h:106
SurgSim::DataStructures::Vertex< void >::position
SurgSim::Math::Vector3d position
Position of the vertex.
Definition: Vertex.h:115
SurgSim::DataStructures::Vertex< void >::operator!=
bool operator!=(const Vertex< void > &vertex) const
Compare the vertex to another one (inequality)
Definition: Vertex.h:128
SurgSim::DataStructures::Vertex::Vertex
Vertex()
Constructor.
Definition: Vertex.h:47
SurgSim::DataStructures::Vertex
Vertex structure for meshes.
Definition: Vertex.h:44
SurgSim::DataStructures::Vertex::Vertex
Vertex(const Vertex< T > &other)
Copy constructor when the template data is a different type In this case, no data will be copied...
Definition: Vertex.h:65
SurgSim::DataStructures::Vertex::Vertex
Vertex(const SurgSim::Math::Vector3d &position, const Data &data=Data())
Constructor.
Definition: Vertex.h:54
Vector.h
Definitions of small fixed-size vector types.
SurgSim::DataStructures::Vertex::data
Data data
Extra vertex data.
Definition: Vertex.h:84
SurgSim::DataStructures::Vertex< void >::Vertex
Vertex(const SurgSim::Math::Vector3d &position)
Constructor.
Definition: Vertex.h:110
SurgSim::DataStructures::Vertex::operator!=
bool operator!=(const Vertex< Data > &vertex) const
Compare the vertex to another one (inequality)
Definition: Vertex.h:97
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57