Package com.google.common.geometry
Class S2Loop.LoopCrosser
- java.lang.Object
-
- com.google.common.geometry.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.
-
-
Field Summary
Fields Modifier and Type Field Description private S2Loop
a
private int
aCrossingTarget
private int
aj
private S2Loop
b
private java.util.List<S2ShapeIndex.Cell>
bCells
private int
bCrossingTarget
private int
bjPrev
private S2EdgeQuery
bQuery
private S2EdgeUtil.EdgeCrosser
crosser
private S2Loop.LoopRelation
relation
private boolean
swapped
-
Constructor Summary
Constructors Constructor Description LoopCrosser(S2Loop a, S2Loop b, S2Loop.LoopRelation relation, boolean swapped)
Ifswapped
is true, the loops A and B have been swapped.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
aCrossingTarget()
Returns the crossing targets for the loop relation, taking into account whether the loops have been swapped.int
bCrossingTarget()
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 withinbId
.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.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.private boolean
hasCrossing(S2ShapeIndex.RangeIterator ai, S2ShapeIndex.RangeIterator bi)
Given two iterators positioned such thatai.id().contains(bi.id())
, returns true if there is an edge crossing or a wedge crossing anywhere withinai.id()
.boolean
hasCrossingRelation(S2ShapeIndex.RangeIterator ai, S2ShapeIndex.RangeIterator bi)
Given two iterators positioned such thatai.id().contains(bi.id())
, returns true if there is a crossing relationship anywhere withinai.id()
.private void
startEdge(int aj)
Prepares to check the given edge of loop A for crossings.
-
-
-
Field Detail
-
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 java.util.List<S2ShapeIndex.Cell> bCells
-
-
Constructor Detail
-
LoopCrosser
public LoopCrosser(S2Loop a, S2Loop b, S2Loop.LoopRelation relation, boolean swapped)
Ifswapped
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 thatai.id().contains(bi.id())
, returns true if there is a crossing relationship anywhere withinai.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 pastai.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 thatai.id().contains(bi.id())
, returns true if there is an edge crossing or a wedge crossing anywhere withinai.id()
. Advancesbi
(only) pastai.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 withinbId
.
-
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.
-
-