]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/adapted/boost_tuple.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / adapted / boost_tuple.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 //[boost_tuple
11 /*`
12 Shows how to use Boost.Tuple points in Boost.Geometry
13
14 Working with Boost.Tuples in Boost.Geometry is straightforward and shown in
15 various other examples as well.
16
17 */
18
19 #include <iostream>
20
21 #include <boost/geometry.hpp>
22 #include <boost/geometry/geometries/polygon.hpp>
23 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
24
25 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
26
27 int main()
28 {
29 boost::geometry::model::polygon<boost::tuple<double, double> > poly;
30 poly.outer().push_back(boost::make_tuple(1.0, 2.0));
31 poly.outer().push_back(boost::make_tuple(6.0, 4.0));
32 poly.outer().push_back(boost::make_tuple(5.0, 1.0));
33 poly.outer().push_back(boost::make_tuple(1.0, 2.0));
34
35 std::cout << "Area: " << boost::geometry::area(poly) << std::endl;
36 std::cout << "Contains (1.5, 2.5): "
37 << std::boolalpha
38 << boost::geometry::within(boost::make_tuple(1.5, 2.5), poly)
39 << std::endl;
40
41 return 0;
42 }
43
44 //]
45
46 //[boost_tuple_output
47 /*`
48 Output:
49 [pre
50 Area: 6.5
51 Contains (1.5, 2.5): false
52 ]
53 */
54 //]