public final class SubdivisionFace
extends java.lang.Object
Subdivision
.
Represents any polygonal region that is bounded by the edges of a Subdivision
, whether
on the inside, on the outside, or both. There is always exactly one face without an outer boundary,
called the unbounded face, which comprises the entire plane outside of the Subdivision
.
A SubdivisionFace
stores one SubdivisionEdge
for each of its outer and inner
boundaries. The corresponding polygonal region can be reconstructed from the cycle of half-edges
that begins with an incident outerEdge()
or innerEdges()
element. Use the cycle… properties of these half-edges to obtain face boundaries etc.
Modifier and Type | Field and Description |
---|---|
Subdivision |
owner
The
Subdivision that contains the SubdivisionFace . |
Modifier and Type | Method and Description |
---|---|
java.util.List<SubdivisionEdge> |
allCycleEdges()
Gets all
SubdivisionEdge instances on all boundaries of the SubdivisionFace . |
boolean |
equals(java.lang.Object obj)
Compares the specified
Object to this SubdivisionFace instance. |
FindEdgeResult |
findNearestEdge(PointD q)
Finds the
SubdivisionEdge bounding the SubdivisionFace
that is nearest to and facing the specified PointD coordinates. |
int |
hashCode()
Returns a hash code for the
SubdivisionFace . |
java.util.List<SubdivisionEdge> |
innerEdges()
|
int |
key()
Gets the unique key of the
SubdivisionFace . |
SubdivisionEdge |
outerEdge()
Gets a
SubdivisionEdge on the outer boundary of the SubdivisionFace . |
java.lang.String |
toString()
Returns a
String representation of the SubdivisionFace . |
public final Subdivision owner
public int key()
SubdivisionFace
.
Starts at zero for the first SubdivisionFace
in a Subdivision
,
and is incremented by one for each additional SubdivisionFace
. key()
thus reflects the order in which SubdivisionFace
instances were created.
Immutable unless Subdivision.renumberFaces()
is called on the owner
.SubdivisionFace
within owner
public java.util.List<SubdivisionEdge> allCycleEdges()
SubdivisionEdge
instances on all boundaries of the SubdivisionFace
.
Starts with outerEdge()
, if any, and follows the chain of SubdivisionEdge.next()
links until the cycle is complete. This process is then repeated for all innerEdges()
.List
containing all SubdivisionEdge
instances
surrounding all boundaries of the SubdivisionFace
public SubdivisionEdge outerEdge()
SubdivisionEdge
on the outer boundary of the SubdivisionFace
.SubdivisionEdge
on the outer boundary of the SubdivisionFace
,
or null
if the SubdivisionFace
has no outer boundarypublic java.util.List<SubdivisionEdge> innerEdges()
List
containing one SubdivisionEdge
on each inner boundary of the SubdivisionFace
.
Never returns null
. Returns an empty List
if the
SubdivisionFace
contains no inner boundaries, or “holes.”List
containing one outward-facing SubdivisionEdge
on each disconnected inner boundary of the SubdivisionFace
public FindEdgeResult findNearestEdge(PointD q)
SubdivisionEdge
bounding the SubdivisionFace
that is nearest to and facing the specified PointD
coordinates.
Traverses the outerEdge()
boundary and all innerEdges()
boundaries,
computing the distance from q
to each SubdivisionEdge
. This is an O(n)
operation where n is the number of half-edges incident on the SubdivisionFace
.
If q
is nearest to an edge that belongs to a zero-area protrusion into the
SubdivisionFace
, findNearestEdge(org.kynosarges.tektosyne.geometry.PointD)
returns the twin half-edge that faces
q
, according to its SubdivisionEdge.face()
orientation.
q
- the PointD
coordinates to examineFindEdgeResult
containing the SubdivisionEdge
on any boundary
of the SubdivisionFace
nearest to and facing q
, or null
if the SubdivisionFace
is completely unbounded; and the distance between
q
and the returned SubdivisionEdge
, if any, else Double.MAX_VALUE
java.lang.NullPointerException
- if q
is null
public boolean equals(java.lang.Object obj)
Object
to this SubdivisionFace
instance.
Intended for testing, as any two SubdivisionFace
instances in the same
Subdivision
are never equal.equals
in class java.lang.Object
obj
- the Object
to compare to this instancetrue
if obj
is not null
and a SubdivisionFace
instance
whose key()
and incident edges equal those of this instance, else false
public int hashCode()
SubdivisionFace
.
Returns key()
which is guaranteed to be unique within owner
.hashCode
in class java.lang.Object
Integer
hash code for the SubdivisionFace
public java.lang.String toString()
String
representation of the SubdivisionFace
.
Objects that are null
are represented with a key value of -1.toString
in class java.lang.Object
String
containing the values of key()
and the keys
of outerEdge()
and all innerEdges()
elements