11#ifndef EASY3D_ALGO_DELAUNAY_H
12#define EASY3D_ALGO_DELAUNAY_H
16#include <easy3d/core/types.h>
44 unsigned int dimension()
const {
return dimension_; }
50 unsigned int cell_size()
const {
return cell_size_; }
86 unsigned int nb_cells()
const {
return nb_cells_; }
116 return cell_to_v_[c * cell_v_stride_ + lv];
128 return cell_to_cell_[c * cell_neigh_stride_ + lf];
138 assert(v < v_to_cell_.size());
139 return v_to_cell_[v];
148 unsigned int index(
unsigned int c,
int v)
const {
151 for (
unsigned int iv = 0; iv <
cell_size(); iv++) {
154 DCHECK(
false) <<
"should not have reached here";
167 for (
unsigned int f = 0; f <
cell_size(); f++) {
170 DCHECK(
false) <<
"should not have reached here";
191 virtual void get_neighbors(
unsigned int v, std::vector<unsigned int> &neighbors)
const;
202 void get_neighbors_internal(
unsigned int v, std::vector<unsigned int> &neighbors)
const;
206 void update_v_to_cell();
210 void update_neighbors();
212 void set_next_around_vertex(
unsigned int c1,
unsigned int lv,
unsigned int c2) {
216 cicl_[
cell_size() * c1 + lv] =
static_cast<int>(c2);
220 unsigned int dimension_;
221 unsigned int cell_size_;
222 unsigned int cell_v_stride_;
223 unsigned int cell_neigh_stride_;
224 const float *vertices_;
225 unsigned int nb_vertices_;
226 unsigned int nb_cells_;
227 const int *cell_to_v_;
228 const int *cell_to_cell_;
229 std::vector<int> v_to_cell_;
230 std::vector<int> cicl_;
231 std::vector<std::vector<unsigned int>> neighbors_;
unsigned int index(unsigned int c, int v) const
Returns the local index of vertex v within cell c.
Definition delaunay.h:148
const float * vertices_ptr() const
Returns a pointer to the vertices array.
Definition delaunay.h:64
const int * cell_to_cell() const
Returns a pointer to the cell-to-cell mapping.
Definition delaunay.h:98
unsigned int nb_cells() const
Returns the number of cells.
Definition delaunay.h:86
int vertex_cell(unsigned int v) const
Returns the index of a cell containing the vertex v.
Definition delaunay.h:136
int cell_adjacent(unsigned int c, unsigned int lf) const
Returns the index of the cell adjacent to the lf-th face of the c-th cell.
Definition delaunay.h:125
unsigned int next_around_vertex(unsigned int c, unsigned int lv) const
Returns the next cell around vertex lv in cell c.
Definition delaunay.h:180
unsigned int adjacent_index(unsigned int c1, unsigned int c2) const
Returns the local index of the face shared by cells c1 and c2.
Definition delaunay.h:164
virtual unsigned int nearest_vertex(const float *p) const
Finds the index of the nearest vertex to a given point.
Definition delaunay.cpp:74
unsigned int nb_vertices() const
Returns the number of vertices.
Definition delaunay.h:80
virtual ~Delaunay()
Virtual destructor.
const float * vertex_ptr(unsigned int i) const
Returns a pointer to the vertex of index i.
Definition delaunay.h:71
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:113
const int * cell_to_v() const
Returns a pointer to the cell-to-vertex mapping.
Definition delaunay.h:92
Delaunay(unsigned int dimension)
Constructor.
Definition delaunay.cpp:34
bool check_duplicate_vertices()
Checks for duplicate vertices in stored neighbor lists.
Definition delaunay.cpp:221
unsigned int dimension() const
Returns the dimension of the triangulation.
Definition delaunay.h:44
virtual void set_vertices(unsigned int nb_vertices, const float *vertices)
Sets the vertices for the triangulation.
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 a cell.
Definition delaunay.h:50
Definition collider.cpp:182