| 1 | #include <iostream>
|
|---|
| 2 | #include <deque>
|
|---|
| 3 |
|
|---|
| 4 | #include <boost/geometry.hpp>
|
|---|
| 5 | #include <boost/geometry/geometries/point_xy.hpp>
|
|---|
| 6 | #include <boost/geometry/geometries/polygon.hpp>
|
|---|
| 7 |
|
|---|
| 8 | #include <boost/foreach.hpp>
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | int main()
|
|---|
| 12 | {
|
|---|
| 13 | typedef boost::geometry::model::d2::point_xy<boost::int32_t> point;
|
|---|
| 14 | typedef boost::geometry::model::polygon<point> polygon;
|
|---|
| 15 |
|
|---|
| 16 | polygon green, blue;
|
|---|
| 17 |
|
|---|
| 18 | boost::geometry::read_wkt(
|
|---|
| 19 | "POLYGON((0 65536, 0 131072, 65536 131072, 131072 131072, 131072 65536, 65536 65536, 0 65536))", green);
|
|---|
| 20 |
|
|---|
| 21 | boost::geometry::read_wkt(
|
|---|
| 22 | "POLYGON((65536 0, 65536 65536, 65536 131072, 65536 196608, 196608 196608, 196608 0, 65536 0))", blue);
|
|---|
| 23 |
|
|---|
| 24 | boost::geometry::correct(green);
|
|---|
| 25 | boost::geometry::correct(blue);
|
|---|
| 26 |
|
|---|
| 27 | std::deque<polygon> output;
|
|---|
| 28 | boost::geometry::intersection(blue, green, output);
|
|---|
| 29 |
|
|---|
| 30 | int i = 0;
|
|---|
| 31 | std::cout << "green && blue:" << std::endl;
|
|---|
| 32 | BOOST_FOREACH(polygon const& p, output)
|
|---|
| 33 | {
|
|---|
| 34 | std::cout << i++ << ": " << boost::geometry::dsv(p) << std::endl;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | return 0;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|