]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/convex_hull.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
11 //` Shows how to generate the convex_hull of a geometry
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/polygon.hpp>
17 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
19 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
21 /*<-*/ #include "create_svg_two.hpp" /*->*/
24 typedef boost::tuple
<double, double> point
;
25 typedef boost::geometry::model::polygon
<point
> polygon
;
28 boost::geometry::read_wkt("polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
29 ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))", poly
);
32 boost::geometry::convex_hull(poly
, hull
);
34 using boost::geometry::dsv
;
36 << "polygon: " << dsv(poly
) << std::endl
37 << "hull: " << dsv(hull
) << std::endl
40 /*<-*/ create_svg("hull.svg", poly
, hull
); /*->*/
51 polygon: (((2, 1.3), (2.4, 1.7), (2.8, 1.8), (3.4, 1.2), (3.7, 1.6), (3.4, 2), (4.1, 3), (5.3, 2.6), (5.4, 1.2), (4.9, 0.8), (2.9, 0.7), (2, 1.3)))
52 hull: (((2, 1.3), (2.4, 1.7), (4.1, 3), (5.3, 2.6), (5.4, 1.2), (4.9, 0.8), (2.9, 0.7), (2, 1.3)))
54 [$img/algorithms/convex_hull.png]