11#ifndef EASY3D_ALGO_DELAUNAY_H
12#define EASY3D_ALGO_DELAUNAY_H
16#include <easy3d/core/types.h>
35 unsigned int dimension()
const {
return dimension_; }
38 unsigned int cell_size()
const {
return cell_size_; }
56 unsigned int nb_cells()
const {
return nb_cells_; }
58 const int *cell_to_v()
const {
return cell_to_v_; }
60 const int *cell_to_cell()
const {
return cell_to_cell_; }
62 virtual unsigned int nearest_vertex(
const float *p)
const;
68 return cell_to_v_[c * cell_v_stride_ + lv];
71 int cell_adjacent(
unsigned int c,
unsigned int lf)
const {
74 return cell_to_cell_[c * cell_neigh_stride_ + lf];
77 int vertex_cell(
unsigned int v)
const {
79 assert(v < v_to_cell_.size());
83 unsigned int index(
unsigned int c,
int v)
const {
86 for (
unsigned int iv = 0; iv <
cell_size(); iv++) {
89 DCHECK(
false) <<
"should not have reached here";
93 unsigned int adjacent_index(
unsigned int c1,
unsigned int c2)
const {
96 for (
unsigned int f = 0; f <
cell_size(); f++) {
97 if (cell_adjacent(c1, f) == c2) {
return f; }
99 DCHECK(
false) <<
"should not have reached here";
103 unsigned int next_around_vertex(
unsigned int c,
unsigned int lv)
const {
112 virtual void get_neighbors(
unsigned int v, std::vector<unsigned int> &neighbors)
const;
123 void get_neighbors_internal(
124 unsigned int v, std::vector<unsigned int> &neighbors
127 virtual void set_arrays(
128 unsigned int nb_cells,
const int *cell_to_v,
const int *cell_to_cell
131 void update_v_to_cell();
135 void update_neighbors();
137 void set_next_around_vertex(
138 unsigned int c1,
unsigned int lv,
unsigned int c2
143 cicl_[
cell_size() * c1 + lv] =
static_cast<int>(c2);
147 unsigned int dimension_;
148 unsigned int cell_size_;
149 unsigned int cell_v_stride_;
150 unsigned int cell_neigh_stride_;
151 const float *vertices_;
152 unsigned int nb_vertices_;
153 unsigned int nb_cells_;
154 const int *cell_to_v_;
155 const int *cell_to_cell_;
156 std::vector<int> v_to_cell_;
157 std::vector<int> cicl_;
158 std::vector <std::vector<unsigned int>> neighbors_;
Base class for Delaunay triangulation.
Definition: delaunay.h:25
const float * vertices_ptr() const
Returns the pointer to the vertices.
Definition: delaunay.h:44
unsigned int nb_cells() const
Returns the number of cells.
Definition: delaunay.h:56
unsigned int nb_vertices() const
Returns the number of vertices.
Definition: delaunay.h:53
const float * vertex_ptr(unsigned int i) const
Returns the pointer to the vertex of index i.
Definition: delaunay.h:47
int cell_vertex(unsigned int c, unsigned int lv) const
Returns the index of the lv_th vertex in the c_th cell.
Definition: delaunay.h:65
Delaunay(unsigned int dimension)
Constructor.
Definition: delaunay.cpp:34
bool check_duplicate_vertices()
Checks for duplicate vertices in stored neighbor lists. Returns true if there where some duplicate ve...
Definition: delaunay.cpp:221
unsigned int dimension() const
Returns the dimension.
Definition: delaunay.h:35
virtual void set_vertices(unsigned int nb_vertices, const float *vertices)
Sets the vertices.
Definition: delaunay.cpp:51
virtual void get_neighbors(unsigned int v, std::vector< unsigned int > &neighbors) const
Retrieves the one-ring neighbors of vertex v.
Definition: delaunay.cpp:90
unsigned int cell_size() const
Returns the size of the cell.
Definition: delaunay.h:38
Definition: collider.cpp:182