]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/views/segment_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::segment
22 boost::geometry::model::point
<double, 2, boost::geometry::cs::cartesian
>
25 typedef boost::geometry::segment_view
<segment_type
> segment_view
;
28 boost::geometry::assign_values(segment
, 0, 0, 1, 1);
30 segment_view
view(segment
);
32 // Iterating over the points of this segment
33 for (boost::range_iterator
<segment_view
const>::type it
= boost::begin(view
);
34 it
!= boost::end(view
); ++it
)
36 std::cout
<< " " << boost::geometry::dsv(*it
);
38 std::cout
<< std::endl
;
40 // Note that a segment_view is tagged as a linestring, so supports length etc.
41 std::cout
<< "Length: " << boost::geometry::length(view
) << std::endl
;
49 //[segment_view_output
53 (0, 0) (0, 4) (4, 4) (4, 0) (0, 0)