CGAL 6.0 - 2D Straight Skeleton and Polygon Offsetting
Loading...
Searching...
No Matches
Straight_skeleton_2/Create_straight_skeleton_2.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <CGAL/draw_straight_skeleton_2.h>
#include <cassert>
typedef K::Point_2 Point ;
typedef CGAL::Polygon_2<K> Polygon_2 ;
typedef std::shared_ptr<Ss> SsPtr ;
int main()
{
Polygon_2 poly ;
poly.push_back( Point(-1,-1) ) ;
poly.push_back( Point(0,-12) ) ;
poly.push_back( Point(1,-1) ) ;
poly.push_back( Point(12,0) ) ;
poly.push_back( Point(1,1) ) ;
poly.push_back( Point(0,12) ) ;
poly.push_back( Point(-1,1) ) ;
poly.push_back( Point(-12,0) ) ;
assert(poly.is_counterclockwise_oriented());
// You can pass the polygon via an iterator pair
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
CGAL::Straight_skeletons_2::IO::print_straight_skeleton(*iss);
CGAL::draw(*iss);
// 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);
CGAL::Straight_skeletons_2::IO::print_straight_skeleton(*oss);
CGAL::draw(*oss);
return EXIT_SUCCESS;
}
The class Straight_skeleton_2 provides a model for the StraightSkeleton_2 concept which is the class ...
Definition: Straight_skeleton_2.h:178
void draw(const PS2 &ps2, const GSOptions &gso)
std::shared_ptr< Straight_skeleton_2< SsK > > create_exterior_straight_skeleton_2(FT max_offset, PointIterator vertices_begin, PointIterator vertices_end, SsK k=CGAL::Exact_predicates_inexact_constructions_kernel())
creates a straight skeleton in the exterior of a 2D polygon with holes.
std::shared_ptr< Straight_skeleton_2< SsK > > create_interior_straight_skeleton_2(PointIterator outer_contour_vertices_begin, PointIterator outer_contour_vertices_end, HoleIterator holes_begin, HoleIterator holes_end, SsK k=CGAL::Exact_predicates_inexact_constructions_kernel())
creates a straight skeleton in the interior of the 2D polygon with holes.