ConstrainedVoronoiDiagram

class ConstrainedVoronoiDiagram(val constrainedDelaunayTriangulation: ConstrainedDelaunayTriangulation, val bounds: Rectangle) : AbstractVoronoiDiagram(source)

The Voronoi diagram dual to a ConstrainedDelaunayTriangulation's points, with every cell clipped both to bounds and to the triangulation's ConstrainedDelaunayTriangulation.shape -- so cells never extend outside a non-convex outer contour or across a hole boundary.

This delegates the heavy lifting (circumcenters, exterior-cell rays, rectangle clipping) to an ordinary, unconstrained VoronoiDiagram of the same points, then additionally intersects each resulting cell with shape. When that intersection yields more than one polygon (a cell straddling a hole, for example), the largest (by area) is kept, since cellPolygon returns a single ShapeContour.

Constructors

Link copied to clipboard
constructor(constrainedDelaunayTriangulation: ConstrainedDelaunayTriangulation, bounds: Rectangle)

Properties

Link copied to clipboard
open override val bounds: Rectangle

The rectangular region cells are clipped to.

Link copied to clipboard

The triangulation whose points are the Voronoi sites.

Functions

Link copied to clipboard
open fun cellArea(i: Int, contour: ShapeContour = cellPolygon(i)): Double

The (signed) area of cell i.

Link copied to clipboard
open fun cellCentroid(i: Int, contour: ShapeContour = cellPolygon(i)): Vector2

The centroid of cell i.

Link copied to clipboard
open fun cellCentroids(): List<Vector2>

The centroids of every cell, in point order.

Link copied to clipboard
open override fun cellPolygon(i: Int): ShapeContour

The Voronoi cell polygon for site i (index into triangulation's points), clipped to bounds.

Link copied to clipboard
open fun cellPolygons(): List<ShapeContour>

The Voronoi cell polygons for every site, in point order.

Link copied to clipboard
open override fun internalEdges(): Pair<List<Vector2>, List<IntArray>>

The internal edges of the unconstrained diagram (see VoronoiDiagram.internalEdges) that lie strictly inside shape: both endpoints inside the shape and away from its contours, and the edge not crossing any contour.

Link copied to clipboard
open override fun neighbors(cellIndex: Int): Sequence<Int>

Two sites are neighbors here iff they share an edge in the constrained triangulation.