#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_2_algorithms.h>
#include <CGAL/Straight_skeleton_builder_2.h>
#include <CGAL/Polygon_offset_builder_2.h>
#include <CGAL/compute_outer_frame_margin.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <boost/shared_ptr.hpp>
#include <vector>
#include <cassert>
typedef boost::shared_ptr<Contour> ContourPtr;
typedef std::vector<ContourPtr> ContourSequence ;
typedef Ss::Halfedge_iterator Halfedge_iterator;
typedef Ss::Halfedge_handle Halfedge_handle;
typedef Ss::Vertex_handle Vertex_handle;
int main()
{
Point_2 pts[] = { Point_2(-1,-1)
, Point_2(0,-12)
, Point_2(1,-1)
, Point_2(12,0)
, Point_2(1,1)
, Point_2(0,12)
, Point_2(-1,1)
, Point_2(-12,0)
} ;
std::vector<Point_2> star(pts,pts+8);
double offset = 3 ;
if ( margin )
{
double fxmin = bbox.
xmin() - *margin ;
double fxmax = bbox.
xmax() + *margin ;
double fymin = bbox.
ymin() - *margin ;
double fymax = bbox.
ymax() + *margin ;
Point_2 frame[4]= { Point_2(fxmin,fymin)
, Point_2(fxmax,fymin)
, Point_2(fxmax,fymax)
, Point_2(fxmin,fymax)
} ;
SsBuilder ssb ;
ssb.enter_contour(frame,frame+4);
ssb.enter_contour(star.rbegin(),star.rend());
boost::shared_ptr<Ss> ss = ssb.construct_skeleton();
if ( ss )
{
CGAL::Straight_skeletons_2::IO::print_straight_skeleton(*ss);
ContourSequence offset_contours ;
OffsetBuilder ob(*ss);
ob.construct_offset_contours(offset, std::back_inserter(offset_contours));
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() ) ;
if ( lArea > lLargestArea )
{
f = i ;
lLargestArea = lArea ;
}
}
offset_contours.erase(f);
CGAL::Straight_skeletons_2::IO::print_polygons(offset_contours);
}
}
return 0;
}
The class Polygon_offset_builder_2 encapsulates the construction of inward offset contours of a 2D si...
Definition: Polygon_offset_builder_2.h:20
Definition: Polygon_offset_builder_traits_2.h:17
The class Straight_skeleton_2 provides a model for the StraightSkeleton_2 concept which is the class ...
Definition: Straight_skeleton_2.h:178
The class Straight_skeleton_builder_2 encapsulates the construction of the 2D straight skeleton in th...
Definition: Straight_skeleton_builder_2.h:118
Definition: Straight_skeleton_builder_traits_2.h:17
Orientation orientation_2(ForwardIterator first, ForwardIterator last, const Traits &traits)
boost::optional< typename Traits::FT > compute_outer_frame_margin(InputIterator first, InputIterator beyond, typename Traits::FT offset, const Traits &traits=Default_traits)
computes the separation required between a polygon and the outer frame used to obtain an exterior ske...
const CGAL::Orientation COUNTERCLOCKWISE