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
Indexing structure to efficiently
S2EdgeIndex.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 (for S2Polygon.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)
, calling decodeIndex(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
FieldsModifier and TypeFieldDescriptionprivate final int[]
Map from the uni-dimensional edge index to the loop this edge belongs to.private final int[]
Reverse ofindexToLoop
: maps a loop index to the uni-dimensional index of the first edge in the loop. -
Constructor Summary
ConstructorsConstructorDescriptionS2LoopSequenceIndex
(int[] numVertices) Must be called by each subclass with the array of vertices per loop. -
Method Summary
Modifier and TypeMethodDescriptiondecodeIndex
(int index) 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)
.edgeTo
(int index) Returns the ending vertex of the edge at offsetindex
.final int
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 Details
-
indexToLoop
private final int[] indexToLoopMap from the uni-dimensional edge index to the loop this edge belongs to. -
loopToFirstIndex
private final int[] loopToFirstIndexReverse ofindexToLoop
: maps a loop index to the uni-dimensional index of the first edge in the loop.
-
-
Constructor Details
-
S2LoopSequenceIndex
public S2LoopSequenceIndex(int[] numVertices) Must be called by each subclass with the array of vertices per loop. The length of the array is the number of loops, and thei
th loop's vertex count is in thei
th index of the array.
-
-
Method Details
-
decodeIndex
-
getNumEdges
public final int getNumEdges()Description copied from class:S2EdgeIndex
Returns the number of edges in this index.- Specified by:
getNumEdges
in classS2EdgeIndex
-
edgeFromTo
Mark theedgeFromTo(int)
method abstract again, so children of this class must implement it without usingedgeFrom(int)
andedgeTo(int)
.- Overrides:
edgeFromTo
in classS2EdgeIndex
-
edgeFrom
Description copied from class:S2EdgeIndex
Returns the starting vertex of the edge at offsetindex
.- Specified by:
edgeFrom
in classS2EdgeIndex
-
edgeTo
Description copied from class:S2EdgeIndex
Returns the ending vertex of the edge at offsetindex
.- Specified by:
edgeTo
in classS2EdgeIndex
-