]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/views/box_view.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 the Boost.Range compatible view on a box
15 #include <boost/geometry.hpp>
20 typedef boost::geometry::model::box
22 boost::geometry::model::point
<double, 2, boost::geometry::cs::cartesian
>
25 // Define the Boost.Range compatible type:
26 typedef boost::geometry::box_view
<box_type
> box_view
;
29 boost::geometry::assign_values(box
, 0, 0, 4, 4);
33 // Iterating in clockwise direction over the points of this box
34 for (boost::range_iterator
<box_view
const>::type it
= boost::begin(view
);
35 it
!= boost::end(view
); ++it
)
37 std::cout
<< " " << boost::geometry::dsv(*it
);
39 std::cout
<< std::endl
;
41 // Note that a box_view is tagged as a ring, so supports area etc.
42 std::cout
<< "Area: " << boost::geometry::area(view
) << std::endl
;
54 (0, 0) (0, 4) (4, 4) (4, 0) (0, 0)