Package com.google.common.geometry
Class S2Polygon.EdgeClipper
- java.lang.Object
-
- com.google.common.geometry.S2Polygon.EdgeClipper
-
- Enclosing class:
- S2Polygon
private static class S2Polygon.EdgeClipper extends java.lang.Object
EdgeClipper finds all the intersections of a given edge with the edges contained in an S2ShapeIndex. It is used to implement polygon operations such as intersection and union.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
addSharedEdges
private S2EdgeQuery
query
private com.google.common.base.Predicate<S2Shape>
reverseEdges
-
Constructor Summary
Constructors Constructor Description EdgeClipper(S2ShapeIndex index, boolean addSharedEdges, com.google.common.base.Predicate<S2Shape> reverseEdges)
Initialize an EdgeClipper for the given S2ShapeIndex.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addIntersection(S2Point a0, S2Point a1, S2Point b0, S2Point b1, S2Shape bShape, int crossing, java.util.List<ParametrizedS2Point> intersections)
Given two edges A and B such that robustCrossing(A, B) >= 0, determines if they intersect and adds any intersection point tointersections
.void
clipEdge(S2Point a0, S2Point a1, java.util.List<ParametrizedS2Point> intersections)
Finds all points where the polygon B intersects the edge (a0, a1), and add the corresponding parameter values (in the range [0,1]) tointersections
.
-
-
-
Field Detail
-
query
private final S2EdgeQuery query
-
addSharedEdges
private final boolean addSharedEdges
-
reverseEdges
private final com.google.common.base.Predicate<S2Shape> reverseEdges
-
-
Constructor Detail
-
EdgeClipper
public EdgeClipper(S2ShapeIndex index, boolean addSharedEdges, com.google.common.base.Predicate<S2Shape> reverseEdges)
Initialize an EdgeClipper for the given S2ShapeIndex. If the query edge is the same as an index edge (a "shared edge"), then the edge will be included in the output if and only ifaddSharedEdges
is true. ThereverseEdges
function allows the edges of any index shape to be reversed before this test is performed (this is used to reverse the loop orientation of "holes" in certain algorithms).
-
-
Method Detail
-
clipEdge
public void clipEdge(S2Point a0, S2Point a1, java.util.List<ParametrizedS2Point> intersections)
Finds all points where the polygon B intersects the edge (a0, a1), and add the corresponding parameter values (in the range [0,1]) tointersections
. The result is unsorted.
-
addIntersection
private void addIntersection(S2Point a0, S2Point a1, S2Point b0, S2Point b1, S2Shape bShape, int crossing, java.util.List<ParametrizedS2Point> intersections)
Given two edges A and B such that robustCrossing(A, B) >= 0, determines if they intersect and adds any intersection point tointersections
.bShape
is the S2Shape containing edge B, andcrossing
is the result ofrobustCrossing(A, B)
.
-
-