From e97bbb4da1b6bc61b3bfaf5bd15f592946ee08bd Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Thu, 12 Nov 2015 19:46:29 +0100 Subject: [PATCH] [overlay] fix cases where IP is not at endpoint. This fixes the last union/buffer cases with less_by_segment_ratio instead of handle_tangencies --- .../detail/overlay/less_by_segment_ratio.hpp | 43 ++++++++++--------- .../buffer/buffer_multi_polygon.cpp | 6 --- .../set_operations/union/union_multi.cpp | 2 - 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp b/include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp index 085797874..29d9ab208 100644 --- a/include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp @@ -140,38 +140,37 @@ private : inline int union_code(Indexed const& left, Indexed const& right) const { typedef typename boost::range_value::type turn_type; + typedef typename turn_type::turn_operation_type turn_op_type; + turn_type const& left_turn = m_turn_points[left.turn_index]; turn_type const& right_turn = m_turn_points[right.turn_index]; - segment_identifier const left_id = left_turn.operations[left.operation_index].seg_id; - segment_identifier const right_id = right_turn.operations[right.operation_index].seg_id; - segment_identifier const left_other_id = left_turn.operations[1 - left.operation_index].seg_id; - segment_identifier const right_other_id = right_turn.operations[1 - right.operation_index].seg_id; + turn_op_type const& left_op = left_turn.operations[left.operation_index]; + turn_op_type const& right_op = right_turn.operations[right.operation_index]; + turn_op_type const& left_other_op = left_turn.operations[1 - left.operation_index]; + turn_op_type const& right_other_op = right_turn.operations[1 - right.operation_index]; // Check, otherwise it would have been sorted on left/right segid - BOOST_ASSERT(left_id == right_id); + BOOST_ASSERT(left_op.seg_id == right_op.seg_id); point_type p_both1, p_both2, p_both3; point_type p_left_o1, p_left_o2, p_left_o3; point_type p_right_o1, p_right_o2, p_right_o3; - geometry::copy_segment_points(m_geometry1, m_geometry2, left_id, p_both1, p_both2, p_both3); - geometry::copy_segment_points(m_geometry1, m_geometry2, left_other_id, p_left_o1, p_left_o2, p_left_o3); - geometry::copy_segment_points(m_geometry1, m_geometry2, right_other_id, p_right_o1, p_right_o2, p_right_o3); + geometry::copy_segment_points(m_geometry1, m_geometry2, left_op.seg_id, p_both1, p_both2, p_both3); + geometry::copy_segment_points(m_geometry1, m_geometry2, left_other_op.seg_id, p_left_o1, p_left_o2, p_left_o3); + geometry::copy_segment_points(m_geometry1, m_geometry2, right_other_op.seg_id, p_right_o1, p_right_o2, p_right_o3); // If the operation is union, get the two union-operations - operation_type const left_op = left_turn.operations[left.operation_index].operation; - operation_type const left_other_op = left_turn.operations[1 - left.operation_index].operation; - operation_type const right_op = right_turn.operations[right.operation_index].operation; - operation_type const right_other_op = right_turn.operations[1 - right.operation_index].operation; - point_type p_lhs; - if (left_op == operation_union && left_other_op != operation_union) + if (left_op.operation == operation_union + && left_other_op.operation != operation_union) { - p_lhs = p_both3; + p_lhs = left_op.fraction.is_one() ? p_both3 : p_both2; } - else if (left_other_op == operation_union && left_op != operation_union) + else if (left_other_op.operation == operation_union + && left_op.operation != operation_union) { - p_lhs = p_left_o3; + p_lhs = left_other_op.fraction.is_one() ? p_left_o3 : p_left_o2; } else { @@ -179,13 +178,15 @@ private : } point_type p_rhs; - if (right_op == operation_union && right_other_op != operation_union) + if (right_op.operation == operation_union + && right_other_op.operation != operation_union) { - p_rhs = p_both3; + p_rhs = right_op.fraction.is_one() ? p_both3 : p_both2; } - else if (right_other_op == operation_union && right_op != operation_union) + else if (right_other_op.operation == operation_union + && right_op.operation != operation_union) { - p_rhs = p_right_o3; + p_rhs = right_other_op.fraction.is_one() ? p_right_o3 : p_right_o2; } else { diff --git a/test/algorithms/buffer/buffer_multi_polygon.cpp b/test/algorithms/buffer/buffer_multi_polygon.cpp index 0e225331a..32c579b83 100644 --- a/test/algorithms/buffer/buffer_multi_polygon.cpp +++ b/test/algorithms/buffer/buffer_multi_polygon.cpp @@ -324,11 +324,7 @@ void test_all() test_one("wrapped_05", wrapped, join_round, end_flat, 104.570, 0.5); test_one("wrapped_05", wrapped, join_miter, end_flat, 105.000, 0.5); test_one("wrapped_10", wrapped, join_round, end_flat, 142.281, 1.0); - -#ifdef BOOST_GEOMETRY_TEST_FAIL_TANGENCIES test_one("wrapped_10", wrapped, join_miter, end_flat, 144.000, 1.0); -#endif - test_one("wrapped_15", wrapped, join_round, end_flat, 167.066, 1.5); test_one("wrapped_15", wrapped, join_miter, end_flat, 169.000, 1.5); @@ -480,9 +476,7 @@ void test_all() test_one("rt_u8", rt_u8, join_miter, end_flat, 70.9142, 1.0); test_one("rt_u9", rt_u9, join_miter, end_flat, 59.3063, 1.0); test_one("rt_u10", rt_u10, join_miter, end_flat, 144.0858, 1.0); -#ifdef BOOST_GEOMETRY_TEST_FAIL_TANGENCIES test_one("rt_u10_50", rt_u10, join_miter, end_flat, 0.2145, -0.50); -#endif test_one("rt_u10_25", rt_u10, join_miter, end_flat, 9.6682, -0.25); test_one("rt_u11", rt_u11, join_miter, end_flat, 131.3995, 1.0); diff --git a/test/algorithms/set_operations/union/union_multi.cpp b/test/algorithms/set_operations/union/union_multi.cpp index 4169e7d27..31c7fe1b8 100644 --- a/test/algorithms/set_operations/union/union_multi.cpp +++ b/test/algorithms/set_operations/union/union_multi.cpp @@ -127,12 +127,10 @@ void test_areal() case_recursive_boxes_5[0], case_recursive_boxes_5[1], 3, 2, 110, 70.0); -#ifdef BOOST_GEOMETRY_TEST_FAIL_TANGENCIES // TODO: fix self touching interior ring (should get 3 interior rings) test_one("case_recursive_boxes_6", case_recursive_boxes_6[0], case_recursive_boxes_6[1], 1, 2, 25, 24.0); -#endif test_one("ggl_list_20120915_h2_a", ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],