Ticket #6019: boost_geom_test.cpp

File boost_geom_test.cpp, 1.1 KB (added by Crispin Cooper <cooperch@…>, 11 years ago)
Line 
1#include <boost/geometry.hpp>
2#include <boost/geometry/geometries/geometries.hpp>
3#include <boost/geometry/multi/geometries/multi_point.hpp>
4
5#define ADD(X,Y) append(all_points_in_radius,make<point_xy<float> >(X,Y))
6
7double convex_hull_area()
8{
9 using boost::geometry::model::d2::point_xy;
10 using boost::geometry::append;
11 using boost::geometry::make;
12
13 boost::geometry::model::polygon<point_xy<float> > all_points_in_radius;
14
15 ADD(0,53);
16 ADD(0,103); // point is on hull
17 ADD(0,53);
18 ADD(0,3);
19 ADD(0,3);
20 ADD(0,0); // point is on hull
21 ADD(1,0);
22 ADD(1,1);
23 ADD(2,1);
24 ADD(2,0);
25 ADD(2,0);
26 ADD(2,0);
27 ADD(3,0);
28 ADD(3,1);
29 ADD(4,1);
30 ADD(4,0);
31 ADD(5,0);
32 ADD(0,3);
33 ADD(10,3);
34 ADD(10,2);
35 ADD(10,2);
36 ADD(10,2);
37 ADD(5,2);
38 ADD(5,0);
39 ADD(5,0);
40 ADD(55,0);
41 ADD(105,0); // point is on hull
42
43 boost::geometry::model::polygon<point_xy<float> > hull;
44 boost::geometry::convex_hull(all_points_in_radius,hull);
45 return boost::geometry::area(hull);
46}
47
48int main()
49{
50 std::cout << "This should give 1407.5:" << std::endl;
51 std::cout << convex_hull_area() << std::endl;
52 return 0;
53}
54