diff options
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/get_turns.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/overlay/get_turns.hpp | 80 |
1 files changed, 25 insertions, 55 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/boost/geometry/algorithms/detail/overlay/get_turns.hpp index a96538c43a..a5d8f3f023 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -54,6 +54,7 @@ #include <boost/geometry/algorithms/detail/interior_iterator.hpp> #include <boost/geometry/algorithms/detail/partition.hpp> #include <boost/geometry/algorithms/detail/recalculate.hpp> +#include <boost/geometry/algorithms/detail/sections/section_box_policies.hpp> #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp> #include <boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp> @@ -62,8 +63,7 @@ #include <boost/geometry/algorithms/detail/sections/range_by_section.hpp> #include <boost/geometry/algorithms/detail/sections/sectionalize.hpp> - -#include <boost/geometry/algorithms/expand.hpp> +#include <boost/geometry/algorithms/detail/sections/section_functions.hpp> #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION # include <sstream> @@ -229,7 +229,7 @@ public : // section 2: [--------------] // section 1: |----|---|---|---|---| for (prev1 = it1++, next1++; - it1 != end1 && ! exceeding<0>(dir1, *prev1, sec2.bounding_box, robust_policy); + it1 != end1 && ! detail::section::exceeding<0>(dir1, *prev1, sec2.bounding_box, robust_policy); ++prev1, ++it1, ++index1, ++next1, ++ndi1) { ever_circling_iterator<range1_iterator> nd_next1( @@ -247,7 +247,7 @@ public : next2++; for (prev2 = it2++, next2++; - it2 != end2 && ! exceeding<0>(dir2, *prev2, sec1.bounding_box, robust_policy); + it2 != end2 && ! detail::section::exceeding<0>(dir2, *prev2, sec1.bounding_box, robust_policy); ++prev2, ++it2, ++index2, ++next2, ++ndi2) { bool skip = same_source; @@ -299,8 +299,8 @@ public : if (InterruptPolicy::enabled) { if (interrupt_policy.apply( - std::make_pair(boost::begin(turns) + size_before, - boost::end(turns)))) + std::make_pair(range::pos(turns, size_before), + boost::end(turns)))) { return false; } @@ -318,25 +318,6 @@ private : typedef typename model::referring_segment<point1_type const> segment1_type; typedef typename model::referring_segment<point2_type const> segment2_type; - - template <size_t Dim, typename Point, typename Box, typename RobustPolicy> - static inline bool preceding(int dir, Point const& point, Box const& box, RobustPolicy const& robust_policy) - { - typename robust_point_type<Point, RobustPolicy>::type robust_point; - geometry::recalculate(robust_point, point, robust_policy); - return (dir == 1 && get<Dim>(robust_point) < get<min_corner, Dim>(box)) - || (dir == -1 && get<Dim>(robust_point) > get<max_corner, Dim>(box)); - } - - template <size_t Dim, typename Point, typename Box, typename RobustPolicy> - static inline bool exceeding(int dir, Point const& point, Box const& box, RobustPolicy const& robust_policy) - { - typename robust_point_type<Point, RobustPolicy>::type robust_point; - geometry::recalculate(robust_point, point, robust_policy); - return (dir == 1 && get<Dim>(robust_point) > get<max_corner, Dim>(box)) - || (dir == -1 && get<Dim>(robust_point) < get<min_corner, Dim>(box)); - } - template <typename Iterator, typename RangeIterator, typename Section, typename RobustPolicy> static inline void advance_to_non_duplicate_next(Iterator& next, RangeIterator const& it, Section const& section, RobustPolicy const& robust_policy) @@ -387,7 +368,7 @@ private : // Mimic section-iterator: // Skip to point such that section interects other box prev = it++; - for(; it != end && preceding<0>(dir, *it, other_bounding_box, robust_policy); + for(; it != end && detail::section::preceding<0>(dir, *it, other_bounding_box, robust_policy); prev = it++, index++, ndi++) {} // Go back one step because we want to start completely preceding @@ -395,24 +376,6 @@ private : } }; -struct get_section_box -{ - template <typename Box, typename InputItem> - static inline void apply(Box& total, InputItem const& item) - { - geometry::expand(total, item.bounding_box); - } -}; - -struct ovelaps_section_box -{ - template <typename Box, typename InputItem> - static inline bool apply(Box const& box, InputItem const& item) - { - return ! detail::disjoint::disjoint_box_box(box, item.bounding_box); - } -}; - template < typename Geometry1, typename Geometry2, @@ -496,12 +459,15 @@ public: point_type, RobustPolicy >::type > box_type; - typedef typename geometry::sections<box_type, 2> sections_type; + typedef geometry::sections<box_type, 2> sections_type; sections_type sec1, sec2; + typedef boost::mpl::vector_c<std::size_t, 0, 1> dimensions; - geometry::sectionalize<Reverse1>(geometry1, robust_policy, true, sec1, 0); - geometry::sectionalize<Reverse2>(geometry2, robust_policy, true, sec2, 1); + geometry::sectionalize<Reverse1, dimensions>(geometry1, robust_policy, + sec1, 0); + geometry::sectionalize<Reverse2, dimensions>(geometry2, robust_policy, + sec2, 1); // ... and then partition them, intersecting overlapping sections in visitor method section_visitor @@ -513,7 +479,9 @@ public: geometry::partition < - box_type, get_section_box, ovelaps_section_box + box_type, + detail::section::get_section_box, + detail::section::overlaps_section_box >::apply(sec1, sec2, visitor); } }; @@ -556,7 +524,8 @@ struct get_turns_cs RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy, - int multi_index = -1, int ring_index = -1) + signed_index_type multi_index = -1, + signed_index_type ring_index = -1) { if ( boost::size(range) <= 1) { @@ -569,7 +538,8 @@ struct get_turns_cs cview_type cview(range); view_type view(cview); - typename boost::range_size<view_type>::type segments_count1 = boost::size(view) - 1; + typedef typename boost::range_size<view_type>::type size_type; + size_type segments_count1 = boost::size(view) - 1; iterator_type it = boost::begin(view); @@ -582,7 +552,7 @@ struct get_turns_cs //char previous_side[2] = {0, 0}; - int index = 0; + signed_index_type index = 0; for (iterator_type prev = it++; it != boost::end(view); @@ -621,7 +591,7 @@ struct get_turns_cs bp[0], bp[1], bp[2], bp[3], // NOTE: some dummy values could be passed below since this would be called only for Polygons and Boxes index == 0, - unsigned(index) == segments_count1, + size_type(index) == segments_count1, robust_policy, turns, interrupt_policy); // Future performance enhancement: @@ -726,7 +696,7 @@ struct get_turns_polygon_cs int source_id2, Box const& box, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy, - int multi_index = -1) + signed_index_type multi_index = -1) { typedef typename geometry::ring_type<Polygon>::type ring_type; @@ -744,7 +714,7 @@ struct get_turns_polygon_cs turns, interrupt_policy, multi_index, -1); - int i = 0; + signed_index_type i = 0; typename interior_return_type<Polygon const>::type rings = interior_rings(polygon); @@ -783,7 +753,7 @@ struct get_turns_multi_polygon_cs Multi const >::type iterator_type; - int i = 0; + signed_index_type i = 0; for (iterator_type it = boost::begin(multi); it != boost::end(multi); ++it, ++i) |