From dbc45fac53d0c5d1473d2b4766b29a6ae6690c85 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Tue, 27 Nov 2018 16:32:07 +0200 Subject: [PATCH 1/2] Fixed face filtering in case one of the summands does not have an outer boundary --- .../AABB_collision_detector_2.h | 32 +++++++++++++------ .../Minkowski_sum_by_reduced_convolution_2.h | 9 +++--- .../test/Minkowski_sum_2/data/pwh10.dat | 3 ++ .../test/Minkowski_sum_2/data/pwh11.dat | 3 ++ .../test/Minkowski_sum_2/data/pwh12.dat | 10 ++++++ .../test/Minkowski_sum_2/data/pwh9.dat | 3 ++ .../test_minkowski_sum_with_holes.cmd | 6 ++++ 7 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 Minkowski_sum_2/test/Minkowski_sum_2/data/pwh10.dat create mode 100644 Minkowski_sum_2/test/Minkowski_sum_2/data/pwh11.dat create mode 100644 Minkowski_sum_2/test/Minkowski_sum_2/data/pwh12.dat create mode 100644 Minkowski_sum_2/test/Minkowski_sum_2/data/pwh9.dat diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h index ce242327a99..07237a6828b 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/AABB_collision_detector_2.h @@ -83,22 +83,34 @@ public: // If t_q is inside of P, or t_p is inside of Q, one polygon is completely // inside of the other. - Point_2 t_q = *m_q.outer_boundary().vertices_begin() - Vector_2(ORIGIN, t); - Point_2 t_p = *m_p.outer_boundary().vertices_begin() + Vector_2(ORIGIN, t); + + // Obtain a point on the boundary of m_q: + Point_2 t_q = (! m_q.outer_boundary().is_empty()) ? + *m_q.outer_boundary().vertices_begin() - Vector_2(ORIGIN, t) : + *m_q.holes_begin()->vertices_begin() - Vector_2(ORIGIN, t); + + // Obtain a point on the boundary of m_p: + Point_2 t_p = (! m_p.outer_boundary().is_empty()) ? + *m_p.outer_boundary().vertices_begin() + Vector_2(ORIGIN, t) : + *m_p.holes_begin()->vertices_begin() + Vector_2(ORIGIN, t); // Use bounded_side_2() instead of on_bounded_side() because the latter // checks vor simplicity every time. - bool in_mp = - bounded_side_2(m_p.outer_boundary().vertices_begin(), - m_p.outer_boundary().vertices_end(), t_q, - m_p.outer_boundary().traits_member()) == ON_BOUNDED_SIDE; + bool in_mp(true); + if (! m_p.outer_boundary().is_empty()) + in_mp = + bounded_side_2(m_p.outer_boundary().vertices_begin(), + m_p.outer_boundary().vertices_end(), t_q, + m_p.outer_boundary().traits_member()) == ON_BOUNDED_SIDE; if (m_p.number_of_holes() == 0) { if (in_mp) return true; } - bool in_mq = - bounded_side_2(m_q.outer_boundary().vertices_begin(), - m_q.outer_boundary().vertices_end(), t_p, - m_q.outer_boundary().traits_member()) == ON_BOUNDED_SIDE; + bool in_mq(true); + if (! m_q.outer_boundary().is_empty()) + in_mq = + bounded_side_2(m_q.outer_boundary().vertices_begin(), + m_q.outer_boundary().vertices_end(), t_p, + m_q.outer_boundary().traits_member()) == ON_BOUNDED_SIDE; if (m_q.number_of_holes() == 0) { if (in_mq) return true; } diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h index ef37f9d9336..0dfe977b2ee 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Minkowski_sum_by_reduced_convolution_2.h @@ -169,6 +169,9 @@ private: for (Face_iterator fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { // Check whether the face is on the M-sum's border. + // The unbounded face cannot contribute to the Minkowski sum + if (fit->is_unbounded()) continue; + // If the face contains holes, it can't be on the Minkowski sum's border if (0 < fit->number_of_holes()) continue; @@ -177,10 +180,8 @@ private: // When the reversed polygon 1, translated by a point inside of this face, // collides with polygon 2, this cannot be a hole - if (! is_outer_boundary_empty) { - Point_2 inner_point = get_point_in_face(fit); - if (collision_detector.check_collision(inner_point)) continue; - } + Point_2 inner_point = get_point_in_face(fit); + if (collision_detector.check_collision(inner_point)) continue; add_face(fit, holes); } diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh10.dat b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh10.dat new file mode 100644 index 00000000000..f483926d047 --- /dev/null +++ b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh10.dat @@ -0,0 +1,3 @@ +8 +0 0 40 0 40 30 30 30 30 60 10 60 10 30 0 30 +0 diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh11.dat b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh11.dat new file mode 100644 index 00000000000..9e9300123ec --- /dev/null +++ b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh11.dat @@ -0,0 +1,3 @@ +0 +1 +4 0 40 50 40 50 0 0 0 diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh12.dat b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh12.dat new file mode 100644 index 00000000000..b27a3197cbf --- /dev/null +++ b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh12.dat @@ -0,0 +1,10 @@ +8 + 0 0 +40 0 +40 30 +30 30 +30 40 +10 40 +10 30 + 0 30 +0 diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh9.dat b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh9.dat new file mode 100644 index 00000000000..3997e4a2e0a --- /dev/null +++ b/Minkowski_sum_2/test/Minkowski_sum_2/data/pwh9.dat @@ -0,0 +1,3 @@ +0 +1 +4 0 40 50 60 50 0 0 0 diff --git a/Minkowski_sum_2/test/Minkowski_sum_2/test_minkowski_sum_with_holes.cmd b/Minkowski_sum_2/test/Minkowski_sum_2/test_minkowski_sum_with_holes.cmd index 864824fd88e..c1c27446dea 100644 --- a/Minkowski_sum_2/test/Minkowski_sum_2/test_minkowski_sum_with_holes.cmd +++ b/Minkowski_sum_2/test/Minkowski_sum_2/test_minkowski_sum_with_holes.cmd @@ -14,3 +14,9 @@ data/pwh7.dat data/pwh6.dat data/pwh2.dat data/pwh8.dat data/pwh8.dat data/pwh2.dat data/pwh8.dat data/pwh8.dat +data/pwh9.dat data/pwh10.dat +data/pwh10.dat data/pwh9.dat +data/pwh11.dat data/pwh10.dat +data/pwh10.dat data/pwh11.dat +data/pwh9.dat data/pwh12.dat +data/pwh12.dat data/pwh9.dat From 0ff6b941cb485745dc00d5f88782dcc6d1fc7249 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 28 Nov 2018 13:06:40 +0200 Subject: [PATCH 2/2] Added a note about a fix to the minkowski_sum_2() function in the 2D Minkowski sum package --- Installation/CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 672d71541a4..1bd7272394c 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -54,6 +54,12 @@ Release date: March 2019 `Arr_polyline_traits_2`, `Arr_polycurve_traits_2`, and `Arr_polycurve_basic_traits_2`. +### 2D Minkowski Sums + +- Fixed a bug in the function that computed the Minkowski sum using the + reduced-convolution method. In particular, correctly handled the case where + one of the summands does not have an outer boundaey. + Release 4.13 ------------