diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index a8cd52195eb..c4ce7a51d6d 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -121,6 +121,7 @@ extracted from labeled images. ### [2D Minkowski Sums](https://doc.cgal.org/5.6/Manual/packages.html#PkgMinkowskiSum2) - Fixed a bug that made holes in the Minkowski sum disappear +- Fixed hole filtering. The code used to erroneously remove holes from the container of holes of polygons with holes that did not affect the minkowsi sum. Now it simply adds those that do affect it. [Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5) ----------- diff --git a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h index cfb2cedde6f..8248045f598 100644 --- a/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h +++ b/Minkowski_sum_2/include/CGAL/Minkowski_sum_2/Hole_filter_2.h @@ -26,16 +26,12 @@ namespace CGAL { * to the Minkowski sum boundary. */ template -class Hole_filter_2 -{ +class Hole_filter_2 { private: - typedef Kernel_ Kernel; - typedef Container_ Container; - - typedef CGAL::Polygon_2 Polygon_2; - typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; - typedef typename Polygon_with_holes_2::Hole_iterator Hole_iterator; - typedef std::vector Hole_iterator_vector; + using Kernel = Kernel_; + using Container = Container_; + using Polygon_2 = CGAL::Polygon_2; + using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2; public: /*! Filter out holes of a polygon with holes. @@ -45,29 +41,17 @@ public: */ void operator()(const Polygon_with_holes_2& pgn1, const Polygon_2& pgn2, - Polygon_with_holes_2& filtered_pgn1) const - { - filtered_pgn1 = pgn1; - - Hole_iterator_vector to_erase; + Polygon_with_holes_2& filtered_pgn1) const { Bbox_2 boundary_bbox = pgn2.bbox(); - - Hole_iterator it = filtered_pgn1.holes_begin(); - while (it != filtered_pgn1.holes_end()) { - Bbox_2 hole_bbox = (*it).bbox(); - - if ((hole_bbox.ymax()-hole_bbox.ymin() < - boundary_bbox.ymax()-boundary_bbox.ymin()) || - (hole_bbox.xmax()-hole_bbox.xmin() < + filtered_pgn1 = Polygon_with_holes_2(pgn1.outer_boundary()); + for (const auto& h : pgn1.holes()) { + Bbox_2 hole_bbox = h.bbox(); + if ((hole_bbox.ymax()-hole_bbox.ymin() >= + boundary_bbox.ymax()-boundary_bbox.ymin()) && + (hole_bbox.xmax()-hole_bbox.xmin() >= boundary_bbox.xmax()-boundary_bbox.xmin())) - { - to_erase.push_back(it); - } - ++it; + filtered_pgn1.add_hole(h); } - - typename Hole_iterator_vector::iterator it2 = to_erase.begin(); - while (it2 != to_erase.end()) filtered_pgn1.erase_hole(*it2++); } /*! Filter out holes of a polygon with holes.