]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/clear.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / clear.cpp
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 //[clear
11 //` Shows how to clear a ring or polygon
12
13 #include <iostream>
14
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/polygon.hpp>
17 #include <boost/geometry/geometries/ring.hpp>
18 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
19
20 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
21
22 #include <boost/assign.hpp>
23
24 int main()
25 {
26 using boost::assign::tuple_list_of;
27
28 typedef boost::tuple<float, float> point;
29 typedef boost::geometry::model::polygon<point> polygon;
30 typedef boost::geometry::model::ring<point> ring;
31
32 polygon poly;
33
34 // Fill the polygon (using its own methods + Boost.Assign)
35 poly.outer() = tuple_list_of(0, 0)(0, 9)(10, 10)(0, 0);
36 poly.inners().push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2));
37
38 std::cout << boost::geometry::dsv(poly) << std::endl;
39 boost::geometry::clear(poly);
40 std::cout << boost::geometry::dsv(poly) << std::endl;
41
42 // Create a ring using Boost.Assign
43 ring r = tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0);
44
45 std::cout << boost::geometry::dsv(r) << std::endl;
46 boost::geometry::clear(r);
47 std::cout << boost::geometry::dsv(r) << std::endl;
48
49 return 0;
50 }
51
52 //]
53
54
55 //[clear_output
56 /*`
57 Output:
58 [pre
59 (((0, 0), (0, 10), (11, 11), (0, 0)), ((0, 0), (0, 10), (11, 11), (0, 0)))
60 (())
61 ((0, 0), (0, 9), (8, 8), (0, 0))
62 ()
63 ]
64 */
65 //]