Package com.google.common.geometry
Class S2Polygon.S2LoopSequenceIndex
- java.lang.Object
-
- com.google.common.geometry.S2EdgeIndex
-
- com.google.common.geometry.S2Polygon.S2LoopSequenceIndex
-
- Direct Known Subclasses:
S2Polygon.S2PolygonIndex
- Enclosing class:
- S2Polygon
private abstract static class S2Polygon.S2LoopSequenceIndex extends S2EdgeIndex
Indexing structure to efficientlyS2EdgeIndex.clipEdge(com.google.common.geometry.S2Point, com.google.common.geometry.S2Point, boolean, java.util.Collection<com.google.common.geometry.ParametrizedS2Point>)
of a polygon. This is an abstract class because we need to use if for both polygons (forS2Polygon.initToIntersection(com.google.common.geometry.S2Polygon, com.google.common.geometry.S2Polygon)
and friends) and for sets of lists of points (for initToSimplified() future?).Usage: In your subclass, create an array of vertex counts for each loop in the loop sequence and pass it to this constructor. Overwrite
edgeFromTo(int)
, callingdecodeIndex(int)
and use the resulting two indices to access your vertices.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.geometry.S2EdgeIndex
S2EdgeIndex.DataEdgeIterator
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
indexToLoop
Map from the uni-dimensional edge index to the loop this edge belongs to.private int[]
loopToFirstIndex
Reverse ofindexToLoop
: maps a loop index to the uni-dimensional index of the first edge in the loop.
-
Constructor Summary
Constructors Constructor Description S2LoopSequenceIndex(int[] numVertices)
Must be called by each subclass with the array of vertices per loop.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description S2Polygon.LoopVertexIndexPair
decodeIndex(int index)
S2Point
edgeFrom(int index)
Returns the starting vertex of the edge at offsetindex
.abstract S2Edge
edgeFromTo(int index)
Mark theedgeFromTo(int)
method abstract again, so children of this class must implement it without usingedgeFrom(int)
andedgeTo(int)
.S2Point
edgeTo(int index)
Returns the ending vertex of the edge at offsetindex
.int
getNumEdges()
Returns the number of edges in this index.-
Methods inherited from class com.google.common.geometry.S2EdgeIndex
clipEdge, computeIndex, findCandidateCrossings, incrementQueryCount, isIndexComputed, predictAdditionalCalls, reset
-
-
-
-
Field Detail
-
indexToLoop
private final int[] indexToLoop
Map from the uni-dimensional edge index to the loop this edge belongs to.
-
loopToFirstIndex
private final int[] loopToFirstIndex
Reverse ofindexToLoop
: maps a loop index to the uni-dimensional index of the first edge in the loop.
-
-
Method Detail
-
decodeIndex
public final S2Polygon.LoopVertexIndexPair decodeIndex(int index)
-
getNumEdges
public final int getNumEdges()
Description copied from class:S2EdgeIndex
Returns the number of edges in this index.- Specified by:
getNumEdges
in classS2EdgeIndex
-
edgeFromTo
public abstract S2Edge edgeFromTo(int index)
Mark theedgeFromTo(int)
method abstract again, so children of this class must implement it without usingedgeFrom(int)
andedgeTo(int)
.- Overrides:
edgeFromTo
in classS2EdgeIndex
-
edgeFrom
public S2Point edgeFrom(int index)
Description copied from class:S2EdgeIndex
Returns the starting vertex of the edge at offsetindex
.- Specified by:
edgeFrom
in classS2EdgeIndex
-
edgeTo
public S2Point edgeTo(int index)
Description copied from class:S2EdgeIndex
Returns the ending vertex of the edge at offsetindex
.- Specified by:
edgeTo
in classS2EdgeIndex
-
-