| 1 | #include <boost/geometry.hpp>
|
|---|
| 2 | #include <boost/geometry/geometries/geometries.hpp>
|
|---|
| 3 | #include <boost/geometry/multi/geometries/multi_point.hpp>
|
|---|
| 4 | #include <boost/geometry/algorithms/perimeter.hpp>
|
|---|
| 5 | #include <vector>
|
|---|
| 6 | using namespace std;
|
|---|
| 7 |
|
|---|
| 8 | #define ADD(X,Y) append(all_points_in_radius,make<point_xy<float> >(X,Y))
|
|---|
| 9 |
|
|---|
| 10 | int main()
|
|---|
| 11 | {
|
|---|
| 12 | using boost::geometry::model::d2::point_xy;
|
|---|
| 13 | using boost::geometry::append;
|
|---|
| 14 | using boost::geometry::make;
|
|---|
| 15 |
|
|---|
| 16 | boost::geometry::model::polygon<point_xy<float> > all_points_in_radius;
|
|---|
| 17 |
|
|---|
| 18 | ADD(0,0);
|
|---|
| 19 | ADD(0,2);
|
|---|
| 20 |
|
|---|
| 21 | cout << "num inner rings in poly: " << all_points_in_radius.inners().size() << endl;
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | typedef vector<point_xy<float> > pointvector;
|
|---|
| 25 | pointvector &r = all_points_in_radius.outer();
|
|---|
| 26 | cout << "points in poly:" << endl;
|
|---|
| 27 | for (pointvector::iterator pi = r.begin(); pi!=r.end(); ++pi)
|
|---|
| 28 | cout << pi->x() << "," << pi->y() << endl;
|
|---|
| 29 |
|
|---|
| 30 | boost::geometry::model::polygon<point_xy<float> > hull;
|
|---|
| 31 | boost::geometry::convex_hull(all_points_in_radius,hull);
|
|---|
| 32 | pointvector &p = hull.outer();
|
|---|
| 33 | cout << "points in hull:" << endl;
|
|---|
| 34 | for (pointvector::iterator pi = p.begin(); pi!=p.end(); ++pi)
|
|---|
| 35 | cout << pi->x() << "," << pi->y() << endl;
|
|---|
| 36 | cout << "hull perimiter:" << endl;
|
|---|
| 37 | cout << boost::geometry::perimeter(hull) << endl;
|
|---|
| 38 | cout << "hull area:" << endl;
|
|---|
| 39 | cout << boost::geometry::area(hull) << endl;
|
|---|
| 40 |
|
|---|
| 41 | return 0;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|