]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/reverse.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 reverse 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
<int, int> point
;
29 typedef boost::geometry::model::polygon
<point
> polygon
;
30 typedef boost::geometry::model::ring
<point
> ring
;
34 boost::geometry::exterior_ring(poly
) = tuple_list_of(0, 0)(0, 9)(10, 10)(0, 0);
35 boost::geometry::interior_rings(poly
).push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2));
37 double area_before
= boost::geometry::area(poly
);
38 boost::geometry::reverse(poly
);
39 double area_after
= boost::geometry::area(poly
);
40 std::cout
<< boost::geometry::dsv(poly
) << std::endl
;
41 std::cout
<< area_before
<< " -> " << area_after
<< std::endl
;
43 ring r
= tuple_list_of(0, 0)(0, 9)(8, 8)(0, 0);
45 area_before
= boost::geometry::area(r
);
46 boost::geometry::reverse(r
);
47 area_after
= boost::geometry::area(r
);
48 std::cout
<< boost::geometry::dsv(r
) << std::endl
;
49 std::cout
<< area_before
<< " -> " << area_after
<< std::endl
;
61 (((0, 0), (10, 10), (0, 9), (0, 0)), ((1, 2), (2, 8), (4, 6), (1, 2)))
63 ((0, 0), (8, 8), (0, 9), (0, 0))