Class S2Polygon.EdgeClipper

java.lang.Object
com.google.common.geometry.S2Polygon.EdgeClipper
Enclosing class:
S2Polygon

private static class S2Polygon.EdgeClipper extends 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 Details

    • query

      private final S2EdgeQuery query
    • addSharedEdges

      private final boolean addSharedEdges
    • reverseEdges

      private final com.google.common.base.Predicate<S2Shape> 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 if addSharedEdges is true. The reverseEdges 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

      public 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]) to intersections. 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 to intersections. bShape is the S2Shape containing edge B, and crossing is the result of robustCrossing(A, B).