Class 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.
    • 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 to intersections.
      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]) to intersections.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

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