Class S2Loop.LoopCrosser

java.lang.Object
com.google.common.geometry.S2Loop.LoopCrosser
Enclosing class:
S2Loop

private static final class S2Loop.LoopCrosser extends Object
LoopCrosser is a helper class for determining whether two loops cross. It is instantiated twice for each pair of loops to be tested, once for the pair (A, B) and once for the pair (B, A), in order to be able to process edges in either loop nesting order.
  • Field Details

    • a

      private final S2Loop a
    • b

      private final S2Loop b
    • relation

      private final S2Loop.LoopRelation relation
    • swapped

      private final boolean swapped
    • aCrossingTarget

      private final int aCrossingTarget
    • bCrossingTarget

      private final int bCrossingTarget
    • crosser

      private S2EdgeUtil.EdgeCrosser crosser
    • aj

      private int aj
    • bjPrev

      private int bjPrev
    • bQuery

      private final S2EdgeQuery bQuery
    • bCells

      private final List<S2ShapeIndex.Cell> bCells
  • Constructor Details

    • LoopCrosser

      public LoopCrosser(S2Loop a, S2Loop b, S2Loop.LoopRelation relation, boolean swapped)
      If swapped is true, the loops A and B have been swapped. This affects how arguments are passed to the given loop relation, since for example A.contains(B) is not the same as B.contains(A).
  • Method Details

    • aCrossingTarget

      public int aCrossingTarget()
      Returns the crossing targets for the loop relation, taking into account whether the loops have been swapped.
    • bCrossingTarget

      public int bCrossingTarget()
    • hasCrossingRelation

      public boolean hasCrossingRelation(S2ShapeIndex.RangeIterator ai, S2ShapeIndex.RangeIterator bi)
      Given two iterators positioned such that ai.id().contains(bi.id()), returns true if there is a crossing relationship anywhere within ai.id(). Specifically, this method returns true if there is an edge crossing, a wedge crossing, or a point P that matches both "crossing targets". Advances both iterators past ai.id().
    • cellCrossesCell

      public boolean cellCrossesCell(S2ShapeIndex.S2ClippedShape aClipped, S2ShapeIndex.S2ClippedShape bClipped)
      Given two index cells, returns true if there are any edge crossings or wedge crossings within those cells.
    • hasCrossing

      private boolean hasCrossing(S2ShapeIndex.RangeIterator ai, S2ShapeIndex.RangeIterator bi)
      Given two iterators positioned such that ai.id().contains(bi.id()), returns true if there is an edge crossing or a wedge crossing anywhere within ai.id(). Advances bi (only) past ai.id().
    • cellCrossesAnySubcell

      private boolean cellCrossesAnySubcell(S2ShapeIndex.S2ClippedShape aClipped, S2CellId bId)
      Given an index cell of A, returns true if there are any edge or wedge crossings with any index cell of B contained within bId.
    • startEdge

      private void startEdge(int aj)
      Prepares to check the given edge of loop A for crossings.
    • edgeCrossesCell

      private boolean edgeCrossesCell(S2ShapeIndex.S2ClippedShape bClipped)
      Checks the current edge of loop A for crossings with all edges of the given index cell of loop B.