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 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.

  • Field Details

    • 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 of indexToLoop: 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 the i th loop's vertex count is in the i th index of the array.
  • Method Details