]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/assign_points.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 Boost.Geometry's assign, Boost.Assign, and Boost.Range to assign ranges of a linestring
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/linestring.hpp>
17 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
19 #include <boost/assign.hpp>
20 #include <boost/geometry/geometries/adapted/boost_range/filtered.hpp>
22 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS ( cs :: cartesian
)
32 bool operator ()( P
const & p
) const
34 return boost :: geometry :: get
< 0 >( p
) >= fa
35 && boost :: geometry :: get
< 0 >( p
) <= fb
;
44 using namespace boost :: assign
;
46 typedef boost :: geometry :: model :: linestring
< boost :: tuple
< int , int > > ls
;
48 ls line1
, line2
, line3
;
50 line1
= tuple_list_of ( 0 , 0 )( 2 , 3 )( 4 , 0 )( 6 , 3 )( 8 , 0 )( 10 , 3 )( 12 , 0 ); /*< tuple_list_of is part of Boost.Assign and can be used for Boost.Geometry if points are tuples >*/
51 boost :: geometry :: assign_points ( line2
, tuple_list_of ( 0 , 0 )( 2 , 2 )( 4 , 0 )( 6 , 2 )( 8 , 0 )); /*< tuple_list_of delivers a range and can therefore be used in boost::geometry::assign >*/
52 boost :: geometry :: assign_points ( line3
, line1
| boost :: adaptors :: filtered ( x_between
< int >( 4 , 8 ))); /*< Boost.Range adaptors can also be used in boost::geometry::assign >*/
54 std :: cout
<< "line 1: " << boost :: geometry :: dsv ( line1
) << std :: endl
;
55 std :: cout
<< "line 2: " << boost :: geometry :: dsv ( line2
) << std :: endl
;
56 std :: cout
<< "line 3: " << boost :: geometry :: dsv ( line3
) << std :: endl
;
64 //[assign_points_output
68 line 1: ((0, 0), (2, 3), (4, 0), (6, 3), (8, 0), (10, 3), (12, 0))
69 line 2: ((0, 0), (2, 2), (4, 0), (6, 2), (8, 0))
70 line 3: ((4, 0), (6, 3), (8, 0))