public final class VoronoiResults
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
RectD |
clippingBounds
The clipping bounds for the entire Voronoi diagram.
|
PointD[] |
generatorSites
The generator sites for the Voronoi diagram and Delaunay triangulation.
|
VoronoiEdge[] |
voronoiEdges
The edge list for the Voronoi diagram.
|
PointD[] |
voronoiVertices
The vertex list for the Voronoi diagram.
|
Modifier and Type | Method and Description |
---|---|
void |
clearVoronoiRegions()
Clears the
voronoiRegions() cache. |
LineD[] |
clipDelaunayEdges(RectD bounds)
Clips the edge list for the Delaunay triangulation to the specified bounds.
|
LineD[] |
delaunayEdges()
Gets the edge list for the Delaunay triangulation.
|
Subdivision |
toDelaunaySubdivision(boolean addRegions)
|
Subdivision |
toDelaunaySubdivision(RectD bounds,
boolean addRegions)
Converts all
delaunayEdges() to a planar Subdivision ,
using the specified clipping bounds. |
PointD[][] |
voronoiRegions()
Gets the regions of the Voronoi diagram.
|
public final RectD clippingBounds
RectD
that was actually used by the Voronoi
algorithm,
which may be larger than that originally supplied to Voronoi.findAll(org.kynosarges.tektosyne.geometry.PointD[])
.
All Voronoi edges are terminated with a pseudo-vertex in voronoiVertices
when they intersect the clippingBounds
. No voronoiVertices
lie
outside the clippingBounds
.
Moreover, the four corners of the clippingBounds
are always part of some
voronoiRegions()
that were originally unbounded. voronoiVertices
does not usually contain these corner vertices.
public final PointD[] generatorSites
PointD
coordinates whose Voronoi diagram and Delaunay triangulation
are provided by the VoronoiResults
. This is the original PointD
array that was supplied to the Voronoi
algorithm and resulted in the
VoronoiResults
. This field is provided merely for convenience.public final VoronoiEdge[] voronoiEdges
generatorSites
and voronoiVertices
arrays.
The complete Voronoi diagram is defined both by the voronoiVertices
and by
the voronoiEdges
that connect the vertices. All coordinates are bounded by
the current clippingBounds
.
public final PointD[] voronoiVertices
PointD
coordinates of all vertices in the Voronoi diagram.
The complete Voronoi diagram is defined both by the voronoiVertices
and by
the voronoiEdges
that connect the vertices. All coordinates are bounded by
the current clippingBounds
.
public LineD[] delaunayEdges()
voronoiEdges
. Each LineD
element
connects the generatorSites
indicated by VoronoiEdge.site1
and
VoronoiEdge.site2
of the VoronoiEdge
at the same index position.LineD
edges in the Delaunay triangulationpublic PointD[][] voronoiRegions()
clippingBounds
.
The PointD
array for each generator site contains the vertices of a convex
polygon. The last vertex is implicitly assumed to be connected with the first vertex.
Most vertices also appear in voronoiVertices
, except for the four corners
of the clippingBounds
which terminate the outermost regions.
PointD
polygons that represent the Voronoi
regions corresponding to the same generatorSites
indicespublic void clearVoronoiRegions()
voronoiRegions()
cache.
This will cause voronoiRegions()
to be recalculated (with identical results)
when requested again. Call this method to reduce memory consumption when the cached
voronoiRegions()
are no longer required, e.g. after creating VoronoiMap
.public LineD[] clipDelaunayEdges(RectD bounds)
delaunayEdges()
whose corresponding voronoiEdges
element fulfils two conditions:
VoronoiEdge.site1
and VoronoiEdge.site2
both fall within
the specified bounds
.VoronoiEdge.vertex1
and VoronoiEdge.vertex2
intersects the specified bounds
.clipDelaunayEdges(org.kynosarges.tektosyne.geometry.RectD)
selects those delaunayEdges()
that
fall entirely within bounds
, and which connect two voronoiRegions()
that share a common border within bounds
.bounds
- a RectD
indicating the clipping bounds for all delaunayEdges()
delaunayEdges()
which intersect bounds
, as defined abovejava.lang.NullPointerException
- if bounds
is null
public Subdivision toDelaunaySubdivision(boolean addRegions)
addRegions
- true
to add all voronoiRegions()
with the corresponding
generatorSites
to the Subdivision.vertexRegions()
of the new Subdivision
, else false
Subdivision
whose Subdivision.edges()
correspond to the
delaunayEdges()
of the VoronoiResults
public Subdivision toDelaunaySubdivision(RectD bounds, boolean addRegions)
delaunayEdges()
to a planar Subdivision
,
using the specified clipping bounds.
The specified bounds
determine the subset of generatorSites
and delaunayEdges()
that is stored in the new Subdivision
,
as described in clipDelaunayEdges(org.kynosarges.tektosyne.geometry.RectD)
.
If addRegions
is true
, the polygons added to
Subdivision.vertexRegions()
are also clipped the specified bounds
.
bounds
- a RectD
indicating the clipping bounds for all delaunayEdges()
addRegions
- true
to add all voronoiRegions()
with the corresponding
generatorSites
to the Subdivision.vertexRegions()
of the new Subdivision
, else false
Subdivision
whose Subdivision.edges()
correspond to the
delaunayEdges()
of the VoronoiResults
java.lang.NullPointerException
- if bounds
is null