8 #ifndef META_OCEAN_TRACKING_MAPTEXTURING_HASHABLE_TRIANGLE_H
9 #define META_OCEAN_TRACKING_MAPTEXTURING_HASHABLE_TRIANGLE_H
21 namespace MapTexturing
25 template <
typename T>
class HashableTriangleT;
125 template <
typename T>
128 ocean_assert(vertices !=
nullptr);
130 vertices_[0] = vertices[0];
131 vertices_[1] = vertices[1];
132 vertices_[2] = vertices[2];
135 template <
typename T>
138 vertices_[0] = vertex0;
139 vertices_[1] = vertex1;
140 vertices_[2] = vertex2;
143 template <
typename T>
149 template <
typename T>
155 template <
typename T>
161 template <
typename T>
167 template <
typename T>
170 return vertices_[0].x() == triangle.
vertices_[0].x() && vertices_[0].y() == triangle.
vertices_[0].y() && vertices_[0].z() == triangle.
vertices_[0].z()
171 && vertices_[1].x() == triangle.
vertices_[1].x() && vertices_[1].y() == triangle.
vertices_[1].y() && vertices_[1].z() == triangle.
vertices_[1].z()
172 && vertices_[2].x() == triangle.
vertices_[2].x() && vertices_[2].y() == triangle.
vertices_[2].y() && vertices_[2].z() == triangle.
vertices_[2].z();
175 template <
typename T>
178 return !(*
this == triangle);
181 template <
typename T>
187 template <
typename T>
190 size_t seed = std::hash<T>{}(vertex0.
x());
191 seed ^= std::hash<T>{}(vertex0.
y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
192 seed ^= std::hash<T>{}(vertex0.
z()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
194 seed ^= std::hash<T>{}(vertex1.
x()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
195 seed ^= std::hash<T>{}(vertex1.
y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
196 seed ^= std::hash<T>{}(vertex1.
z()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
198 seed ^= std::hash<T>{}(vertex2.
x()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
199 seed ^= std::hash<T>{}(vertex2.
y()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
200 seed ^= std::hash<T>{}(vertex2.
z()) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
This class implements a 3D triangle which is hash-able.
Definition: HashableTriangle.h:41
const VectorT3< T > & vertex2() const
Returns the third vertex of this triangle.
Definition: HashableTriangle.h:156
const VectorT3< T > * vertices() const
Returns the three vertices of this triangle.
Definition: HashableTriangle.h:162
size_t operator()(const HashableTriangleT< T > &triangle) const
Hash function.
Definition: HashableTriangle.h:182
HashableTriangleT()=default
Default constructor for an invalid triangle.
const VectorT3< T > & vertex0() const
Returns the first vertex of this triangle.
Definition: HashableTriangle.h:144
const VectorT3< T > & vertex1() const
Returns the second vertex of this triangle.
Definition: HashableTriangle.h:150
bool operator!=(const HashableTriangleT< T > &triangle) const
Returns whether two triangles do not contain exactly the same vertices.
Definition: HashableTriangle.h:176
VectorT3< T > vertices_[3]
The three vertices of this triangle.
Definition: HashableTriangle.h:122
bool operator==(const HashableTriangleT< T > &triangle) const
Returns whether two triangles contain exactly the same vertices.
Definition: HashableTriangle.h:168
static size_t hashValue(const VectorT3< T > &vertex0, const VectorT3< T > &vertex1, const VectorT3< T > &vertex2)
Determines the hash value for three vertices.
Definition: HashableTriangle.h:188
This class implements a vector with three elements.
Definition: Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition: Vector3.h:812
const T & x() const noexcept
Returns the x value.
Definition: Vector3.h:800
const T & z() const noexcept
Returns the z value.
Definition: Vector3.h:824
HashableTriangleT< Scalar > HashableTriangle
Definition of a hash-able triangle with Scalar precision.
Definition: HashableTriangle.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15