]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/register/ring.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / register / ring.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 //[register_ring
11 //` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING
12
13 #include <iostream>
14
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
17 #include <boost/geometry/geometries/register/ring.hpp>
18
19 typedef boost::geometry::model::d2::point_xy<double> point_2d;
20
21 BOOST_GEOMETRY_REGISTER_RING(std::vector<point_2d>) /*< The magic: adapt vector to Boost.Geometry Ring Concept >*/
22
23 int main()
24 {
25 // Normal usage of std::
26 std::vector<point_2d> ring;
27 ring.push_back(point_2d(1, 1));
28 ring.push_back(point_2d(2, 2));
29 ring.push_back(point_2d(2, 1));
30
31
32 // Usage of Boost.Geometry
33 boost::geometry::correct(ring);
34 std::cout << "Area: " << boost::geometry::area(ring) << std::endl;
35 std::cout << "WKT: " << boost::geometry::wkt(ring) << std::endl;
36
37 return 0;
38 }
39
40 //]
41
42
43 //[register_ring_output
44 /*`
45 Output:
46 [pre
47 Area: 0.5
48 WKT: POLYGON((1 1,2 2,2 1,1 1))
49 ]
50 */
51 //]