From 29c6a7905f579e4d34d79bcaeb36bb8016f00b0c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 19 Apr 2024 08:10:46 +0100 Subject: [PATCH] Add is_empty() --- Polygon/include/CGAL/General_polygon_with_holes_2.h | 13 +++++++++++++ Polygon/include/CGAL/Multipolygon_with_holes_2.h | 9 +++++++++ .../test/Polygon/Multipolygon_with_holes_test.cpp | 1 + Polygon_repair/include/CGAL/Polygon_repair/repair.h | 1 - 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Polygon/include/CGAL/General_polygon_with_holes_2.h b/Polygon/include/CGAL/General_polygon_with_holes_2.h index bb19fcf9943..1e47948076e 100644 --- a/Polygon/include/CGAL/General_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/General_polygon_with_holes_2.h @@ -123,6 +123,19 @@ public: bool is_plane() const { return (m_pgn.is_empty() && m_holes.empty()); } + bool is_empty() const + { + if(! outer_boundary().is_empty()) { + return false; + } + for(const auto& h : holes()){ + if(! h.is_empty()){ + return false; + } + } + return true; + } + protected: Polygon_2 m_pgn; Holes_container m_holes; diff --git a/Polygon/include/CGAL/Multipolygon_with_holes_2.h b/Polygon/include/CGAL/Multipolygon_with_holes_2.h index 79e515a2b78..6cbf3551e67 100644 --- a/Polygon/include/CGAL/Multipolygon_with_holes_2.h +++ b/Polygon/include/CGAL/Multipolygon_with_holes_2.h @@ -111,6 +111,15 @@ public: return bb; } + bool is_empty() const + { + for(const auto& pwh : polygons_with_holes()){ + if(! pwh.is_empty()){ + return false; + } + } + return true; + } protected: Polygon_with_holes_container m_polygons; diff --git a/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp b/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp index 49584c7b011..18ddb1b7f45 100644 --- a/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp +++ b/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp @@ -47,5 +47,6 @@ int main() CGAL::Bbox_2 bb = mp.bbox(); std::cout << bb << std::endl; + assert(! mp.is_empty()); return 0; } diff --git a/Polygon_repair/include/CGAL/Polygon_repair/repair.h b/Polygon_repair/include/CGAL/Polygon_repair/repair.h index 8f420a478d8..f6f2e84cfee 100644 --- a/Polygon_repair/include/CGAL/Polygon_repair/repair.h +++ b/Polygon_repair/include/CGAL/Polygon_repair/repair.h @@ -314,7 +314,6 @@ public: using Face_circulator = typename Triangulation::Face_circulator; using Edge = typename Triangulation::Edge; - // TODO: Edge_map and Vertex_map use std::set and std::map with exact kernels since Point_2 can't be hashed otherwise using Edge_map = typename std::conditional::value, std::unordered_set, boost::hash>>,