Class S2Loop.LoopCrosser

  • Enclosing class:
    S2Loop

    private static final class S2Loop.LoopCrosser
    extends java.lang.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.
    • Constructor Detail

      • 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 Detail

      • 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().
      • 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.