From 2a30c8ac0d1f05fd842113ef1a499afa9d40e376 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 28 Mar 2014 14:55:28 +0100 Subject: [PATCH] [geometry] Fixes after merge in get_turns - use of arrivals, compilation fixes in relate, use of fractions for sorting turns in relate --- .../overlay/get_turn_info_for_endpoint.hpp | 35 ++++++++++--------- .../algorithms/detail/overlay/get_turns.hpp | 2 +- .../algorithms/detail/relate/turns.hpp | 34 +++++++++--------- test/algorithms/overlay/test_get_turns.hpp | 4 +-- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp index efd8754e7..a25366e9c 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp @@ -210,6 +210,7 @@ struct get_turn_info_for_endpoint return result_ignore_ip0 || result_ignore_ip1; } + // TODO remove how_a and how_b template static inline void handle_segment(bool /*first_a*/, bool last_a, int how_a, int arrival_a, @@ -238,8 +239,8 @@ struct get_turn_info_for_endpoint { op0_a = operation_intersection; op0_b = operation_intersection; - op1_a = arrival_to_union_or_blocked(arrival_a, last_a); - op1_b = arrival_to_union_or_blocked(arrival_b, last_b); + op1_a = union_or_blocked_same_dirs(arrival_a, last_a); + op1_b = union_or_blocked_same_dirs(arrival_b, last_b); i0_a = equals::equals_point_point(pi, ip0); i0_b = equals::equals_point_point(qi, ip0); @@ -249,8 +250,8 @@ struct get_turn_info_for_endpoint else { op0_a = operation_intersection; - op0_b = arrival_to_union_or_blocked(arrival_b, last_b); - op1_a = arrival_to_union_or_blocked(arrival_a, last_a); + op0_b = union_or_blocked_same_dirs(arrival_b, last_b); + op1_a = union_or_blocked_same_dirs(arrival_a, last_a); op1_b = operation_intersection; i0_a = arrival_b != 1; @@ -262,29 +263,29 @@ struct get_turn_info_for_endpoint else { BOOST_ASSERT(ip_count == 1); - op0_a = arrival_to_union_or_blocked(arrival_a, last_a); - op0_b = arrival_to_union_or_blocked(arrival_b, last_b); + op0_a = union_or_blocked_same_dirs(arrival_a, last_a); + op0_b = union_or_blocked_same_dirs(arrival_b, last_b); - i0_a = how_a == -1; - i0_b = how_b == -1; + i0_a = arrival_a == -1; + i0_b = arrival_b == -1; j0_a = arrival_a == 0; j0_b = arrival_b == 0; } } else { - op0_a = how_to_union_or_blocked(how_a, last_a); - op0_b = how_to_union_or_blocked(how_b, last_b); + op0_a = union_or_blocked_different_dirs(arrival_a, last_a); + op0_b = union_or_blocked_different_dirs(arrival_b, last_b); - i0_a = how_a == -1; - i0_b = how_b == -1; - j0_a = how_a == 1; - j0_b = how_b == 1; + i0_a = arrival_a == -1; + i0_b = arrival_b == -1; + j0_a = arrival_a == 1; + j0_b = arrival_b == 1; } } // only if collinear (same_dirs) - static inline operation_type arrival_to_union_or_blocked(int arrival, bool is_last) + static inline operation_type union_or_blocked_same_dirs(int arrival, bool is_last) { if ( arrival == 1 ) return operation_blocked; @@ -296,9 +297,9 @@ struct get_turn_info_for_endpoint } // only if not collinear (!same_dirs) - static inline operation_type how_to_union_or_blocked(int how, bool is_last) + static inline operation_type union_or_blocked_different_dirs(int arrival, bool is_last) { - if ( how == 1 ) + if ( arrival == 1 ) //return operation_blocked; return is_last ? operation_blocked : operation_union; else diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 7e5a43ed5..b3462f28f 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -817,7 +817,7 @@ template ::type, typename TagBase2 = typename topological_tag_base::type> struct turn_operation_type { - typedef overlay::turn_operation type; + typedef overlay::turn_operation type; }; template diff --git a/include/boost/geometry/algorithms/detail/relate/turns.hpp b/include/boost/geometry/algorithms/detail/relate/turns.hpp index 10e101e16..26150e5c7 100644 --- a/include/boost/geometry/algorithms/detail/relate/turns.hpp +++ b/include/boost/geometry/algorithms/detail/relate/turns.hpp @@ -74,6 +74,19 @@ template > struct get_turns { + typedef typename geometry::point_type::type point1_type; + + typedef overlay::turn_info + < + point1_type, + typename segment_ratio_type::type, + enriched_turn_operation_linear + < + point1_type, + typename segment_ratio_type::type + > + > turn_info; + template static inline void apply(Turns & turns, Geometry1 const& geometry1, @@ -84,25 +97,14 @@ struct get_turns apply(turns, geometry1, geometry2, interrupt_policy); } - template + template static inline void apply(Turns & turns, Geometry1 const& geometry1, Geometry2 const& geometry2, - RobustPolicy const& , InterruptPolicy & interrupt_policy) { typedef typename geometry::point_type::type point1_type; - typedef overlay::turn_info - < - point1_type, - enriched_turn_operation_linear - < - point1_type, - typename segment_ratio_type::type - > - > turn_info; - static const bool reverse1 = detail::overlay::do_reverse::value>::value; static const bool reverse2 = detail::overlay::do_reverse::value>::value; @@ -200,12 +202,12 @@ struct less_seg_dist_op } template static inline - bool use_distance(Op const& left, Op const& right) + bool use_fraction(Op const& left, Op const& right) { - if ( geometry::math::equals(left.enriched.distance, right.enriched.distance) ) + if ( left.fraction == right.fraction ) return use_other_multi_ring_id(left, right); else - return left.enriched.distance < right.enriched.distance; + return left.fraction < right.fraction; } template @@ -214,7 +216,7 @@ struct less_seg_dist_op segment_identifier const& sl = left.operations[OpId].seg_id; segment_identifier const& sr = right.operations[OpId].seg_id; - return sl < sr || ( sl == sr && use_distance(left.operations[OpId], right.operations[OpId]) ); + return sl < sr || ( sl == sr && use_fraction(left.operations[OpId], right.operations[OpId]) ); } }; diff --git a/test/algorithms/overlay/test_get_turns.hpp b/test/algorithms/overlay/test_get_turns.hpp index 9a3737b9d..f5e72797d 100644 --- a/test/algorithms/overlay/test_get_turns.hpp +++ b/test/algorithms/overlay/test_get_turns.hpp @@ -164,8 +164,8 @@ struct expected_pusher typedef std::vector::iterator iterator; typedef std::vector::const_iterator const_iterator; - //iterator begin() { return vec.begin(); } - //iterator end() { return vec.end(); } + iterator begin() { return vec.begin(); } + iterator end() { return vec.end(); } const_iterator begin() const { return vec.begin(); } const_iterator end() const { return vec.end(); }