public class VoronoiMap extends java.lang.Object implements SubdivisionMap<java.lang.Integer>
Subdivision
to VoronoiResults.generatorSites
indices.
Provides a mapping between all faces of a planar Subdivision
and the
VoronoiResults.generatorSites
indices of the VoronoiResults
from which the Subdivision
was created.
The mapping is realized by a pair of arrays for optimal runtime efficiency. However,
VoronoiMap
will not reflect changes to the underlying Subdivision
.
Constructor and Description |
---|
VoronoiMap(VoronoiResults results)
|
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
fromFace(SubdivisionFace face)
Converts the specified
SubdivisionFace into the associated
VoronoiResults.generatorSites index. |
Subdivision |
source()
Gets the
Subdivision that contains all mapped Subdivision.faces() . |
VoronoiResults |
target()
Gets the
VoronoiResults that defines all mapped VoronoiResults.generatorSites indices. |
SubdivisionFace |
toFace(int value)
Converts the specified
VoronoiResults.generatorSites index
into the associated SubdivisionFace . |
SubdivisionFace |
toFace(java.lang.Integer value)
Converts the specified
VoronoiResults.generatorSites index
into the associated SubdivisionFace . |
public VoronoiMap(VoronoiResults results)
VoronoiMap
from a new Subdivision
to the specified VoronoiResults
.
The bounded Subdivision.faces()
of the new Subdivision
correspond
to the VoronoiResults.voronoiRegions()
of the specified results
.
All VoronoiResults.voronoiRegions()
are calculated if necessary. After the
VoronoiMap
has been created, you may call VoronoiResults.clearVoronoiRegions()
if you do not otherwise require this data.
results
- the VoronoiResults
that defines all mapped
VoronoiResults.generatorSites
indicesjava.lang.NullPointerException
- if results
is null
public VoronoiResults target()
VoronoiResults
that defines all mapped VoronoiResults.generatorSites
indices.target
in interface SubdivisionMap<java.lang.Integer>
VoronoiResults
that defines all VoronoiResults.generatorSites
indices
returned and accepted by fromFace(org.kynosarges.tektosyne.subdivision.SubdivisionFace)
and toFace(java.lang.Integer)
, respectivelypublic Subdivision source()
Subdivision
that contains all mapped Subdivision.faces()
.source
in interface SubdivisionMap<java.lang.Integer>
Subdivision
that contains all Subdivision.faces()
accepted
and returned by fromFace(org.kynosarges.tektosyne.subdivision.SubdivisionFace)
and toFace(java.lang.Integer)
, respectivelypublic java.lang.Integer fromFace(SubdivisionFace face)
SubdivisionFace
into the associated
VoronoiResults.generatorSites
index.fromFace
in interface SubdivisionMap<java.lang.Integer>
face
- the SubdivisionFace
to convertVoronoiResults.generatorSites
index associated with face
java.lang.ArrayIndexOutOfBoundsException
- if face
is the unbounded SubdivisionFace
,
or its SubdivisionFace.key()
is greater than
the number of VoronoiResults.generatorSites
java.lang.NullPointerException
- if face
is null
public SubdivisionFace toFace(java.lang.Integer value)
VoronoiResults.generatorSites
index
into the associated SubdivisionFace
.toFace
in interface SubdivisionMap<java.lang.Integer>
value
- the VoronoiResults.generatorSites
index to convertSubdivisionFace
associated with value
java.lang.ArrayIndexOutOfBoundsException
- if value
is not a valid
VoronoiResults.generatorSites
indexpublic SubdivisionFace toFace(int value)
VoronoiResults.generatorSites
index
into the associated SubdivisionFace
.
Overload typed with a primitive int
parameter to avoid Integer
boxing.value
- the VoronoiResults.generatorSites
index to convertSubdivisionFace
associated with value
java.lang.ArrayIndexOutOfBoundsException
- if value
is not a valid
VoronoiResults.generatorSites
index