Ticket #11575: PolygonGet.cpp

File PolygonGet.cpp, 1.1 KB (added by cybfly1@…, 7 years ago)

Codes

Line 
1
2#include <iostream>
3#include <boost/polygon/polygon.hpp>
4#include <cassert>
5namespace gtl = boost::polygon;
6using namespace boost::polygon::operators;
7
8//lets construct a 10x10 rectangle shaped polygon
9typedef gtl::polygon_data<int> Polygon;
10typedef gtl::polygon_traits<Polygon>::point_type Point;
11typedef gtl::polygon_set_data<int> PolygonSet;
12typedef std::vector<Polygon> PolyDataSet;
13
14void getOBS(Polygon &oPrboundary, PolyDataSet &pinGroup)
15{
16 PolygonSet o_full_set;
17 o_full_set.insert(oPrboundary, false);
18
19 foreach (Polygon o_item, pinGroup)
20 {
21 //o_full_set.insert(o_item, true); // Insert As Hole, which works in 1_53 but not in 1_56
22 o_full_set -= o_item; // works in 1_53 and 1_56
23 }
24
25 PolyDataSet o_OBS_set;
26 o_full_set.get(o_OBS_set);
27
28 for (int i = 0; i < o_OBS_set.size(); ++i)
29 {
30 Polygon o_poly = o_OBS_set.at(i);
31 std::vector<Point> poly_points;
32 poly_points.insert(poly_points.end(), o_poly.begin(), o_poly.end());
33 foreach(Point o_pos, poly_points)
34 {
35 std::cout << "(" << o_pos.x() << ", " << ") ";
36 }
37 std::cout << std::endl;
38 }
39}