1 | #include <vector>
|
---|
2 | #include <boost/polygon/polygon.hpp>
|
---|
3 |
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | namespace gtl = boost::polygon;
|
---|
7 |
|
---|
8 | typedef gtl::polygon_data<int> Polygon;
|
---|
9 | typedef gtl::polygon_traits<Polygon>::point_type Point;
|
---|
10 |
|
---|
11 | void print(const vector<Polygon>& pset, int layer)
|
---|
12 | {
|
---|
13 | for(unsigned int i=0; i<pset.size(); i++) {
|
---|
14 | printf("p %d 0 ", layer);
|
---|
15 | for(Polygon::iterator_type j=pset[i].begin(); j!=pset[i].end(); j++) {
|
---|
16 | printf(" %d %d", x(*j), y(*j));
|
---|
17 | }
|
---|
18 | printf("\n");
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | int main()
|
---|
23 | {
|
---|
24 | int const pts[][2] = {
|
---|
25 | // {0,0}, {2,0}, {2,2}, {0, 2}, {0, 0}};
|
---|
26 | // {-23,-20}, {27, -70}, {-22, -20}, {-22, 5}, {-23, 5}};
|
---|
27 | {0,0}, {0,5}, {1, 5}, {1, 0}, {3, -3}};
|
---|
28 |
|
---|
29 | std::vector<Polygon::point_type> points;
|
---|
30 | for(size_t i = 0; i < 5; ++i)
|
---|
31 | points.push_back(Polygon::point_type(pts[i][0], pts[i][1]));
|
---|
32 |
|
---|
33 | Polygon polygon;
|
---|
34 | polygon.set(points.begin(), points.end());
|
---|
35 |
|
---|
36 | typedef std::vector<Polygon> PolygonSet;
|
---|
37 | PolygonSet polygonSet;
|
---|
38 | polygonSet.push_back(polygon);
|
---|
39 |
|
---|
40 | printf("B test\n");
|
---|
41 | print(polygonSet, 1);
|
---|
42 | boost::polygon::resize(polygonSet, -1);
|
---|
43 | // boost::polygon::resize(polygonSet, 1);
|
---|
44 | print(polygonSet, 2);
|
---|
45 | printf("E\n");
|
---|
46 |
|
---|
47 | return 0;
|
---|
48 | }
|
---|