diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/Straight_skeleton_builder_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/Straight_skeleton_builder_2.h index dc4ec8c2d48d..1331edf5f388 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/Straight_skeleton_builder_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/Straight_skeleton_builder_2.h @@ -190,7 +190,7 @@ Straight_skeleton_builder_2& enter_contour( InputPointIterator aBegin, InputPoin /*! defines the weights of the contour last entered through `enter_contour()`. -\tparam InputPointIterator must be a model `InputIterator` whose `value_type` is `FT`. +\tparam WeightIterator must be a model `InputIterator` whose `value_type` is `FT`. \pre `std::distance(aBegin,aEnd)` must be equal to the number of vertices of the contour last entered. \pre Weights are (strictly) positive. diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_2.h index 551215202ae7..e51856028e39 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_offset_polygons_2.h @@ -9,11 +9,11 @@ If `ss` is the interior skeleton of a polygon with holes, the offset polygons wi in its interior. If `ss` is the outer skeleton of a polygon with holes, the offset polygons will be generated in its exterior. -\tparam OfK must be a model of `Kernel`. It is used to instantiate - `Polygon_offset_builder_traits_2` for constructing the offset polygons. +\tparam OfKPolygon is a polygon without holes type determined from `OfK`, see Section \ref SLSOffsetPolygonReturnType. \tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT`. \tparam StraightSkeleton is an object of type `CGAL::Straight_skeleton_2`. -\tparam OfKPolygon is a polygon without holes type determined from `OfK`, see Section \ref SLSOffsetPolygonReturnType. +\tparam OfK must be a model of `Kernel`. It is used to instantiate + `Polygon_offset_builder_traits_2` for constructing the offset polygons. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -44,16 +44,16 @@ The construction of this skeleton is the most expensive operation, therefore, to at more than one single distance, it is advised to use `create_interior_straight_skeleton_2()` to create the skeleton only once, and then call `create_offset_polygons_2()` for each distance. -\tparam OfK must be a model of `Kernel`. It is used to instantiate - `Polygon_offset_builder_traits_2` for constructing the offset polygons. -\tparam SsK must be a model of `Kernel`. It is used to instantiate - `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. +\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. \tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. \tparam HoleIterator must be a model of `InputIterator` with value type being a model of `ConstRange` with value type `SsK::Point_2`. \tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`). -\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. +\tparam OfK must be a model of `Kernel`. It is used to instantiate + `Polygon_offset_builder_traits_2` for constructing the offset polygons. +\tparam SsK must be a model of `Kernel`. It is used to instantiate + `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -84,20 +84,20 @@ The construction of this skeleton is the most expensive operation, therefore, to at more than one single distance, it is advised to use `create_interior_straight_skeleton_2()` to create the skeleton only once, and then call `create_offset_polygons_2()` for each distance +\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. \pre `offset` is positive -\pre poly` is weakly simple, counterclockwise polygon. +\pre `poly` is weakly simple, counterclockwise polygon. \sa `CGAL::create_exterior_skeleton_and_offset_polygons_2()` \sa `CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2()` @@ -125,20 +125,20 @@ to obtain the offsets. The construction of this skeleton is the most expensive o therefore, to construct offsets at more than one single distance, use the separate functions `create_exterior_straight_skeleton_2()` and `create_offset_polygons_2()` instead. +\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. \pre `offset` is positive -\pre poly` is weakly simple, counterclockwise polygon. +\pre `poly` is weakly simple, counterclockwise polygon. \sa `CGAL::create_interior_skeleton_and_offset_polygons_2()` \sa `CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2()` 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 839612ff6f39..e4aff14d810d 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 @@ -8,15 +8,16 @@ of the 2D polygon with holes `poly_with_holes`. This is equivalent to `arrange_offset_polygons_2(create_interior_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))`. +\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. + \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -42,19 +43,19 @@ at distance `offset` of the 2D polygon `poly_with_holes`. Note that the offset of the outer frame is ignored. 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 +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 OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_2.h index e08f4d7b1d29..cdc19eb8ffb6 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_2.h @@ -20,19 +20,19 @@ The construction of this skeleton is the most expensive operation, therefore, to at more than one single distance, it is advised to use the separate functions `create_interior_straight_skeleton_2()` and `create_offset_polygons_2()` instead. -\tparam OfK must be a model of `Kernel`. It is used to instantiate - `Polygon_offset_builder_traits_2` for constructing the offset polygons. -\tparam SsK must be a model of `Kernel`. It is used to instantiate - `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. +\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. \tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. \tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`). -\tparam InKWeights must be a model of `Range` with value type `InK::FT`. \tparam HoleIterator must be a model of `InputIterator` with value type being a model of `ConstRange` with value type `SsK::Point_2`. -\tparam HoleWeightsIterator must be a model of `InputIterator` with value type being a model of `ConstRange` +\tparam InKWeights must be a model of `SequenceContainer` whose value type is `InK::FT`. +\tparam HoleWeightsIterator must be a model of `InputIterator` with value type being a model of `SequenceContainer` with value type `InK::FT`. -\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. +\tparam OfK must be a model of `Kernel`. It is used to instantiate + `Polygon_offset_builder_traits_2` for constructing the offset polygons. +\tparam SsK must be a model of `Kernel`. It is used to instantiate + `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -45,9 +45,9 @@ template > create_interior_weighted_skeleton_and_offset_polygons_2(FT offset, const InKPolygon& outer_boundary, - const InKWeights& outer_boundary_weights, HoleIterator holes_begin, HoleIterator holes_end, + const InKWeights& outer_boundary_weights, HoleWeightsIterator holes_weights_begin, HoleWeightsIterator holes_weights_end, OfK ofk = CGAL::Exact_predicates_inexact_constructions_kernel, @@ -66,16 +66,16 @@ The construction of this skeleton is the most expensive operation, therefore, to at more than one single distance, use the separate functions `create_interior_straight_skeleton_2()` and `create_offset_polygons_2()` instead. +\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam InKWeights must be a model of `Range` with value type `InK::FT`. -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -109,21 +109,21 @@ to obtain the offsets. The construction of this skeleton is the most expensive o therefore, to construct offsets at more than one single distance, use the separate functions `create_exterior_straight_skeleton_2()` and `create_offset_polygons_2()` instead. +\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam InKWeights must be a model of `Range` with value type `InK::FT`. -\tparam OfKPolygon is a polygon without holes type determined from `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2`. \pre `offset` is positive -\pre poly` is weakly simple, counterclockwise polygon. +\pre `poly` is weakly simple, counterclockwise polygon. \sa `CGAL::create_interior_skeleton_and_offset_polygons_2()` \sa `CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2()` diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h index e2f4f1096481..7e05b15bc406 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h @@ -1,22 +1,23 @@ namespace CGAL { /*! -\ingroup PkgStraightSkeleton2OffsetFunctions +\ingroup PkgStraightSkeleton2WeightedOffsetFunctions \brief returns a container with all the inner offset polygons with holes at distance `offset` of the 2D polygon with holes `poly_with_holes`. This is equivalent to `arrange_offset_polygons_2(create_interior_weighted_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))`. +\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the weighted straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed weighted straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -35,26 +36,27 @@ create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT offset, // ---------------------------------------------- EXTERIOR ----------------------------------------- /*! -\ingroup PkgStraightSkeleton2OffsetFunctions +\ingroup PkgStraightSkeleton2WeightedOffsetFunctions \brief returns a container with all the outer offset polygons 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 a call to `CGAL::arrange_offset_polygons_2()` on the -output of \link CGAL::create_exterior_weighted_skeleton_and_offset_polygons_2() `create_exterior_weighted_skeleton_and_offset_polygons_2(offset, poly_with_holes, ofk, ssk))` \endlink +output of \link CGAL::create_exterior_weighted_skeleton_and_offset_polygons_2() `create_exterior_weighted_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 OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, + see Section \ref SLSOffsetPolygonReturnType. +\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. +\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) + or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \tparam OfK must be a model of `Kernel`. It is used to instantiate `Polygon_offset_builder_traits_2` for constructing the offset polygons. \tparam SsK must be a model of `Kernel`. It is used to instantiate `Straight_skeleton_builder_traits_2` for constructing the straight skeleton. -\tparam FT must be a model of `FieldNumberType` convertible to `OfK::FT` and `SsK::FT`. -\tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) - or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam OfKPolygon is a polygon without holes type determined by `OfK` and `InKPolygon`, - see Section \ref SLSOffsetPolygonReturnType. \note If `SsK != OfK` the constructed weighted straight skeleton is converted to `CGAL::Straight_skeleton_2`. @@ -65,7 +67,9 @@ having reversed the orientation of all other polygons. template std::vector > create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT offset, - const InKPolygon& poly_with_holes, + const InKPolygon& + poly_with_holes, + const InKWeights& weights, OfK ofk = Exact_predicates_inexact_constructions_kernel(), SsK ssk = Exact_predicates_inexact_constructions_kernel()); diff --git a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_straight_skeleton_2.h b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_straight_skeleton_2.h index f036609721fc..aeb39576705d 100644 --- a/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_straight_skeleton_2.h +++ b/Straight_skeleton_2/doc/Straight_skeleton_2/CGAL/create_weighted_straight_skeleton_2.h @@ -87,14 +87,14 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice \brief creates a weighted straight skeleton in the interior of a 2D polygon, possibly with holes. -Range of weights `weights` must be provided in the same order as the contours (i.e., first +Weights must be provided in the same order as the contours (i.e., first the weights of the outer boundary, and then the weights of the holes, if there are any). Within each range of weights, the weights must be given in the same order as the vertices of the contour: the `i`-th weight in the range is associated to the contour edge between the `i-1`-th and `i`-th vertices. \tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`), or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam InKWeights must be a model of `Range` whose value type is itself a model of `Range` with value type `InK::FT`. +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \tparam SsK must be a model of `Kernel`. \note `Cartesian_converter` and `NT_converter` are used to convert objects from `InK` to `SsK`, @@ -177,7 +177,7 @@ is associated to the contour edge between the `i-1`-th and `i`-th vertices. \tparam FT must be a model of `FieldNumberType` convertible to `SsK::FT`. \tparam InKPolygon must be a model of `SequenceContainer` with value type `InK::Point_2` (e.g. `Polygon_2`) or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2`). -\tparam InKWeights must be a model of `Range` whose value type is itself a model of `Range` with value type `InK::FT`. +\tparam InKWeights must be a model of `SequenceContainer` whose value type is itself a model of `SequenceContainer` with value type `InK::FT`. \note `Cartesian_converter` and `NT_converter` are used to convert objects from `InK` to `SsK`, if they differ. 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 30b1e25de59a..102f4552a085 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,8 @@ #include #include +#include +#include #include #include @@ -193,8 +195,8 @@ struct Default_return_polygon_type // Polygon type supports holes typename Kernel_traits::type>::Kernel, OfK>::value, - typename Polygon::Polygon_2, // correct kernel - CGAL::Polygon_2 /*incorrect kernel*/ >::type type; + typename Polygon::Polygon_2, // same kernel + CGAL::Polygon_2 /*different kernel*/ >::type type; }; template @@ -203,10 +205,14 @@ struct Default_return_polygon_type // Polygon type does NOT typedef typename std::conditional::type>::Kernel, OfK>::value, - Polygon, // correct kernel - CGAL::Polygon_2 /*incorrect kernel*/ >::type type; + Polygon, // same kernel + CGAL::Polygon_2 /*different kernel*/ >::type type; }; +template +using Polygon_return_type = typename CGAL::Default::Get::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 @@ -234,6 +240,10 @@ struct Default_return_polygon_with_holes_type // Polygon ty CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; }; +template +using Polygon_with_holes_return_type = typename CGAL::Default::Get::type>::type; + } // namespace CGAL_SS_i } // namespace CGAL diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h index 90110820a369..ffe8eaaba491 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_builder_2.h @@ -1454,10 +1454,10 @@ private : CGAL_assertion(fit != mSSkel->SSkel::Base::faces_end()); Halfedge_handle lBorder = fit->halfedge(); - FT lWeight = *aWeightsBegin; CGAL_assertion(lBorder->opposite()->is_border()); - CGAL_STSKEL_BUILDER_TRACE(4, "Assign " << lWeight << " cvt to " << cvt(lWeight) << " to E" << lBorder->id()); - lBorder->set_weight(cvt(lWeight)); + FT lWeight = cvt(*aWeightsBegin); + CGAL_STSKEL_BUILDER_TRACE(4, "Assign " << *aWeightsBegin << " (converted to " << cvt(lWeight) << ") to E" << lBorder->id()); + lBorder->set_weight(lWeight); } return *this; diff --git a/Straight_skeleton_2/include/CGAL/arrange_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/arrange_offset_polygons_2.h index cd63666e9e7e..2899fa00ed0c 100644 --- a/Straight_skeleton_2/include/CGAL/arrange_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/arrange_offset_polygons_2.h @@ -20,11 +20,11 @@ #include #include -#include #include #include #include +#include #include namespace CGAL { @@ -48,7 +48,9 @@ bool arrange_offset_polygons_2 ( InputPolygonPtrIterator aBegin { typedef typename std::iterator_traits::difference_type difference_type ; typedef typename std::iterator_traits::value_type PolygonPtr ; + typedef typename Kernel_traits::type>::Kernel OfK; + typedef typename PolygonWithHoles::Polygon_2 Inner_polygon; typedef std::shared_ptr PolygonWithHolesPtr ; difference_type lSize = std::distance(aBegin,aEnd); @@ -61,14 +63,16 @@ bool arrange_offset_polygons_2 ( InputPolygonPtrIterator aBegin const PolygonPtr lPoly = *it ; - Orientation lOrient = CGAL::Polygon::internal::orientation_2_no_precondition(lPoly->vertices().begin(), - lPoly->vertices().end(), - lPoly->traits_member()); + Orientation lOrient = CGAL::Polygon::internal::orientation_2_no_precondition( + CGAL_SS_i::vertices_begin(lPoly), CGAL_SS_i::vertices_end(lPoly), + OfK() /*lPoly->traits_member()*/); // It's an outer boundary if ( lOrient == COUNTERCLOCKWISE ) { - PolygonWithHolesPtr lOuter( new PolygonWithHoles(*lPoly) ); + PolygonWithHolesPtr lOuter = std::make_shared( + Inner_polygon(CGAL_SS_i::vertices_begin(lPoly), + CGAL_SS_i::vertices_end(lPoly))); *rOut ++ = lOuter ; lTable[lIdx] = lOuter ; } @@ -100,7 +104,7 @@ bool arrange_offset_polygons_2 ( InputPolygonPtrIterator aBegin if (lParent == nullptr) return false; - lParent->add_hole(*lPoly); + lParent->add_hole(Inner_polygon(CGAL_SS_i::vertices_begin(lPoly), CGAL_SS_i::vertices_end(lPoly))); } } 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 bbdf0d158534..139675d28082 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -24,9 +24,8 @@ #include #include +#include #include -#include -#include #include #include @@ -129,7 +128,7 @@ create_partial_exterior_straight_skeleton_2 ( FT const& aMaxOffset std::vector holes ; holes.push_back(lPoly) ; - rSkeleton = create_partial_interior_straight_skeleton_2(aMaxOffset,frame, frame+4, holes.begin(), holes.end(), k ) ; + rSkeleton = create_partial_interior_straight_skeleton_2(aMaxOffset, frame, frame+4, holes.begin(), holes.end(), k ) ; } return rSkeleton ; @@ -142,7 +141,9 @@ template std::vector< std::shared_ptr > create_offset_polygons_2 ( FT const& aOffset, Skeleton const& aSs, K const& , Tag_false ) { - typedef std::shared_ptr OutPolygonPtr ; + static_assert(!(std::is_same::value)); + + typedef std::shared_ptr OutPolygonPtr ; typedef std::vector OutPolygonPtrVector ; typedef Straight_skeleton_2 OfSkeleton ; @@ -166,16 +167,18 @@ template std::vector< std::shared_ptr > create_offset_polygons_2 ( FT const& aOffset, Skeleton const& aSs, K const& /*k*/, Tag_true ) { - typedef std::shared_ptr OutPolygonPtr ; + static_assert(!(std::is_same::value)); + + typedef std::shared_ptr OutPolygonPtr ; typedef std::vector OutPolygonPtrVector ; typedef Polygon_offset_builder_traits_2 OffsetBuilderTraits; typedef Polygon_offset_builder_2 OffsetBuilder; - OutPolygonPtrVector rR ; - OffsetBuilder ob(aSs); - ob.construct_offset_contours(aOffset, std::back_inserter(rR) ) ; + typename K::FT lOffset = aOffset; + OutPolygonPtrVector rR ; + ob.construct_offset_contours(lOffset, std::back_inserter(rR) ) ; return rR ; } @@ -190,43 +193,39 @@ Skeleton const& dereference ( std::shared_ptr const& ss ) } // namespace CGAL_SS_i -template -std::vector< std::shared_ptr > +template +std::vector > inline create_offset_polygons_2(const FT& aOffset, const Skeleton& aSs, - const K& k) + const K& k = K()) { typename CGAL_SS_i::Is_same_type::type same_kernel; return CGAL_SS_i::create_offset_polygons_2(aOffset, aSs, k, same_kernel); } -template, - class FT, class Skeleton> -std::vector< std::shared_ptr > -inline -create_offset_polygons_2(const FT& aOffset, - const Skeleton& aSs) -{ - return create_offset_polygons_2(aOffset, aSs, Exact_predicates_inexact_constructions_kernel()); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// /// INTERIOR -template::type> -std::vector< std::shared_ptr > +template +std::vector > > inline create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aOuterBoundary, HoleIterator aHolesBegin, HoleIterator aHolesEnd, - const OfK& ofk, - const SsK& ssk) + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), + std::enable_if_t::value>* = 0) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + return create_offset_polygons_2( aOffset, CGAL_SS_i::dereference( @@ -240,63 +239,26 @@ create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk); } -template::type> -std::vector< std::shared_ptr > -inline -create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aOuterBoundary, - HoleIterator aHolesBegin, - HoleIterator aHolesEnd, - const OfK& ofk) -{ - return create_interior_skeleton_and_offset_polygons_2(aOffset, aOuterBoundary, - aHolesBegin, aHolesEnd, - ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -// Overload where Polygon actually is a simple polygon (no holes) -template::type> -std::vector< std::shared_ptr > +// Overload where APolygon is a simple polygon (no holes) +template +std::vector > > inline create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aPoly, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< ! CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { - std::vector no_holes; - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, - no_holes.begin(), no_holes.end(), - ofk, ssk); -} - -// Overloads common to both polygons with and without holes, a simple polygon is returned in any case -template::type> -std::vector > -inline -create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const OfK& ofk) -{ - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, - Exact_predicates_inexact_constructions_kernel()); -} + using OutPolygon = CGAL_SS_i::Polygon_return_type; -template::type> -std::vector > -inline -create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly) -{ - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, - Exact_predicates_inexact_constructions_kernel()); + std::vector no_holes; + return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, + no_holes.begin(), no_holes.end(), + ofk, ssk); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -307,17 +269,21 @@ create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, /*! create_exterior_skeleton_and_offset_polygons_2 (no sorting of the result) */ // Overload where Polygon actually is a simple polygon (no holes) -template::type> -std::vector< std::shared_ptr > +template +std::vector > > inline create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aPoly, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< ! CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + return create_offset_polygons_2( aOffset, CGAL_SS_i::dereference( @@ -329,31 +295,6 @@ create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, ofk); } -// Overloads common to both polygons with and without holes, a simple polygons is returned in any case -template::type> -std::vector< std::shared_ptr > -inline -create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const OfK& ofk) -{ - return create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -template::type> -std::vector< std::shared_ptr > -inline -create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly) -{ - return create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, - Exact_predicates_inexact_constructions_kernel()); -} - } // namespace CGAL #endif // CGAL_CREATE_OFFSET_POLYGONS_2_H 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 ccedabda0b55..f22c3a8eea71 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 @@ -14,10 +14,9 @@ #include +#include #include #include -#include -#include #include @@ -36,60 +35,45 @@ namespace CGAL { /*! 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 > +template +std::vector > > inline create_interior_skeleton_and_offset_polygons_2(const FT& aOffset, const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { - return create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), - aPoly.holes_begin(), aPoly.holes_end(), - ofk, ssk); + using OutPolygon = CGAL_SS_i::Polygon_return_type; + + 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 -template::type> -std::vector > -inline -create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const OfK& ofk, - const SsK& ssk) -{ - return arrange_offset_polygons_2( - create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk)); -} - -template::type> -std::vector > +// 'Polygon' might be a polygon with holes or not, but it returns a polygon with holes +template +std::vector > > inline create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, const Polygon& aPoly, - const OfK& ofk) + const OfK& ofk = OfK(), + const SsK& ssk = SsK()) { - return create_interior_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, ofk, - Exact_predicates_inexact_constructions_kernel()); -} + using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type::type; + using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type; -template::type> -std::vector > -inline -create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly) -{ - return create_interior_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, - Exact_predicates_inexact_constructions_kernel()); + return arrange_offset_polygons_2( + create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk)); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -100,25 +84,34 @@ create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, /*! 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 -template::type> -std::vector > +template +std::vector > > inline create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, const Polygon& aPoly, - const OfK& ofk, - const SsK& ssk) + const OfK& ofk = OfK(), + const SsK& ssk = 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); + using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type::type; + using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type; + + std::vector > raw_output = + create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk); // filter offset of the outer frame std::swap(raw_output[0], raw_output.back()); raw_output.pop_back(); - for (std::shared_ptr ptr : raw_output) - ptr->reverse_orientation(); + for (std::shared_ptr ptr : raw_output) { + if (ptr->size() > 1) { + // keep the first in place is just to get the same behavior as for Polygon_2 + auto first = std::next(ptr->begin()); + std::reverse(first, ptr->end()); + } + } return arrange_offset_polygons_2(raw_output); } @@ -126,58 +119,38 @@ create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, /*! 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 > +template +std::vector > > inline create_exterior_skeleton_and_offset_polygons_2(const FT& aOffset, const PolygonWithHoles& aPoly, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + std::vector > polygons = - create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk); + 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); + 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 > -inline -create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const OfK& ofk) -{ - return create_exterior_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -template::type> -std::vector > -inline -create_exterior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly) -{ - return create_exterior_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, - Exact_predicates_inexact_constructions_kernel()); -} - } // namespace CGAL #endif // CGAL_CREATE_OFFSET_POLYGONS_FROM_POLYGON_WITH_HOLES_2_H diff --git a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h index c65e61ffc8ce..5a2371e395f3 100644 --- a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h +++ b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_2.h @@ -32,14 +32,14 @@ namespace CGAL { -template +template std::shared_ptr< Straight_skeleton_2 > create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin , PointIterator aOuterContour_VerticesEnd , HoleIterator aHolesBegin , HoleIterator aHolesEnd - , K const& - ) + , const K& = K()) { typedef Straight_skeleton_2 Ss ; @@ -62,30 +62,13 @@ create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin return ssb.construct_skeleton(); } -template -std::shared_ptr< Straight_skeleton_2< Exact_predicates_inexact_constructions_kernel > > -inline -create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin - , PointIterator aOuterContour_VerticesEnd - , HoleIterator aHolesBegin - , HoleIterator aHolesEnd - ) -{ - return create_interior_straight_skeleton_2(aOuterContour_VerticesBegin - ,aOuterContour_VerticesEnd - ,aHolesBegin - ,aHolesEnd - ,Exact_predicates_inexact_constructions_kernel() - ); -} - -template +template std::shared_ptr< Straight_skeleton_2 > inline create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin , PointIterator aOuterContour_VerticesEnd - , K const& k - ) + , const K& k = K()) { typedef typename std::iterator_traits::value_type InputPoint ; typedef typename Kernel_traits::Kernel InputKernel ; @@ -99,24 +82,12 @@ create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin ); } -template -std::shared_ptr< Straight_skeleton_2 > -inline -create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin - , PointIterator aOuterContour_VerticesEnd - ) -{ - return create_interior_straight_skeleton_2(aOuterContour_VerticesBegin - ,aOuterContour_VerticesEnd - ,Exact_predicates_inexact_constructions_kernel() - ); -} - -template +template std::shared_ptr< Straight_skeleton_2 > inline -create_interior_straight_skeleton_2 ( Polygon const& aOutContour, - K const& k, +create_interior_straight_skeleton_2 ( const Polygon& aOutContour, + const K& k = K(), std::enable_if_t< ! CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { @@ -126,26 +97,18 @@ create_interior_straight_skeleton_2 ( Polygon const& aOutContour, ); } -template -std::shared_ptr< Straight_skeleton_2< Exact_predicates_inexact_constructions_kernel > > -inline -create_interior_straight_skeleton_2 ( Polygon const& aOutContour ) -{ - return create_interior_straight_skeleton_2(aOutContour, Exact_predicates_inexact_constructions_kernel() ); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// /// EXTERIOR -template +template std::shared_ptr< Straight_skeleton_2 > create_exterior_straight_skeleton_2 ( FT const& aMaxOffset , PointIterator aVerticesBegin , PointIterator aVerticesEnd - , K const& k - ) + , const K& k = K()) { CGAL_precondition( aMaxOffset > 0 ) ; @@ -195,25 +158,13 @@ create_exterior_straight_skeleton_2 ( FT const& aMaxOffset return rSkeleton ; } -template -std::shared_ptr< Straight_skeleton_2 > -inline -create_exterior_straight_skeleton_2 ( FT const& aMaxOffset - , PointIterator aVerticesBegin - , PointIterator aVerticesEnd - ) -{ - return create_exterior_straight_skeleton_2(aMaxOffset - ,aVerticesBegin - ,aVerticesEnd - ,Exact_predicates_inexact_constructions_kernel() - ); -} - -template +template std::shared_ptr< Straight_skeleton_2 > inline -create_exterior_straight_skeleton_2 ( FT const& aMaxOffset, Polygon const& aPoly, K const& k ) +create_exterior_straight_skeleton_2(const FT& aMaxOffset, + const Polygon& aPoly, + const K& k = K()) { return create_exterior_straight_skeleton_2(aMaxOffset ,CGAL_SS_i::vertices_begin(aPoly) @@ -222,17 +173,6 @@ create_exterior_straight_skeleton_2 ( FT const& aMaxOffset, Polygon const& aPoly ); } -template -std::shared_ptr< Straight_skeleton_2 > -inline -create_exterior_straight_skeleton_2 ( FT const& aMaxOffset, Polygon const& aPoly ) -{ - return create_exterior_straight_skeleton_2(aMaxOffset - ,aPoly - ,Exact_predicates_inexact_constructions_kernel() - ); -} - } // namespace CGAL #endif // CGAL_CREATE_STRAIGHT_SKELETON_2_H diff --git a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_from_polygon_with_holes_2.h index ae229d32e448..4e8f51dbee43 100644 --- a/Straight_skeleton_2/include/CGAL/create_straight_skeleton_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_straight_skeleton_from_polygon_with_holes_2.h @@ -26,11 +26,12 @@ namespace CGAL { -template +template std::shared_ptr< Straight_skeleton_2 > inline -create_interior_straight_skeleton_2 ( Polygon const& aPolyWithHoles, - K const& k, +create_interior_straight_skeleton_2 ( const Polygon& aPolyWithHoles, + const K& k = K(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { 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 d25538494758..0fd2ca8236a3 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 @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include #include @@ -127,6 +125,8 @@ create_partial_exterior_weighted_straight_skeleton_2(const FT& aMaxOffset, typedef typename Kernel_traits::Kernel IK; typedef typename IK::FT IFT; + static_assert((std::is_same::value_type, IFT>::value)); + std::shared_ptr > rSkeleton; // That's because we might not have FT == IK::FT (e.g. `double` and `Core`) @@ -169,11 +169,11 @@ create_partial_exterior_weighted_straight_skeleton_2(const FT& aMaxOffset, holes.push_back(lPoly) ; // put a weight large enough such that frame edges are not relevant - const FT frame_weight = FT(10) * *(std::max_element(aWeightsBegin, aWeightsEnd)); + const IFT frame_weight = FT(10) * *(std::max_element(aWeightsBegin, aWeightsEnd)); CGAL_STSKEL_BUILDER_TRACE(4, "Frame weight = " << frame_weight); - std::vector lFrameWeights(4, frame_weight); - std::vector > lHoleWeights; + std::vector lFrameWeights(4, frame_weight); + std::vector > lHoleWeights; lHoleWeights.emplace_back(aWeightsBegin, aWeightsEnd); // If w[0] pointed to v_0, then when we reverse the polygon, the last polygon is pointing to v_{n-1} @@ -200,10 +200,11 @@ create_partial_exterior_weighted_straight_skeleton_2(const FT& aMaxOffset, //////////////////////////////////////////////////////////////////////////////////////////////////// /// INTERIOR -template::type> -std::vector< std::shared_ptr > +template +std::vector > > inline create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aOuterBoundary, @@ -212,9 +213,11 @@ create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const Weights& aWeights, HoleWeightsIterator aHoles_WeightsBegin, HoleWeightsIterator aHoles_WeightsEnd, - const OfK& ofk, - const SsK& ssk) + const OfK& ofk = OfK(), + const SsK& ssk = SsK()) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + if(aHolesBegin == aHolesEnd) // see @partial_wsls_pwh { return create_offset_polygons_2( @@ -252,69 +255,33 @@ create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, } } -template::type> -std::vector< std::shared_ptr > -inline -create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aOuterBoundary, - HoleIterator aHolesBegin, - HoleIterator aHolesEnd, - const Weights& aWeights, - const OfK& ofk) -{ - return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aOuterBoundary, - aHolesBegin, aHolesEnd, - aWeights, - ofk, - Exact_predicates_inexact_constructions_kernel()); -} - // Overload where Polygon actually is a simple polygon (no holes) -template::type> -std::vector< std::shared_ptr > +template +std::vector > > inline create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< ! CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { - std::vector no_holes; - return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, - no_holes.begin(), no_holes.end(), - aWeights, - ofk, ssk); -} + using OutPolygon = CGAL_SS_i::Polygon_return_type; -// Overloads common to both polygons with and without holes, a simple polygon is returned in any case -template::type> -std::vector > -inline -create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const Weights& aWeights, - const OfK& ofk) -{ - return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, - Exact_predicates_inexact_constructions_kernel()); -} + using IFT = typename boost::range_value::type>::type; -template::type> -std::vector > -inline -create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const Weights& aWeights) -{ - return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, - Exact_predicates_inexact_constructions_kernel()); + std::vector no_holes; + std::vector > no_hole_weights; + + return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, + no_holes.begin(), no_holes.end(), + aWeights[0], + no_hole_weights.begin(), no_hole_weights.end(), + ofk, ssk); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -325,18 +292,22 @@ create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, /*! create_exterior_skeleton_and_offset_polygons_2 (no sorting of the result) */ // Overload where Polygon actually is a simple polygon (no holes) -template::type> -std::vector< std::shared_ptr > +template +std::vector > > inline create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const APolygon& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< ! CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + return create_offset_polygons_2( aOffset, CGAL_SS_i::dereference( @@ -344,39 +315,12 @@ create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, aOffset, CGAL_SS_i::vertices_begin(aPoly), CGAL_SS_i::vertices_end (aPoly), - aWeights[0].begin(), - aWeights[0].end(), + std::begin(aWeights[0]), + std::end(aWeights[0]), ssk)), ofk); } -// Overloads common to both polygons with and without holes, a simple polygons is returned in any case -template::type> -std::vector< std::shared_ptr > -inline -create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const Weights& aWeights, - const OfK& ofk) -{ - return create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -template::type> -std::vector< std::shared_ptr > -inline -create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, - const APolygon& aPoly, - const Weights& aWeights) -{ - return create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, - Exact_predicates_inexact_constructions_kernel()); -} - } // namespace CGAL #endif // CGAL_CREATE_WEIGHTED_OFFSET_POLYGONS_2_H diff --git a/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h index 51e1fd3752ec..ca6f8d8d64f0 100644 --- a/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h @@ -14,10 +14,9 @@ #include +#include #include -#include -#include -#include +#include #include @@ -35,67 +34,50 @@ namespace CGAL { /*! 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 > +template +std::vector > > inline create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const PolygonWithHoles& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { - return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), - aPoly.holes_begin(), aPoly.holes_end(), - aWeights[0], - std::next(std::begin(aWeights)), - std::end(aWeights), - ofk, ssk); + using OutPolygon = CGAL_SS_i::Polygon_return_type; + + return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), + aPoly.holes_begin(), aPoly.holes_end(), + aWeights[0], + std::next(std::begin(aWeights)), + std::end(aWeights), + ofk, ssk); } /*! create_interior_weighted_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 -template::type> -std::vector > +template +std::vector > > inline create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, const Polygon& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk) + const OfK& ofk = OfK(), + const SsK& ssk = SsK()) { - return arrange_offset_polygons_2( - create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, ssk)); -} + using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type::type; + using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type; -template::type> -std::vector > -inline -create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const Weights& aWeights, - const OfK& ofk) -{ - return create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, aWeights, ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -template::type> -std::vector > -inline -create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const Weights& aWeights) -{ - return create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, aWeights, - Exact_predicates_inexact_constructions_kernel()); + return arrange_offset_polygons_2( + create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, ssk)); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -103,28 +85,37 @@ create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOf //////////////////////////////////////////////////////////////////////////////////////////////////// /// EXTERIOR -/*! create_exterior_skeleton_and_offset_polygons_with_holes_2 (orders the resulting polygons) */ +/*! create_exterior_weighted_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 -template::type> -std::vector > +template +std::vector > > create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, const Polygon& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk) + const OfK& ofk = OfK(), + const SsK& ssk = SsK()) { - typedef typename CGAL_SS_i::Default_return_polygon_type::type Polygon_; - std::vector > raw_output = - create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, ssk); + using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type::type; + using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type; + + std::vector > raw_output = + create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, ssk); // filter offset of the outer frame std::swap(raw_output[0], raw_output.back()); raw_output.pop_back(); - for(std::shared_ptr ptr : raw_output) - ptr->reverse_orientation(); + for (std::shared_ptr ptr : raw_output) { + if (ptr->size() > 1) { + // keep the first in place is just to get the same behavior as for Polygon_2 + auto first = std::next(ptr->begin()); + std::reverse(first, ptr->end()); + } + } return arrange_offset_polygons_2(raw_output); } @@ -132,22 +123,26 @@ create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOf /*! 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 > +template +std::vector > > inline create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, const PolygonWithHoles& aPoly, const Weights& aWeights, - const OfK& ofk, - const SsK& ssk, + const OfK& ofk = OfK(), + const SsK& ssk = SsK(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { + using OutPolygon = CGAL_SS_i::Polygon_return_type; + CGAL_precondition(aWeights.size() == aPoly.number_of_holes() + 1); std::vector > polygons = - create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), {aWeights[0]}, ofk, ssk); + create_exterior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), aWeights, ofk, ssk); std::size_t weight_pos = 1; for(typename PolygonWithHoles::Hole_const_iterator hit=aPoly.holes_begin(); hit!=aPoly.holes_end(); ++hit, ++weight_pos) @@ -155,42 +150,16 @@ create_exterior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset, typename PolygonWithHoles::Polygon_2 hole = *hit; hole.reverse_orientation(); std::vector > hole_polygons = - create_interior_skeleton_and_offset_polygons_2(aOffset, - hole, - {aWeights[weight_pos]}, - ofk, ssk); + create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, + hole, + Weights{aWeights[weight_pos]}, + ofk, ssk); polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end()); } return polygons; } -template::type> -std::vector > -inline -create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const Weights& aWeights, - const OfK& ofk) -{ - return create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, aWeights, ofk, - Exact_predicates_inexact_constructions_kernel()); -} - -template::type> -std::vector > -inline -create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset, - const Polygon& aPoly, - const Weights& aWeights) -{ - return create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, aWeights, - Exact_predicates_inexact_constructions_kernel()); -} - } // namespace CGAL #endif // CGAL_CREATE_WEIGHTED_OFFSET_POLYGONS_FROM_POLYGON_WITH_HOLES_2_H diff --git a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h index 85c4cd6b99e9..cb40a6fe2465 100644 --- a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h +++ b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_2.h @@ -26,13 +26,14 @@ #include #include #include +#include #include namespace CGAL { template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr > create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertices_begin, PointIterator outer_contour_vertices_end, @@ -42,7 +43,7 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice WeightIterator outer_contour_weights_end, HoleWeightsIterator holes_weights_begin, HoleWeightsIterator holes_weights_end, - const K&) + const K& = K()) { using Skeleton = Straight_skeleton_2; @@ -76,37 +77,16 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice return ssb.construct_skeleton(); } -template -std::shared_ptr > -inline -create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertices_begin, - PointIterator outer_contour_vertices_end, - HoleIterator holes_begin, - HoleIterator holes_end, - WeightIterator outer_contour_weights_begin, - WeightIterator outer_contour_weights_end, - HoleWeightsIterator holes_weights_begin, - HoleWeightsIterator holes_weights_end) -{ - return create_interior_weighted_straight_skeleton_2(outer_contour_vertices_begin, outer_contour_vertices_end, - holes_begin, holes_end, - outer_contour_weights_begin, outer_contour_weights_end, - holes_weights_begin, holes_weights_end, - Exact_predicates_inexact_constructions_kernel()); -} - template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr > inline create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertices_begin, PointIterator outer_contour_vertices_end, WeightIterator outer_contour_weights_begin, WeightIterator outer_contour_weights_end, - const K& k) + const K& k = K()) { using InputPoint = typename std::iterator_traits::value_type; using InputKernel = typename Kernel_traits::Kernel; @@ -126,51 +106,23 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice k); } -template -std::shared_ptr > -inline -create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertices_begin, - PointIterator outer_contour_vertices_end, - WeightIterator outer_contour_weights_begin, - WeightIterator outer_contour_weights_end) -{ - return create_interior_weighted_straight_skeleton_2(outer_contour_vertices_begin, - outer_contour_vertices_end, - outer_contour_weights_begin, - outer_contour_weights_end, - Exact_predicates_inexact_constructions_kernel()); -} - template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr > inline create_interior_weighted_straight_skeleton_2(const Polygon& out_contour, const Weights& weights, - const K& k, + const K& k = K(), std::enable_if_t::value>* = nullptr) { return create_interior_weighted_straight_skeleton_2(CGAL_SS_i::vertices_begin(out_contour), CGAL_SS_i::vertices_end(out_contour), - weights.begin(), - weights.end(), + weights[0].begin(), + weights[0].end(), k); } -template -std::shared_ptr > -inline -create_interior_weighted_straight_skeleton_2(const Polygon& out_contour, - const Weights& weights) -{ - return create_interior_weighted_straight_skeleton_2(out_contour, - weights, - Exact_predicates_inexact_constructions_kernel()); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -179,14 +131,14 @@ create_interior_weighted_straight_skeleton_2(const Polygon& out_contour, template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr > create_exterior_weighted_straight_skeleton_2(const FT& max_offset, PointIterator vertices_begin, PointIterator vertices_end, WeightIterator weights_begin, WeightIterator weights_end, - const K& k) + const K& k = K()) { CGAL_precondition(max_offset > 0); CGAL_precondition(std::distance(weights_begin, weights_end) == std::distance(vertices_begin, vertices_end)); @@ -195,6 +147,8 @@ create_exterior_weighted_straight_skeleton_2(const FT& max_offset, using IK = typename Kernel_traits::Kernel; using IFT = typename IK::FT; + static_assert((std::is_same::value_type, IFT>::value)); + std::shared_ptr > skeleton; // That's because we might not have FT == IK::FT (e.g. `double` and `Core`) @@ -236,11 +190,11 @@ create_exterior_weighted_straight_skeleton_2(const FT& max_offset, holes.push_back(poly); // put a weight large enough such that frame edges are not relevant - const FT frame_weight = FT(10) * *(std::max_element(weights_begin, weights_end)); + const IFT frame_weight = IFT(10) * *(std::max_element(weights_begin, weights_end)); CGAL_STSKEL_BUILDER_TRACE(4, "Frame weight = " << frame_weight); - std::vector lFrameWeights(4, frame_weight); - std::vector > lHoleWeights; + std::vector lFrameWeights(4, frame_weight); + std::vector > lHoleWeights; lHoleWeights.emplace_back(weights_begin, weights_end); // If w[0] pointed to v_0, then when we reverse the polygon, the last polygon is pointing to v_{n-1} @@ -258,59 +212,25 @@ create_exterior_weighted_straight_skeleton_2(const FT& max_offset, return skeleton; } -template -std::shared_ptr > -inline -create_exterior_weighted_straight_skeleton_2(const FT& max_offset, - PointIterator vertices_begin, - PointIterator vertices_end, - WeightIterator weights_begin, - WeightIterator weights_end) -{ - return create_exterior_weighted_straight_skeleton_2(max_offset, - vertices_begin, - vertices_end, - weights_begin, - weights_end, - Exact_predicates_inexact_constructions_kernel()); -} - template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr > inline create_exterior_weighted_straight_skeleton_2(const FT& max_offset, const Polygon& aPoly, Weights& weights, - const K& k) + const K& k = K()) { return create_exterior_weighted_straight_skeleton_2(max_offset, CGAL_SS_i::vertices_begin(aPoly), CGAL_SS_i::vertices_end(aPoly), - weights.begin(), - weights.end(), + weights[0].begin(), + weights[0].end(), k); } -template -std::shared_ptr > -inline -create_exterior_weighted_straight_skeleton_2(const FT& max_offset, - Weights& weights, - const Polygon& aPoly) -{ - return create_exterior_weighted_straight_skeleton_2(max_offset, - aPoly, - weights, - Exact_predicates_inexact_constructions_kernel()); -} - } // namespace CGAL #endif // CGAL_CREATE_WEIGHTED_STRAIGHT_SKELETON_2_H diff --git a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_from_polygon_with_holes_2.h b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_from_polygon_with_holes_2.h index acc2046f2a61..df77c7da6d02 100644 --- a/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_from_polygon_with_holes_2.h +++ b/Straight_skeleton_2/include/CGAL/create_weighted_straight_skeleton_from_polygon_with_holes_2.h @@ -26,12 +26,12 @@ namespace CGAL { template + typename K = Exact_predicates_inexact_constructions_kernel> std::shared_ptr< Straight_skeleton_2 > inline create_interior_weighted_straight_skeleton_2(const Polygon& poly_with_holes, const Weights& weights, - const K& k, + const K& k = K(), std::enable_if_t< CGAL_SS_i::has_Hole_const_iterator::value>* = nullptr) { diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt index c7395c3cc446..48b126bf732e 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt +++ b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt @@ -22,17 +22,19 @@ if(CGAL_Qt6_FOUND) endif() if (CGAL_Core_FOUND OR LEDA_FOUND) - create_single_source_cgal_program("test_sls_offset.cpp") + create_single_source_cgal_program("issue7149.cpp") create_single_source_cgal_program("issue7284.cpp") + create_single_source_cgal_program("test_sls_offset.cpp") + create_single_source_cgal_program("test_sls_weighted_offset.cpp") create_single_source_cgal_program("test_sls_simple.cpp") + create_single_source_cgal_program("test_sls_weighted_polygons.cpp") create_single_source_cgal_program("test_sls_weighted_polygons_with_holes.cpp") - create_single_source_cgal_program("issue7149.cpp") if(CGAL_Qt6_FOUND) target_link_libraries(issue7149 PUBLIC CGAL::CGAL_Basic_viewer) target_link_libraries(issue7284 PUBLIC CGAL::CGAL_Basic_viewer) target_link_libraries(test_sls_offset PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(test_sls_weighted_offset PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(test_sls_weighted_polygons PUBLIC CGAL::CGAL_Basic_viewer) target_link_libraries(test_sls_weighted_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer) endif() -else() - message("NOTICE: Some test require CGAL_Core (or LEDA), and will not be compiled.") endif() 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 90ed7dc9ef31..7259dd75e965 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 @@ -22,10 +22,13 @@ #include #include -#include +#include + +#include #include #include +#include #include #include @@ -34,90 +37,248 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt; typedef CGAL::Timer Timer; + +namespace CGAL { + +template +class Test_polygon_2 : public CGAL::Polygon_2 { + typedef CGAL::Polygon_2 Base; + Test_polygon_2(const Base&); +public: + using Base::Base; +}; + +template +class Test_polygon_with_holes_2 : public CGAL::Polygon_with_holes_2 { + typedef CGAL::Polygon_with_holes_2 Base; + Test_polygon_with_holes_2(const Base&); +public: + using Base::Base; +}; + +} // namespace CGAL + +using namespace CGAL; + template void test_API() { + typedef typename K::FT FT; + typedef typename K::Point_2 Point_2; + typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; typedef CGAL::Polygon_2 Polygon_2_EPICK; typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2_EPICK; + typedef CGAL::Test_polygon_2 Test_Polygon_2; + typedef CGAL::Test_polygon_with_holes_2 Test_Polygon_with_holes_2; + + typedef CGAL::Test_polygon_2 Test_Polygon_2_EPICK; + typedef CGAL::Test_polygon_with_holes_2 Test_Polygon_with_holes_2_EPICK; + + std::vector v; Polygon_2 p; Polygon_with_holes_2 pwh; std::vector< std::shared_ptr > res; std::vector< std::shared_ptr > res_EPICK; - std::vector< std::shared_ptr > res_w; - std::vector< std::shared_ptr > res_w_EPICK; + std::vector< std::shared_ptr > res_wh; + std::vector< std::shared_ptr > res_wh_EPICK; + + std::vector< std::shared_ptr > res_test; + std::vector< std::shared_ptr > res_test_EPICK; + std::vector< std::shared_ptr > res_wh_test; + std::vector< std::shared_ptr > res_wh_test_EPICK; // First kernel is the offset construction (and thus output kernel), second kernel is the skeleton construction // simple interior, no holes res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p) ; res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK()) ; - res_EPICK = create_interior_skeleton_and_offset_polygons_2(0, p, EPICK(), K()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; res = create_interior_skeleton_and_offset_polygons_2(0.1, p, K()) ; - res = create_interior_skeleton_and_offset_polygons_2(0, p, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, p, K(), EPICK()) ; res = create_interior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, p, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, v, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, v, EPICK(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(0.1, v, K(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(FT(0.1), v, K(), K()) ; // simple interior, holes res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh) ; res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK()) ; - res_EPICK = create_interior_skeleton_and_offset_polygons_2(0, pwh, EPICK(), K()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; res = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K()) ; - res = create_interior_skeleton_and_offset_polygons_2(0, pwh, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K(), EPICK()) ; res = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), EPICK()) ; + res = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res = create_interior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; + + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res_test = create_interior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; // simple exterior, no holes res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p) ; res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK()) ; - res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0, p, EPICK(), K()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; res = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K()) ; - res = create_exterior_skeleton_and_offset_polygons_2(0, p, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K(), EPICK()) ; res = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, p, EPICK(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(0.1, p, K(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), p, K(), K()) ; + + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, v, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, v, EPICK(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(0.1, v, K(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), v, K(), K()) ; // simple exterior, holes res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh) ; res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK()) ; - res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0, pwh, EPICK(), K()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; res = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K()) ; - res = create_exterior_skeleton_and_offset_polygons_2(0, pwh, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K(), EPICK()) ; res = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), EPICK()) ; + res = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; + + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, EPICK(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(0.1, pwh, K(), K()) ; + res_test = create_exterior_skeleton_and_offset_polygons_2(FT(0.1), pwh, K(), K()) ; // Same, but the result has holes -------------------- // arranged interior, no holes - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p) ; - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK()) ; - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0, p, EPICK(), K()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0, p, K(), EPICK()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), K()) ; + + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), K()) ; + + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, v, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, v, EPICK(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, v, K(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), v, K(), K()) ; // arranged interior, holes - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh) ; - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK()) ; - res_w_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0, pwh, EPICK(), K()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0, pwh, K(), EPICK()) ; - res_w = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), EPICK()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), K()) ; + + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), K()) ; // arranged exterior, no holes - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p) ; - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK()) ; - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0, p, EPICK(), K()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0, p, K(), EPICK()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), EPICK()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), EPICK()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), EPICK()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), K()) ; + + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, EPICK(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, p, K(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, K(), K()) ; + + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, v, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, v, EPICK(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, v, K(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), v, K(), K()) ; // arranged exterior, holes - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh) ; - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK()) ; - res_w_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0, pwh, EPICK(), K()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0, pwh, K(), EPICK()) ; - res_w = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), EPICK()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), EPICK()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), K()) ; + + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, EPICK(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, K(), K()) ; + res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, K(), K()) ; } template @@ -209,7 +370,7 @@ void test_offset_four_square_holes() outer.push_back(Point( 0, 0)); outer.push_back(Point(10, 0)); outer.push_back(Point(10, 10)); - outer.push_back(Point(0, 10)); + outer.push_back(Point( 0, 10)); hole1.push_back(Point(1, 1)); hole1.push_back(Point(1, 4.5)); @@ -969,9 +1130,8 @@ void test_kernel() std::cout.precision(17); std::cerr.precision(17); -#ifndef CGAL_SLS_TEST_SPEED_THINGS_UP_FOR_THE_TESTSUITE - // test_API(); -#endif + void (*dummy_ptr)() = &test_API; + CGAL_USE(dummy_ptr); // Artificial data test_offset_square(); diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_simple.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_simple.cpp index d90bc8adf5fe..4f5ad6215678 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_simple.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_simple.cpp @@ -34,10 +34,13 @@ void Straight_skeleton_traits_external_trace(std::string m) #include #include -#include +#include + +#include #include #include +#include #include #include #include @@ -221,9 +224,8 @@ void test_kernel() { // CGAL_STSKEL_TRAITS_ENABLE_TRACE -#ifndef CGAL_SLS_TEST_SPEED_THINGS_UP_FOR_THE_TESTSUITE - // test_API(); -#endif + void (*dummy_ptr)() = &test_API; + CGAL_USE(dummy_ptr); test_skeleton("data/pseudo_split_0.poly", 13, 40, 8); test_skeleton("data/pseudo_split_1.poly", 21, 68, 12); diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_offset.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_offset.cpp new file mode 100644 index 000000000000..e4e64c2c95b5 --- /dev/null +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_offset.cpp @@ -0,0 +1,291 @@ +#define CGAL_SLS_TEST_SPEED_THINGS_UP_FOR_THE_TESTSUITE +#define CGAL_ENABLE_DISABLE_ASSERTIONS_AT_RUNTIME + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; +typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt; + +namespace CGAL { + +template +class Test_polygon_2 : public CGAL::Polygon_2 { + typedef CGAL::Polygon_2 Base; + Test_polygon_2(const Base&); +public: + using Base::Base; +}; + +template +class Test_polygon_with_holes_2 : public CGAL::Polygon_with_holes_2 { + typedef CGAL::Polygon_with_holes_2 Base; + Test_polygon_with_holes_2(const Base&); +public: + using Base::Base; +}; + +} // namespace CGAL + +using namespace CGAL; + +template +void test_API() +{ + typedef typename K::FT FT; + typedef typename K::Point_2 Point_2; + + typedef CGAL::Polygon_2 Polygon_2; + typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; + + typedef CGAL::Polygon_2 Polygon_2_EPICK; + typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2_EPICK; + + typedef CGAL::Test_polygon_2 Test_Polygon_2; + typedef CGAL::Test_polygon_with_holes_2 Test_Polygon_with_holes_2; + + typedef CGAL::Test_polygon_2 Test_Polygon_2_EPICK; + typedef CGAL::Test_polygon_with_holes_2 Test_Polygon_with_holes_2_EPICK; + + std::vector v; + Polygon_2 p; + Polygon_with_holes_2 pwh; + std::vector > weights; + + std::vector > res; + std::vector > res_EPICK; + std::vector > res_wh; + std::vector > res_wh_EPICK; + + std::vector > res_test; + std::vector > res_test_EPICK; + std::vector > res_wh_test; + std::vector > res_wh_test_EPICK; + + // First kernel is the offset construction (and thus output kernel), second kernel is the skeleton construction + + // simple interior, no holes + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, EPICK(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, K(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), v, weights, K(), K()) ; + + // simple interior, holes + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), EPICK()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res_test = create_interior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + + // simple exterior, no holes + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, EPICK(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, p, weights, K(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), p, weights, K(), K()) ; + + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, EPICK(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, v, weights, K(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), v, weights, K(), K()) ; + + // simple exterior, holes + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), EPICK()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, EPICK(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(0.1, pwh, weights, K(), K()) ; + res_test = create_exterior_weighted_skeleton_and_offset_polygons_2(FT(0.1), pwh, weights, K(), K()) ; + + // Same, but the result has holes -------------------- + + // arranged interior, no holes + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), K()) ; + + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), K()) ; + + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, EPICK(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, K(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), v, weights, K(), K()) ; + + // arranged interior, holes + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), EPICK()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), K()) ; + res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), K()) ; + + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), K()) ; + res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), K()) ; + + // arranged exterior, no holes + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), EPICK()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), EPICK()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), EPICK()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), K()) ; + + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, EPICK(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, p, weights, K(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), p, weights, K(), K()) ; + + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, EPICK(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, v, weights, K(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), v, weights, K(), K()) ; + + // arranged exterior, holes + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), EPICK()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), EPICK()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), K()) ; + res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), K()) ; + + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), EPICK()) ; + res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, EPICK(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(0.1, pwh, weights, K(), K()) ; + res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights, K(), K()) ; +} + +template +void test_kernel() +{ + void (*dummy_ptr)() = &test_API; + CGAL_USE(dummy_ptr); +} + +int main(int, char**) +{ + std::cout.precision(17); + std::cerr.precision(17); + + test_kernel(); + test_kernel(); + test_kernel(); + + std::cout << "Done!" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons.cpp new file mode 100644 index 000000000000..54a3be0ad86a --- /dev/null +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons.cpp @@ -0,0 +1,147 @@ +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +namespace SS = CGAL::CGAL_SS_i; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; +typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt; + +template +void test_API() +{ + typedef typename K::FT FT; + + typedef CGAL::Polygon_2 Polygon_2; + typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; + + typedef CGAL::Straight_skeleton_2 Straight_skeleton_EPICK; + typedef std::shared_ptr Straight_skeleton_Ptr_EPICK; + + typedef CGAL::Straight_skeleton_2 Straight_skeleton; + typedef std::shared_ptr Straight_skeleton_Ptr; + + std::vector > weights; + + Polygon_2 p; + Straight_skeleton_Ptr_EPICK ss_epick = CGAL::create_interior_weighted_straight_skeleton_2(p, weights); + Straight_skeleton_Ptr ss = CGAL::create_interior_weighted_straight_skeleton_2(p, weights, K()); + ss_epick = CGAL::create_exterior_weighted_straight_skeleton_2(double(1.01), p, weights); + ss = CGAL::create_exterior_weighted_straight_skeleton_2(int(2), p, weights, K()); + + Polygon_with_holes_2 pwh; + ss_epick = CGAL::create_interior_weighted_straight_skeleton_2(pwh, weights); + ss = CGAL::create_interior_weighted_straight_skeleton_2(pwh, weights, K()); + ss_epick = CGAL::create_exterior_weighted_straight_skeleton_2(double(1.01), p, weights); + ss = CGAL::create_exterior_weighted_straight_skeleton_2(int(2), p, weights, K()); +} + +template +void test_kernel(const int polygon_nv, CGAL::Random& rnd) +{ + using FT = typename K::FT; + using Point_2 = typename K::Point_2; + using Point_3 = typename K::Point_3; + + using Polygon_2 = CGAL::Polygon_2; + + using Straight_skeleton_2 = CGAL::Straight_skeleton_2; + using Straight_skeleton_2_ptr = std::shared_ptr; + + using Mesh = CGAL::Surface_mesh; + + void (*dummy_ptr)() = &test_API; + CGAL_USE(dummy_ptr); + + typedef CGAL::Random_points_in_square_2 Point_generator; + Polygon_2 pol; + CGAL::random_polygon_2(polygon_nv, std::back_inserter(pol), Point_generator(0.25, rnd)); + + std::vector > weights(1); + for(int i=0; i& ws : weights) + { + for(FT w : ws) + std::cout << w << " "; + std::cout << std::endl; + } + + CGAL::draw(pol); + + Straight_skeleton_2_ptr ss_ptr = CGAL::create_interior_weighted_straight_skeleton_2(pol, weights, K()); + assert(ss_ptr); + if(!ss_ptr) + { + std::cerr << "Error: failed to create straight skeleton" << std::endl; + return; + } + + CGAL::draw(*ss_ptr); + + ss_ptr = CGAL::create_exterior_weighted_straight_skeleton_2(0.1, pol, weights, K()); + assert(ss_ptr); + if(!ss_ptr) + { + std::cerr << "Error: failed to create straight skeleton" << std::endl; + return; + } + + CGAL::draw(*ss_ptr); + + Mesh sm; + bool success = extrude_skeleton(pol, sm, CGAL::parameters::weights(weights)); + assert(success); + if(!success) + { + std::cerr << "Error: failed to extrude skeleton" << std::endl; + return; + } + + std::cout << num_vertices(sm) << " vertices and " << num_faces(sm) << " faces" << std::endl; + + CGAL::draw(sm); +} + +int main(int argc, char** argv) +{ + std::cout.precision(17); + std::cerr.precision(17); + + const int polygon_nv = (argc > 1) ? std::atoi(argv[1]) : 10; + const int seed = (argc > 2) ? std::atoi(argv[2]) : std::time(nullptr); + + CGAL::Random rnd(seed); + std::cout << "Seed is " << rnd.get_seed() << std::endl; + + test_kernel(polygon_nv, rnd); + test_kernel(polygon_nv, rnd); + test_kernel(polygon_nv, rnd); + + return EXIT_SUCCESS; +} diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons_with_holes.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons_with_holes.cpp index 7ebe00f75a49..e193238c6013 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons_with_holes.cpp +++ b/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_weighted_polygons_with_holes.cpp @@ -1,6 +1,7 @@ #include #include #include + #include #include @@ -22,44 +23,33 @@ namespace SS = CGAL::CGAL_SS_i; -using K = CGAL::Exact_predicates_inexact_constructions_kernel; -using FT = K::FT; -using Point_2 = K::Point_2; -using Vector_2 = K::Vector_2; -using Point_3 = K::Point_3; - -using Polygon_2 = CGAL::Polygon_2; -using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2; - -using Straight_skeleton_2 = CGAL::Straight_skeleton_2; -using Straight_skeleton_2_ptr = std::shared_ptr; +typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; +typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK; +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt; -using Mesh = CGAL::Surface_mesh; - -Polygon_2 generate_random_polygon(CGAL::Random& rnd) +template +void test_kernel(const int hole_n, const int hole_nv, CGAL::Random& rnd) { - typedef CGAL::Random_points_in_square_2 Point_generator; + using FT = typename K::FT; + using Point_2 = typename K::Point_2; + using Point_3 = typename K::Point_3; - Polygon_2 poly; - CGAL::random_polygon_2(10, std::back_inserter(poly), Point_generator(0.25, rnd)); - return poly; -} + using Polygon_2 = CGAL::Polygon_2; + using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2; -int main(int argc, char** argv) -{ - std::cout.precision(17); - std::cerr.precision(17); + using Straight_skeleton_2 = CGAL::Straight_skeleton_2; + using Straight_skeleton_2_ptr = std::shared_ptr; - int hole_n = (argc > 1) ? std::atoi(argv[1]) : 2; - int hole_nv = (argc > 2) ? std::atoi(argv[2]) : 10; - int seed = (argc > 3) ? std::atoi(argv[3]) : CGAL::get_default_random().get_seed(); - - CGAL::Random rnd(seed); + using Mesh = CGAL::Surface_mesh; - std::cout << "Seed is " << rnd.get_seed() << std::endl; - std::cout << 2*hole_n << " holes of size " << hole_nv << std::endl; + auto generate_random_polygon = [&](CGAL::Random& rnd) -> Polygon_2 + { + typedef CGAL::Random_points_in_square_2 Point_generator; - std::vector > weights(1); + Polygon_2 poly; + CGAL::random_polygon_2(hole_nv, std::back_inserter(poly), Point_generator(0.25, rnd)); + return poly; + }; // each hole is in a square of size 1 std::vector ob = { Point_2(-hole_n-1, -0.5), @@ -71,6 +61,8 @@ int main(int argc, char** argv) std::cout << "pwh.outer_boundary() = " << pwh.outer_boundary() << std::endl; + std::vector > weights(1); + // tiny weight (far-reaching) for vertical sides weights[0].push_back(rnd.get_double(0.05, 0.5)); weights[0].push_back(rnd.get_double(1, 10)); @@ -118,33 +110,49 @@ int main(int argc, char** argv) std::cout << std::endl; } -// CGAL::draw(pwh); // @tmp remove draw() calls - - auto ss_ptr = CGAL::create_interior_weighted_straight_skeleton_2(pwh, weights, K()); +// CGAL::draw(pwh); + Straight_skeleton_2_ptr ss_ptr = CGAL::create_interior_weighted_straight_skeleton_2(pwh, weights, K()); + assert(ss_ptr); if(!ss_ptr) { std::cerr << "Error: failed to create straight skeleton" << std::endl; - return EXIT_FAILURE; + return; } // CGAL::draw(*ss_ptr); - auto offsets = CGAL::create_interior_weighted_skeleton_and_offset_polygons_with_holes_2(FT(0.1), pwh, weights); - CGAL_USE(offsets); - Mesh sm; bool success = extrude_skeleton(pwh, sm, CGAL::parameters::weights(weights)); - + assert(success); if(!success) { std::cerr << "Error: failed to extrude skeleton" << std::endl; - return EXIT_FAILURE; + return; } std::cout << num_vertices(sm) << " vertices and " << num_faces(sm) << " faces" << std::endl; // CGAL::draw(sm); +} + +int main(int argc, char** argv) +{ + std::cout.precision(17); + std::cerr.precision(17); + + int hole_n = (argc > 1) ? std::atoi(argv[1]) : 2; + int hole_nv = (argc > 2) ? std::atoi(argv[2]) : 10; + int seed = (argc > 3) ? std::atoi(argv[3]) : std::time(nullptr); + + CGAL::Random rnd(seed); + + std::cout << "Seed is " << rnd.get_seed() << std::endl; + std::cout << 2*hole_n << " holes of size " << hole_nv << std::endl; + + test_kernel(hole_n, hole_nv, rnd); + test_kernel(hole_n, hole_nv, rnd); + test_kernel(hole_n, hole_nv, rnd); return EXIT_SUCCESS; }