]>
Commit | Line | Data |
---|---|---|
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_box_templated | |
11 | //` Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED | |
12 | ||
13 | #include <iostream> | |
14 | ||
15 | #include <boost/geometry.hpp> | |
16 | #include <boost/geometry/geometries/point_xy.hpp> | |
17 | #include <boost/geometry/geometries/register/box.hpp> | |
18 | ||
19 | template <typename P> | |
20 | struct my_box | |
21 | { | |
22 | P ll, ur; | |
23 | }; | |
24 | ||
25 | // Register the box type | |
26 | BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(my_box, ll, ur) | |
27 | ||
28 | int main() | |
29 | { | |
30 | typedef my_box<boost::geometry::model::d2::point_xy<double> > box; | |
31 | box b = boost::geometry::make<box>(0, 0, 2, 2); | |
32 | std::cout << "Area: " << boost::geometry::area(b) << std::endl; | |
33 | return 0; | |
34 | } | |
35 | ||
36 | //] | |
37 | ||
38 | ||
39 | //[register_box_templated_output | |
40 | /*` | |
41 | Output: | |
42 | [pre | |
43 | Area: 4 | |
44 | ] | |
45 | */ | |
46 | //] |