40 #ifndef GEOGRAM_DELAUNAY_DELAUNAY_3D
41 #define GEOGRAM_DELAUNAY_DELAUNAY_3D
45 #include <geogram/delaunay/cavity.h>
128 index_t nb_vertices,
const double* vertices
183 const double* p,
index_t hint = NO_TETRAHEDRON,
184 bool thread_safe =
false,
185 Sign* orient =
nullptr
347 tet_vertex(t1,
index_t(halfedge_facet_[t1ft2][t1fborder]));
349 tet_vertex(t1,
index_t(halfedge_facet_[t1fborder][t1ft2]));
358 while(tet_is_in_list(next_t)) {
361 cur_f = get_facet_by_halfedge(cur_t,ev1,ev2);
362 next_t =
index_t(tet_adjacent(cur_t, cur_f));
368 get_facets_by_halfedge(next_t, ev1, ev2, f12, f21);
369 t2 =
index_t(tet_adjacent(next_t,f21));
371 t2ft1 = find_tet_vertex(t2, v_neigh_opposite);
390 return cell_to_v_store_.size() / 4;
433 static const index_t END_OF_LIST = ~(NOT_IN_LIST_BIT);
455 return (cell_next_[t] & NOT_IN_LIST_BIT) == 0;
471 return cell_next_[t];
487 if(last == END_OF_LIST) {
490 cell_next_[t] = END_OF_LIST;
492 cell_next_[t] = first;
509 cell_next_[t] = NOT_IN_LIST;
532 cell_to_v_store_[4 * t] >= 0 &&
533 cell_to_v_store_[4 * t + 1] >= 0 &&
534 cell_to_v_store_[4 * t + 2] >= 0 &&
535 cell_to_v_store_[4 * t + 3] >= 0;
550 return !tet_is_free(t) && tet_is_finite(t);
565 cell_to_v_store_[4 * t] == VERTEX_AT_INFINITY ||
566 cell_to_v_store_[4 * t + 1] == VERTEX_AT_INFINITY ||
567 cell_to_v_store_[4 * t + 2] == VERTEX_AT_INFINITY ||
568 cell_to_v_store_[4 * t + 3] == VERTEX_AT_INFINITY) ;
582 return tet_is_in_list(t);
594 if(first_free_ == END_OF_LIST) {
595 cell_to_v_store_.resize(cell_to_v_store_.size() + 4, -1);
596 cell_to_cell_store_.resize(cell_to_cell_store_.size() + 4, -1);
600 cell_next_.push_back(
index_t(NOT_IN_LIST));
601 result = max_t() - 1;
603 result = first_free_;
604 first_free_ = tet_next(first_free_);
605 remove_tet_from_list(result);
608 cell_to_cell_store_[4 * result] = -1;
609 cell_to_cell_store_[4 * result + 1] = -1;
610 cell_to_cell_store_[4 * result + 2] = -1;
611 cell_to_cell_store_[4 * result + 3] = -1;
632 index_t result = new_tetrahedron();
633 cell_to_v_store_[4 * result] = v1;
634 cell_to_v_store_[4 * result + 1] = v2;
635 cell_to_v_store_[4 * result + 2] = v3;
636 cell_to_v_store_[4 * result + 3] = v4;
648 cur_stamp_ = (stamp | NOT_IN_LIST_BIT);
667 return cell_next_[t] == cur_stamp_;
684 cell_next_[t] = cur_stamp_;
709 return index_t(tet_facet_vertex_[f][v]);
722 return cell_to_v_store_[4 * t + lv];
751 return index_t(cell_to_v_store_[4 * t + lv]);
763 cell_to_v_store_[4 * t + lv] = v;
844 cell_to_v_store_[4 * t] = v0;
845 cell_to_v_store_[4 * t + 1] = v1;
846 cell_to_v_store_[4 * t + 2] = v2;
847 cell_to_v_store_[4 * t + 3] = v3;
875 return index_t(halfedge_facet_[lv1][lv2]);
904 (T[1] == v1) | ((T[2] == v1) * 2) | ((T[3] == v1) * 3);
907 (T[1] == v2) | ((T[2] == v2) * 2) | ((T[3] == v2) * 3);
915 f12 =
index_t(halfedge_facet_[lv1][lv2]);
916 f21 =
index_t(halfedge_facet_[lv2][lv1]);
933 t, get_facet_by_halfedge(t, v1, v2)
958 pv[i] = (v == -1) ?
nullptr : vertex_ptr(
index_t(v));
963 for(
index_t lf = 0; lf < 4; ++lf) {
965 if(pv[lf] ==
nullptr) {
991 if(tet_is_in_list(t2)) {
996 if(tet_is_marked(t2)) {
1000 return tet_is_conflict(t2, p);
1009 double h0 = heights_[finite_tet_vertex(t, 0)];
1010 double h1 = heights_[finite_tet_vertex(t, 1)];
1011 double h2 = heights_[finite_tet_vertex(t, 2)];
1012 double h3 = heights_[finite_tet_vertex(t, 3)];
1014 (p - vertex_ptr(0)) /
int(vertex_stride_)
1016 double h = heights_[pindex];
1018 pv[0],pv[1],pv[2],pv[3],p,h0,h1,h2,h3,h
1047 (T[1] == v) | ((T[2] == v) * 2) | ((T[3] == v) * 3)
1080 index_t first,
const std::string& list_name
1111 bool verbose_debug_mode_;
1116 bool benchmark_mode_;
1126 static char tet_facet_vertex_[4][3];
1132 static char halfedge_facet_[4][4];
1138 std::stack<index_t> S_;
1145 class StellateConflictStack {
1158 store_.resize(store_.size()+1);
1172 top().new_t = new_t;
1186 void get_parameters(
1191 t1fbord =
index_t(top().t1fbord);
1192 t1fprev =
index_t(top().t1fprev);
1206 new_t = top().new_t;
1224 bool empty()
const {
1225 return store_.empty();
1254 return *store_.rbegin();
1263 const Frame& top()
const {
1265 return *store_.rbegin();
1268 std::vector<Frame> store_;
1275 StellateConflictStack S2_;
#define geo_debug_assert(x)
Verifies that a condition is met.
Implementation of Delaunay in 3d.
index_t locate_inexact(const double *p, index_t hint, index_t max_iter) const
Finds the tetrahedron that (approximately) contains a point using inexact predicates.
void check_geometry(bool verbose=false) const
For debugging purposes, test some geometrical properties.
void show_tet_adjacent(index_t t, index_t lf) const
For debugging purposes, displays a tetrahedron adjacency.
signed_index_t tet_vertex(index_t t, index_t lv) const
Gets the index of a vertex of a tetrahedron.
void set_tet_adjacent(index_t t1, index_t lf1, index_t t2)
Sets a tetrahedron-to-tetrahedron adjacency.
index_t get_facet_by_halfedge(index_t t, signed_index_t v1, signed_index_t v2) const
bool get_neighbor_along_conflict_zone_border(index_t t1, index_t t1fborder, index_t t1ft2, index_t &t2, index_t &t2fborder, index_t &t2ft1) const
Finds the neighbor of a tetrahedron on the border of the conflict zone.
void set_tet(index_t t, signed_index_t v0, signed_index_t v1, signed_index_t v2, signed_index_t v3, index_t a0, index_t a1, index_t a2, index_t a3)
Sets the vertices and adjacent tetrahedra of a tetrahedron.
index_t next_around_halfedge(index_t &t, signed_index_t v1, signed_index_t v2) const
Gets the next tetrahedron around an oriented edge of a tetrahedron.
void mark_tet(index_t t)
Marks a tetrahedron.
index_t find_tet_adjacent(index_t t1, index_t t2_in) const
Finds the index of the facet accros which t1 is adjacent to t2_in.
static index_t find_4(const signed_index_t *T, signed_index_t v)
Finds the index of an integer in an array of four integers.
index_t nearest_vertex(const double *p) const override
Computes the nearest vertex from a query point.
~Delaunay3d() override
Delaunay3d destructor.
bool tet_is_in_list(index_t t) const
Tests whether a tetrahedron belongs to a linked list.
index_t find_tet_vertex(index_t t, signed_index_t v) const
Finds the index of the vertex in a tetrahedron.
index_t tet_next(index_t t) const
Gets the index of a successor of a tetrahedron.
bool tet_is_finite(index_t t) const
Tests whether a given tetrahedron is a finite one.
void check_combinatorics(bool verbose=false) const
For debugging purposes, tests some combinatorial properties.
bool tet_is_marked(index_t t) const
Tests whether a tetrahedron is marked.
bool tet_is_free(index_t t) const
Tests whether a tetrahedron is in the free list.
bool tet_is_virtual(index_t t) const
Tests whether a tetrahedron is a virtual one.
index_t stellate_conflict_zone_iterative(index_t v, index_t t_bndry, index_t f_bndry, index_t prev_f=index_t(-1))
Creates a star of tetrahedra filling the conflict zone.
index_t insert(index_t v, index_t hint=NO_TETRAHEDRON)
Inserts a point in the triangulation.
void set_tet_mark_stamp(index_t stamp)
Generates a unique stamp for marking tets.
void set_tet_vertex(index_t t, index_t lv, signed_index_t v)
Sets a tetrahedron-to-vertex adjacency.
Delaunay3d(coord_index_t dimension=3)
Constructs a new Delaunay3d.
void set_vertices(index_t nb_vertices, const double *vertices) override
Sets the vertices of this Delaunay, and recomputes the cells.
void remove_tet_from_list(index_t t)
Removes a tetrahedron from the linked list it belongs to.
void add_tet_to_list(index_t t, index_t &first, index_t &last)
Adds a tetrahedron to a linked list.
signed_index_t tet_adjacent(index_t t, index_t lf) const
Gets the index of a tetrahedron adjacent to another one.
void show_tet(index_t t) const
For debugging purposes, displays a tetrahedron.
void find_conflict_zone_iterative(const double *p, index_t t, index_t &t_bndry, index_t &f_bndry, index_t &first, index_t &last)
This function is used to implement find_conflict_zone.
void get_facets_by_halfedge(index_t t, signed_index_t v1, signed_index_t v2, index_t &f12, index_t &f21) const
bool create_first_tetrahedron(index_t &iv0, index_t &iv1, index_t &iv2, index_t &iv3)
Finds in the pointset a set of four non-coplanar points.
void find_conflict_zone(index_t v, index_t t, const Sign *orient, index_t &t_bndry, index_t &f_bndry, index_t &first, index_t &last)
Determines the list of tetrahedra in conflict with a given point.
index_t new_tetrahedron()
Creates a new tetrahedron.
void show_list(index_t first, const std::string &list_name) const
For debugging purposes, displays a tetrahedron.
index_t new_tetrahedron(signed_index_t v1, signed_index_t v2, signed_index_t v3, signed_index_t v4)
Creates a new tetrahedron.
bool tet_is_conflict(index_t t, const double *p) const
Tests whether a given tetrahedron is in conflict with a given 3d point.
index_t finite_tet_vertex(index_t t, index_t lv) const
Gets the index of a vertex of a tetrahedron.
index_t stellate_cavity(index_t v)
Creates a star of tetrahedra filling the conflict zone.
bool tet_is_real(index_t t) const
Tests whether a tetrahedron is a real one.
index_t max_t() const
Maximum valid index for a tetrahedron.
static index_t tet_facet_vertex(index_t f, index_t v)
Returns the local index of a vertex by facet and by local vertex index in the facet.
index_t locate(const double *p, index_t hint=NO_TETRAHEDRON, bool thread_safe=false, Sign *orient=nullptr) const
Finds the tetrahedron that contains a point.
Abstract interface for Delaunay triangulation in Nd.
Regular Delaunay triangulation of weighted points.
RegularWeightedDelaunay3d(coord_index_t dimension=4)
Constructs a new Regular Delaunay3d triangulation.
~RegularWeightedDelaunay3d() override
RegularWeightedDelaunay3d destructor.
Abstract interface for Delaunay.
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
Sign orient_3dlifted_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4, double h0, double h1, double h2, double h3, double h4)
Computes the 4d orientation test with symbolic perturbation.
Sign in_sphere_3d_SOS(const double *p0, const double *p1, const double *p2, const double *p3, const double *p4)
Tests whether a 3d point is inside the circumscribed sphere of a 3d tetrahedron.
Sign orient_3d(const vec3HE &p0, const vec3HE &p1, const vec3HE &p2, const vec3HE &p3)
Computes the orientation predicate in 3d.
Global Vorpaline namespace.
geo_signed_index_t signed_index_t
The type for storing and manipulating indices differences.
geo_index_t index_t
The type for storing and manipulating indices.
Sign
Integer constants that represent the sign of a value.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Filtered exact predicates for restricted Voronoi diagrams.