]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/clear.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 clear a ring or polygon
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>
20 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
22 #include <boost/assign.hpp>
26 using boost::assign::tuple_list_of
;
28 typedef boost::tuple
<float, float> point
;
29 typedef boost::geometry::model::polygon
<point
> polygon
;
30 typedef boost::geometry::model::ring
<point
> ring
;
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));
38 std::cout
<< boost::geometry::dsv(poly
) << std::endl
;
39 boost::geometry::clear(poly
);
40 std::cout
<< boost::geometry::dsv(poly
) << std::endl
;
42 // Create a ring using Boost.Assign
43 ring r
= tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0);
45 std::cout
<< boost::geometry::dsv(r
) << std::endl
;
46 boost::geometry::clear(r
);
47 std::cout
<< boost::geometry::dsv(r
) << std::endl
;
59 (((0, 0), (0, 10), (11, 11), (0, 0)), ((0, 0), (0, 10), (11, 11), (0, 0)))
61 ((0, 0), (0, 9), (8, 8), (0, 0))