All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vertex.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DATASTRUCTURES_VERTEX_H
17 #define SURGSIM_DATASTRUCTURES_VERTEX_H
18 
19 #include "SurgSim/Math/Vector.h"
20 
21 #include <memory>
22 
23 namespace SurgSim
24 {
25 
26 namespace DataStructures
27 {
28 
43 template <class Data>
44 struct Vertex
45 {
49  Vertex(const SurgSim::Math::Vector3d& position, const Data& data = Data()) :
50  position(position),
51  data(data)
52  {
53  }
54 
58  Data data;
59 
63  bool operator==(const Vertex<Data>& vertex) const
64  {
65  return data == vertex.data && position == vertex.position;
66  }
67 
71  bool operator!=(const Vertex<Data>& vertex) const
72  {
73  return ! ((*this) == vertex);
74  }
75 };
76 
79 template <>
80 struct Vertex<void>
81 {
84  explicit Vertex(const SurgSim::Math::Vector3d& position) : position(position)
85  {
86  }
87 
90 
94  bool operator==(const Vertex<void>& vertex) const
95  {
96  return position == vertex.position;
97  }
98 
102  bool operator!=(const Vertex<void>& vertex) const
103  {
104  return ! ((*this) == vertex);
105  }
106 };
107 
108 }; // namespace DataStructures
109 
110 }; // namespace SurgSim
111 
112 #endif // SURGSIM_DATASTRUCTURES_VERTEX_H
SurgSim::Math::Vector3d position
Position of the vertex.
Definition: Vertex.h:56
bool operator==(const Vertex< Data > &vertex) const
Compare the vertex to another one (equality)
Definition: Vertex.h:63
Specialization of Vertex with no data.
Definition: Vertex.h:80
SurgSim::Math::Vector3d position
Position of the vertex.
Definition: Vertex.h:89
Vertex structure for meshes.
Definition: Vertex.h:44
bool operator!=(const Vertex< Data > &vertex) const
Compare the vertex to another one (inequality)
Definition: Vertex.h:71
Vertex(const SurgSim::Math::Vector3d &position, const Data &data=Data())
Constructor.
Definition: Vertex.h:49
Definitions of small fixed-size vector types.
bool operator==(const Vertex< void > &vertex) const
Compare the vertex to another one (equality)
Definition: Vertex.h:94
Data data
Extra vertex data.
Definition: Vertex.h:58
bool operator!=(const Vertex< void > &vertex) const
Compare the vertex to another one (inequality)
Definition: Vertex.h:102
Vertex(const SurgSim::Math::Vector3d &position)
Constructor.
Definition: Vertex.h:84
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56