From c8c67472b0f19ce312d7966dec7f6207c9545bef Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 16 Apr 2024 10:28:19 +0100 Subject: [PATCH] Add Mpwh::bbox() --- Polygon/include/CGAL/Multipolygon_with_holes_2.h | 10 ++++++++++ Polygon/test/Polygon/Multipolygon_with_holes_test.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Polygon/include/CGAL/Multipolygon_with_holes_2.h b/Polygon/include/CGAL/Multipolygon_with_holes_2.h index 39ebd29dff32..8636626d1a9f 100644 --- a/Polygon/include/CGAL/Multipolygon_with_holes_2.h +++ b/Polygon/include/CGAL/Multipolygon_with_holes_2.h @@ -101,6 +101,16 @@ class Multipolygon_with_holes_2 { Size number_of_polygons_with_holes() const { return static_cast(m_polygons.size()); } + Bbox_2 bbox() const + { + Bbox_2 bb; + for(const auto& pwh : polygons_with_holes()){ + bb += pwh.bbox(); + } + return bb; + } + + 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 1257db73f903..7592211bd436 100644 --- a/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp +++ b/Polygon/test/Polygon/Multipolygon_with_holes_test.cpp @@ -45,5 +45,7 @@ int main() std::cout << mp << std::endl; + CGAL::Bbox_2 bb = mp.bbox(); + return 0; }