diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index b8e17b357..bd2552193 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -27,9 +27,9 @@ #include #include -#include #include #include +#include #ifdef BOOST_GEOMETRY_DEBUG_ENRICH # include #endif @@ -152,12 +152,26 @@ private : { robust_point_type pi, pj, ri, rj, si, sj; get_situation_map(left, right, pi, pj, ri, rj, si, sj); - int const order = get_relative_order + + typedef typename strategy::side::services::default_strategy < - robust_point_type - >::apply(pi, pj, ri, rj, si, sj); - //debug("r/o", order == -1); - return order == -1; + typename cs_tag::type + >::type strategy; + int const side_rj_p = strategy::apply(pi, pj, rj); + int const side_sj_p = strategy::apply(pi, pj, sj); + + // Put the one turning left (1; right == -1) as last + if (side_rj_p != side_sj_p) + { + return side_rj_p < side_sj_p; + } + + int const side_sj_r = strategy::apply(ri, rj, sj); + int const side_rj_s = strategy::apply(si, sj, rj); + + // If they both turn left: the most left as last + // If they both turn right: this is not relevant, but take also here most left + return side_rj_s < side_sj_r; } public : @@ -176,9 +190,6 @@ public : { // First check "real" intersection (crosses) // -> distance zero due to precision, solve it by sorting - // TODO: reconsider this. Using integer maths, this will - // ALWAYS return 0 because either fractions are different, or - // the (currently calculated) relative-order is identical if (m_turn_points[left.turn_index].method == method_crosses && m_turn_points[right.turn_index].method == method_crosses) { diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index c86c75a6a..90b5c40b7 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -236,7 +236,6 @@ static std::string const rt_u6 // For this case (and more), get_left_turns or using a more specific sort order is essential static std::string const rt_u7 = "MULTIPOLYGON(((4 5,4 6,5 5,4 5)),((9 2,9 3,10 3,10 2,9 2)),((7 3,7 4,8 4,8 3,7 3)),((5 5,6 6,6 5,5 5)),((3 6,4 7,4 6,3 6)),((0 5,0 6,1 5,0 5)))"; - // = "MULTIPOLYGON(((4 5,4 6,5 5,4 5)),((9 2,9 3,10 3,10 2,9 2)),((7 3,7 4,8 4,8 3,7 3)),((5 5,6 6,6 5,5 5)),((3 6,4 7,4 6,3 6)))"; //removing the leftmost uninvolved polygon solves somehow the problem... template void test_all() @@ -246,6 +245,7 @@ void test_all() bg::strategy::buffer::join_miter join_miter; bg::strategy::buffer::join_round join_round(100); + bg::strategy::buffer::join_round join_round_rough(12); bg::strategy::buffer::end_flat end_flat; test_one("triangles424", triangles, join_miter, end_flat, 417.910, 4.24); @@ -353,12 +353,10 @@ void test_all() test_one("rt_u4", rt_u4, join_round, end_flat, 126.9268, 1.0); test_one("rt_u5", rt_u5, join_round, end_flat, 78.4906, 1.0); test_one("rt_u6", rt_u6, join_round, end_flat, 115.4461, 1.0); -#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) - { - bg::strategy::buffer::join_round join_round_rough(12); // temporary - test_one("rt_u7", rt_u7, join_round_rough, end_flat, 999, 1.0); - } -#endif + + test_one("rt_u7", rt_u7, join_round, end_flat, 35.6233, 1.0); + test_one("rt_u7", rt_u7, join_miter, end_flat, 42.6421, 1.0); + test_one("rt_u7_rough", rt_u7, join_round_rough, end_flat, 35.0483, 1.0); } int test_main(int, char* [])