]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/convex_hull.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / convex_hull.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// QuickBook Example
3
4// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
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)
9
10//[convex_hull
11//` Shows how to generate the convex_hull of a geometry
12
13#include <iostream>
14
15#include <boost/geometry.hpp>
16#include <boost/geometry/geometries/polygon.hpp>
17#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
18
19BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
20
21/*<-*/ #include "create_svg_two.hpp" /*->*/
22int main()
23{
24 typedef boost::tuple<double, double> point;
25 typedef boost::geometry::model::polygon<point> polygon;
26
27 polygon poly;
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);
30
31 polygon hull;
32 boost::geometry::convex_hull(poly, hull);
33
34 using boost::geometry::dsv;
35 std::cout
36 << "polygon: " << dsv(poly) << std::endl
37 << "hull: " << dsv(hull) << std::endl
38 ;
39
40 /*<-*/ create_svg("hull.svg", poly, hull); /*->*/
41 return 0;
42}
43
44//]
45
46
47//[convex_hull_output
48/*`
49Output:
50[pre
51polygon: (((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)))
52hull: (((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)))
53
54[$img/algorithms/convex_hull.png]
55]
56*/
57//]