]>
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_box | |
11 | //` Show the use of the macro BOOST_GEOMETRY_REGISTER_BOX | |
12 | ||
13 | #include <iostream> | |
14 | #include <boost/geometry.hpp> | |
15 | #include <boost/geometry/geometries/register/point.hpp> | |
16 | #include <boost/geometry/geometries/register/box.hpp> | |
17 | ||
18 | struct my_point | |
19 | { | |
20 | double x, y; | |
21 | }; | |
22 | ||
23 | struct my_box | |
24 | { | |
25 | my_point ll, ur; | |
26 | }; | |
27 | ||
28 | // Register the point type | |
29 | BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y) | |
30 | ||
31 | // Register the box type, also notifying that it is based on "my_point" | |
32 | BOOST_GEOMETRY_REGISTER_BOX(my_box, my_point, ll, ur) | |
33 | ||
34 | int main() | |
35 | { | |
36 | my_box b = boost::geometry::make<my_box>(0, 0, 2, 2); | |
37 | std::cout << "Area: " << boost::geometry::area(b) << std::endl; | |
38 | return 0; | |
39 | } | |
40 | ||
41 | //] | |
42 | ||
43 | ||
44 | //[register_box_output | |
45 | /*` | |
46 | Output: | |
47 | [pre | |
48 | Area: 4 | |
49 | ] | |
50 | */ | |
51 | //] |