Package com.google.common.geometry
Class S2Polygon.EdgeClipper
java.lang.Object
com.google.common.geometry.S2Polygon.EdgeClipper
- Enclosing class:
S2Polygon
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
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final S2EdgeQuery
private final com.google.common.base.Predicate
<S2Shape> -
Constructor Summary
ConstructorsConstructorDescriptionEdgeClipper
(S2ShapeIndex index, boolean addSharedEdges, com.google.common.base.Predicate<S2Shape> reverseEdges) Initialize an EdgeClipper for the given S2ShapeIndex. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addIntersection
(S2Point a0, S2Point a1, S2Point b0, S2Point b1, S2Shape bShape, int crossing, 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, 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 Details
-
query
-
reverseEdges
-
-
Constructor Details
-
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 Details
-
clipEdge
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, 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)
.
-