From 1b5ad071ff0e5534d04264965efc70b36a013052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 11:49:48 +0200 Subject: [PATCH 01/19] move function in right header --- .../include/CGAL/create_offset_polygons_2.h | 20 ++++++++++++++++++- ...ffset_polygons_from_polygon_with_holes_2.h | 17 ---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index 42ea8cadcf1..da5ff8c024d 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -389,7 +389,25 @@ create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk); } -// Overloads common to both polygons with and without holes, a simple polygon is returned in any case +/*! create_interior_skeleton_and_offset_polygons_2 with a polygon with holes */ + +// overload where PolygonWithHoles actually is a type of Polygon that supports holes +template::type> +std::vector > +inline +create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, + const PolygonWithHoles& aPoly, + const OfK& ofk, + const SsK& ssk, + typename std::enable_if< + CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) +{ + return create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); +} + + +// Overloads common to both polygons with and without holes, a simple polygons are returned in any case template::type> std::vector< boost::shared_ptr > diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h index ea9e3312316..eae8869e751 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h @@ -97,23 +97,6 @@ create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, //////////////////////////////////////////////////////////////////////////////////////////////////// /// EXTERIOR -/*! create_interior_skeleton_and_offset_polygons_2 with a polygon with holes */ - -// overload where PolygonWithHoles actually is a type of Polygon that supports holes -template::type> -std::vector > -inline -create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, - const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, - typename std::enable_if< - CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) -{ - return create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); -} - /*! create_exterior_skeleton_and_offset_polygons_with_holes_2 (orders the resulting polygons) */ // Polygon might be a Polygon with holes or not, but it returns a Polygon with holes From 034e5199b0f6e17000bd2d2fb037a60b1126e624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 11:50:20 +0200 Subject: [PATCH 02/19] remove leftover --- .../doc/Straight_skeleton_2/Straight_skeleton_2.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt b/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt index f795e14f2a3..e3c7c49fc68 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt @@ -441,7 +441,7 @@ On the other hand, only reflex vertices (whose internal angle \f$ > \pi\f$) are the source of deviations of the bisectors from its center location. Therefore, for convex polygons, the straight skeleton, the medial axis and the Voronoi diagram are exactly equivalent, -and, if a non-convex polygon contains only vertices of lowfor f in *.txt ; do echo $f ; aspell list < $f | sort | uniq -c ; done +and, if a non-convex polygon contains only vertices of low reflexivity, the straight skeleton bisectors will be placed nearly equidistant to their defining edges, producing a straight skeleton pretty much alike a proper medial axis. From 79693c56748510fb7dffaa1072ef889109fc57a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 13:07:06 +0200 Subject: [PATCH 03/19] add exterior offset parts of polygon with holes --- .../include/CGAL/create_offset_polygons_2.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index da5ff8c024d..0d84b27e3fc 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -403,7 +403,21 @@ create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, typename std::enable_if< CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) { - return create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); + std::vector > polygons = + create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); + + for (typename PolygonWithHoles::Hole_const_iterator hit=aPoly.holes_begin(); hit!=aPoly.holes_end(); ++hit) + { + typename PolygonWithHoles::Polygon_2 hole = *hit; + hole.reverse_orientation(); + std::vector > hole_polygons = + create_interior_skeleton_and_offset_polygons_2(aOffset, + hole, + ofk,ssk); + polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end()); + } + + return polygons; } From f6680b793f7d9a4ded579fb80157679c414ea6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 13:11:32 +0200 Subject: [PATCH 04/19] move function in right header --- .../include/CGAL/create_offset_polygons_2.h | 19 +++++++++++++++++++ ...ffset_polygons_from_polygon_with_holes_2.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index 0d84b27e3fc..c3f44f0276b 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -334,6 +334,25 @@ create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk, ssk); } +/*! create_interior_skeleton_and_offset_polygons_2 (no sorting of the result) */ + +// overload where PolygonWithHoles actually is a type of Polygon that supports holes +template::type> // Hole-less polygon type +std::vector > +inline +create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, + const PolygonWithHoles& aPoly, + const OfK& ofk, + const SsK& ssk, + typename std::enable_if< + CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) +{ + return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), + aPoly.holes_begin(), aPoly.holes_end(), + ofk, ssk); +} + // Overloads common to both polygons with and without holes, a simple polygon is returned in any case template::type> diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h index eae8869e751..139c7a17254 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h @@ -33,25 +33,6 @@ namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// /// INTERIOR -/*! create_interior_skeleton_and_offset_polygons_2 (no sorting of the result) */ - -// overload where PolygonWithHoles actually is a type of Polygon that supports holes -template::type> // Hole-less polygon type -std::vector > -inline -create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, - const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, - typename std::enable_if< - CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) -{ - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), - aPoly.holes_begin(), aPoly.holes_end(), - ofk, ssk); -} - /*! create_interior_skeleton_and_offset_polygons_with_holes_2 (orders the resulting polygons) */ // Polygon might be a Polygon with holes or not, but it returns a Polygon with holes From ccb0db385bbbe0ae4cdc8fc99f89d5fdf5b94852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 13:43:36 +0200 Subject: [PATCH 05/19] make create_exterior_skeleton_and_offset_polygons_with_holes_2 ignore the offset of the outer frame --- ...ffset_polygons_from_polygon_with_holes_2.h | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h index 139c7a17254..12f5e937513 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h @@ -90,8 +90,30 @@ create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, const OfK& ofk, const SsK& ssk) { - return arrange_offset_polygons_2( - create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk)); + typedef typename CGAL_SS_i::Default_return_polygon_type::type Polygon_; + std::vector > raw_output = + create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk); + + // filter offset of the outer frame + typename OfK::Point_2 xtrm_pt = *(raw_output[0]->begin()); + std::size_t outer_id=0; + for(std::size_t i=0; iorientation() == COUNTERCLOCKWISE) + { + for (const typename OfK::Point_2& p : raw_output[i]->container()) + if (p < xtrm_pt) + { + xtrm_pt=p; + outer_id=i; + } + } + if (outer_id != (raw_output.size()-1)) + std::swap(raw_output[outer_id], raw_output.back()); + raw_output.pop_back(); + for (boost::shared_ptr ptr : raw_output) + ptr->reverse_orientation(); + + return arrange_offset_polygons_2(raw_output); } template Date: Thu, 23 Jun 2022 13:59:41 +0200 Subject: [PATCH 06/19] update doc --- .../create_offset_polygons_from_polygon_with_holes_2.h | 8 ++++++-- .../doc/Straight_skeleton_2/Straight_skeleton_2.txt | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_from_polygon_with_holes_2.h index 780adf8dfbe..b2eea3ecf4b 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_from_polygon_with_holes_2.h @@ -38,9 +38,13 @@ create_interior_skeleton_and_offset_polygons_with_holes_2(FT offset, \ingroup PkgStraightSkeleton2OffsetFunctions returns a container with all the outer offset polygons with holes -at distance `offset` of the 2D polygon `poly_with_holes`. +at distance `offset` of the 2D polygon `poly_with_holes`. Note that the +offset of the outer frame is ignored. -This is equivalent to `arrange_offset_polygons_2(create_exterior_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))`. +This is equivalent to a call to `CGAL::arrange_offset_polygons_2()` on the +output of \link CGAL::create_exterior_skeleton_and_offset_polygons_2() `create_exterior_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))` \endlink +after having filtered out the polygon corresponding to the offset of the outer frame and +having reversed the orientation of all other polygons. \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt b/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt index e3c7c49fc68..30063a178b5 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/Straight_skeleton_2.txt @@ -422,11 +422,15 @@ This \cgal packages provides a helper function to compute the required separatio If you use this function to place the outer frame you are guaranteed to obtain an offset contour corresponding exclusively to the frame, which you can always identify as the one with the largest area and which you can simple remove from the result (to keep just the relevant outer contours). - \cgalFigureBegin{Exterior,exterior_skeleton.png,exterior_offset.png} Exterior skeleton obtained using a frame (left) and 2 sample exterior offset contours (right) \cgalFigureEnd +For convenience, the following functions are provided: + +- `CGAL::create_exterior_skeleton_and_offset_polygons_2()` adds the outer frame to the input polygon (with or without holes) and provides output offset polygons (`CGAL::Polygon_2`), including the offset of the outer frame. +- `CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2()` adds the outer frame to the input polygon (with or without holes) and provides as output offset polygons with holes (`CGAL::Polygon_with_holes_2`), exclusing the offset of the outer frame. + \section Straight_skeleton_2Straight Straight Skeletons, Medial Axis and Voronoi Diagrams The straight skeleton of a polygon is similar to the medial From 10fb4caaee5a65f178ab55cb2a1c6be93b5629b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 14:06:09 +0200 Subject: [PATCH 07/19] update changes --- Installation/CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 74c86d2e2bc..34eb44f4581 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -21,6 +21,11 @@ Release date: June 2022 See also the [announcement page](https://www.cgal.org/2022/05/18/alpha_wrap/). +### [2D Straight Skeleton and Polygon Offsetting (breaking change)](https://doc.cgal.org/5.5/Manual/packages.html#PkgStraightSkeleton2) +- Fix the output of the function [CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2()](https://doc.cgal.org/5.5/Straight_skeleton_2/group__PkgStraightSkeleton2OffsetFunctions.html#gaa159f093e5d6d7fdb62c1660a44f95fe) + to not take into account the offset of the outer frame. +- Fix the computation of the exterior offset of a polygon with holes that was not computing the offset of the holes + ### [3D Convex Hulls](https://doc.cgal.org/5.5/Manual/packages.html#PkgConvexHull3) - Added an [overload of the function `CGAL::convex_hull_3()`](https://doc.cgal.org/5.5/Convex_hull_3/group__PkgConvexHull3Functions.html#ga52fca4745c2ef0351063fbe66b035fd1), which writes the result in an indexed triangle set. From 86938310e6208695b98136e90d2501aa9b3ba495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 14:31:30 +0200 Subject: [PATCH 08/19] update testsuite --- .../Straight_skeleton_2/test_sls_offset.cpp | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp index 0bbfd140895..76ec40f8660 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp @@ -760,9 +760,8 @@ void test_offset_polygon_exterior() // print_polygon_with_holes(*offp); assert(offset_poly_with_holes.size() == 1); - assert(offset_poly_with_holes[0]->outer_boundary().size() == 4); - assert(offset_poly_with_holes[0]->number_of_holes() == 1); - assert(offset_poly_with_holes[0]->holes_begin()->size() == 12); + assert(offset_poly_with_holes[0]->outer_boundary().size() == 12); + assert(offset_poly_with_holes[0]->number_of_holes() == 0); // ----------------------------------------------------------------------------------------------- // Value such that it is clearly separated into two contours @@ -770,20 +769,19 @@ void test_offset_polygon_exterior() offset_poly_with_holes = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(7), poly, K(), EPICK()); -// for(const auto& offp : offset_poly_with_holes) -// print_polygon_with_holes(*offp); + // for(const auto& offp : offset_poly_with_holes) + // print_polygon_with_holes(*offp); - assert(offset_poly_with_holes.size() == 2); - assert(offset_poly_with_holes[0]->outer_boundary().size() == 4); + assert(offset_poly_with_holes.size() == 1); assert(offset_poly_with_holes[0]->number_of_holes() == 1); // Technically both polygons below should be rectangles, but the algorithm puts a 5th vertex collinear. // Tolerating it for now... - // assert(offset_poly_with_holes[0]->holes_begin()->size() == 4); - // assert(offset_poly_with_holes[1]->outer_boundary().size() == 4); + assert(offset_poly_with_holes[0]->holes_begin()->size() >= 4); + assert(offset_poly_with_holes[0]->outer_boundary().size() >= 4); assert(offset_poly_with_holes[0]->holes_begin()->is_simple()); - assert(offset_poly_with_holes[1]->outer_boundary().is_simple()); + assert(offset_poly_with_holes[0]->outer_boundary().is_simple()); // ----------------------------------------------------------------------------------------------- // Border value between a single contour and two contours @@ -795,17 +793,16 @@ void test_offset_polygon_exterior() // for(const auto& offp : offset_poly_with_holes) // print_polygon_with_holes(*offp); - assert(offset_poly_with_holes.size() == 2); - assert(offset_poly_with_holes[0]->outer_boundary().size() == 4); + assert(offset_poly_with_holes.size() >= 1); assert(offset_poly_with_holes[0]->number_of_holes() == 1); // Technically both polygons below should be rectangles, but the algorithm puts a 5th vertex collinear. // Tolerating it for now... - // assert(offset_poly_with_holes[0]->holes_begin()->size() == 4); - // assert(offset_poly_with_holes[1]->outer_boundary().size() == 4); + assert(offset_poly_with_holes[0]->holes_begin()->size() >= 4); + assert(offset_poly_with_holes[0]->outer_boundary().size() >= 4); assert(offset_poly_with_holes[0]->holes_begin()->is_simple()); - assert(offset_poly_with_holes[1]->outer_boundary().is_simple()); + assert(offset_poly_with_holes[0]->outer_boundary().is_simple()); } template From e7186992c736f491d9c30a134ff2344d70626bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 14:40:36 +0200 Subject: [PATCH 09/19] add a test for the exterior of a polygon with holes --- .../Straight_skeleton_2/test_sls_offset.cpp | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp index 76ec40f8660..ad14146a74b 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_offset.cpp @@ -805,6 +805,44 @@ void test_offset_polygon_exterior() assert(offset_poly_with_holes[0]->outer_boundary().is_simple()); } +template +void test_offset_polygon_with_holes_exterior() +{ + std::cout << " --- Test Polygon exterior, kernel: " << typeid(K).name() << std::endl; + + typedef typename K::Point_2 Point; + + typedef CGAL::Polygon_2 Polygon_2; + typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; + typedef boost::shared_ptr Polygon_with_holes_2_ptr; + typedef std::vector Polygon_with_holes_2_ptr_container; + + Polygon_2 outer ; + outer.push_back( Point( 10.0, 10.0) ) ; + outer.push_back( Point(-10.0, 10.0) ) ; + outer.push_back( Point(-10.0, -10.0) ) ; + outer.push_back( Point(10.0, -10.0) ) ; + + Polygon_2 hole ; + hole.push_back( Point(5.0,5.0) ) ; + hole.push_back( Point(5.0,-5.0) ) ; + hole.push_back( Point(-5.0,-5.0) ) ; + hole.push_back( Point(-5.0,5.0) ) ; + + Polygon_with_holes_2 pwh(outer) ; + pwh.add_hole( hole ) ; + + Polygon_with_holes_2_ptr_container offset_poly_with_holes_1 = + CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2(1., pwh, K(), EPICK()); + assert(offset_poly_with_holes_1.size()==1); + assert(offset_poly_with_holes_1[0]->number_of_holes()==1); + + Polygon_with_holes_2_ptr_container offset_poly_with_holes_2 = + CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2(5., pwh, K(), EPICK()); + assert(offset_poly_with_holes_2.size()==1); + assert(offset_poly_with_holes_2[0]->number_of_holes()==0); +} + template void test_offset(const char* filename) { @@ -937,6 +975,7 @@ void test_kernel() test_offset_non_manifold(); test_offset_non_manifold_2(); test_offset_polygon_exterior(); + test_offset_polygon_with_holes_exterior(); test_offset_multiple_CCs(); // Real data From d6888482fecaac44c11d20ae36a09cdb430393b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 15:54:27 +0200 Subject: [PATCH 10/19] add an example to compute the exterior offset of disjoint polygons with holes --- .../Straight_skeleton_2/CMakeLists.txt | 1 + ...offset_of_multiple_polygons_with_holes.cpp | 131 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt b/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt index 25c92ece93b..56b2fffadd5 100644 --- a/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/CMakeLists.txt @@ -15,6 +15,7 @@ endforeach() if(CGAL_Qt5_FOUND) target_link_libraries(draw_straight_skeleton_2 PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(exterior_offset_of_multiple_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer) else() message(STATUS "NOTICE: The example draw_straight_skeleton_2 requires Qt and will not be compiled.") endif() diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp b/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp new file mode 100644 index 00000000000..a190f3d98d0 --- /dev/null +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp @@ -0,0 +1,131 @@ +#include + +#include +#include + +#include + +#include + + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K ; + +typedef K::Point_2 Point ; +typedef CGAL::Polygon_2 Polygon ; +typedef CGAL::Polygon_with_holes_2 PolygonWithHoles ; + +typedef boost::shared_ptr PolygonWithHolesPtr ; +typedef boost::shared_ptr PolygonPtr ; + +typedef std::vector PolygonWithHolesPtrVector; +typedef std::vector PolygonPtrVector; + +PolygonWithHolesPtrVector +exterior_offset_of_disjoint_polygons_with_holes(double lOffset, const std::vector& pwhs) +{ + std::vector outer_vertices; + for (const PolygonWithHoles& pwh : pwhs) + outer_vertices.insert(outer_vertices.end(), + pwh.outer_boundary().container().begin(), + pwh.outer_boundary().container().end()); + boost::optional margin = compute_outer_frame_margin(outer_vertices.begin(), + outer_vertices.end(), + lOffset); + + if ( margin ) + { + double lm = CGAL::to_double(*margin); + CGAL::Bbox_2 bbox = bbox_2(outer_vertices.begin(), outer_vertices.end()); + + double fxmin = bbox.xmin() - lm ; + double fxmax = bbox.xmax() + lm ; + double fymin = bbox.ymin() - lm ; + double fymax = bbox.ymax() + lm ; + + Polygon frame ; + frame.push_back( Point(fxmin,fymin) ); + frame.push_back( Point(fxmax,fymin) ); + frame.push_back( Point(fxmax,fymax) ); + frame.push_back( Point(fxmin,fymax) ); + + std::vector outer_as_holes; + outer_as_holes.reserve(pwhs.size()); + for (const PolygonWithHoles& pwh : pwhs) + outer_as_holes.emplace_back(pwh.outer_boundary().container().rbegin(), + pwh.outer_boundary().container().rend()); + + PolygonWithHoles pwh(frame, outer_as_holes.begin(), outer_as_holes.end()); + PolygonPtrVector off_polys = CGAL::create_interior_skeleton_and_offset_polygons_2(lOffset,pwh); + + // filter outer frame + Point xtrm_pt = *(off_polys[0]->begin()); + std::size_t outer_id=0; + for(std::size_t i=0; iorientation() == CGAL::COUNTERCLOCKWISE) + { + for (const Point& p : off_polys[i]->container()) + if (p < xtrm_pt) + { + xtrm_pt=p; + outer_id=i; + } + } + if (outer_id != (off_polys.size()-1)) + std::swap(off_polys[outer_id], off_polys.back()); + off_polys.pop_back(); + for (PolygonPtr ptr : off_polys) + ptr->reverse_orientation(); + + // offset of holes + for (const PolygonWithHoles& pwh : pwhs) + { + for (PolygonWithHoles::Hole_const_iterator hit=pwh.holes_begin(); + hit!=pwh.holes_end(); + ++hit) + { + Polygon h = *hit; + h.reverse_orientation(); + PolygonPtrVector off_hole = CGAL::create_interior_skeleton_and_offset_polygons_2(lOffset,h); + off_polys.insert(off_polys.end(), off_hole.begin(), off_hole.end()); + } + } + + return CGAL::arrange_offset_polygons_2(off_polys); + } + + return PolygonWithHolesPtrVector(); +} + +int main() +{ + std::vector pwhs; + + for (int i=0; i<4; ++i) + { + Polygon outer; + outer.push_back( Point(i+0+i*10, 0) ); + outer.push_back( Point(i+0+(i+1)*10, 0) ); + outer.push_back( Point(i+0+(i+1)*10, 10) ); + outer.push_back( Point(i+0+i*10, 10) ); + pwhs.emplace_back(outer); + + Polygon hole; + hole.push_back( Point(i+3+i*10,3) ) ; + hole.push_back( Point(i+6+i*10,3) ) ; + hole.push_back( Point(i+6+i*10,6) ) ; + hole.push_back( Point(i+3+i*10,6) ) ; + pwhs[i].add_hole( hole ) ; + } + + double lOffset = 1.1 ; + + PolygonWithHolesPtrVector offset_poly_with_holes = exterior_offset_of_disjoint_polygons_with_holes(lOffset,pwhs); + + for (PolygonWithHolesPtr ptr : offset_poly_with_holes) + CGAL::draw(*ptr); + + return 0; +} From 6462cac12efc9fa312b1c12f26a8c05bc6caf90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 23 Jun 2022 16:29:11 +0200 Subject: [PATCH 11/19] move back functions \o^o/ --- .../include/CGAL/create_offset_polygons_2.h | 51 ------------------- ...ffset_polygons_from_polygon_with_holes_2.h | 50 ++++++++++++++++++ 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index c3f44f0276b..88ef7c68046 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -334,25 +334,6 @@ create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk, ssk); } -/*! create_interior_skeleton_and_offset_polygons_2 (no sorting of the result) */ - -// overload where PolygonWithHoles actually is a type of Polygon that supports holes -template::type> // Hole-less polygon type -std::vector > -inline -create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, - const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, - typename std::enable_if< - CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) -{ - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), - aPoly.holes_begin(), aPoly.holes_end(), - ofk, ssk); -} - // Overloads common to both polygons with and without holes, a simple polygon is returned in any case template::type> @@ -408,38 +389,6 @@ create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk); } -/*! create_interior_skeleton_and_offset_polygons_2 with a polygon with holes */ - -// overload where PolygonWithHoles actually is a type of Polygon that supports holes -template::type> -std::vector > -inline -create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, - const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, - typename std::enable_if< - CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) -{ - std::vector > polygons = - create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); - - for (typename PolygonWithHoles::Hole_const_iterator hit=aPoly.holes_begin(); hit!=aPoly.holes_end(); ++hit) - { - typename PolygonWithHoles::Polygon_2 hole = *hit; - hole.reverse_orientation(); - std::vector > hole_polygons = - create_interior_skeleton_and_offset_polygons_2(aOffset, - hole, - ofk,ssk); - polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end()); - } - - return polygons; -} - - // Overloads common to both polygons with and without holes, a simple polygons are returned in any case template::type> diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h index 12f5e937513..1e4cb324fff 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_from_polygon_with_holes_2.h @@ -33,6 +33,25 @@ namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// /// INTERIOR +/*! create_interior_skeleton_and_offset_polygons_2 (no sorting of the result) */ + +// overload where PolygonWithHoles actually is a type of Polygon that supports holes +template::type> // Hole-less polygon type +std::vector > +inline +create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, + const PolygonWithHoles& aPoly, + const OfK& ofk, + const SsK& ssk, + typename std::enable_if< + CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) +{ + return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), + aPoly.holes_begin(), aPoly.holes_end(), + ofk, ssk); +} + /*! create_interior_skeleton_and_offset_polygons_with_holes_2 (orders the resulting polygons) */ // Polygon might be a Polygon with holes or not, but it returns a Polygon with holes @@ -116,6 +135,37 @@ create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, return arrange_offset_polygons_2(raw_output); } +/*! create_interior_skeleton_and_offset_polygons_2 with a polygon with holes */ + +// overload where PolygonWithHoles actually is a type of Polygon that supports holes +template::type> +std::vector > +inline +create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, + const PolygonWithHoles& aPoly, + const OfK& ofk, + const SsK& ssk, + typename std::enable_if< + CGAL_SS_i::has_Hole_const_iterator::value>::type* = nullptr) +{ + std::vector > polygons = + create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); + + for (typename PolygonWithHoles::Hole_const_iterator hit=aPoly.holes_begin(); hit!=aPoly.holes_end(); ++hit) + { + typename PolygonWithHoles::Polygon_2 hole = *hit; + hole.reverse_orientation(); + std::vector > hole_polygons = + create_interior_skeleton_and_offset_polygons_2(aOffset, + hole, + ofk,ssk); + polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end()); + } + + return polygons; +} + template::type> std::vector > From 10903485c5a116c50d16438f371a19ae5d78de75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 30 Jun 2022 09:19:31 +0200 Subject: [PATCH 12/19] rename typedef --- ...rior_offset_of_multiple_polygons_with_holes.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp b/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp index a190f3d98d0..f6e0a86a931 100644 --- a/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/exterior_offset_of_multiple_polygons_with_holes.cpp @@ -14,11 +14,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K ; typedef K::Point_2 Point ; -typedef CGAL::Polygon_2 Polygon ; +typedef CGAL::Polygon_2 Polygon_2 ; typedef CGAL::Polygon_with_holes_2 PolygonWithHoles ; typedef boost::shared_ptr PolygonWithHolesPtr ; -typedef boost::shared_ptr PolygonPtr ; +typedef boost::shared_ptr PolygonPtr ; typedef std::vector PolygonWithHolesPtrVector; typedef std::vector PolygonPtrVector; @@ -45,13 +45,13 @@ exterior_offset_of_disjoint_polygons_with_holes(double lOffset, const std::vecto double fymin = bbox.ymin() - lm ; double fymax = bbox.ymax() + lm ; - Polygon frame ; + Polygon_2 frame ; frame.push_back( Point(fxmin,fymin) ); frame.push_back( Point(fxmax,fymin) ); frame.push_back( Point(fxmax,fymax) ); frame.push_back( Point(fxmin,fymax) ); - std::vector outer_as_holes; + std::vector outer_as_holes; outer_as_holes.reserve(pwhs.size()); for (const PolygonWithHoles& pwh : pwhs) outer_as_holes.emplace_back(pwh.outer_boundary().container().rbegin(), @@ -86,7 +86,7 @@ exterior_offset_of_disjoint_polygons_with_holes(double lOffset, const std::vecto hit!=pwh.holes_end(); ++hit) { - Polygon h = *hit; + Polygon_2 h = *hit; h.reverse_orientation(); PolygonPtrVector off_hole = CGAL::create_interior_skeleton_and_offset_polygons_2(lOffset,h); off_polys.insert(off_polys.end(), off_hole.begin(), off_hole.end()); @@ -105,14 +105,14 @@ int main() for (int i=0; i<4; ++i) { - Polygon outer; + Polygon_2 outer; outer.push_back( Point(i+0+i*10, 0) ); outer.push_back( Point(i+0+(i+1)*10, 0) ); outer.push_back( Point(i+0+(i+1)*10, 10) ); outer.push_back( Point(i+0+i*10, 10) ); pwhs.emplace_back(outer); - Polygon hole; + Polygon_2 hole; hole.push_back( Point(i+3+i*10,3) ) ; hole.push_back( Point(i+6+i*10,3) ) ; hole.push_back( Point(i+6+i*10,6) ) ; From c53ae08deb04e16844c3dd4c280d72cd21a90e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 30 Jun 2022 19:01:43 +0200 Subject: [PATCH 13/19] Spatial_searching: unsigned int -> size_t for vector copy --- Spatial_searching/include/CGAL/Kd_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spatial_searching/include/CGAL/Kd_tree.h b/Spatial_searching/include/CGAL/Kd_tree.h index 777a0dad29d..239d3a2b290 100644 --- a/Spatial_searching/include/CGAL/Kd_tree.h +++ b/Spatial_searching/include/CGAL/Kd_tree.h @@ -330,7 +330,7 @@ public: dim_ = static_cast(std::distance(ccci(p), ccci(p,0))); data.reserve(pts.size()); - for(unsigned int i = 0; i < pts.size(); i++){ + for(std::size_t i = 0; i < pts.size(); i++){ data.push_back(&pts[i]); } From a691eeff9741f814b2dcaa381ad7465eaee5a17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 23 Jun 2022 17:11:20 +0200 Subject: [PATCH 14/19] Rewrite merge_duplicate_points_in_polygon_soup() without container.insert(...) --- .../repair_polygon_soup.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index fdc57bf0c05..c609dc2415a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -604,22 +604,31 @@ Polygon construct_canonical_polygon_with_markers(const Polygon& polygon, const bool reversed) { const std::size_t polygon_size = polygon.size(); + Polygon canonical_polygon; + CGAL::internal::resize(canonical_polygon, polygon_size); if(reversed) { - std::size_t rfirst = polygon_size - 1 - first; - canonical_polygon.insert(canonical_polygon.end(), polygon.rbegin() + rfirst, polygon.rend()); - canonical_polygon.insert(canonical_polygon.end(), polygon.rbegin(), polygon.rbegin() + rfirst); + std::size_t rfirst = first + 1; + std::size_t pos = 0; + for(std::size_t i=rfirst; i --> 0 ;) // first to 0 + canonical_polygon[pos++] = polygon[i]; + for(std::size_t i=polygon_size; i --> rfirst ;) // polygon_size-1 to first+1 + canonical_polygon[pos++] = polygon[i]; } else { - canonical_polygon.insert(canonical_polygon.end(), polygon.begin() + first, polygon.end()); - canonical_polygon.insert(canonical_polygon.end(), polygon.begin(), polygon.begin() + first); + std::size_t pos = 0; + for(std::size_t i=first; i Date: Thu, 23 Jun 2022 17:12:34 +0200 Subject: [PATCH 15/19] Add an overload of repair_polygon_soup for array-based soups which does not call functions that are meaningless for ranges of fixed size faces --- .../repair_polygon_soup.h | 79 +++++++++++++++---- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index c609dc2415a..8fb8cca46af 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -990,6 +991,66 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(const PointRange& points, return removed_polygons_n; } +template ::Polygon_3> +struct Polygon_soup_fixer +{ + template + void operator()(PointRange& points, + PolygonRange& polygons, + const NamedParameters& np) const + { + using parameters::get_parameter; + using parameters::choose_parameter; + + typedef typename internal::GetPolygonGeomTraits::type Traits; + Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + + #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE + std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " polygons" << std::endl; + #endif + + merge_duplicate_points_in_polygon_soup(points, polygons, np); + internal::simplify_polygons_in_polygon_soup(points, polygons, traits); + internal::split_pinched_polygons_in_polygon_soup(points, polygons, traits); + internal::remove_invalid_polygons_in_polygon_soup(points, polygons); + merge_duplicate_polygons_in_polygon_soup(points, polygons, np); + remove_isolated_points_in_polygon_soup(points, polygons); + } +}; + +// Specialization if the polygon soup is an array +// Disable repair functions that are meaningless for arrays +template +struct Polygon_soup_fixer > +{ + template + void operator()(PointRange& points, + PolygonRange& polygons, + const NamedParameters& np) const + { + using parameters::get_parameter; + using parameters::choose_parameter; + + typedef typename internal::GetPolygonGeomTraits::type Traits; + Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + + #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE + std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " polygons" << std::endl; + #endif + + merge_duplicate_points_in_polygon_soup(points, polygons, np); + +// internal::simplify_polygons_in_polygon_soup(points, polygons, traits); +// internal::split_pinched_polygons_in_polygon_soup(points, polygons, traits); + + internal::remove_invalid_polygons_in_polygon_soup(points, polygons); + merge_duplicate_polygons_in_polygon_soup(points, polygons, np); + remove_isolated_points_in_polygon_soup(points, polygons); + } +}; + + /// \ingroup PMP_repairing_grp /// /// \brief cleans a given polygon soup through various repairing operations. @@ -1053,22 +1114,8 @@ void repair_polygon_soup(PointRange& points, PolygonRange& polygons, const NamedParameters& np = parameters::default_values()) { - using parameters::get_parameter; - using parameters::choose_parameter; - - typedef typename internal::GetPolygonGeomTraits::type Traits; - Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - -#ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE - std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " polygons" << std::endl; -#endif - - merge_duplicate_points_in_polygon_soup(points, polygons, np); - internal::simplify_polygons_in_polygon_soup(points, polygons, traits); - internal::split_pinched_polygons_in_polygon_soup(points, polygons, traits); - internal::remove_invalid_polygons_in_polygon_soup(points, polygons); - merge_duplicate_polygons_in_polygon_soup(points, polygons, np); - remove_isolated_points_in_polygon_soup(points, polygons); + Polygon_soup_fixer fixer; + fixer(points, polygons, np); } } // end namespace Polygon_mesh_processing From d934a0465fe00eb5c9584421aa2b88c24beb6285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 23 Jun 2022 17:13:29 +0200 Subject: [PATCH 16/19] Test range of array faces in repair_polygon_soup() --- .../test_repair_polygon_soup.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp index 68ca3351965..4b9b0abbd3e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp @@ -564,6 +564,21 @@ void test_slit_pinched_polygons(const bool /*verbose*/ = false) int main() { + // test compilation with different polygon soup types + std::vector vpoints; + std::vector > vpolygons; + PMP::repair_polygon_soup(vpoints, vpolygons); + + std::vector > dpolygons; + PMP::repair_polygon_soup(vpoints, dpolygons); + + std::deque > dvpolygons; + PMP::repair_polygon_soup(vpoints, dvpolygons); + + std::deque > apolygons; + PMP::repair_polygon_soup(vpoints, apolygons); + + // test functions test_polygon_canonicalization(true); test_merge_duplicate_points(false); test_merge_duplicate_polygons(false); From 3be846927781361ace4e4981db6362a137ae7701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 23 Jun 2022 17:23:09 +0200 Subject: [PATCH 17/19] Move build into 'internal' namespace --- .../repair_polygon_soup.h | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index 8fb8cca46af..a90a70f60d5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -991,8 +991,10 @@ std::size_t merge_duplicate_polygons_in_polygon_soup(const PointRange& points, return removed_polygons_n; } +namespace internal { + template ::Polygon_3> + typename Polygon = typename Polygon_types::Polygon_3> struct Polygon_soup_fixer { template @@ -1003,7 +1005,7 @@ struct Polygon_soup_fixer using parameters::get_parameter; using parameters::choose_parameter; - typedef typename internal::GetPolygonGeomTraits::type Traits; + typedef typename GetPolygonGeomTraits::type Traits; Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE @@ -1011,9 +1013,9 @@ struct Polygon_soup_fixer #endif merge_duplicate_points_in_polygon_soup(points, polygons, np); - internal::simplify_polygons_in_polygon_soup(points, polygons, traits); - internal::split_pinched_polygons_in_polygon_soup(points, polygons, traits); - internal::remove_invalid_polygons_in_polygon_soup(points, polygons); + simplify_polygons_in_polygon_soup(points, polygons, traits); + split_pinched_polygons_in_polygon_soup(points, polygons, traits); + remove_invalid_polygons_in_polygon_soup(points, polygons); merge_duplicate_polygons_in_polygon_soup(points, polygons, np); remove_isolated_points_in_polygon_soup(points, polygons); } @@ -1032,24 +1034,23 @@ struct Polygon_soup_fixer > using parameters::get_parameter; using parameters::choose_parameter; - typedef typename internal::GetPolygonGeomTraits::type Traits; + typedef typename GetPolygonGeomTraits::type Traits; Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE - std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " polygons" << std::endl; + std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " arrays" << std::endl; #endif merge_duplicate_points_in_polygon_soup(points, polygons, np); - -// internal::simplify_polygons_in_polygon_soup(points, polygons, traits); -// internal::split_pinched_polygons_in_polygon_soup(points, polygons, traits); - - internal::remove_invalid_polygons_in_polygon_soup(points, polygons); +// simplify_polygons_in_polygon_soup(points, polygons, traits); +// split_pinched_polygons_in_polygon_soup(points, polygons, traits); + remove_invalid_polygons_in_polygon_soup(points, polygons); merge_duplicate_polygons_in_polygon_soup(points, polygons, np); remove_isolated_points_in_polygon_soup(points, polygons); } }; +} // namespace internal /// \ingroup PMP_repairing_grp /// @@ -1114,7 +1115,7 @@ void repair_polygon_soup(PointRange& points, PolygonRange& polygons, const NamedParameters& np = parameters::default_values()) { - Polygon_soup_fixer fixer; + internal::Polygon_soup_fixer fixer; fixer(points, polygons, np); } From ceb8ca70ef0b045f50827cab91dd91229ce00eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 5 Jul 2022 14:03:38 +0200 Subject: [PATCH 18/19] fix warning --- .../include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index a90a70f60d5..4c4019bd68c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -1035,7 +1035,7 @@ struct Polygon_soup_fixer > using parameters::choose_parameter; typedef typename GetPolygonGeomTraits::type Traits; - Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); +// Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " arrays" << std::endl; From b25217ed5334edd7643c349454b8ca50e78fa93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 7 Jul 2022 13:42:37 +0200 Subject: [PATCH 19/19] remove unused typedef --- .../CGAL/Polygon_mesh_processing/repair_polygon_soup.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h index 4c4019bd68c..219a4925c24 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h @@ -1031,17 +1031,12 @@ struct Polygon_soup_fixer > PolygonRange& polygons, const NamedParameters& np) const { - using parameters::get_parameter; - using parameters::choose_parameter; - - typedef typename GetPolygonGeomTraits::type Traits; -// Traits traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - #ifdef CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE std::cout << "Repairing soup with " << points.size() << " points and " << polygons.size() << " arrays" << std::endl; #endif merge_duplicate_points_in_polygon_soup(points, polygons, np); +// skipped steps: // simplify_polygons_in_polygon_soup(points, polygons, traits); // split_pinched_polygons_in_polygon_soup(points, polygons, traits); remove_invalid_polygons_in_polygon_soup(points, polygons);