1 #include<CGAL/Exact_predicates_inexact_constructions_kernel.h>
2
3 #include<CGAL/Polygon_2.h>
4 #include<CGAL/create_straight_skeleton_2.h>
5 #include "print.h"
6
7 #include<boost/shared_ptr.hpp>
8
9 #include <cassert>
10
11 typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
12
13 typedef K::Point_2 Point ;
14 typedef CGAL::Polygon_2<K> Polygon_2 ;
15 typedef CGAL::Straight_skeleton_2<K> Ss ;
16
17 typedef boost::shared_ptr<Ss> SsPtr ;
18
main()19 int main()
20 {
21 Polygon_2 poly ;
22 poly.push_back( Point(-1,-1) ) ;
23 poly.push_back( Point(0,-12) ) ;
24 poly.push_back( Point(1,-1) ) ;
25 poly.push_back( Point(12,0) ) ;
26 poly.push_back( Point(1,1) ) ;
27 poly.push_back( Point(0,12) ) ;
28 poly.push_back( Point(-1,1) ) ;
29 poly.push_back( Point(-12,0) ) ;
30
31 assert(poly.is_counterclockwise_oriented());
32
33 // You can pass the polygon via an iterator pair
34 SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
35
36 // Or you can pass the polygon directly, as below.
37
38 // To create an exterior straight skeleton you need to specify a maximum offset.
39 double lMaxOffset = 5 ;
40 SsPtr oss = CGAL::create_exterior_straight_skeleton_2(lMaxOffset, poly);
41
42 print_straight_skeleton(*iss);
43 print_straight_skeleton(*oss);
44
45 return 0;
46 }
47