MeshElement.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_MESHELEMENT_H
#define SURGSIM_DATASTRUCTURES_MESHELEMENT_H
#include <array>
#include <memory>
namespace SurgSim
{
namespace DataStructures
{
template <size_t N, class Data>
struct MeshElement
{
MeshElement(const std::array<size_t, N>& verticesId, const Data& data) :
verticesId(verticesId),
data(data),
isValid(true)
{
}
explicit MeshElement(const std::array<size_t, N>& verticesId) :
verticesId(verticesId),
isValid(true)
{
}
template <class T>
explicit MeshElement(const MeshElement<N, T>& other) :
verticesId(other.verticesId),
isValid(other.isValid)
{
}
typedef std::array<size_t, N> IdType;
IdType verticesId;
Data data;
bool isValid;
bool operator==(const MeshElement<N, Data>& element) const
{
return isValid == element.isValid && verticesId == element.verticesId && data == element.data;
}
bool operator!=(const MeshElement<N, Data>& element) const
{
return !((*this) == element);
}
};
}; // namespace DataStructures
}; // namespace SurgSim
#endif // SURGSIM_DATASTRUCTURES_MESHELEMENT_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::MeshElement::MeshElement
MeshElement(const std::array< size_t, N > &verticesId)
Constructor where the Data is constructed by its default constructor.
Definition: MeshElement.h:58
SurgSim::DataStructures::MeshElement::IdType
std::array< size_t, N > IdType
Definition: MeshElement.h:75
SurgSim::DataStructures::MeshElement::MeshElement
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
SurgSim::DataStructures::MeshElement::operator!=
bool operator!=(const MeshElement< N, Data > &element) const
Compare the element with another one (inequality)
Definition: MeshElement.h:97
SurgSim::DataStructures::MeshElement::operator==
bool operator==(const MeshElement< N, Data > &element) const
Compare the element with another one (equality)
Definition: MeshElement.h:89
SurgSim::DataStructures::MeshElement::verticesId
IdType verticesId
Element vertices.
Definition: MeshElement.h:78
SurgSim::DataStructures::MeshElement::MeshElement
MeshElement(const std::array< size_t, N > &verticesId, const Data &data)
Constructor.
Definition: MeshElement.h:49
SurgSim::DataStructures::MeshElement
Element structure for meshes.
Definition: MeshElement.h:44
SurgSim::DataStructures::MeshElement::data
Data data
Extra element data.
Definition: MeshElement.h:81
SurgSim::DataStructures::MeshElement::isValid
bool isValid
Is this a valid element.
Definition: MeshElement.h:84