33#include <NDEVR/Geometry.h>
35#include <NDEVR/GeometrySurfacing.h>
36#include <NDEVR/Buffer.h>
37#include <NDEVR/Vector.h>
38#include <NDEVR/RadialObject.h>
41 template<u
int01 t_dims,
class t_type>
class RTree;
45 class DesignObjectLookup;
49 class DelaunayPoint :
public Vector<2, fltp08>
53 DelaunayPoint(fltp08 a, fltp08 b);
54 DelaunayPoint(fltp08 a, fltp08 b, fltp08 x);
55 DelaunayPoint(
const DelaunayPoint& p);
57 DelaunayPoint& operator=(
const DelaunayPoint& p);
58 DelaunayPoint& operator=(
const Vector<2, fltp08>& p);
59 bool operator==(
const DelaunayPoint& p2)
const;
60 bool operator!=(
const DelaunayPoint& p2)
const;
61 bool operator<(
const DelaunayPoint& b)
const;
71 class DelaunayTriangle :
public Triangle<1, uint04>
75 DelaunayTriangle(uint04 a, uint04 b);
76 DelaunayTriangle(uint04 a, uint04 b, uint04 c);
77 DelaunayTriangle(uint04 a, uint04 b, uint04 c, uint04 ab, uint04 bc, uint04 ac);
78 DelaunayTriangle(
const DelaunayTriangle& p);
79 constexpr uint04& neighborTriangle(TriangleLocation location)
86 default:
lib_assert(
false,
"Not a valid line segment request");
return edges[0];
89 constexpr const uint04& neighborTriangle(TriangleLocation location)
const
96 default:
lib_assert(
false,
"Not a valid line segment request");
return edges[0];
100 constexpr void swapNeighborTriangle(uint04 old_tri_index, uint04 new_tri_index)
102 if (neighborTriangle(edge_ab) == old_tri_index)
103 neighborTriangle(edge_ab) = new_tri_index;
104 else if (neighborTriangle(edge_bc) == old_tri_index)
105 neighborTriangle(edge_bc) = new_tri_index;
106 else if (neighborTriangle(edge_ca) == old_tri_index)
107 neighborTriangle(edge_ca) = new_tri_index;
111 DelaunayTriangle& operator=(
const DelaunayTriangle& p);
113 Vector<3, uint04> edges;
114 RadialObject<2, fltp08> circle;
120 class DelaunayTriangulation :
public GeometrySurfacing
123 DelaunayTriangulation();
124 virtual ~DelaunayTriangulation()
override =
default;
125 virtual bool runSurfacing(GeometrySurfacingParameters & parameters)
override;
126 virtual Buffer<SurfacingDescription> defaultSurfacingArguments()
override;
128 static Buffer<Triangle<1, uint04>> Delaunay(
const Matrix<fltp08> matrix,
const Buffer<Vertex<3, fltp08>>& points, ProgressInfo* log =
nullptr);
129 static void Delaunay(
const Matrix<fltp08> matrix, Geometry& points,
const void* lock, ProgressInfo* log =
nullptr);
130 static bool isDelaunay(
const Vector<2, fltp08>& A,
const Vector<2, fltp08>& B,
const Vector<2, fltp08>& C,
const Vector<2, fltp08>& D);
133 explicit DelaunayTriangulation(ProgressInfo* log);
135 void setPoints(
const Matrix<fltp08> matrix,
const Buffer<Vertex<3, fltp08>>& points);
136 void setPoints(
const Matrix<fltp08> matrix,
const Geometry& points);
137 void setupMaxCircle();
138 void fillLookupTable();
141 void formHull(uint04 k);
142 void formHullConvex(uint04& hidx, Vector<2, fltp08>& d,
const Vector<2, fltp08>& x, DelaunayPoint& point);
143 void formHullConcave(uint04& hidx, Vector<2, fltp08>& d,
const Vector<2, fltp08>& x, DelaunayPoint& point);
144 Buffer<Triangle<1, uint04>> getTris();
145 inline void getFlipVars(uint04 tri_index, uint01 t_pos,
const DelaunayTriangle& t1,
const DelaunayTriangle& t2, Vector<5, uint04>& L, Vector<4, uint04>& p)
const;
146 template<
bool t_protected>
147 void checkTriAndFlip(uint04 tri_index, Buffer<uint04>& ids);
150 RTree<2, fltp04>* m_r_tree;
151 Buffer<uint04> m_point_cache;
152 Buffer<uint04> m_tri_cache;
153 Buffer<DelaunayPoint> m_cache_bounds;
154 Buffer<DelaunayPoint> m_points;
155 Buffer<DelaunayTriangle> m_tris;
156 Buffer<uint04> m_lookup_table;
157 RadialObject<2, fltp08> m_max_circle;
#define lib_assert(expression, message)
Definition LibAssert.h:61
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
constexpr bool operator<(const Vector< vec_1_size, t_type > &v1, const Vector< vec_2_size, t_type > &v2)
Definition VectorFunctions.hpp:720
@ edge_ab
Definition Triangle.hpp:49
@ edge_bc
Definition Triangle.hpp:50
@ edge_ca
Definition Triangle.hpp:51
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149