From 15c674d5c91a985f3bb1cbf970f590ca113ccae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 14 Feb 2023 14:59:10 +0100 Subject: [PATCH] Move helper classes to SLS_aux.h --- .../Straight_skeleton_2/Polygon_iterators.h | 6 +- .../Straight_skeleton_aux.h | 65 +++++++++++++++++++ .../include/CGAL/create_offset_polygons_2.h | 61 +---------------- .../CGAL/create_weighted_offset_polygons_2.h | 4 +- 4 files changed, 70 insertions(+), 66 deletions(-) diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Polygon_iterators.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Polygon_iterators.h index 09b8caec5bc..01328936363 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Polygon_iterators.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Polygon_iterators.h @@ -13,7 +13,8 @@ #include -#include +#include + #include #include @@ -21,9 +22,6 @@ namespace CGAL { namespace CGAL_SS_i { -// to distinguish between SequenceContainers of points, and GeneralPolygonWithHoles_2 -BOOST_MPL_HAS_XXX_TRAIT_DEF(Hole_const_iterator) - // Polygon_2-type container template inline typename Poly::const_iterator diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h index 8a2ad91ab86..05e220c3968 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/Straight_skeleton_aux.h @@ -17,6 +17,9 @@ #include #include +#include + +#include #include #include #include @@ -171,6 +174,68 @@ private: Handle mE[3]; } ; +template +struct Is_same_type { typedef Tag_false type ; } ; + +template +struct Is_same_type { typedef Tag_true type ; } ; + +// to distinguish between SequenceContainers of points, and GeneralPolygonWithHoles_2 +BOOST_MPL_HAS_XXX_TRAIT_DEF(Hole_const_iterator) + +// The return type of create_(weighted)_interior/exterior_skeleton_and_offset_polygons_2: +// - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type +// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::Polygon_2 +// - if polygon input is just a sequence container of points (e.g. Polygon_2), then the same type +// is expected in output +template ::value> +struct Default_return_polygon_type // Polygon type supports holes +{ + typedef typename std::conditional::type>::Kernel, + OfK>::value, + typename Polygon::Polygon_2, // correct kernel + CGAL::Polygon_2 /*incorrect kernel*/ >::type type; +}; + +template +struct Default_return_polygon_type // Polygon type does NOT support holes +{ + typedef typename std::conditional::type>::Kernel, + OfK>::value, + Polygon, // correct kernel + CGAL::Polygon_2 /*incorrect kernel*/ >::type type; +}; + +// The return type of create_interior/exterior_skeleton_and_offset_polygons_with_holes_2: +// - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type should be the same +// - if polygon input is just a sequence container of points (e.g. Polygon_2), then use +// General_polygon_with_holes_2 +template ::value> +struct Default_return_polygon_with_holes_type // Polygon type supports holes +{ + typedef typename std::conditional::type>::Kernel, + OfK>::value, + Polygon, // correct kernel + CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; +}; + +template +struct Default_return_polygon_with_holes_type // Polygon type does NOT support holes +{ + // Maybe on paper the `conditional` should be `General_polygon_with_holes_2`... + typedef typename std::conditional::type>::Kernel, + OfK>::value, + CGAL::Polygon_with_holes_2, // correct kernel but no holes + CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; +}; } // namespace CGAL_SS_i 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 20c5c85ab42..3903767cf07 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -14,6 +14,7 @@ #include +#include #include #include #include @@ -42,66 +43,6 @@ namespace CGAL { namespace CGAL_SS_i { -template -struct Is_same_type { typedef Tag_false type ; } ; - -template -struct Is_same_type { typedef Tag_true type ; } ; - -// The return type of create_interior/exterior_skeleton_and_offset_polygons_2: -// - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type -// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::Polygon_2 -// - if polygon input is just a sequence container of points (e.g. Polygon_2), then the same type -// is expected in output -template ::value> -struct Default_return_polygon_type // Polygon type supports holes -{ - typedef typename std::conditional::type>::Kernel, - OfK>::value, - typename Polygon::Polygon_2, // correct kernel - CGAL::Polygon_2 /*incorrect kernel*/ >::type type; -}; - -template -struct Default_return_polygon_type // Polygon type does NOT support holes -{ - typedef typename std::conditional::type>::Kernel, - OfK>::value, - Polygon, // correct kernel - CGAL::Polygon_2 /*incorrect kernel*/ >::type type; -}; - -// The return type of create_interior/exterior_skeleton_and_offset_polygons_with_holes_2: -// - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type should be the same -// - if polygon input is just a sequence container of points (e.g. Polygon_2), then use -// General_polygon_with_holes_2 -template ::value> -struct Default_return_polygon_with_holes_type // Polygon type supports holes -{ - typedef typename std::conditional::type>::Kernel, - OfK>::value, - Polygon, // correct kernel - CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; -}; - -template -struct Default_return_polygon_with_holes_type // Polygon type does NOT support holes -{ - // Maybe on paper the `conditional` should be `General_polygon_with_holes_2`... - typedef typename std::conditional::type>::Kernel, - OfK>::value, - CGAL::Polygon_with_holes_2, // correct kernel but no holes - CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; -}; - template boost::shared_ptr< Straight_skeleton_2 > create_partial_interior_straight_skeleton_2 ( FT const& aMaxTime diff --git a/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_2.h index 007766940d9..fe5d369186e 100644 --- a/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_2.h @@ -14,8 +14,8 @@ #include -#include -#include +#include +#include #include #include #include