]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/views/segment_view.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / views / segment_view.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
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)
9
10 //[segment_view
11 //` Shows usage of the Boost.Range compatible view on a box
12
13 #include <iostream>
14
15 #include <boost/geometry.hpp>
16
17
18 int main()
19 {
20 typedef boost::geometry::model::segment
21 <
22 boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
23 > segment_type;
24
25 typedef boost::geometry::segment_view<segment_type> segment_view;
26
27 segment_type segment;
28 boost::geometry::assign_values(segment, 0, 0, 1, 1);
29
30 segment_view view(segment);
31
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)
35 {
36 std::cout << " " << boost::geometry::dsv(*it);
37 }
38 std::cout << std::endl;
39
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;
42
43 return 0;
44 }
45
46 //]
47
48
49 //[segment_view_output
50 /*`
51 Output:
52 [pre
53 (0, 0) (0, 4) (4, 4) (4, 0) (0, 0)
54 Area: 16
55 ]
56 */
57 //]