8 #ifndef META_OCEAN_GEOMETRY_DELAUNAY_H
9 #define META_OCEAN_GEOMETRY_DELAUNAY_H
51 inline IndexTriangle(
const unsigned int index0,
const unsigned int index1,
const unsigned int index2);
57 inline unsigned int index0()
const;
63 inline unsigned int index1()
const;
69 inline unsigned int index2()
const;
75 inline bool isValid()
const;
82 inline unsigned int operator[](
const unsigned int n)
const;
108 unsigned int indices_[3];
146 inline CircumCricleIndexTriangle(
const unsigned int index0,
const unsigned int index1,
const unsigned int index2,
const Vector2* points,
const size_t size,
const Vector2* pointsSuperTriangle);
175 inline bool isRightOfCircumCircle(
const Vector2 &point)
const;
216 inline bool operator()(
const unsigned int a,
const unsigned int b)
const;
236 inline IndexEdge(
const unsigned int indexFirst,
const unsigned int indexSecond);
244 inline IndexEdge(
const unsigned int indexFirst,
const unsigned int indexSecond,
const Vector2* points);
250 inline unsigned int firstIndex()
const;
256 inline unsigned int secondIndex()
const;
263 inline bool operator<(
const IndexEdge& right)
const;
268 unsigned int firstIndex_ = (
unsigned int)(-1);
271 unsigned int secondIndex_ = (
unsigned int)(-1);
277 typedef std::map<IndexEdge, unsigned int>
EdgeMap;
321 indices_[0] = index0;
322 indices_[1] = index1;
323 indices_[2] = index2;
325 ocean_assert(isValid());
345 return indices_[0] != indices_[1] && indices_[0] != indices_[2] && indices_[1] != indices_[2];
350 ocean_assert(n < 3u);
356 ocean_assert(isValid() && second.
isValid());
358 return (index0() == second.
index0() || index0() == second.
index1() || index0() == second.
index2())
359 && (index1() == second.
index0() || index1() == second.
index1() || index1() == second.
index2())
360 && (index2() == second.
index0() || index2() == second.
index1() || index2() == second.
index2());
365 ocean_assert(isValid() && points);
367 return Triangle2(points[indices_[0]], points[indices_[1]], points[indices_[2]]);
372 ocean_assert(isValid() && points);
374 return Triangle3(points[indices_[0]], points[indices_[1]], points[indices_[2]]);
380 circumcircleRadius_(-1)
382 ocean_assert(points);
387 if constexpr (std::is_same<double, Scalar>::value)
393 ocean_assert(triangle.
isValid());
402 if constexpr (std::is_same<double, Scalar>::value)
416 circumcircleRadius_(-1)
418 ocean_assert(points && pointsSuperTriangle);
425 ocean_assert(point0 != point1 && point0 != point2 && point1 != point2);
427 if constexpr (std::is_same<double, Scalar>::value)
429 ocean_assert(!
Line2(point0, (point1 - point0).normalizedOrZero()).isOnLine(point2));
432 const Triangle2 triangle(point0, point1, point2);
433 ocean_assert(triangle.
isValid());
442 if constexpr (std::is_same<double, Scalar>::value)
455 std::swap(indices_[1], indices_[2]);
460 ocean_assert(isValid());
461 ocean_assert(circumcircleRadius_ >= 0);
462 ocean_assert(epsilon >= 0);
465 return circumcenter_.sqrDistance(point) <=
Numeric::sqr(circumcircleRadius_ + epsilon);
470 ocean_assert(isValid());
471 ocean_assert(circumcircleRadius_ >= 0);
472 ocean_assert(epsilon >= 0);
480 ocean_assert(isValid());
481 ocean_assert(circumcircleRadius_ >= 0);
483 return (circumcenter_.x() + circumcircleRadius_) < point.
x();
494 ocean_assert(dataPoints_);
496 return dataPoints_[a].x() < dataPoints_[b].x();
500 firstIndex_(indexFirst < indexSecond ? indexFirst : indexSecond),
501 secondIndex_(indexFirst < indexSecond ? indexSecond : indexFirst)
508 firstIndex_(points[indexFirst] < points[indexSecond] ? indexFirst : indexSecond),
509 secondIndex_(points[indexFirst] < points[indexSecond] ? indexSecond : indexFirst)
This class extends the IndexTriangle class by an additional circumcircle as the Delaunay triangulatio...
Definition: Delaunay.h:122
Scalar circumcircleRadius_
Radius of the circumcircle, with range [0, infinity), -1 for and invalid triangle object.
Definition: Delaunay.h:183
CircumCricleIndexTriangle(const unsigned int index0, const unsigned int index1, const unsigned int index2, const Vector2 *points)
Creates a new index triangle object and calculates circumcenter and radius.
Definition: Delaunay.h:377
bool isOutsideCircumCircle(const Vector2 &point, const Scalar epsilon=Numeric::eps()) const
Returns whether a point is outside the circumcircle of the triangle.
Definition: Delaunay.h:468
bool isInsideCircumCircle(const Vector2 &point, const Scalar epsilon=Numeric::eps()) const
Returns whether a point is within the circumcircle of the triangle.
Definition: Delaunay.h:458
bool isRightOfCircumCircle(const Vector2 &point) const
Returns whether a point is completely right of the circumcircle (i.e.
Definition: Delaunay.h:478
Vector2 circumcenter_
2D (Cartesian) circumcenter.
Definition: Delaunay.h:180
void swap()
Swaps the order of the indices from a counter clockwise order to a clockwise order or vice versa.
Definition: Delaunay.h:453
This class implements the lesser operator for indices of points.
Definition: Delaunay.h:201
bool operator()(const unsigned int a, const unsigned int b) const
Compares two point indices and returns whether the x coordinate of the first point is below the x coo...
Definition: Delaunay.h:492
const Vector2 * dataPoints_
The points to be compared.
Definition: Delaunay.h:221
ComparePointsX(const Vector2 *points)
Creates a new comparison object by a set of given points.
Definition: Delaunay.h:486
This class stores the sorted indices of an edge.
Definition: Delaunay.h:228
bool operator<(const IndexEdge &right) const
Lesser operator for two edge objects.
Definition: Delaunay.h:525
unsigned int firstIndex_
The index of the first point.
Definition: Delaunay.h:268
unsigned int secondIndex() const
Returns the index of the second point.
Definition: Delaunay.h:520
unsigned int secondIndex_
The index of the second point.
Definition: Delaunay.h:271
IndexEdge(const unsigned int indexFirst, const unsigned int indexSecond)
Creates a new edge object and sorts the provided two point indices to ensure that the first index is ...
Definition: Delaunay.h:499
unsigned int firstIndex() const
Returns the index of the first point.
Definition: Delaunay.h:515
This class holds three indices of points representing a triangle.
Definition: Delaunay.h:37
unsigned int index2() const
Returns the third index.
Definition: Delaunay.h:338
Triangle3 triangle3(const Vector3 *points) const
Creates a 3D triangle with positions as corners from this index triangle.
Definition: Delaunay.h:370
IndexTriangle()
Creates an invalid index triangle object.
Definition: Delaunay.h:310
Triangle2 triangle2(const Vector2 *points) const
Creates a 2D triangle with positions as corners from this index triangle.
Definition: Delaunay.h:363
bool operator==(const IndexTriangle &second) const
Returns whether two triangles are equal (i.e.
Definition: Delaunay.h:354
bool isValid() const
Returns whether three individual indices are stored.
Definition: Delaunay.h:343
unsigned int index1() const
Returns the second index.
Definition: Delaunay.h:333
unsigned int operator[](const unsigned int n) const
Returns one index of this triangle.
Definition: Delaunay.h:348
unsigned int indices_[3]
Triangle indices;.
Definition: Delaunay.h:108
unsigned int index0() const
Returns the first index.
Definition: Delaunay.h:328
This class implements Delaunay triangulation functions.
Definition: Delaunay.h:30
static bool checkTriangulation(const CircumCricleIndexTriangles &triangles, const Vectors2 &points, const Scalar epsilon=Numeric::eps())
Checks a Delaunay triangulation for integrity: no points are allowed within the circumcircle of a tri...
std::map< IndexEdge, unsigned int > EdgeMap
Definition of a map mapping edge pairs to a counter.
Definition: Delaunay.h:277
std::vector< CircumCricleIndexTriangle > CircumCricleIndexTriangles
Definition of a vector holding extended index triangles.
Definition: Delaunay.h:189
std::vector< IndexTriangle > IndexTriangles
Definition of a vector holding index triangles.
Definition: Delaunay.h:114
static bool checkTriangulation(const IndexTriangles &triangles, const Vectors2 &points, const Scalar epsilon=Numeric::eps())
Checks a Delaunay triangulation for integrity: no points are allowed within the circumcircle of a tri...
std::list< CircumCricleIndexTriangle > CircumCricleIndexTriangleList
Definition of a list holding extended index triangles.
Definition: Delaunay.h:194
static IndexTriangles triangulation(const Vectors2 &points)
Determines the delaunay triangulation for a given 2D point set.
static constexpr T weakEps()
Returns a weak epsilon.
static constexpr T eps()
Returns a small epsilon.
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition: Numeric.h:2386
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition: Numeric.h:1495
This class implements a 2D triangle with Cartesian coordinates.
Definition: Triangle2.h:81
const VectorT2< T > & point2() const
Returns the third triangle corner.
Definition: Triangle2.h:415
const VectorT2< T > & point0() const
Returns the first triangle corner.
Definition: Triangle2.h:403
VectorT2< T > cartesianCircumcenter() const
Returns the circumcenter for this triangle in Cartesian coordinates.
Definition: Triangle2.h:792
const VectorT2< T > & point1() const
Returns the second triangle corner.
Definition: Triangle2.h:409
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition: Triangle2.h:806
This class implements a 3D triangle.
Definition: Triangle3.h:80
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
T distance(const VectorT2< T > &right) const
Returns the distance between this 2D position and a second 2D position.
Definition: Vector2.h:627
TriangleT3< Scalar > Triangle3
Definition of the Triangle3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition: Triangle3.h:21
float Scalar
Definition of a scalar type.
Definition: Math.h:128
LineT2< Scalar > Line2
Definition of the Line2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition: Line2.h:21
TriangleT2< Scalar > Triangle2
Definition of the Triangle2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition: Triangle2.h:21
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15