]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // QuickBook Example | |
3 | ||
4 | // Copyright (c) 2014 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 | //[buffer_join_round | |
11 | //` Shows how the join_round strategy can be used as a JoinStrategy to create rounded corners | |
12 | ||
13 | #include <boost/geometry.hpp> | |
14 | #include <boost/geometry/geometries/point_xy.hpp> | |
15 | #include <boost/geometry/geometries/geometries.hpp> | |
16 | /*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/ | |
17 | ||
18 | int main() | |
19 | { | |
20 | typedef boost::geometry::model::d2::point_xy<double> point; | |
21 | typedef boost::geometry::model::polygon<point> polygon; | |
22 | ||
23 | // Declare the join_round strategy with 72 points for a full circle | |
24 | boost::geometry::strategy::buffer::join_round join_strategy(72); | |
25 | ||
26 | // Declare other strategies | |
27 | boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0); | |
28 | boost::geometry::strategy::buffer::end_flat end_strategy; | |
29 | boost::geometry::strategy::buffer::side_straight side_strategy; | |
30 | boost::geometry::strategy::buffer::point_circle point_strategy; | |
31 | ||
32 | // Declare/fill a multi polygon | |
33 | boost::geometry::model::multi_polygon<polygon> mp; | |
34 | boost::geometry::read_wkt("MULTIPOLYGON(((5 5,7 8,9 5,5 5)),((8 7,8 10,11 10,11 7,8 7)))", mp); | |
35 | ||
36 | // Create the buffered geometry with rounded corners | |
37 | boost::geometry::model::multi_polygon<polygon> result; | |
38 | boost::geometry::buffer(mp, result, | |
39 | distance_strategy, side_strategy, | |
40 | join_strategy, end_strategy, point_strategy); | |
41 | /*<-*/ create_svg_buffer("buffer_join_round.svg", mp, result); /*->*/ | |
42 | ||
43 | return 0; | |
44 | } | |
45 | ||
46 | //] | |
47 |