From 9298ac2a2cc5f72d10313af954e09a77886b40fd Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 17 Sep 2014 16:30:03 +0200 Subject: [PATCH] [buffer] fix intersection points on border, equal points should not be checked and correct order in call to side strategy This fixes case rt_u10 --- .../detail/buffer/turn_in_piece_visitor.hpp | 17 ++++++++++++----- test/algorithms/buffer/multi_polygon_buffer.cpp | 4 +--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index 97463cacd..1f2513a00 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -95,18 +96,24 @@ class turn_in_piece_visitor < typename cs_tag::type >::type side_strategy; + geometry::equal_to comparator; for (int i = 1; i < piece.offsetted_count; i++) { Point const& previous = piece.robust_ring[i - 1]; Point const& current = piece.robust_ring[i]; - int const side = side_strategy::apply(point, previous, current); - if (side == 0) + + // The robust ring contains duplicates, avoid applying side on them (will be 0) + if (! comparator(previous, current)) { - // Collinear, check if projection falls on it - if (projection_on_segment(point, previous, current)) + int const side = side_strategy::apply(previous, current, point); + if (side == 0) { - return true; + // Collinear, check if projection falls on it + if (projection_on_segment(point, previous, current)) + { + return true; + } } } } diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index 9cecc6290..c75ea82bf 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -373,9 +373,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); -#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) - test_one("rt_u10", rt_u10, join_miter, end_flat, 999, 1.0); -#endif + test_one("rt_u10", rt_u10, join_miter, end_flat, 144.0858, 1.0); } int test_main(int, char* [])