mirror of https://github.com/CGAL/cgal
Weighted straight skeleton API update
This commit is contained in:
parent
6247a8b5bc
commit
60b038972e
|
|
@ -31,10 +31,7 @@ int main()
|
|||
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
|
||||
|
||||
// Or you can pass the polygon directly, as below.
|
||||
|
||||
// To create an exterior straight skeleton you need to specify a maximum offset.
|
||||
double lMaxOffset = 5 ;
|
||||
SsPtr oss = CGAL::create_exterior_straight_skeleton_2(lMaxOffset, poly);
|
||||
SsPtr oss = CGAL::create_exterior_straight_skeleton_2(poly);
|
||||
|
||||
print_straight_skeleton(*iss);
|
||||
print_straight_skeleton(*oss);
|
||||
|
|
|
|||
|
|
@ -54,87 +54,33 @@ int main()
|
|||
, Point_2(-12,0)
|
||||
} ;
|
||||
|
||||
std::vector<Point_2> star(pts,pts+8);
|
||||
std::vector<Point_2> star (pts,pts+8);
|
||||
|
||||
// We want an offset contour in the outside.
|
||||
// Since the package doesn't support that operation directly, we use the following trick:
|
||||
// (1) Place the polygon as a hole of a big outer frame.
|
||||
// (2) Construct the skeleton on the interior of that frame (with the polygon as a hole)
|
||||
// (3) Construc the offset contours
|
||||
// (4) Identify the offset contour that corresponds to the frame and remove it from the result
|
||||
// Instantiate the skeleton builder
|
||||
SsBuilder ssb ;
|
||||
|
||||
// Pass -1.0 as uniform weight to obtain an exterior skeleton
|
||||
ssb.enter_contour(star.begin(), star.end(), -1.0 );
|
||||
|
||||
double offset = 3 ; // The offset distance
|
||||
// Construct the skeleton
|
||||
boost::shared_ptr<Ss> ss = ssb.construct_skeleton();
|
||||
|
||||
// First we need to determine the proper separation between the polygon and the frame.
|
||||
// We use this helper function provided in the package.
|
||||
boost::optional<double> margin = CGAL::compute_outer_frame_margin(star.begin(),star.end(),offset);
|
||||
|
||||
// Proceed only if the margin was computed (an extremely sharp corner might cause overflow)
|
||||
if ( margin )
|
||||
// Proceed only if the skeleton was correctly constructed.
|
||||
if ( ss )
|
||||
{
|
||||
// Get the bbox of the polygon
|
||||
CGAL::Bbox_2 bbox = CGAL::bbox_2(star.begin(),star.end());
|
||||
print_straight_skeleton(*ss);
|
||||
|
||||
// Compute the boundaries of the frame
|
||||
double fxmin = bbox.xmin() - *margin ;
|
||||
double fxmax = bbox.xmax() + *margin ;
|
||||
double fymin = bbox.ymin() - *margin ;
|
||||
double fymax = bbox.ymax() + *margin ;
|
||||
// Instantiate the container of offset contours
|
||||
ContourSequence offset_contours ;
|
||||
|
||||
// Create the rectangular frame
|
||||
Point_2 frame[4]= { Point_2(fxmin,fymin)
|
||||
, Point_2(fxmax,fymin)
|
||||
, Point_2(fxmax,fymax)
|
||||
, Point_2(fxmin,fymax)
|
||||
} ;
|
||||
// Instantiate the offset builder with the skeleton
|
||||
OffsetBuilder ob(*ss);
|
||||
|
||||
// Instantiate the skeleton builder
|
||||
SsBuilder ssb ;
|
||||
// Obtain the offset contours
|
||||
double offset = 3 ; // The offset distance
|
||||
ob.construct_offset_contours(offset, std::back_inserter(offset_contours));
|
||||
|
||||
// Enter the frame
|
||||
ssb.enter_contour(frame,frame+4);
|
||||
|
||||
// Enter the polygon as a hole of the frame (NOTE: as it is a hole we insert it in the opposite orientation)
|
||||
ssb.enter_contour(star.rbegin(),star.rend());
|
||||
|
||||
// Construct the skeleton
|
||||
boost::shared_ptr<Ss> ss = ssb.construct_skeleton();
|
||||
|
||||
// Proceed only if the skeleton was correctly constructed.
|
||||
if ( ss )
|
||||
{
|
||||
print_straight_skeleton(*ss);
|
||||
|
||||
// Instantiate the container of offset contours
|
||||
ContourSequence offset_contours ;
|
||||
|
||||
// Instantiate the offset builder with the skeleton
|
||||
OffsetBuilder ob(*ss);
|
||||
|
||||
// Obtain the offset contours
|
||||
ob.construct_offset_contours(offset, std::back_inserter(offset_contours));
|
||||
|
||||
// Locate the offset contour that corresponds to the frame
|
||||
// That must be the outmost offset contour, which in turn must be the one
|
||||
// with the largetst unsigned area.
|
||||
ContourSequence::iterator f = offset_contours.end();
|
||||
double lLargestArea = 0.0 ;
|
||||
for (ContourSequence::iterator i = offset_contours.begin(); i != offset_contours.end(); ++ i )
|
||||
{
|
||||
double lArea = CGAL_NTS abs( (*i)->area() ) ; //Take abs() as Polygon_2::area() is signed.
|
||||
if ( lArea > lLargestArea )
|
||||
{
|
||||
f = i ;
|
||||
lLargestArea = lArea ;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the offset contour that corresponds to the frame.
|
||||
offset_contours.erase(f);
|
||||
|
||||
print_polygons(offset_contours);
|
||||
}
|
||||
print_polygons(offset_contours);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include<vector>
|
||||
#include<iterator>
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include<iomanip>
|
||||
#include<string>
|
||||
|
||||
|
|
|
|||
|
|
@ -941,6 +941,32 @@ private :
|
|||
|
||||
}
|
||||
|
||||
template<class InputPointIterator, class NT, class Converter>
|
||||
Halfedge_handle enter_valid_contour ( InputPointIterator aPBegin
|
||||
, InputPointIterator aPEnd
|
||||
, NT aWeight
|
||||
, bool aIsClosed
|
||||
, Converter const& aCvt
|
||||
)
|
||||
{
|
||||
Halfedge_handle rHead = enter_valid_contour(aPBegin, aPEnd, aIsClosed, aCvt ) ;
|
||||
|
||||
Halfedge_handle lH = rHead ;
|
||||
|
||||
do
|
||||
{
|
||||
CGAL_STSKEL_BUILDER_TRACE(1, "E" << hid(lH) << " is given weight " << aWeight );
|
||||
lH->HBase_base::set_weight(aWeight);
|
||||
Halfedge_handle lN = lH->next();
|
||||
if ( !handle_assigned(lN) || lN == rHead )
|
||||
break ;
|
||||
lH = lN ;
|
||||
}
|
||||
while ( true ) ;
|
||||
|
||||
return rHead ;
|
||||
}
|
||||
|
||||
template<class InputPointIterator, class InputWeightIterator, class Converter>
|
||||
Halfedge_handle enter_valid_contour ( InputPointIterator aPBegin
|
||||
, InputPointIterator aPEnd
|
||||
|
|
@ -985,9 +1011,10 @@ public:
|
|||
}
|
||||
} ;
|
||||
|
||||
template<class InputPointIterator, class Converter>
|
||||
template<class InputPointIterator, class Converter, class NT>
|
||||
Straight_skeleton_builder_2& enter_contour ( InputPointIterator aBegin
|
||||
, InputPointIterator aEnd
|
||||
, NT aWeight
|
||||
, bool aIsClosed
|
||||
, Converter const& aCvt
|
||||
, bool aCheckValidity = true
|
||||
|
|
@ -1009,7 +1036,7 @@ public:
|
|||
|
||||
if ( lList.size() >= ( aIsClosed ? 3u : 2u ) )
|
||||
{
|
||||
enter_valid_contour(lList.begin(), lList.end(), aIsClosed, aCvt);
|
||||
enter_valid_contour(lList.begin(), lList.end(), aWeight, aIsClosed, aCvt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1018,7 +1045,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
enter_valid_contour(aBegin, aEnd, aIsClosed, aCvt);
|
||||
enter_valid_contour(aBegin, aEnd, aWeight, aIsClosed, aCvt);
|
||||
}
|
||||
|
||||
return *this ;
|
||||
|
|
@ -1087,26 +1114,28 @@ public:
|
|||
return *this ;
|
||||
}
|
||||
|
||||
template<class InputPointIterator>
|
||||
template<class InputPointIterator, class NT>
|
||||
Straight_skeleton_builder_2& enter_contour ( InputPointIterator aBegin
|
||||
, InputPointIterator aEnd
|
||||
, NT aWeight = 1.0
|
||||
, bool aIsClosed = true
|
||||
, bool aCheckValidity = true
|
||||
)
|
||||
{
|
||||
return enter_contour(aBegin, aEnd, aIsClosed, Cartesian_converter<K,K>(), aCheckValidity);
|
||||
return enter_contour(aBegin, aEnd, aWeight, aIsClosed, Cartesian_converter<K,K>(), aCheckValidity);
|
||||
}
|
||||
|
||||
template<class InputPointIterator, class InputWeightIterator>
|
||||
template<class InputPointIterator, class InputWeightIterator, class NT>
|
||||
Straight_skeleton_builder_2& enter_contour ( InputPointIterator aPBegin
|
||||
, InputPointIterator aPEnd
|
||||
, InputWeightIterator aWBegin
|
||||
, InputWeightIterator aWEnd
|
||||
, NT aWeight = 1.0
|
||||
, bool aIsClosed = true
|
||||
, bool aCheckValidity = true
|
||||
)
|
||||
{
|
||||
return enter_contour(aPBegin, aPEnd, aWBegin, aWEnd, aIsClosed, Cartesian_converter<K,K>(), aCheckValidity ) ;
|
||||
return enter_contour(aPBegin, aPEnd, aWBegin, aWEnd, aWeight, aIsClosed, Cartesian_converter<K,K>(), aCheckValidity ) ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
|
|
|||
|
|
@ -35,93 +35,6 @@ template<class U, class V> struct Is_same_type { typedef Tag_false type ; } ;
|
|||
template<class U> struct Is_same_type<U,U> { typedef Tag_true type ; } ;
|
||||
|
||||
|
||||
template<class FT, class PointIterator, class HoleIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_partial_interior_straight_skeleton_2 ( FT const& aMaxTime
|
||||
, PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, K const&
|
||||
)
|
||||
{
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
typedef Straight_skeleton_builder_traits_2<K> SsBuilderTraits;
|
||||
|
||||
typedef Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;
|
||||
|
||||
typedef typename K::FT KFT ;
|
||||
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type InputPoint ;
|
||||
typedef typename Kernel_traits<InputPoint>::Kernel InputKernel ;
|
||||
|
||||
Cartesian_converter<InputKernel, K> Converter ;
|
||||
|
||||
boost::optional<KFT> lMaxTime( Converter(aMaxTime) ) ;
|
||||
|
||||
SsBuilder ssb( lMaxTime ) ;
|
||||
|
||||
ssb.enter_contour( aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, true, Converter ) ;
|
||||
|
||||
for ( HoleIterator hi = aHolesBegin ; hi != aHolesEnd ; ++ hi )
|
||||
ssb.enter_contour( CGAL_SS_i::vertices_begin(*hi), CGAL_SS_i::vertices_end(*hi), true, Converter ) ;
|
||||
|
||||
return ssb.construct_skeleton();
|
||||
}
|
||||
|
||||
template<class FT, class PointIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_partial_exterior_straight_skeleton_2 ( FT const& aMaxOffset
|
||||
, PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
, K const& k
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type Point_2 ;
|
||||
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
SsPtr rSkeleton ;
|
||||
|
||||
boost::optional<FT> margin = compute_outer_frame_margin( aVerticesBegin
|
||||
, aVerticesEnd
|
||||
, aMaxOffset
|
||||
);
|
||||
|
||||
if ( margin )
|
||||
{
|
||||
|
||||
Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd);
|
||||
|
||||
FT fxmin = bbox.xmin() - *margin ;
|
||||
FT fxmax = bbox.xmax() + *margin ;
|
||||
FT fymin = bbox.ymin() - *margin ;
|
||||
FT fymax = bbox.ymax() + *margin ;
|
||||
|
||||
Point_2 frame[4] ;
|
||||
|
||||
frame[0] = Point_2(fxmin,fymin) ;
|
||||
frame[1] = Point_2(fxmax,fymin) ;
|
||||
frame[2] = Point_2(fxmax,fymax) ;
|
||||
frame[3] = Point_2(fxmin,fymax) ;
|
||||
|
||||
typedef std::vector<Point_2> Hole ;
|
||||
|
||||
Hole lPoly(aVerticesBegin, aVerticesEnd);
|
||||
std::reverse(lPoly.begin(), lPoly.end());
|
||||
|
||||
std::vector<Hole> holes ;
|
||||
holes.push_back(lPoly) ;
|
||||
|
||||
rSkeleton = create_partial_interior_straight_skeleton_2(aMaxOffset,frame, frame+4, holes.begin(), holes.end(), k ) ;
|
||||
}
|
||||
|
||||
return rSkeleton ;
|
||||
}
|
||||
|
||||
//
|
||||
// Kernel != Skeleton::kernel. The skeleton is converted to Straight_skeleton_2<Kernel>
|
||||
//
|
||||
|
|
@ -234,13 +147,14 @@ create_interior_skeleton_and_offset_polygons_2 ( FT const& aOffset
|
|||
return create_offset_polygons_2<Polygon>
|
||||
(aOffset
|
||||
,CGAL_SS_i::dereference
|
||||
( CGAL_SS_i::create_partial_interior_straight_skeleton_2(aOffset
|
||||
,CGAL_SS_i::vertices_begin(aOuterBoundary)
|
||||
,CGAL_SS_i::vertices_end (aOuterBoundary)
|
||||
,aHolesBegin
|
||||
,aHolesEnd
|
||||
,ssk
|
||||
)
|
||||
( create_straight_skeleton_2(CGAL_SS_i::vertices_begin(aOuterBoundary)
|
||||
,CGAL_SS_i::vertices_end (aOuterBoundary)
|
||||
,aHolesBegin
|
||||
,aHolesEnd
|
||||
,FT(1.0)
|
||||
,boost::optional<FT>(aOffset)
|
||||
,ssk
|
||||
)
|
||||
)
|
||||
,ofk
|
||||
);
|
||||
|
|
@ -312,11 +226,12 @@ create_exterior_skeleton_and_offset_polygons_2 ( FT const& aOffset, Polygon cons
|
|||
return create_offset_polygons_2<Polygon>
|
||||
(aOffset
|
||||
,CGAL_SS_i::dereference
|
||||
(CGAL_SS_i::create_partial_exterior_straight_skeleton_2(aOffset
|
||||
,CGAL_SS_i::vertices_begin(aPoly)
|
||||
,CGAL_SS_i::vertices_end (aPoly)
|
||||
,ssk
|
||||
)
|
||||
(create_straight_skeleton_2( CGAL_SS_i::vertices_begin(aPoly)
|
||||
, CGAL_SS_i::vertices_end (aPoly)
|
||||
, FT(1.0)
|
||||
, boost::optional<FT>(aOffset)
|
||||
, ssk
|
||||
)
|
||||
)
|
||||
,ofk
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2006 Fernando Luis Cacciola Carballal. All rights reserved.
|
||||
// Copyright (c) 2006-2010 Fernando Luis Cacciola Carballal. All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
|
|
@ -14,13 +14,12 @@
|
|||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
|
||||
// Author(s) : Fernando Cacciola <fernando.cacciola@gmail.com>
|
||||
//
|
||||
#ifndef CGAL_CREATE_STRAIGHT_SKELETON_2_H
|
||||
#define CGAL_CREATE_STRAIGHT_SKELETON_2_H
|
||||
|
||||
#include <CGAL/Straight_skeleton_builder_2.h>
|
||||
#include <CGAL/compute_outer_frame_margin.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
|
@ -51,14 +50,19 @@ inline typename Poly::const_iterator vertices_end ( boost::shared_ptr<Poly> cons
|
|||
|
||||
}
|
||||
|
||||
template<class PointIterator, class HoleIterator, class K>
|
||||
template<class PointIterator, class HoleIterator, class WeightIterator, class WeightSequenceIterator, class NT, class K >
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, K const&
|
||||
)
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, WeightIterator aOuterContour_WeightsBegin
|
||||
, WeightIterator aOuterContour_WeightsEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, WeightSequenceIterator aHolesWeightBegin
|
||||
, WeightSequenceIterator aHolesWeightEnd
|
||||
, boost::optional<NT> const& aMaxTime
|
||||
, K const&
|
||||
)
|
||||
{
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
|
@ -72,170 +76,355 @@ create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
|||
|
||||
Cartesian_converter<InputKernel, K> Point_converter ;
|
||||
|
||||
SsBuilder ssb ;
|
||||
SsBuilder ssb(aMaxTime) ;
|
||||
|
||||
ssb.enter_contour( aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, true, Point_converter ) ;
|
||||
ssb.enter_contour( aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aOuterContour_WeightsBegin, aOuterContour_WeightsEnd, false, Point_converter ) ;
|
||||
|
||||
WeightSequenceIterator whi = aHolesWeightBegin ;
|
||||
for ( HoleIterator hi = aHolesBegin ; hi != aHolesEnd ; ++ hi, ++ whi )
|
||||
ssb.enter_contour( CGAL_SS_i::vertices_begin(*hi), CGAL_SS_i::vertices_end(*hi), whi->begin(), whi->end(), false, Point_converter ) ;
|
||||
|
||||
return ssb.construct_skeleton();
|
||||
}
|
||||
|
||||
template<class PointIterator, class HoleIterator, class WeightIterator, class WeightSequenceIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, WeightIterator aOuterContour_WeightsBegin
|
||||
, WeightIterator aOuterContour_WeightsEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, WeightSequenceIterator aHolesWeightBegin
|
||||
, WeightSequenceIterator aHolesWeightEnd
|
||||
, boost::optional<double> const& aMaxTime = boost::optional<double>()
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin
|
||||
,aOuterContour_VerticesEnd
|
||||
,aOuterContour_WeightsBegin
|
||||
,aOuterContour_WeightsEnd
|
||||
,aHolesBegin
|
||||
,aHolesEnd
|
||||
,aHolesWeightBegin
|
||||
,aHolesWeightEnd
|
||||
,aMaxTime
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class PointIterator, class HoleIterator, class NT, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, NT aWeight
|
||||
, boost::optional<NT> const& aMaxTime
|
||||
, K const&
|
||||
)
|
||||
{
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
typedef Straight_skeleton_builder_traits_2<K> SsBuilderTraits;
|
||||
|
||||
typedef Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;
|
||||
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type InputPoint ;
|
||||
typedef typename Kernel_traits<InputPoint>::Kernel InputKernel ;
|
||||
|
||||
Cartesian_converter<InputKernel, K> Point_converter ;
|
||||
|
||||
SsBuilder ssb(aMaxTime) ;
|
||||
|
||||
ssb.enter_contour( aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aWeight, false, Point_converter ) ;
|
||||
|
||||
for ( HoleIterator hi = aHolesBegin ; hi != aHolesEnd ; ++ hi )
|
||||
ssb.enter_contour( CGAL_SS_i::vertices_begin(*hi), CGAL_SS_i::vertices_end(*hi), true, Point_converter ) ;
|
||||
ssb.enter_contour( CGAL_SS_i::vertices_begin(*hi), CGAL_SS_i::vertices_end(*hi), aWeight, false, Point_converter ) ;
|
||||
|
||||
return ssb.construct_skeleton();
|
||||
}
|
||||
|
||||
template<class PointIterator, class HoleIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2< Exact_predicates_inexact_constructions_kernel > >
|
||||
inline
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, double aWeight = 1.0
|
||||
, boost::optional<double> const& aMaxTime = boost::optional<double>()
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin
|
||||
,aOuterContour_VerticesEnd
|
||||
,aHolesBegin
|
||||
,aHolesEnd
|
||||
,aWeight
|
||||
,aMaxTime
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
}
|
||||
|
||||
template<class PointIterator, class WeightIterator, class NT, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, WeightIterator aOuterContour_WeightsBegin
|
||||
, WeightIterator aOuterContour_WeightsEnd
|
||||
, boost::optional<NT> const& aMaxTime
|
||||
, K const&
|
||||
)
|
||||
{
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
typedef Straight_skeleton_builder_traits_2<K> SsBuilderTraits;
|
||||
|
||||
typedef Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;
|
||||
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type InputPoint ;
|
||||
typedef typename Kernel_traits<InputPoint>::Kernel InputKernel ;
|
||||
|
||||
Cartesian_converter<InputKernel, K> Point_converter ;
|
||||
|
||||
SsBuilder ssb(aMaxTime) ;
|
||||
|
||||
ssb.enter_contour( aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aOuterContour_WeightsBegin, aOuterContour_WeightsEnd, false, Point_converter ) ;
|
||||
|
||||
return ssb.construct_skeleton();
|
||||
}
|
||||
|
||||
template<class PointIterator, class WeightIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, WeightIterator aOuterContour_WeightsBegin
|
||||
, WeightIterator aOuterContour_WeightsEnd
|
||||
, boost::optional<double> const& aMaxTime = boost::optional<double>()
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin
|
||||
,aOuterContour_VerticesEnd
|
||||
,aOuterContour_WeightsBegin
|
||||
,aOuterContour_WeightsEnd
|
||||
,aMaxTime
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
}
|
||||
|
||||
template<class PointIterator, class NT, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_straight_skeleton_2 ( PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
, NT aWeight
|
||||
, boost::optional<NT> const& aMaxTime
|
||||
, K const&
|
||||
)
|
||||
{
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
typedef Straight_skeleton_builder_traits_2<K> SsBuilderTraits;
|
||||
|
||||
typedef Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;
|
||||
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type InputPoint ;
|
||||
typedef typename Kernel_traits<InputPoint>::Kernel InputKernel ;
|
||||
|
||||
Cartesian_converter<InputKernel, K> Point_converter ;
|
||||
|
||||
SsBuilder ssb(aMaxTime) ;
|
||||
|
||||
ssb.enter_contour( aVerticesBegin, aVerticesEnd, aWeight, false, Point_converter ) ;
|
||||
|
||||
return ssb.construct_skeleton();
|
||||
}
|
||||
|
||||
template<class PointIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_straight_skeleton_2 ( PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
, double aWeight = 1.0
|
||||
, boost::optional<double> const& aMaxTime = boost::optional<double>()
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2( aVerticesBegin
|
||||
, aVerticesEnd
|
||||
, aWeight
|
||||
, aMaxTime
|
||||
, Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
}
|
||||
|
||||
template<class Polygon, class NT, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_straight_skeleton_2 ( Polygon const& aContour
|
||||
, NT aWeight
|
||||
, boost::optional<NT> const& aMaxTime
|
||||
, K const& aK
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2(CGAL_SS_i::vertices_begin(aContour)
|
||||
,CGAL_SS_i::vertices_end (aContour)
|
||||
,aWeight
|
||||
,aMaxTime
|
||||
,aK
|
||||
);
|
||||
}
|
||||
|
||||
template<class Polygon>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_straight_skeleton_2 ( Polygon const& aContour
|
||||
, double aWeight = 1.0
|
||||
, boost::optional<double> const& aMaxTime = boost::optional<double>()
|
||||
)
|
||||
{
|
||||
return create_straight_skeleton_2(aContour
|
||||
,aWeight
|
||||
,aMaxTime
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
template<class PointIterator, class HoleIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, K const& aK
|
||||
)
|
||||
{
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aHolesBegin, aHolesEnd, FT(1.0), boost::optional<FT>(), aK ) ;
|
||||
}
|
||||
|
||||
|
||||
template<class PointIterator, class HoleIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
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()
|
||||
);
|
||||
return create_interior_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aHolesBegin, aHolesEnd, Exact_predicates_inexact_constructions_kernel() ) ;
|
||||
}
|
||||
|
||||
template<class PointIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
inline
|
||||
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, K const& k
|
||||
, K const& aK
|
||||
)
|
||||
{
|
||||
std::vector< Polygon_2<K> > no_holes ;
|
||||
return create_interior_straight_skeleton_2(aOuterContour_VerticesBegin
|
||||
,aOuterContour_VerticesEnd
|
||||
,no_holes.begin()
|
||||
,no_holes.end()
|
||||
,k
|
||||
);
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, FT(1.0), boost::optional<FT>(), aK ) ;
|
||||
}
|
||||
|
||||
template<class PointIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
inline
|
||||
create_interior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
create_interior_straight_skeleton_2 ( PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
)
|
||||
{
|
||||
return create_interior_straight_skeleton_2(aOuterContour_VerticesBegin
|
||||
,aOuterContour_VerticesEnd
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
return create_interior_straight_skeleton_2(aVerticesBegin, aVerticesEnd, Exact_predicates_inexact_constructions_kernel() ) ;
|
||||
}
|
||||
|
||||
template<class Polygon, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
inline
|
||||
create_interior_straight_skeleton_2 ( Polygon const& aOutContour, K const& k )
|
||||
create_interior_straight_skeleton_2 ( Polygon const& aContour, K const& aK )
|
||||
{
|
||||
return create_interior_straight_skeleton_2(CGAL_SS_i::vertices_begin(aOutContour)
|
||||
,CGAL_SS_i::vertices_end(aOutContour)
|
||||
,k
|
||||
);
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aContour, FT(1.0), boost::optional<FT>(), aK );
|
||||
}
|
||||
|
||||
template<class Polygon>
|
||||
boost::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() );
|
||||
}
|
||||
|
||||
template<class FT, class PointIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_exterior_straight_skeleton_2 ( FT const& aMaxOffset
|
||||
, PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
, K const& k
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<PointIterator>::value_type Point_2 ;
|
||||
|
||||
typedef Straight_skeleton_2<K> Ss ;
|
||||
typedef boost::shared_ptr<Ss> SsPtr ;
|
||||
|
||||
SsPtr rSkeleton ;
|
||||
|
||||
boost::optional<FT> margin = compute_outer_frame_margin( aVerticesBegin
|
||||
, aVerticesEnd
|
||||
, aMaxOffset
|
||||
);
|
||||
|
||||
if ( margin )
|
||||
{
|
||||
|
||||
Bbox_2 bbox = bbox_2(aVerticesBegin, aVerticesEnd);
|
||||
|
||||
FT fxmin = bbox.xmin() - *margin ;
|
||||
FT fxmax = bbox.xmax() + *margin ;
|
||||
FT fymin = bbox.ymin() - *margin ;
|
||||
FT fymax = bbox.ymax() + *margin ;
|
||||
|
||||
Point_2 frame[4] ;
|
||||
|
||||
frame[0] = Point_2(fxmin,fymin) ;
|
||||
frame[1] = Point_2(fxmax,fymin) ;
|
||||
frame[2] = Point_2(fxmax,fymax) ;
|
||||
frame[3] = Point_2(fxmin,fymax) ;
|
||||
|
||||
typedef std::vector<Point_2> Hole ;
|
||||
|
||||
Hole lPoly(aVerticesBegin, aVerticesEnd);
|
||||
std::reverse(lPoly.begin(), lPoly.end());
|
||||
|
||||
std::vector<Hole> holes ;
|
||||
holes.push_back(lPoly) ;
|
||||
|
||||
rSkeleton = create_interior_straight_skeleton_2(frame, frame+4, holes.begin(), holes.end(), k ) ;
|
||||
}
|
||||
|
||||
return rSkeleton ;
|
||||
}
|
||||
|
||||
template<class FT, class PointIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
inline
|
||||
create_exterior_straight_skeleton_2 ( FT const& aMaxOffset
|
||||
, PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
create_interior_straight_skeleton_2 ( Polygon const& aContour )
|
||||
{
|
||||
return create_interior_straight_skeleton_2(aContour, Exact_predicates_inexact_constructions_kernel() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
template<class PointIterator, class HoleIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_exterior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
, K const& aK
|
||||
)
|
||||
{
|
||||
return create_exterior_straight_skeleton_2(aMaxOffset
|
||||
,aVerticesBegin
|
||||
,aVerticesEnd
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aHolesBegin, aHolesEnd, FT(-1.0), boost::optional<FT>(), aK ) ;
|
||||
}
|
||||
|
||||
|
||||
template<class FT, class Polygon, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
inline
|
||||
create_exterior_straight_skeleton_2 ( FT const& aMaxOffset, Polygon const& aPoly, K const& k )
|
||||
template<class PointIterator, class HoleIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
create_exterior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, HoleIterator aHolesBegin
|
||||
, HoleIterator aHolesEnd
|
||||
)
|
||||
{
|
||||
return create_exterior_straight_skeleton_2(aMaxOffset
|
||||
,CGAL_SS_i::vertices_begin(aPoly)
|
||||
,CGAL_SS_i::vertices_end (aPoly)
|
||||
,k
|
||||
);
|
||||
return create_exterior_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, aHolesBegin, aHolesEnd, Exact_predicates_inexact_constructions_kernel() ) ;
|
||||
}
|
||||
|
||||
template<class FT, class Polygon>
|
||||
template<class PointIterator, class HoleIterator, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
create_exterior_straight_skeleton_2 ( PointIterator aOuterContour_VerticesBegin
|
||||
, PointIterator aOuterContour_VerticesEnd
|
||||
, K const& aK
|
||||
)
|
||||
{
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aOuterContour_VerticesBegin, aOuterContour_VerticesEnd, FT(-1.0), boost::optional<FT>(), aK ) ;
|
||||
}
|
||||
|
||||
template<class PointIterator>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
inline
|
||||
create_exterior_straight_skeleton_2 ( FT const& aMaxOffset, Polygon const& aPoly )
|
||||
create_exterior_straight_skeleton_2 ( PointIterator aVerticesBegin
|
||||
, PointIterator aVerticesEnd
|
||||
)
|
||||
{
|
||||
return create_exterior_straight_skeleton_2(aMaxOffset
|
||||
,aPoly
|
||||
,Exact_predicates_inexact_constructions_kernel()
|
||||
);
|
||||
return create_exterior_straight_skeleton_2(aVerticesBegin, aVerticesEnd, Exact_predicates_inexact_constructions_kernel() ) ;
|
||||
}
|
||||
|
||||
template<class Polygon, class K>
|
||||
boost::shared_ptr< Straight_skeleton_2<K> >
|
||||
inline
|
||||
create_exterior_straight_skeleton_2 ( Polygon const& aContour, K const& aK )
|
||||
{
|
||||
typedef typename K::FT FT ;
|
||||
return create_straight_skeleton_2(aContour, FT(-1.0), boost::optional<FT>(), aK );
|
||||
}
|
||||
|
||||
template<class Polygon>
|
||||
boost::shared_ptr< Straight_skeleton_2<Exact_predicates_inexact_constructions_kernel> >
|
||||
inline
|
||||
create_exterior_straight_skeleton_2 ( Polygon const& aContour )
|
||||
{
|
||||
return create_exterior_straight_skeleton_2(aContour, Exact_predicates_inexact_constructions_kernel() );
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue