]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/append.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 usage of Boost.Geometry's append to append a point or a range to a polygon
15 #include <boost/assign.hpp>
17 #include <boost/geometry.hpp>
18 #include <boost/geometry/geometries/polygon.hpp>
19 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
21 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
25 using boost::assign::tuple_list_of
;
26 using boost::make_tuple
;
27 using boost::geometry::append
;
29 typedef boost::geometry::model::polygon
<boost::tuple
<int, int> > polygon
;
34 append(poly
, tuple_list_of(0, 0)(0, 10)(11, 11)(10, 0)); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::append >*/
35 // Append a point (in this case the closing point)
36 append(poly
, make_tuple(0, 0));
38 // Create an interior ring (append does not do this automatically)
39 boost::geometry::interior_rings(poly
).resize(1);
41 // Append a range to the interior ring
42 append(poly
, tuple_list_of(2, 2)(2, 5)(6, 6)(5, 2), 0); /*< The last parameter ring_index 0 denotes the first interior ring >*/
43 // Append a point to the first interior ring
44 append(poly
, make_tuple(2, 2), 0);
46 std::cout
<< boost::geometry::dsv(poly
) << std::endl
;
58 (((0, 0), (0, 10), (11, 11), (10, 0), (0, 0)), ((2, 2), (2, 5), (6, 6), (5, 2), (2, 2)))