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;
49 class DelaunayPoint :
public Vector<2, fltp08>
58 DelaunayPoint(fltp08 a, fltp08 b);
64 DelaunayPoint(fltp08 a, fltp08 b, fltp08 x);
68 DelaunayPoint(
const DelaunayPoint& p);
70 DelaunayPoint& operator=(
const DelaunayPoint& p);
71 DelaunayPoint& operator=(
const Vector<2, fltp08>& p);
72 bool operator==(
const DelaunayPoint& p2)
const;
73 bool operator!=(
const DelaunayPoint& p2)
const;
74 bool operator<(
const DelaunayPoint& b)
const;
85 class DelaunayTriangle :
public Triangle<1, uint04>
94 DelaunayTriangle(uint04 a, uint04 b);
100 DelaunayTriangle(uint04 a, uint04 b, uint04 c);
109 DelaunayTriangle(uint04 a, uint04 b, uint04 c, uint04 ab, uint04 bc, uint04 ac);
113 DelaunayTriangle(
const DelaunayTriangle& p);
118 constexpr uint04& neighborTriangle(TriangleLocation location)
122 case edge_ab:
return edges[0];
123 case edge_bc:
return edges[1];
124 case edge_ca:
return edges[2];
125 default: lib_assert(
false,
"Not a valid line segment request");
return edges[0];
132 constexpr const uint04& neighborTriangle(TriangleLocation location)
const
136 case edge_ab:
return edges[0];
137 case edge_bc:
return edges[1];
138 case edge_ca:
return edges[2];
139 default: lib_assert(
false,
"Not a valid line segment request");
return edges[0];
146 constexpr const uint04& neighborTriangle(uint01 location)
const
148 return edges[location];
154 constexpr void swapNeighborTriangle(uint04 old_tri_index, uint04 new_tri_index)
156 if (neighborTriangle(edge_ab) == old_tri_index)
157 neighborTriangle(edge_ab) = new_tri_index;
158 else if (neighborTriangle(edge_bc) == old_tri_index)
159 neighborTriangle(edge_bc) = new_tri_index;
160 else if (neighborTriangle(edge_ca) == old_tri_index)
161 neighborTriangle(edge_ca) = new_tri_index;
163 lib_assert(
false,
"Did not swap valid edge");
165 DelaunayTriangle& operator=(
const DelaunayTriangle& p);
167 Vector<3, uint04> edges;
168 RadialObject<2, fltp08> circle;
175 class NDEVR_SURFACING_API DelaunayTriangulation :
public GeometrySurfacing
179 DelaunayTriangulation();
180 virtual ~DelaunayTriangulation()
override =
default;
185 virtual bool runSurfacing(GeometrySurfacingParameters & parameters)
override;
189 virtual Buffer<SurfacingDescription> defaultSurfacingArguments()
override;
197 static Buffer<Triangle<1, uint04>> Delaunay(
const Matrix<fltp08> matrix,
const Buffer<Vertex<3, fltp08>>& points, LogPtr log = LogPtr());
204 static void Delaunay(
const Matrix<fltp08> matrix, Geometry& points,
const void* lock, LogPtr log = LogPtr());
212 static bool isDelaunay(
const Vector<2, fltp08>& A,
const Vector<2, fltp08>& B,
const Vector<2, fltp08>& C,
const Vector<2, fltp08>& D);
214 static void RegisterSurfacingEngine();
216 void clipBoundaryTris();
221 explicit DelaunayTriangulation(LogPtr log);
228 void setPoints(
const Matrix<fltp08> matrix,
const Buffer<Vertex<3, fltp08>>& points);
233 void setPoints(
const Matrix<fltp08> matrix,
const Geometry& points);
235 void setupMaxCircle();
237 void fillLookupTable();
245 void formHull(uint04 k);
252 void formHullConvex(uint04& hidx, Vector<2, fltp08>& d,
const Vector<2, fltp08>& x, DelaunayPoint& point);
259 void formHullConcave(uint04& hidx, Vector<2, fltp08>& d,
const Vector<2, fltp08>& x, DelaunayPoint& point);
263 Buffer<Triangle<1, uint04>> getTris();
272 inline void getFlipVars(uint04 tri_index, uint01 t_pos,
const DelaunayTriangle& t1,
const DelaunayTriangle& t2, Vector<5, uint04>& L, Vector<4, uint04>& p)
const;
277 template<
bool t_protected>
278 void checkTriAndFlip(uint04 tri_index, Buffer<uint04>& ids);
281 RTree<2, fltp04>* m_r_tree;
282 Buffer<uint04> m_point_cache;
283 Buffer<uint04> m_tri_cache;
284 Buffer<DelaunayPoint> m_cache_bounds;
285 Buffer<DelaunayPoint> m_points;
286 Buffer<DelaunayTriangle> m_tris;
287 RadialObject<2, fltp08> m_max_circle;
A core class where all Design Objects including models, materials, and geometries are stored.
A light-weight base class for Log that allows processes to update, without the need for additional in...
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
A three-vertex polygon representing a triangle in N-dimensional space.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.