Ticket #10049: shrink.cpp

File shrink.cpp, 802 bytes (added by Jakob Schou Jensen <jakob.schou.jensen@…>, 8 years ago)
Line 
1#include <boost/polygon/polygon.hpp>
2#include <vector>
3using namespace boost::polygon;
4
5int main() {
6 typedef polygon_data<int> Polygon;
7 typedef polygon_traits<Polygon>::point_type Point;
8 Point pts[] = {construct<Point>(4000, 0),
9 construct<Point>(2500, 500),
10 construct<Point>(0, 3000),
11 construct<Point>(0, 0) };
12
13 Polygon poly;
14 set_points(poly, pts, pts+4);
15
16 typedef std::vector<polygon_data<int> > PolygonSet;
17
18 PolygonSet ps;
19 assign( ps, poly );
20
21 shrink( ps, 1000 );
22
23 for( auto& polygon: ps ) {
24 printf("polygon: size=%d, holes=%d\n", static_cast<int>(polygon.size()), static_cast<int>( end_holes(polygon) - begin_holes(polygon) ) );
25 for( auto& point: polygon ) {
26 printf(" (%d, %d)\n", get(point,HORIZONTAL), get(point,VERTICAL) );
27 }
28 }
29
30 return 0;
31}