]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/geometries/register/ring_templated.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / register / ring_templated.cpp
CommitLineData
7c673cae
FG
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_templated
11//` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING_TEMPLATED
12
13#include <iostream>
14#include <deque>
15
16#include <boost/geometry.hpp>
17#include <boost/geometry/geometries/point_xy.hpp>
18#include <boost/geometry/geometries/register/ring.hpp>
19
20// Adapt any deque to Boost.Geometry Ring Concept
21BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
22
23int main()
24{
25 std::deque<boost::geometry::model::d2::point_xy<double> > ring(3);
26 boost::geometry::assign_values(ring[0], 0, 0);
27 boost::geometry::assign_values(ring[2], 4, 1);
28 boost::geometry::assign_values(ring[1], 1, 4);
29
30 // Boost.Geometry algorithms work on any deque now
31 boost::geometry::correct(ring);
32 std::cout << "Area: " << boost::geometry::area(ring) << std::endl;
33 std::cout << "Contents: " << boost::geometry::wkt(ring) << std::endl;
34
35 return 0;
36}
37
38//]
39
40
41//[register_ring_templated_output
42/*`
43Output:
44[pre
45Area: 7.5
46Line: ((0, 0), (1, 4), (4, 1), (0, 0))
47]
48*/
49//]