opensurgsim
MeshElement.h
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_MESHELEMENT_H
17 #define SURGSIM_DATASTRUCTURES_MESHELEMENT_H
18 
19 #include <array>
20 #include <memory>
21 
22 namespace SurgSim
23 {
24 
25 namespace DataStructures
26 {
27 
43 template <size_t N, class Data>
45 {
49  MeshElement(const std::array<size_t, N>& verticesId, const Data& data) :
50  verticesId(verticesId),
51  data(data),
52  isValid(true)
53  {
54  }
55 
58  explicit MeshElement(const std::array<size_t, N>& verticesId) :
59  verticesId(verticesId),
60  isValid(true)
61  {
62  }
63 
68  template <class T>
69  explicit MeshElement(const MeshElement<N, T>& other) :
70  verticesId(other.verticesId),
71  isValid(other.isValid)
72  {
73  }
74 
75  typedef std::array<size_t, N> IdType;
76 
78  IdType verticesId;
79 
81  Data data;
82 
84  bool isValid;
85 
89  bool operator==(const MeshElement<N, Data>& element) const
90  {
91  return isValid == element.isValid && verticesId == element.verticesId && data == element.data;
92  }
93 
97  bool operator!=(const MeshElement<N, Data>& element) const
98  {
99  return !((*this) == element);
100  }
101 };
102 
103 
104 
105 }; // namespace DataStructures
106 
107 }; // namespace SurgSim
108 
109 #endif // SURGSIM_DATASTRUCTURES_MESHELEMENT_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
MeshElement(const std::array< size_t, N > &verticesId)
Constructor where the Data is constructed by its default constructor.
Definition: MeshElement.h:58
MeshElement(const MeshElement< N, T > &other)
Copy constructor when the template data is a different type In this case, no data will be copied...
Definition: MeshElement.h:69
bool operator!=(const MeshElement< N, Data > &element) const
Compare the element with another one (inequality)
Definition: MeshElement.h:97
bool operator==(const MeshElement< N, Data > &element) const
Compare the element with another one (equality)
Definition: MeshElement.h:89
IdType verticesId
Element vertices.
Definition: MeshElement.h:78
MeshElement(const std::array< size_t, N > &verticesId, const Data &data)
Constructor.
Definition: MeshElement.h:49
Element structure for meshes.
Definition: MeshElement.h:44
Data data
Extra element data.
Definition: MeshElement.h:81
bool isValid
Is this a valid element.
Definition: MeshElement.h:84