]>
Commit | Line | Data |
---|---|---|
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 | |
21 | BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque) | |
22 | ||
23 | int 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 | /*` | |
43 | Output: | |
44 | [pre | |
45 | Area: 7.5 | |
46 | Line: ((0, 0), (1, 4), (4, 1), (0, 0)) | |
47 | ] | |
48 | */ | |
49 | //] |