]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry |
2 | // QuickBook Example | |
3 | ||
4 | // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland. | |
6 | ||
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | //[ring | |
12 | //` Declaration and use of the Boost.Geometry model::ring, modelling the Ring Concept | |
13 | ||
14 | #include <iostream> | |
15 | #include <boost/geometry.hpp> | |
16 | #include <boost/geometry/geometries/geometries.hpp> | |
17 | ||
18 | namespace bg = boost::geometry; | |
19 | ||
20 | int main() | |
21 | { | |
22 | typedef bg::model::point<double, 2, bg::cs::cartesian> point_t; | |
23 | typedef bg::model::ring<point_t> ring_t; /*< Default parameters, clockwise, closed ring. >*/ | |
24 | ||
25 | ring_t ring1; /*< Default-construct a ring. >*/ | |
26 | ||
27 | #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ | |
28 | && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) | |
29 | ||
30 | ring_t ring2{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}; /*< Construct a ring containing four points plus one closing point, using C++11 unified initialization syntax. >*/ | |
31 | ||
32 | #endif | |
33 | ||
34 | bg::append(ring1, point_t(0.0, 0.0)); /*< Append point. >*/ | |
35 | bg::append(ring1, point_t(0.0, 5.0)); | |
36 | bg::append(ring1, point_t(5.0, 5.0)); | |
37 | bg::append(ring1, point_t(5.0, 0.0)); | |
38 | bg::append(ring1, point_t(0.0, 0.0)); | |
39 | ||
40 | double a = bg::area(ring1); | |
41 | ||
42 | std::cout << a << std::endl; | |
43 | ||
44 | return 0; | |
45 | } | |
46 | ||
47 | //] | |
48 | ||
49 | ||
50 | //[ring_output | |
51 | /*` | |
52 | Output: | |
53 | [pre | |
54 | 25 | |
55 | ] | |
56 | */ | |
57 | //] |