Package com.google.common.geometry
Class S2Loop.LoopCrosser
java.lang.Object
com.google.common.geometry.S2Loop.LoopCrosser
- Enclosing class:
S2Loop
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
FieldsModifier and TypeFieldDescriptionprivate final S2Loop
private final int
private int
private final S2Loop
private final List
<S2ShapeIndex.Cell> private final int
private int
private final S2EdgeQuery
private S2EdgeUtil.EdgeCrosser
private final S2Loop.LoopRelation
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionLoopCrosser
(S2Loop a, S2Loop b, S2Loop.LoopRelation relation, boolean swapped) Ifswapped
is true, the loops A and B have been swapped. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the crossing targets for the loop relation, taking into account whether the loops have been swapped.int
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
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
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 Details
-
a
-
b
-
relation
-
swapped
private final boolean swapped -
aCrossingTarget
private final int aCrossingTarget -
bCrossingTarget
private final int bCrossingTarget -
crosser
-
aj
private int aj -
bjPrev
private int bjPrev -
bQuery
-
bCells
-
-
Constructor Details
-
LoopCrosser
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 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
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
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
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
Checks the current edge of loop A for crossings with all edges of the given index cell of loop B.
-