public final class PolygonGridMap extends java.lang.Object implements SubdivisionMap<PointI>
Subdivision to PolygonGrid locations.
Provides a mapping between all faces of a planar Subdivision and the PointI
locations of the PolygonGrid from which the Subdivision was created.
The mapping is realized by a pair of arrays for optimal runtime efficiency.
However, PolygonGridMap will not reflect changes to the underlying
Subdivision or PolygonGrid.
| Constructor and Description |
|---|
PolygonGridMap(PolygonGrid grid,
PointD offset,
double epsilon)
|
| Modifier and Type | Method and Description |
|---|---|
PointI |
fromFace(SubdivisionFace face)
Converts the specified
SubdivisionFace into the associated PointI location. |
Subdivision |
source()
Gets the
Subdivision that contains all mapped Subdivision.faces(). |
PolygonGrid |
target()
Gets the
PolygonGrid that defines all mapped PointI locations. |
SubdivisionFace |
toFace(PointI value)
Converts the specified
PointI location into the associated SubdivisionFace. |
public PolygonGridMap(PolygonGrid grid, PointD offset, double epsilon)
PolygonGridMap from a new Subdivision to the specified PolygonGrid.
Sets target() to grid, and source() to a new Subdivision
that contains all mapped Subdivision.faces() created from grid locations.
All Subdivision coordinates are based on PolygonGrid.gridToWorld(int, int).
offset may be null which is interpreted as PointD.EMPTY. Otherwise,
the Subdivision.faces() of the new Subdivision are shifted by offset.
epsilon may be equal to or less than zero, in which case one millionth of the
RegularPolygon.length of the current PolygonGrid.element() is used. We
cannot use exact coordinate comparisons because shared vertices of adjacent grid elements
are unlikely to evaluate to the exact same coordinates in all cases.
grid - the PolygonGrid that defines all mapped PointI locationsoffset - an optional offset by which to shift gridepsilon - the maximum absolute difference at which coordinates should be considered equaljava.lang.NullPointerException - if grid is nullpublic Subdivision source()
Subdivision that contains all mapped Subdivision.faces().source in interface SubdivisionMap<PointI>Subdivision that contains all Subdivision.faces() accepted
and returned by fromFace(org.kynosarges.tektosyne.subdivision.SubdivisionFace) and toFace(org.kynosarges.tektosyne.geometry.PointI), respectivelypublic PolygonGrid target()
PolygonGrid that defines all mapped PointI locations.target in interface SubdivisionMap<PointI>PolygonGrid that defines all PointI locations returned
and accepted by fromFace(org.kynosarges.tektosyne.subdivision.SubdivisionFace) and toFace(org.kynosarges.tektosyne.geometry.PointI), respectivelypublic PointI fromFace(SubdivisionFace face)
SubdivisionFace into the associated PointI location.fromFace in interface SubdivisionMap<PointI>face - the SubdivisionFace to convertPointI location associated with facejava.lang.IllegalArgumentException - if source() does not contain face,
or face is the unbounded SubdivisionFacejava.lang.NullPointerException - if face is nullpublic SubdivisionFace toFace(PointI value)
PointI location into the associated SubdivisionFace.toFace in interface SubdivisionMap<PointI>value - the PointI location to convertSubdivisionFace associated with valuejava.lang.IllegalArgumentException - if value does not map to any
SubdivisionFace within source()