]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/assign.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 assign a geometry from another geometry
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/box.hpp>
17 #include <boost/geometry/geometries/point_xy.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 typedef boost::geometry::model::d2::point_xy
<double> point
;
26 typedef boost::geometry::model::box
<point
> box
;
27 typedef boost::geometry::model::polygon
<point
> polygon
;
31 boost::geometry::assign_values(p1
, 1, 1);
32 boost::geometry::assign_values(b
, 1, 1, 2, 2);
34 // Assign a box to a polygon (target = source)
36 boost::geometry::assign(p
, b
);
38 // Assign a point to another point type (conversion of point-type)
39 boost::tuple
<double, double> p2
;
40 boost::geometry::assign(p2
, p1
);
42 using boost::geometry::dsv
;
44 << "box: " << dsv(b
) << std::endl
45 << "polygon: " << dsv(p
) << std::endl
46 << "point: " << dsv(p1
) << std::endl
47 << "point tuples: " << dsv(p2
) << std::endl
61 polygon: (((1, 1), (1, 2), (2, 2), (2, 1), (1, 1)))