MeshElement.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_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 
64  typedef std::array<size_t, N> IdType;
65 
67  IdType verticesId;
68 
70  Data data;
71 
73  bool isValid;
74 
78  bool operator==(const MeshElement<N, Data>& element) const
79  {
80  return isValid == element.isValid && verticesId == element.verticesId && data == element.data;
81  }
82 
86  bool operator!=(const MeshElement<N, Data>& element) const
87  {
88  return !((*this) == element);
89  }
90 };
91 
92 
93 
94 }; // namespace DataStructures
95 
96 }; // namespace SurgSim
97 
98 #endif // SURGSIM_DATASTRUCTURES_MESHELEMENT_H
Definition: DriveElementFromInputBehavior.cpp:27
MeshElement(const std::array< size_t, N > &verticesId)
Constructor where the Data is constructed by its default constructor.
Definition: MeshElement.h:58
std::array< size_t, N > IdType
Definition: MeshElement.h:64
bool operator!=(const MeshElement< N, Data > &element) const
Compare the element with another one (inequality)
Definition: MeshElement.h:86
IdType verticesId
Element vertices.
Definition: MeshElement.h:67
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:70
bool operator==(const MeshElement< N, Data > &element) const
Compare the element with another one (equality)
Definition: MeshElement.h:78
bool isValid
Is this a valid element.
Definition: MeshElement.h:73