Easy3D 2.6.1
Loading...
Searching...
No Matches
Delaunay2 Class Reference

2D Delaunay triangulation, using Jonathan Richard Shewchuk's "triangle" implementation. More...

#include <easy3d/algo/delaunay_2d.h>

Inheritance diagram for Delaunay2:
Delaunay

Public Member Functions

 Delaunay2 ()
 Default constructor.
 
 ~Delaunay2 () override
 Destructor.
 
void set_vertices (unsigned int nb_vertices, const float *pts) override
 Sets the vertices from an array of floating point numbers, in which each consecutive number pair denotes a 2D point.
 
void set_vertices (const std::vector< vec2 > &vertices)
 Sets the vertices from an array of 2D points.
 
unsigned int nearest_vertex (const float *p) const override
 Finds the index of the nearest vertex to a given point.
 
unsigned int nearest_vertex (const vec2 &p) const
 Finds the index of the nearest vertex to a given 2D point.
 
const vec2vertex (unsigned int i) const
 Returns the coordinates of the vertex with index i.
 
const int * tri_to_v () const
 Returns the pointer to the triangle-to-vertex mapping.
 
const int * tri_to_tri () const
 Returns the pointer to the triangle-to-triangle mapping.
 
int vertex_tri (int v) const
 Returns the index of a triangle containing the vertex v.
 
unsigned int nb_triangles () const
 Returns the number of triangles.
 
int tri_vertex (unsigned int t, unsigned int lv) const
 Returns the index of the lv-th vertex in the t-th triangle.
 
int tri_adjacent (unsigned int t, unsigned int le) const
 Returns the index of the triangle adjacent to the le-th edge of the t-th triangle.
 
- Public Member Functions inherited from Delaunay
 Delaunay (unsigned int dimension)
 Constructor.
 
virtual ~Delaunay ()
 Virtual destructor.
 
unsigned int dimension () const
 Returns the dimension of the triangulation.
 
unsigned int cell_size () const
 Returns the size of a cell.
 
const float * vertices_ptr () const
 Returns a pointer to the vertices array.
 
const float * vertex_ptr (unsigned int i) const
 Returns a pointer to the vertex of index i.
 
unsigned int nb_vertices () const
 Returns the number of vertices.
 
unsigned int nb_cells () const
 Returns the number of cells.
 
const int * cell_to_v () const
 Returns a pointer to the cell-to-vertex mapping.
 
const int * cell_to_cell () const
 Returns a pointer to the cell-to-cell mapping.
 
int cell_vertex (unsigned int c, unsigned int lv) const
 Returns the index of the lv-th vertex in the c-th cell.
 
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.
 
int vertex_cell (unsigned int v) const
 Returns the index of a cell containing the vertex v.
 
unsigned int index (unsigned int c, int v) const
 Returns the local index of vertex v within cell c.
 
unsigned int adjacent_index (unsigned int c1, unsigned int c2) const
 Returns the local index of the face shared by cells c1 and c2.
 
unsigned int next_around_vertex (unsigned int c, unsigned int lv) const
 Returns the next cell around vertex lv in cell c.
 
virtual void get_neighbors (unsigned int v, std::vector< unsigned int > &neighbors) const
 Retrieves the one-ring neighbors of vertex v.
 
bool check_duplicate_vertices ()
 Checks for duplicate vertices in stored neighbor lists.
 

Detailed Description

2D Delaunay triangulation, using Jonathan Richard Shewchuk's "triangle" implementation.

This class provides functionality for 2D Delaunay triangulation using the "triangle" library. It manages vertices, triangles, and their relationships, and provides methods for querying the triangulation structure.

See also
Delaunay, Delaunay3

Member Function Documentation

◆ nb_triangles()

unsigned int nb_triangles ( ) const
inline

Returns the number of triangles.

Returns
The number of triangles in the triangulation.

◆ nearest_vertex() [1/2]

unsigned int nearest_vertex ( const float * p) const
inlineoverridevirtual

Finds the index of the nearest vertex to a given point.

Parameters
pA pointer to the coordinates of the point.
Returns
The index of the nearest vertex.

Reimplemented from Delaunay.

◆ nearest_vertex() [2/2]

unsigned int nearest_vertex ( const vec2 & p) const
inline

Finds the index of the nearest vertex to a given 2D point.

Parameters
pThe 2D point.
Returns
The index of the nearest vertex.

◆ set_vertices() [1/2]

void set_vertices ( const std::vector< vec2 > & vertices)
inline

Sets the vertices from an array of 2D points.

Parameters
verticesA vector of 2D points.

◆ set_vertices() [2/2]

void set_vertices ( unsigned int nb_vertices,
const float * pts )
overridevirtual

Sets the vertices from an array of floating point numbers, in which each consecutive number pair denotes a 2D point.

Parameters
nb_verticesThe number of vertices.
ptsA pointer to the array of vertex coordinates.
Note
The vertices array must have a size of nb_vertices * 2.

Reimplemented from Delaunay.

◆ tri_adjacent()

int tri_adjacent ( unsigned int t,
unsigned int le ) const
inline

Returns the index of the triangle adjacent to the le-th edge of the t-th triangle.

Parameters
tThe index of the triangle.
leThe local index of the edge within the triangle.
Returns
The index of the adjacent triangle.

◆ tri_to_tri()

const int * tri_to_tri ( ) const
inline

Returns the pointer to the triangle-to-triangle mapping.

Returns
A pointer to the array mapping triangles to their adjacent triangles.

◆ tri_to_v()

const int * tri_to_v ( ) const
inline

Returns the pointer to the triangle-to-vertex mapping.

Returns
A pointer to the array mapping triangles to their vertices.

◆ tri_vertex()

int tri_vertex ( unsigned int t,
unsigned int lv ) const
inline

Returns the index of the lv-th vertex in the t-th triangle.

Parameters
tThe index of the triangle.
lvThe local index of the vertex within the triangle.
Returns
The global index of the vertex.

◆ vertex()

const vec2 & vertex ( unsigned int i) const
inline

Returns the coordinates of the vertex with index i.

Parameters
iThe index of the vertex.
Returns
The coordinates of the vertex.

◆ vertex_tri()

int vertex_tri ( int v) const
inline

Returns the index of a triangle containing the vertex v.

Parameters
vThe index of the vertex.
Returns
The index of a triangle containing the vertex.

The documentation for this class was generated from the following files: