Voronoi diagram.
More...
#include <Voronoi2.h>
|
bool | getVCellsAtVEdge (VoroVertex2 *pVoroVtx0, VoroVertex2 *pVoroVtx1, VoroCell2 *&pCell0, VoroCell2 *&pCell1) |
| Get the Voronoi cells adjacent to a Voronoi edge. More...
|
|
VoroCell2 * | getVoronoiCell (Point2 *pSite) |
| Retrieve the Voronoi cell of a specific site. More...
|
|
void | getVoronoiCells (std::vector< VoroCell2 * > &vVoronoiCells) |
| Retrieve all Voronoi cells. More...
|
|
VoroVertex2 * | getVoronoiVertex (Triangle2 *pT) |
| Get the Voronoi vertex of a triangle. More...
|
|
bool | isValid () const |
| Check if the Voronoi diagram is valid. More...
|
|
VoroCell2 * | locateVoronoiCell (const Point2 &queryPoint) |
| Locate a Voronoi Cell. More...
|
|
void | show (const char *filename, bool bVoronoi=true, bool bCellColors=true, bool bSites=true, bool bDelaunay=true, bool bCellLabels=false) |
| Draw the Voronoi diagram. More...
|
|
void | show (Visualizer2 *pVisualizer, bool bVoronoi=true, bool bCellColors=true, bool bSites=true, bool bDelaunay=true, bool bCellLabels=false) |
| Draw the Voronoi diagram. More...
|
|
Voronoi diagram
This class represents a Voronoi diagram which is the dual graph of a Delaunay triangulation i.e.,
- Each Voronoi cell contains the area closest to its site which is a Delaunay vertex.
- Each Voronoi edge has a dual edge in the Delaunay triangulation at an angle of 90 degrees to it.
- Each Voronoi vertex is the circumcenter of a Delaunay triangle.
- Note
- While the Voronoi diagram is the dual diagram of a Delaunay triangulation, it is NOT dual to a Constrained Delaunay triangulation.
- See also
- https://en.wikipedia.org/wiki/Voronoi_diagram
-
A C++ example on Voronoi diagrams
◆ getVCellsAtVEdge()
This method retrieves the Voronoi cells adjacent to a Voronoi edge defined by two Voronoi vertices.
- Parameters
-
[in] | pVoroVtx0,pVoroVtx1 | The Voronoi vertices that define the Voronoi edge. |
[out] | pCell0,pCell1 | Pointers to store the adjacent Voronoi cells. If the command fails, they will be set to NULL. |
- Returns
true
if the command succeeds, i.e., if (pVoroVtx0, pVoroVtx1) represents a valid Voronoi edge; false
otherwise.
◆ getVoronoiCell()
This method retrieves the Voronoi cell corresponding to a given site (a vertex in the dual Delaunay triangulation).
- Parameters
-
[in] | pSite | A Point2 pointer to the Delaunay vertex for which the Voronoi cell is to be retrieved. |
- Returns
- A pointer to the Voronoi cell (
VoroCell2
) that contains the site pSite
.
◆ getVoronoiCells()
void GEOM_FADE2D::Voronoi2::getVoronoiCells |
( |
std::vector< VoroCell2 * > & |
vVoronoiCells | ) |
|
This method retrieves both finite and infinite Voronoi cells in the diagram. The cells are returned in the provided vector.
- Parameters
-
[out] | vVoronoiCells | A vector that will contain the Voronoi cells after the method completes. Both finite and infinite cells will be included. |
◆ getVoronoiVertex()
This method returns the Voronoi vertex corresponding to the Delaunay triangle pT
. The Voronoi vertex is located at the circumcenter of the triangle.
- Parameters
-
[in] | pT | The Delaunay triangle whose Voronoi vertex is to be retrieved. |
- Returns
- The Voronoi vertex corresponding to
pT
.
◆ isValid()
bool GEOM_FADE2D::Voronoi2::isValid |
( |
| ) |
const |
This method checks whether the Voronoi diagram is ready for use. The diagram is considered valid as soon as there are at least 3 sites that are not collinear.
- Returns
true
if the Voronoi diagram is valid, i.e., if there are at least 3 non-collinear sites; false
otherwise.
◆ locateVoronoiCell()
VoroCell2* GEOM_FADE2D::Voronoi2::locateVoronoiCell |
( |
const Point2 & |
queryPoint | ) |
|
This high-performance method locates the Voronoi cell that contains the given query point.
- Parameters
-
[in] | queryPoint | The query point to locate within the Voronoi diagram. |
- Returns
- The Voronoi cell that contains the
queryPoint
, or NULL if the Voronoi diagram is invalid.
◆ show() [1/2]
void GEOM_FADE2D::Voronoi2::show |
( |
const char * |
filename, |
|
|
bool |
bVoronoi = true , |
|
|
bool |
bCellColors = true , |
|
|
bool |
bSites = true , |
|
|
bool |
bDelaunay = true , |
|
|
bool |
bCellLabels = false |
|
) |
| |
This method saves a graphical representation of the Voronoi diagram to a PDF or PostScript file. The diagram can be customized by controlling various options, such as whether to display Voronoi edges, cell colors, sites, Delaunay triangles, and cell labels.
- Parameters
-
[in] | filename | The output filename (must have a *.pdf or *.ps extension) |
[in] | bVoronoi | Whether to draw the edges of the Voronoi diagram (default: true). |
[in] | bCellColors | Whether to use background colors for the Voronoi cells (default: true). |
[in] | bSites | Whether to draw the sites (default: true). |
[in] | bDelaunay | Whether to draw the Delaunay triangles (default: true). |
[in] | bCellLabels | Whether to display cell labels (default: false). |
This method automatically crops the viewport to twice the range of the sites. Consequently, very large or infinite cells will appear clipped.
◆ show() [2/2]
void GEOM_FADE2D::Voronoi2::show |
( |
Visualizer2 * |
pVisualizer, |
|
|
bool |
bVoronoi = true , |
|
|
bool |
bCellColors = true , |
|
|
bool |
bSites = true , |
|
|
bool |
bDelaunay = true , |
|
|
bool |
bCellLabels = false |
|
) |
| |
This method saves a graphical representation of the Voronoi diagram to a PDF or PostScript file. The diagram can be customized by controlling various options, such as whether to display Voronoi edges, cell colors, sites, Delaunay triangles, and cell labels.
- Parameters
-
[in] | pVisualizer | A pointer to a Visualizer2 object, which will be used to handle the graphical output. |
[in] | bVoronoi | Whether to draw the edges of the Voronoi diagram (default: true). |
[in] | bCellColors | Whether to use background colors for the Voronoi cells (default: true). |
[in] | bSites | Whether to draw the sites (default: true). |
[in] | bDelaunay | Whether to draw the Delaunay triangles (default: true). |
[in] | bCellLabels | Whether to display cell labels (default: false). |
This method automatically crops the viewport to twice the range of the sites. Consequently, very large or infinite cells will appear clipped. You must call pVisualizer->writeFile()
to finalize and write the output file.
The documentation for this class was generated from the following file: