]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / overlay / intersection_insert.hpp
index 60255cd9538170242677bc794d1543ed377d94cd..9232b0f40764aa3f1f50d98cdae052bb0b1a81f8 100644 (file)
@@ -2,8 +2,8 @@
 
 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
 
-// This file was modified by Oracle on 2014, 2015, 2017.
-// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
+// This file was modified by Oracle on 2014, 2015, 2017, 2019.
+// Modifications copyright (c) 2014-2019 Oracle and/or its affiliates.
 
 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -35,8 +35,9 @@
 #include <boost/geometry/algorithms/detail/overlay/overlay.hpp>
 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
 #include <boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp>
+#include <boost/geometry/algorithms/detail/overlay/segment_as_subrange.hpp>
 
-#include <boost/geometry/policies/robustness/robust_point_type.hpp>
+#include <boost/geometry/policies/robustness/rescale_policy_tags.hpp>
 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
 #include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
 
@@ -71,52 +72,32 @@ struct intersection_segment_segment_point
     >
     static inline OutputIterator apply(Segment1 const& segment1,
             Segment2 const& segment2,
-            RobustPolicy const& robust_policy,
+            RobustPolicy const& ,
             OutputIterator out,
             Strategy const& strategy)
     {
-        typedef typename point_type<PointOut>::type point_type;
-
-        typedef typename geometry::robust_point_type
-            <
-                typename geometry::point_type<Segment1>::type,
-                RobustPolicy
-            >::type robust_point_type;
+        // Make sure this is only called with no rescaling
+        BOOST_STATIC_ASSERT((boost::is_same
+           <
+               no_rescale_policy_tag,
+               typename rescale_policy_type<RobustPolicy>::type
+           >::value));
 
-        // TODO: rescale segment -> robust points
-        robust_point_type pi_rob, pj_rob, qi_rob, qj_rob;
-        {
-            // Workaround:
-            point_type pi, pj, qi, qj;
-            assign_point_from_index<0>(segment1, pi);
-            assign_point_from_index<1>(segment1, pj);
-            assign_point_from_index<0>(segment2, qi);
-            assign_point_from_index<1>(segment2, qj);
-            geometry::recalculate(pi_rob, pi, robust_policy);
-            geometry::recalculate(pj_rob, pj, robust_policy);
-            geometry::recalculate(qi_rob, qi, robust_policy);
-            geometry::recalculate(qj_rob, qj, robust_policy);
-        }
+        typedef typename point_type<PointOut>::type point_type;
 
         // Get the intersection point (or two points)
-        typedef segment_intersection_points
-                <
-                    point_type,
-                    typename segment_ratio_type
-                    <
-                        point_type, RobustPolicy
-                    >::type
-                > intersection_return_type;
+        typedef segment_intersection_points<point_type> intersection_return_type;
 
         typedef policies::relate::segments_intersection_points
             <
                 intersection_return_type
             > policy_type;
 
+        detail::segment_as_subrange<Segment1> sub_range1(segment1);
+        detail::segment_as_subrange<Segment2> sub_range2(segment2);
+
         intersection_return_type
-            is = strategy.apply(segment1, segment2,
-                                policy_type(), robust_policy,
-                                pi_rob, pj_rob, qi_rob, qj_rob);
+            is = strategy.apply(sub_range1, sub_range2, policy_type());
 
         for (std::size_t i = 0; i < is.count; i++)
         {
@@ -144,13 +125,14 @@ struct intersection_linestring_linestring_point
             OutputIterator out,
             Strategy const& strategy)
     {
-        typedef typename point_type<PointOut>::type point_type;
-
-        typedef detail::overlay::turn_info
-            <
-                point_type,
-                typename segment_ratio_type<point_type, RobustPolicy>::type
-            > turn_info;
+        // Make sure this is only called with no rescaling
+        BOOST_STATIC_ASSERT((boost::is_same
+           <
+               no_rescale_policy_tag,
+               typename rescale_policy_type<RobustPolicy>::type
+           >::value));
+
+        typedef detail::overlay::turn_info<PointOut> turn_info;
         std::deque<turn_info> turns;
 
         geometry::get_intersection_points(linestring1, linestring2,
@@ -408,6 +390,13 @@ struct intersection_of_linestring_with_areal
             OutputIterator out,
             Strategy const& strategy)
     {
+        // Make sure this is only called with no rescaling
+        BOOST_STATIC_ASSERT((boost::is_same
+           <
+               no_rescale_policy_tag,
+               typename rescale_policy_type<RobustPolicy>::type
+           >::value));
+
         if (boost::size(linestring) == 0)
         {
             return out;
@@ -423,21 +412,26 @@ struct intersection_of_linestring_with_areal
                 > follower;
 
         typedef typename point_type<LineStringOut>::type point_type;
+
+        typedef geometry::segment_ratio
+            <
+                typename coordinate_type<point_type>::type
+            > ratio_type;
+
 #ifdef BOOST_GEOMETRY_SETOPS_LA_OLD_BEHAVIOR
         typedef detail::overlay::traversal_turn_info
             <
-                point_type,
-                typename geometry::segment_ratio_type<point_type, RobustPolicy>::type
+                point_type, ratio_type
             > turn_info;
 #else
         typedef detail::overlay::turn_info
             <
                 point_type,
-                typename geometry::segment_ratio_type<point_type, RobustPolicy>::type,
+                ratio_type,
                 detail::overlay::turn_operation_linear
                     <
                         point_type,
-                        typename geometry::segment_ratio_type<point_type, RobustPolicy>::type
+                        ratio_type
                     >
             > turn_info;
 #endif
@@ -602,19 +596,23 @@ struct intersection_linear_areal_point
                                        OutputIterator out,
                                        Strategy const& strategy)
     {
-        typedef typename geometry::segment_ratio_type
-            <
-                PointOut, RobustPolicy
-            >::type segment_ratio_type;
+        // Make sure this is only called with no rescaling
+        BOOST_STATIC_ASSERT((boost::is_same
+           <
+               no_rescale_policy_tag,
+               typename rescale_policy_type<RobustPolicy>::type
+           >::value));
+
+        typedef geometry::segment_ratio<typename geometry::coordinate_type<PointOut>::type> ratio_type;
 
         typedef detail::overlay::turn_info
             <
                 PointOut,
-                segment_ratio_type,
+                ratio_type,
                 detail::overlay::turn_operation_linear
                     <
                         PointOut,
-                        segment_ratio_type
+                        ratio_type
                     >
             > turn_info;
 
@@ -1288,13 +1286,16 @@ inline OutputIterator intersection_insert(Geometry1 const& geometry1,
     concepts::check<Geometry1 const>();
     concepts::check<Geometry2 const>();
 
-    typedef typename geometry::rescale_policy_type
+    typedef typename geometry::rescale_overlay_policy_type
         <
-            typename geometry::point_type<Geometry1>::type // TODO from both
+            Geometry1,
+            Geometry2,
+            typename Strategy::cs_tag
         >::type rescale_policy_type;
 
     rescale_policy_type robust_policy
-            = geometry::get_rescale_policy<rescale_policy_type>(geometry1, geometry2);
+            = geometry::get_rescale_policy<rescale_policy_type>(
+                geometry1, geometry2, strategy);
 
     return detail::intersection::insert
         <