Merge remote-tracking branch 'cgal/6.0.x-branch' into master

This commit is contained in:
Sébastien Loriot 2025-02-05 08:42:33 +01:00
commit a6eff02a62
30 changed files with 1097 additions and 755 deletions

View File

@ -627,6 +627,7 @@ public:
out << "SweepStatus:\n";
typename SweepStatus::iterator sit3;
for( sit3 = YS.begin(); *sit3 != &sh; ++sit3 ) {
if (*sit3==&sl) continue;
int b = orientation(sit3, p_sweep);
if(*sit3 == &sl) out << " 1";
else if(*sit3 == &sh) out <<"-1";

View File

@ -402,9 +402,9 @@ class Infimaximal_box<Tag_true, Kernel> {
typename SNC_structure::Vertex_const_iterator v;
CGAL_forall_vertices(v, snc) {
Point_3 p(v->point());
if(p.hx()[0] > eval) eval = p.hx()[0];
if(p.hy()[0] > eval) eval = p.hy()[0];
if(p.hz()[0] > eval) eval = p.hz()[0];
if(abs(p.hx()[0]) > eval) eval = abs(p.hx()[0]);
if(abs(p.hy()[0]) > eval) eval = abs(p.hy()[0]);
if(abs(p.hz()[0]) > eval) eval = abs(p.hz()[0]);
}
eval *= 4;
if(eval == 0) return 1;

View File

@ -517,7 +517,7 @@ Node_handle build_kdtree(Vertex_list& V, Halfedge_list& E, Halffacet_list& F,
int coord = depth%3;
Point_3 point_on_plane = find_median_point(V, coord);
CGAL_NEF_TRACEN("build_kdtree: plane: "<<partition_plane<< " " << point_on_plane);
// CGAL_NEF_TRACEN("build_kdtree: plane: "<<partition_plane<< " " << point_on_plane);
#ifdef CGAL_NEF_EXPLOIT_REFERENCE_COUNTING
Side_of_plane sop(point_on_plane, coord, reference_counted);

View File

@ -473,7 +473,7 @@ public:
CGAL_forall_iterators(it,M4) {
// progress++;
it->second.sort(Halfedge_key_lt());
CGAL_NEF_TRACEN("search opposite "<<it->first);
CGAL_NEF_TRACEN("search opposite (M4) "<<it->first);
typename Halfedge_list::iterator itl;
CGAL_forall_iterators(itl,it->second) {
Halfedge_handle e1 = itl->e;
@ -482,7 +482,7 @@ public:
Halfedge_handle e2 = itl->e;
CGAL_NEF_TRACEN(" " << e1->source()->point()
<< " -> " << e2->source()->point());
CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector());
CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector());
make_twins(e1,e2);
CGAL_assertion(e1->mark()==e2->mark());
@ -493,7 +493,7 @@ public:
CGAL_forall_iterators(it,M3) {
// progress++;
it->second.sort(Halfedge_key_lt());
CGAL_NEF_TRACEN("search opposite "<<it->first);
CGAL_NEF_TRACEN("search opposite (M3) "<<it->first);
typename Halfedge_list::iterator itl;
CGAL_forall_iterators(itl,it->second) {
Halfedge_handle e1 = itl->e;
@ -502,7 +502,7 @@ public:
Halfedge_handle e2 = itl->e;
CGAL_NEF_TRACEN(" " << e1->source()->point()
<< " -> " << e2->source()->point());
CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector());
CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector());
make_twins(e1,e2);
CGAL_assertion(e1->mark()==e2->mark());
@ -513,7 +513,7 @@ public:
CGAL_forall_iterators(it,M2) {
// progress++;
it->second.sort(Halfedge_key_lt());
CGAL_NEF_TRACEN("search opposite "<<it->first);
CGAL_NEF_TRACEN("search opposite (M2) "<<it->first);
typename Halfedge_list::iterator itl;
CGAL_forall_iterators(itl,it->second) {
Halfedge_handle e1 = itl->e;
@ -522,7 +522,7 @@ public:
Halfedge_handle e2 = itl->e;
CGAL_NEF_TRACEN(" " << e1->source()->point()
<< " -> " << e2->source()->point());
CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector());
CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector());
make_twins(e1,e2);
CGAL_assertion(e1->mark()==e2->mark());
@ -533,7 +533,7 @@ public:
CGAL_forall_iterators(it,M) {
// progress++;
it->second.sort(Halfedge_key_lt());
CGAL_NEF_TRACEN("search opposite "<<it->first);
CGAL_NEF_TRACEN("search opposite (M) "<<it->first);
typename Halfedge_list::iterator itl;
CGAL_forall_iterators(itl,it->second) {
Halfedge_handle e1 = itl->e;
@ -542,7 +542,7 @@ public:
Halfedge_handle e2 = itl->e;
CGAL_NEF_TRACEN(" " << e1->source()->point()
<< " -> " << e2->source()->point());
CGAL_NEF_TRACEN(e1->vector()<<" -> "<< -e2->vector());
CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<< -e2->vector());
CGAL_assertion(e1->source()->point() != e2->source()->point());
CGAL_assertion(e1->mark()==e2->mark());
make_twins(e1,e2);
@ -585,10 +585,16 @@ public:
break;
} else
#endif
CGAL_assertion_code(bool found = false;)
CGAL_For_all(cet,cete)
if ( cet->circle() == ce->circle().opposite() &&
cet->source()->twin() == ce->source() )
{
CGAL_assertion_code(found = true;)
break;
}
CGAL_assertion(found);
#ifdef CGAL_USE_TRACE
if( cet->circle() != ce->circle().opposite() )

View File

@ -139,7 +139,7 @@ class SNC_intersection {
if( !CGAL::assign( p, o))
return false;
CGAL_NEF_TRACEN( "-> intersection point: " << p );
CGAL_NEF_TRACEN( "-> point in facet interior? "<<point_in_facet_interior( f, p));
// CGAL_NEF_TRACEN( "-> point in facet interior? "<<point_in_facet_interior( f, p));
return point_in_facet_interior( p, f);
}
@ -159,7 +159,7 @@ class SNC_intersection {
if( !CGAL::assign( p, o))
return false;
CGAL_NEF_TRACEN( "-> intersection point: " << p );
CGAL_NEF_TRACEN( "-> point in facet interior? "<<point_in_facet_interior( f, p));
// CGAL_NEF_TRACEN( "-> point in facet interior? "<<point_in_facet_interior( f, p));
return point_in_facet_interior( p, f);
}

View File

@ -432,7 +432,7 @@ public:
e = *ei;
CGAL_NEF_TRACEN("test edge " << e->source()->point() << "->" << e->twin()->source()->point());
if (SNC_intersection::does_contain_internally(e->source()->point(), e->twin()->source()->point(), p)) {
_CGAL_NEF_TRACEN("found on edge "<< ss);
// _CGAL_NEF_TRACEN("found on edge "<< ss);
return make_object(e);
}
if((e->source() != v) && (e->twin()->source() != v) &&
@ -557,7 +557,7 @@ private:
if(SNC_intersection::does_intersect_internally( s, *f, q) ) {
q = normalized(q);
call_back( e0, *f, q);
_CGAL_NEF_TRACEN("edge intersects facet on plane "<<f->plane()<<" on "<<q);
// _CGAL_NEF_TRACEN("edge intersects facet on plane "<<f->plane()<<" on "<<q);
}
visited[*f] = true;
}

View File

@ -0,0 +1,18 @@
#include <CGAL/Extended_cartesian.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/Nef_polyhedron_3.h>
using Kernel = CGAL::Extended_cartesian<CGAL::Exact_rational>;
using Nef = CGAL::Nef_polyhedron_3<Kernel>;
int main()
{
Nef hspace_1(Nef::Plane_3(1.0, 0.0, 0.0, 0.0), Nef::INCLUDED);
Nef hspace_2(Nef::Plane_3(1.0, 0.0, 0.0, 1.0), Nef::INCLUDED);
Nef hspace_3(Nef::Plane_3(0.0, 0.0, 1.0, 1.0), Nef::INCLUDED);
Nef intersection_1 = hspace_1*hspace_2;
Nef intersection_2 = hspace_2*hspace_3;
return 0;
}

View File

@ -190,7 +190,7 @@ Straight_skeleton_builder_2& enter_contour( InputPointIterator aBegin, InputPoin
/*!
defines the <I>weights</I> 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.

View File

@ -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<OfK>` 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<SsK>`.
\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<OfK>` for constructing the offset polygons.
\note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2<OfK>`.
@ -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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`).
\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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` for constructing the straight skeleton.
\note If `SsK != OfK` the constructed straight skeleton is converted to `CGAL::Straight_skeleton_2<OfK>`.
@ -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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\tparam OfK must be a model of `Kernel`. It is used to instantiate
`Polygon_offset_builder_traits_2<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
\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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\tparam OfK must be a model of `Kernel`. It is used to instantiate
`Polygon_offset_builder_traits_2<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
\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()`

View File

@ -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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\tparam OfK must be a model of `Kernel`. It is used to instantiate
`Polygon_offset_builder_traits_2<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
@ -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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\tparam OfK must be a model of `Kernel`. It is used to instantiate
`Polygon_offset_builder_traits_2<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.

View File

@ -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 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<InK>`).
\tparam HoleIterator must be a model of `InputIterator` with value type being a model of `ConstRange`
with value type `SsK::Point_2`.
\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 OfK must be a model of `Kernel`. It is used to instantiate
`Polygon_offset_builder_traits_2<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`).
\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`
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<OfK>`.
@ -45,9 +45,9 @@ template <typename OfKPolygon, typename FT, typename InKPolygon, typename InKWei
std::vector< std::shared_ptr<OfKPolygon> >
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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
@ -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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
\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()`

View File

@ -1,22 +1,23 @@
namespace CGAL {
/*!
\ingroup PkgStraightSkeleton2OffsetFunctions
\ingroup PkgStraightSkeleton2WeightedOffsetFunctions
\brief returns a container with all the inner offset polygons <I>with holes</I> 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
@ -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 <I>with holes</I>
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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>` for constructing the offset polygons.
\tparam SsK must be a model of `Kernel`. It is used to instantiate
`Straight_skeleton_builder_traits_2<SsK>` 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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<OfK>`.
@ -65,7 +67,9 @@ having reversed the orientation of all other polygons.
template<class OfKPolygon, class FT, class InKPolygon, class OfK, class SsK>
std::vector<std::shared_ptr<OfKPolygon> >
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());

View File

@ -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<InK>`),
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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<InK>`)
or a model of `GeneralPolygonWithHoles_2` (e.g. `Polygon_with_holes_2<InK>`).
\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.

View File

@ -17,6 +17,8 @@
#include <CGAL/Straight_skeleton_2/debug.h>
#include <CGAL/Straight_skeleton_2/test.h>
#include <CGAL/Default.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <boost/mpl/has_xxx.hpp>
@ -193,8 +195,8 @@ struct Default_return_polygon_type // Polygon type supports holes
typename Kernel_traits<typename boost::range_value<
typename Polygon::Polygon_2>::type>::Kernel,
OfK>::value,
typename Polygon::Polygon_2, // correct kernel
CGAL::Polygon_2<OfK> /*incorrect kernel*/ >::type type;
typename Polygon::Polygon_2, // same kernel
CGAL::Polygon_2<OfK> /*different kernel*/ >::type type;
};
template <typename Polygon, typename OfK>
@ -203,10 +205,14 @@ struct Default_return_polygon_type<Polygon, OfK, false> // Polygon type does NOT
typedef typename std::conditional<std::is_same<
typename Kernel_traits<typename boost::range_value<Polygon>::type>::Kernel,
OfK>::value,
Polygon, // correct kernel
CGAL::Polygon_2<OfK> /*incorrect kernel*/ >::type type;
Polygon, // same kernel
CGAL::Polygon_2<OfK> /*different kernel*/ >::type type;
};
template <typename OfKPolygon, typename InKPolygon, typename OfK>
using Polygon_return_type = typename CGAL::Default::Get<OfKPolygon,
typename Default_return_polygon_type<InKPolygon, OfK>::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, OfK, false> // Polygon ty
CGAL::Polygon_with_holes_2<OfK> /*incorrect kernel*/ >::type type;
};
template <typename OfKPolygon, typename InKPolygon, typename OfK>
using Polygon_with_holes_return_type = typename CGAL::Default::Get<OfKPolygon,
typename Default_return_polygon_with_holes_type<InKPolygon, OfK>::type>::type;
} // namespace CGAL_SS_i
} // namespace CGAL

View File

@ -1454,10 +1454,10 @@ public:
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;

View File

@ -20,11 +20,11 @@
#include <CGAL/Polygon_with_holes_2.h>
#include <boost/range/value_type.hpp>
#include <memory>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
#include <vector>
namespace CGAL {
@ -48,7 +48,9 @@ bool arrange_offset_polygons_2 ( InputPolygonPtrIterator aBegin
{
typedef typename std::iterator_traits<InputPolygonPtrIterator>::difference_type difference_type ;
typedef typename std::iterator_traits<InputPolygonPtrIterator>::value_type PolygonPtr ;
typedef typename Kernel_traits<typename boost::range_value<typename PolygonPtr::element_type>::type>::Kernel OfK;
typedef typename PolygonWithHoles::Polygon_2 Inner_polygon;
typedef std::shared_ptr<PolygonWithHoles> 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<PolygonWithHoles>(
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)));
}
}

View File

@ -24,9 +24,8 @@
#include <CGAL/assertions.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Default.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/tags.h>
#include <optional>
@ -129,7 +128,7 @@ create_partial_exterior_straight_skeleton_2 ( FT const& aMaxOffset
std::vector<Hole> 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<class OutPolygon, class FT, class Skeleton, class K>
std::vector< std::shared_ptr<OutPolygon> >
create_offset_polygons_2 ( FT const& aOffset, Skeleton const& aSs, K const& , Tag_false )
{
typedef std::shared_ptr<OutPolygon> OutPolygonPtr ;
static_assert(!(std::is_same<OutPolygon, CGAL::Default>::value));
typedef std::shared_ptr<OutPolygon> OutPolygonPtr ;
typedef std::vector<OutPolygonPtr> OutPolygonPtrVector ;
typedef Straight_skeleton_2<K> OfSkeleton ;
@ -166,16 +167,18 @@ template<class OutPolygon, class FT, class Skeleton, class K>
std::vector< std::shared_ptr<OutPolygon> >
create_offset_polygons_2 ( FT const& aOffset, Skeleton const& aSs, K const& /*k*/, Tag_true )
{
typedef std::shared_ptr<OutPolygon> OutPolygonPtr ;
static_assert(!(std::is_same<OutPolygon, CGAL::Default>::value));
typedef std::shared_ptr<OutPolygon> OutPolygonPtr ;
typedef std::vector<OutPolygonPtr> OutPolygonPtrVector ;
typedef Polygon_offset_builder_traits_2<K> OffsetBuilderTraits;
typedef Polygon_offset_builder_2<Skeleton,OffsetBuilderTraits,OutPolygon> 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<Skeleton> const& ss )
} // namespace CGAL_SS_i
template<class OutPolygon, class FT, class Skeleton, class K>
std::vector< std::shared_ptr<OutPolygon> >
template<class OutPolygon, class FT, class Skeleton,
class K = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<OutPolygon> >
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<K, typename Skeleton::Traits>::type same_kernel;
return CGAL_SS_i::create_offset_polygons_2<OutPolygon>(aOffset, aSs, k, same_kernel);
}
template<class Polygon = Polygon_2<Exact_predicates_inexact_constructions_kernel>,
class FT, class Skeleton>
std::vector< std::shared_ptr<Polygon> >
inline
create_offset_polygons_2(const FT& aOffset,
const Skeleton& aSs)
{
return create_offset_polygons_2<Polygon>(aOffset, aSs, Exact_predicates_inexact_constructions_kernel());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/// INTERIOR
template<class FT, class APolygon, class HoleIterator, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon, class HoleIterator,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<CGAL::is_iterator<HoleIterator>::value>* = 0)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK>;
return create_offset_polygons_2<OutPolygon>(
aOffset,
CGAL_SS_i::dereference(
@ -240,63 +239,26 @@ create_interior_skeleton_and_offset_polygons_2(const FT& aOffset,
ofk);
}
template<class FT, class APolygon, class HoleIterator, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
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<class FT, class APolygon, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
// Overload where APolygon is a simple polygon (no holes)
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<APolygon>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK>;
std::vector<APolygon> 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<class FT, class APolygon, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygon> >
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());
}
template<class FT, class APolygon,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<
APolygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygon> >
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());
return create_interior_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class APolygon, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<APolygon>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK>;
return create_offset_polygons_2<OutPolygon>(
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<class FT, class APolygon, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
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<class FT, class APolygon,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<
APolygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector< std::shared_ptr<OutPolygon> >
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

View File

@ -14,10 +14,9 @@
#include <CGAL/license/Straight_skeleton_2.h>
#include <CGAL/Straight_skeleton_2/Straight_skeleton_aux.h>
#include <CGAL/arrange_offset_polygons_2.h>
#include <CGAL/create_offset_polygons_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -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<class FT, class PolygonWithHoles, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<PolygonWithHoles, OfK>::type> // Hole-less polygon type
std::vector<std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class PolygonWithHoles,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK> > >
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<PolygonWithHoles>::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<OutPolygon_, PolygonWithHoles, OfK>;
return create_interior_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class Polygon, class OfK, class SsK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
// 'Polygon' might be a polygon with holes or not, but it returns a polygon with holes
template <class OutPolygonWithHoles_ = CGAL::Default,
class FT, class Polygon,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK> > >
inline
create_interior_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())
{
using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<Polygon, OfK>::type;
using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK>;
return arrange_offset_polygons_2<OutPolygonWithHoles>(
create_interior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk));
}
template<class FT, class Polygon, class OfK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
inline
create_interior_skeleton_and_offset_polygons_with_holes_2(const FT& aOffset,
const Polygon& aPoly,
const OfK& ofk)
{
return create_interior_skeleton_and_offset_polygons_with_holes_2(aOffset, aPoly, ofk,
Exact_predicates_inexact_constructions_kernel());
}
template<class FT, class Polygon,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<
Polygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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());
create_interior_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class Polygon, class OfK, class SsK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
template <class OutPolygonWithHoles_ = CGAL::Default,
class FT, class Polygon,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK> > >
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<Polygon, OfK>::type Polygon_;
std::vector<std::shared_ptr<Polygon_> > raw_output =
create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly, ofk, ssk);
using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<Polygon, OfK>::type;
using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK>;
std::vector<std::shared_ptr<OutPolygon> > raw_output =
create_exterior_skeleton_and_offset_polygons_2<OutPolygon>(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<Polygon_> ptr : raw_output)
ptr->reverse_orientation();
for (std::shared_ptr<OutPolygon> 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<OutPolygonWithHoles>(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<class FT, class PolygonWithHoles, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<PolygonWithHoles, OfK>::type>
std::vector<std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class PolygonWithHoles,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK> > >
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<PolygonWithHoles>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK>;
std::vector<std::shared_ptr<OutPolygon> > polygons =
create_exterior_skeleton_and_offset_polygons_2(aOffset, aPoly.outer_boundary(), ofk, ssk);
create_exterior_skeleton_and_offset_polygons_2<OutPolygon>(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<std::shared_ptr<OutPolygon> > hole_polygons =
create_interior_skeleton_and_offset_polygons_2(aOffset,
hole,
ofk,ssk);
create_interior_skeleton_and_offset_polygons_2<OutPolygon>(aOffset,
hole,
ofk, ssk);
polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end());
}
return polygons;
}
template<class FT, class Polygon, class OfK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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<class FT, class Polygon,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<
Polygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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

View File

@ -32,14 +32,14 @@
namespace CGAL {
template<class PointIterator, class HoleIterator, class K>
template<class PointIterator, class HoleIterator,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
, PointIterator aOuterContour_VerticesEnd
, HoleIterator aHolesBegin
, HoleIterator aHolesEnd
, K const&
)
, const K& = K())
{
typedef Straight_skeleton_2<K> Ss ;
@ -62,30 +62,13 @@ create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
return ssb.construct_skeleton();
}
template<class PointIterator, class HoleIterator>
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<class PointIterator, class K>
template<class PointIterator,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
inline
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
, PointIterator aOuterContour_VerticesEnd
, K const& k
)
, const K& k = K())
{
typedef typename std::iterator_traits<PointIterator>::value_type InputPoint ;
typedef typename Kernel_traits<InputPoint>::Kernel InputKernel ;
@ -99,24 +82,12 @@ create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
);
}
template<class PointIterator>
std::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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<class Polygon, class K>
template<class Polygon,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
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<Polygon>::value>* = nullptr)
{
@ -126,26 +97,18 @@ create_interior_straight_skeleton_2 ( Polygon const& aOutContour,
);
}
template<class Polygon>
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<class FT, class PointIterator, class K>
template<class FT, class PointIterator,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
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<class FT, class PointIterator>
std::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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<class FT, class Polygon, class K>
template<class FT, class Polygon,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
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<class FT, class Polygon>
std::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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

View File

@ -26,11 +26,12 @@
namespace CGAL {
template<class K, class Polygon>
template<class Polygon,
class K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
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<Polygon>::value>* = nullptr)
{

View File

@ -26,8 +26,6 @@
#include <CGAL/assertions.h>
#include <CGAL/Cartesian_converter.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/tags.h>
#include <boost/range/value_type.hpp>
@ -127,6 +125,8 @@ create_partial_exterior_weighted_straight_skeleton_2(const FT& aMaxOffset,
typedef typename Kernel_traits<Point_2>::Kernel IK;
typedef typename IK::FT IFT;
static_assert((std::is_same<typename std::iterator_traits<WeightIterator>::value_type, IFT>::value));
std::shared_ptr<Straight_skeleton_2<K> > 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<FT> lFrameWeights(4, frame_weight);
std::vector<std::vector<FT> > lHoleWeights;
std::vector<IFT> lFrameWeights(4, frame_weight);
std::vector<std::vector<IFT> > 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<class FT, class APolygon, class HoleIterator, class Weights, class HoleWeightsIterator,
class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon, class HoleIterator, class Weights, class HoleWeightsIterator,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<OutPolygon_, APolygon, OfK>;
if(aHolesBegin == aHolesEnd) // see @partial_wsls_pwh
{
return create_offset_polygons_2<OutPolygon>(
@ -252,69 +255,33 @@ create_interior_weighted_skeleton_and_offset_polygons_2(const FT& aOffset,
}
}
template<class FT, class APolygon, class HoleIterator, class Weights, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
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<class FT, class APolygon, class Weights, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<APolygon>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK>;
using IFT = typename boost::range_value<typename boost::range_value<Weights>::type>::type;
std::vector<APolygon> no_holes;
return create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly,
no_holes.begin(), no_holes.end(),
aWeights,
ofk, ssk);
}
std::vector<std::vector<IFT> > no_hole_weights;
// Overloads common to both polygons with and without holes, a simple polygon is returned in any case
template<class FT, class APolygon, class Weights, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygon> >
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());
}
template<class FT, class APolygon, class Weights,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<
APolygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygon> >
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());
return create_interior_weighted_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class APolygon, class Weights, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class APolygon, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK> > >
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<APolygon>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, APolygon, OfK>;
return create_offset_polygons_2<OutPolygon>(
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<class FT, class APolygon, class Weights, class OfK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<APolygon, OfK>::type>
std::vector< std::shared_ptr<OutPolygon> >
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<class FT, class APolygon, class Weights,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<
APolygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector< std::shared_ptr<OutPolygon> >
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

View File

@ -14,10 +14,9 @@
#include <CGAL/license/Straight_skeleton_2.h>
#include <CGAL/Straight_skeleton_2/Straight_skeleton_aux.h>
#include <CGAL/arrange_offset_polygons_2.h>
#include <CGAL/create_offset_polygons_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/create_weighted_offset_polygons_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -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<class FT, class PolygonWithHoles, class Weights, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<PolygonWithHoles, OfK>::type> // Hole-less polygon type
std::vector<std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default, // Hole-less polygon type
class FT, class PolygonWithHoles, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK> > >
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<PolygonWithHoles>::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<OutPolygon_, PolygonWithHoles, OfK>;
return create_interior_weighted_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class Polygon, class Weights, class OfK, class SsK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
template <class OutPolygonWithHoles_ = CGAL::Default,
class FT, class Polygon, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK> > >
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())
{
using OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<Polygon, OfK>::type;
using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK>;
return arrange_offset_polygons_2<OutPolygonWithHoles>(
create_interior_weighted_skeleton_and_offset_polygons_2(aOffset, aPoly, aWeights, ofk, ssk));
}
template<class FT, class Polygon, class Weights, class OfK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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<class FT, class Polygon, class Weights,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<
Polygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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());
create_interior_weighted_skeleton_and_offset_polygons_2<OutPolygon>(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<class FT, class Polygon, class Weights, class OfK, class SsK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
template <class OutPolygonWithHoles_ = CGAL::Default,
class FT, class Polygon, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK> > >
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<Polygon, OfK>::type Polygon_;
std::vector<std::shared_ptr<Polygon_> > 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<Polygon, OfK>::type;
using OutPolygonWithHoles = CGAL_SS_i::Polygon_with_holes_return_type<OutPolygonWithHoles_, Polygon, OfK>;
std::vector<std::shared_ptr<OutPolygon> > raw_output =
create_exterior_weighted_skeleton_and_offset_polygons_2<OutPolygon>(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<Polygon_> ptr : raw_output)
ptr->reverse_orientation();
for (std::shared_ptr<OutPolygon> 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<OutPolygonWithHoles>(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<class FT, class PolygonWithHoles, class Weights, class OfK, class SsK,
class OutPolygon = typename CGAL_SS_i::Default_return_polygon_type<PolygonWithHoles, OfK>::type>
std::vector<std::shared_ptr<OutPolygon> >
template <class OutPolygon_ = CGAL::Default,
class FT, class PolygonWithHoles, class Weights,
class OfK = Exact_predicates_inexact_constructions_kernel,
class SsK = Exact_predicates_inexact_constructions_kernel>
std::vector<std::shared_ptr<CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK> > >
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<PolygonWithHoles>::value>* = nullptr)
{
using OutPolygon = CGAL_SS_i::Polygon_return_type<OutPolygon_, PolygonWithHoles, OfK>;
CGAL_precondition(aWeights.size() == aPoly.number_of_holes() + 1);
std::vector<std::shared_ptr<OutPolygon> > 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<OutPolygon>(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<std::shared_ptr<OutPolygon> > hole_polygons =
create_interior_skeleton_and_offset_polygons_2(aOffset,
hole,
{aWeights[weight_pos]},
ofk, ssk);
create_interior_weighted_skeleton_and_offset_polygons_2<OutPolygon>(aOffset,
hole,
Weights{aWeights[weight_pos]},
ofk, ssk);
polygons.insert(polygons.end(), hole_polygons.begin(), hole_polygons.end());
}
return polygons;
}
template<class FT, class Polygon, class Weights, class OfK,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<Polygon, OfK>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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<class FT, class Polygon, class Weights,
class OutPolygonWithHoles = typename CGAL_SS_i::Default_return_polygon_with_holes_type<
Polygon, Exact_predicates_inexact_constructions_kernel>::type>
std::vector<std::shared_ptr<OutPolygonWithHoles> >
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

View File

@ -26,13 +26,14 @@
#include <memory>
#include <algorithm>
#include <iterator>
#include <type_traits>
#include <vector>
namespace CGAL {
template <typename PointIterator, typename HoleIterator,
typename WeightIterator, typename HoleWeightsIterator,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr<Straight_skeleton_2<K> >
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<K>;
@ -76,37 +77,16 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice
return ssb.construct_skeleton();
}
template <typename PointIterator, typename HoleIterator,
typename WeightIterator, typename HoleWeightsIterator,
typename Weights>
std::shared_ptr<Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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 PointIterator,
typename WeightIterator,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr<Straight_skeleton_2<K> >
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<PointIterator>::value_type;
using InputKernel = typename Kernel_traits<InputPoint>::Kernel;
@ -126,51 +106,23 @@ create_interior_weighted_straight_skeleton_2(PointIterator outer_contour_vertice
k);
}
template <typename PointIterator,
typename WeightIterator>
std::shared_ptr<Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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 Polygon,
typename Weights,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr<Straight_skeleton_2<K> >
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<! CGAL_SS_i::has_Hole_const_iterator<Polygon>::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 <typename Polygon,
typename Weights>
std::shared_ptr<Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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 FT,
typename PointIterator,
typename WeightIterator,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr<Straight_skeleton_2<K> >
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<Point_2>::Kernel;
using IFT = typename IK::FT;
static_assert((std::is_same<typename std::iterator_traits<WeightIterator>::value_type, IFT>::value));
std::shared_ptr<Straight_skeleton_2<K> > 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<FT> lFrameWeights(4, frame_weight);
std::vector<std::vector<FT> > lHoleWeights;
std::vector<IFT> lFrameWeights(4, frame_weight);
std::vector<std::vector<IFT> > 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 <typename FT,
typename PointIterator,
typename WeightIterator>
std::shared_ptr<Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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 FT,
typename Polygon,
typename Weights,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr<Straight_skeleton_2<K> >
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 <typename FT,
typename Weights,
typename Polygon>
std::shared_ptr<Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
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

View File

@ -26,12 +26,12 @@ namespace CGAL {
template <typename Polygon,
typename Weights,
typename K>
typename K = Exact_predicates_inexact_constructions_kernel>
std::shared_ptr< Straight_skeleton_2<K> >
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<Polygon>::value>* = nullptr)
{

View File

@ -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("issue7284.cpp")
create_single_source_cgal_program("test_sls_simple.cpp")
create_single_source_cgal_program("test_sls_weighted_polygons_with_holes.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")
if(CGAL_Qt6_FOUND)
target_link_libraries(issue7149 PRIVATE CGAL::CGAL_Basic_viewer)
target_link_libraries(issue7284 PRIVATE CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_offset PRIVATE CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_weighted_offset PRIVATE CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_weighted_polygons PRIVATE CGAL::CGAL_Basic_viewer)
target_link_libraries(test_sls_weighted_polygons_with_holes PRIVATE CGAL::CGAL_Basic_viewer)
endif()
else()
message("NOTICE: Some test require CGAL_Core (or LEDA), and will not be compiled.")
endif()

View File

@ -22,10 +22,13 @@
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <CGAL/Timer.h>
#include <memory>
#include <CGAL/use.h>
#include <boost/shared_ptr.hpp>
#include <cassert>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
@ -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<typename K>
class Test_polygon_2 : public CGAL::Polygon_2<K> {
typedef CGAL::Polygon_2<K> Base;
Test_polygon_2(const Base&);
public:
using Base::Base;
};
template<typename K>
class Test_polygon_with_holes_2 : public CGAL::Polygon_with_holes_2<K> {
typedef CGAL::Polygon_with_holes_2<K> Base;
Test_polygon_with_holes_2(const Base&);
public:
using Base::Base;
};
} // namespace CGAL
using namespace CGAL;
template <typename K>
void test_API()
{
typedef typename K::FT FT;
typedef typename K::Point_2 Point_2;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
typedef CGAL::Polygon_2<EPICK> Polygon_2_EPICK;
typedef CGAL::Polygon_with_holes_2<EPICK> Polygon_with_holes_2_EPICK;
typedef CGAL::Test_polygon_2<K> Test_Polygon_2;
typedef CGAL::Test_polygon_with_holes_2<K> Test_Polygon_with_holes_2;
typedef CGAL::Test_polygon_2<EPICK> Test_Polygon_2_EPICK;
typedef CGAL::Test_polygon_with_holes_2<EPICK> Test_Polygon_with_holes_2_EPICK;
std::vector<Point_2> v;
Polygon_2 p;
Polygon_with_holes_2 pwh;
std::vector< std::shared_ptr<Polygon_2> > res;
std::vector< std::shared_ptr<Polygon_2_EPICK> > res_EPICK;
std::vector< std::shared_ptr<Polygon_with_holes_2> > res_w;
std::vector< std::shared_ptr<Polygon_with_holes_2_EPICK> > res_w_EPICK;
std::vector< std::shared_ptr<Polygon_with_holes_2> > res_wh;
std::vector< std::shared_ptr<Polygon_with_holes_2_EPICK> > res_wh_EPICK;
std::vector< std::shared_ptr<Test_Polygon_2> > res_test;
std::vector< std::shared_ptr<Test_Polygon_2_EPICK> > res_test_EPICK;
std::vector< std::shared_ptr<Test_Polygon_with_holes_2> > res_wh_test;
std::vector< std::shared_ptr<Test_Polygon_with_holes_2_EPICK> > 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<Polygon_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_EPICK = create_interior_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, p, K(), EPICK()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, K(), EPICK()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(0.1, p, K(), K()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, K(), K()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, EPICK(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, p, K(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2>(FT(0.1), p, K(), K()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, EPICK(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, v, K(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_EPICK = create_interior_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, pwh, K(), EPICK()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, K(), EPICK()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(0.1, pwh, K(), K()) ;
res = create_interior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, K(), K()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, EPICK(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, pwh, K(), K()) ;
res_test = create_interior_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_EPICK = create_exterior_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, p, K(), EPICK()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, K(), EPICK()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(0.1, p, K(), K()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, K(), K()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, EPICK(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, p, K(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2>(FT(0.1), p, K(), K()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, EPICK(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, v, K(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_EPICK = create_exterior_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, pwh, K(), EPICK()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, K(), EPICK()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(0.1, pwh, K(), K()) ;
res = create_exterior_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, K(), K()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, EPICK(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, pwh, K(), K()) ;
res_test = create_exterior_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, p, K(), EPICK()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, K(), EPICK()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, p, K(), K()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, K(), K()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, p, K(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), p, K(), K()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, EPICK(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, v, K(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_wh_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, pwh, K(), EPICK()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, K(), EPICK()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, pwh, K(), K()) ;
res_wh = create_interior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, K(), K()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, pwh, K(), K()) ;
res_wh_test = create_interior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, p, K(), EPICK()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, K(), EPICK()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, p, K(), K()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, K(), K()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, EPICK(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, p, K(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), p, K(), K()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, EPICK(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, v, K(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_wh_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, pwh, K(), K()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, K(), EPICK()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, pwh, K(), K()) ;
res_wh = create_exterior_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, K(), K()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, EPICK(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, pwh, K(), K()) ;
res_wh_test = create_exterior_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), pwh, K(), K()) ;
}
template <typename K, typename StraightSkeleton>
@ -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<K>();
#endif
void (*dummy_ptr)() = &test_API<K>;
CGAL_USE(dummy_ptr);
// Artificial data
test_offset_square<K>();

View File

@ -34,10 +34,13 @@ void Straight_skeleton_traits_external_trace(std::string m)
#include <CGAL/Polygon_2.h>
#include <CGAL/draw_polygon_2.h>
#include <memory>
#include <CGAL/use.h>
#include <boost/shared_ptr.hpp>
#include <cassert>
#include <iostream>
#include <memory>
#include <set>
#include <string>
#include <vector>
@ -221,9 +224,8 @@ void test_kernel()
{
// CGAL_STSKEL_TRAITS_ENABLE_TRACE
#ifndef CGAL_SLS_TEST_SPEED_THINGS_UP_FOR_THE_TESTSUITE
// test_API<K>();
#endif
void (*dummy_ptr)() = &test_API<K>;
CGAL_USE(dummy_ptr);
test_skeleton<K>("data/pseudo_split_0.poly", 13, 40, 8);
test_skeleton<K>("data/pseudo_split_1.poly", 21, 68, 12);

View File

@ -0,0 +1,291 @@
#define CGAL_SLS_TEST_SPEED_THINGS_UP_FOR_THE_TESTSUITE
#define CGAL_ENABLE_DISABLE_ASSERTIONS_AT_RUNTIME
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
#include <CGAL/create_weighted_offset_polygons_2.h>
#include <CGAL/create_weighted_offset_polygons_from_polygon_with_holes_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <CGAL/use.h>
#include <boost/shared_ptr.hpp>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
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<typename K>
class Test_polygon_2 : public CGAL::Polygon_2<K> {
typedef CGAL::Polygon_2<K> Base;
Test_polygon_2(const Base&);
public:
using Base::Base;
};
template<typename K>
class Test_polygon_with_holes_2 : public CGAL::Polygon_with_holes_2<K> {
typedef CGAL::Polygon_with_holes_2<K> Base;
Test_polygon_with_holes_2(const Base&);
public:
using Base::Base;
};
} // namespace CGAL
using namespace CGAL;
template <typename K>
void test_API()
{
typedef typename K::FT FT;
typedef typename K::Point_2 Point_2;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
typedef CGAL::Polygon_2<EPICK> Polygon_2_EPICK;
typedef CGAL::Polygon_with_holes_2<EPICK> Polygon_with_holes_2_EPICK;
typedef CGAL::Test_polygon_2<K> Test_Polygon_2;
typedef CGAL::Test_polygon_with_holes_2<K> Test_Polygon_with_holes_2;
typedef CGAL::Test_polygon_2<EPICK> Test_Polygon_2_EPICK;
typedef CGAL::Test_polygon_with_holes_2<EPICK> Test_Polygon_with_holes_2_EPICK;
std::vector<Point_2> v;
Polygon_2 p;
Polygon_with_holes_2 pwh;
std::vector<std::vector<FT> > weights;
std::vector<std::shared_ptr<Polygon_2> > res;
std::vector<std::shared_ptr<Polygon_2_EPICK> > res_EPICK;
std::vector<std::shared_ptr<Polygon_with_holes_2> > res_wh;
std::vector<std::shared_ptr<Polygon_with_holes_2_EPICK> > res_wh_EPICK;
std::vector<std::shared_ptr<Test_Polygon_2> > res_test;
std::vector<std::shared_ptr<Test_Polygon_2_EPICK> > res_test_EPICK;
std::vector<std::shared_ptr<Test_Polygon_with_holes_2> > res_wh_test;
std::vector<std::shared_ptr<Test_Polygon_with_holes_2_EPICK> > 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<Polygon_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, p, weights, K(), EPICK()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, weights, K(), EPICK()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(0.1, p, weights, K(), K()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, weights, K(), K()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, weights, EPICK(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, p, weights, K(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(FT(0.1), p, weights, K(), K()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, weights, EPICK(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, v, weights, K(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, pwh, weights, K(), EPICK()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, weights, K(), EPICK()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(0.1, pwh, weights, K(), K()) ;
res = create_interior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, weights, K(), K()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, pwh, weights, K(), K()) ;
res_test = create_interior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, p, weights, K(), EPICK()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, weights, K(), EPICK()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(0.1, p, weights, K(), K()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), p, weights, K(), K()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, p, weights, EPICK(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, p, weights, K(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(FT(0.1), p, weights, K(), K()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, v, weights, EPICK(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, v, weights, K(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2_EPICK>(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<Polygon_2>(0.1, pwh, weights, K(), EPICK()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, weights, K(), EPICK()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(0.1, pwh, weights, K(), K()) ;
res = create_exterior_weighted_skeleton_and_offset_polygons_2<Polygon_2>(FT(0.1), pwh, weights, K(), K()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2_EPICK>(0.1, pwh, weights, EPICK(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_2>(0.1, pwh, weights, K(), K()) ;
res_test = create_exterior_weighted_skeleton_and_offset_polygons_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, p, weights, K(), EPICK()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, weights, K(), EPICK()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, p, weights, K(), K()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, weights, K(), K()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, p, weights, K(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), p, weights, K(), K()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, weights, EPICK(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, v, weights, K(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_wh_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, pwh, weights, K(), EPICK()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, weights, K(), EPICK()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, pwh, weights, K(), K()) ;
res_wh = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, weights, K(), K()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, pwh, weights, K(), K()) ;
res_wh_test = create_interior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, p, weights, K(), EPICK()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, weights, K(), EPICK()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, p, weights, K(), K()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), p, weights, K(), K()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, p, weights, EPICK(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, p, weights, K(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), p, weights, K(), K()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, v, weights, EPICK(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, v, weights, K(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_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<Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_wh_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2_EPICK>(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<Polygon_with_holes_2>(0.1, pwh, weights, K(), K()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, weights, K(), EPICK()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(0.1, pwh, weights, K(), K()) ;
res_wh = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Polygon_with_holes_2>(FT(0.1), pwh, weights, K(), K()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), EPICK()) ;
res_wh_test_EPICK = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2_EPICK>(0.1, pwh, weights, EPICK(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(0.1, pwh, weights, K(), K()) ;
res_wh_test = create_exterior_weighted_skeleton_and_offset_polygons_with_holes_2<Test_Polygon_with_holes_2>(FT(0.1), pwh, weights, K(), K()) ;
}
template <typename K>
void test_kernel()
{
void (*dummy_ptr)() = &test_API<K>;
CGAL_USE(dummy_ptr);
}
int main(int, char**)
{
std::cout.precision(17);
std::cerr.precision(17);
test_kernel<EPICK>();
test_kernel<EPECK>();
test_kernel<EPECK_w_sqrt>();
std::cout << "Done!" << std::endl;
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,147 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <CGAL/draw_straight_skeleton_2.h>
#include <CGAL/draw_polygon_2.h>
#include <CGAL/draw_surface_mesh.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Random.h>
#include <CGAL/random_polygon_2.h>
#include <CGAL/create_weighted_straight_skeleton_2.h>
#include <CGAL/create_weighted_offset_polygons_2.h>
#include <CGAL/extrude_skeleton.h>
#include <CGAL/use.h>
#include <boost/shared_ptr.hpp>
#include <iostream>
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 <typename K>
void test_API()
{
typedef typename K::FT FT;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
typedef CGAL::Straight_skeleton_2<EPICK> Straight_skeleton_EPICK;
typedef std::shared_ptr<Straight_skeleton_EPICK> Straight_skeleton_Ptr_EPICK;
typedef CGAL::Straight_skeleton_2<K> Straight_skeleton;
typedef std::shared_ptr<Straight_skeleton> Straight_skeleton_Ptr;
std::vector<std::vector<FT> > 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 <typename K>
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<K>;
using Straight_skeleton_2 = CGAL::Straight_skeleton_2<K>;
using Straight_skeleton_2_ptr = std::shared_ptr<Straight_skeleton_2>;
using Mesh = CGAL::Surface_mesh<Point_3>;
void (*dummy_ptr)() = &test_API<K>;
CGAL_USE(dummy_ptr);
typedef CGAL::Random_points_in_square_2<Point_2> Point_generator;
Polygon_2 pol;
CGAL::random_polygon_2(polygon_nv, std::back_inserter(pol), Point_generator(0.25, rnd));
std::vector<std::vector<FT> > weights(1);
for(int i=0; i<polygon_nv; ++i)
weights[0].push_back(rnd.get_double(1, 10));
std::cout << "Weights:" << std::endl;
for(const std::vector<FT>& 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<EPICK>(polygon_nv, rnd);
test_kernel<EPECK>(polygon_nv, rnd);
test_kernel<EPECK_w_sqrt>(polygon_nv, rnd);
return EXIT_SUCCESS;
}

View File

@ -1,6 +1,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
@ -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;
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 Polygon_2 = CGAL::Polygon_2<K>;
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<K>;
using Straight_skeleton_2 = CGAL::Straight_skeleton_2<K>;
using Straight_skeleton_2_ptr = std::shared_ptr<Straight_skeleton_2>;
using Mesh = CGAL::Surface_mesh<Point_3>;
Polygon_2 generate_random_polygon(CGAL::Random& rnd)
template <typename K>
void test_kernel(const int hole_n, const int hole_nv, CGAL::Random& rnd)
{
typedef CGAL::Random_points_in_square_2<Point_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<K>;
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<K>;
int main(int argc, char** argv)
{
std::cout.precision(17);
std::cerr.precision(17);
using Straight_skeleton_2 = CGAL::Straight_skeleton_2<K>;
using Straight_skeleton_2_ptr = std::shared_ptr<Straight_skeleton_2>;
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();
using Mesh = CGAL::Surface_mesh<Point_3>;
CGAL::Random rnd(seed);
auto generate_random_polygon = [&](CGAL::Random& rnd) -> Polygon_2
{
typedef CGAL::Random_points_in_square_2<Point_2> Point_generator;
std::cout << "Seed is " << rnd.get_seed() << std::endl;
std::cout << 2*hole_n << " holes of size " << hole_nv << std::endl;
std::vector<std::vector<FT> > 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<Point_2> 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<std::vector<FT> > 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<EPICK>(hole_n, hole_nv, rnd);
test_kernel<EPECK>(hole_n, hole_nv, rnd);
test_kernel<EPECK_w_sqrt>(hole_n, hole_nv, rnd);
return EXIT_SUCCESS;
}