]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/strategies/buffer_end_flat.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / strategies / buffer_end_flat.cpp
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_end_flat
11 //` Shows how the end_flat strategy can be used as a EndStrategy to create flat ends
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::linestring<point> linestring;
22 typedef boost::geometry::model::polygon<point> polygon;
23
24 // Declare the flat-end strategy
25 boost::geometry::strategy::buffer::end_flat end_strategy;
26
27 // Declare other strategies
28 boost::geometry::strategy::buffer::distance_symmetric<double> distance_strategy(1.0);
29 boost::geometry::strategy::buffer::side_straight side_strategy;
30 boost::geometry::strategy::buffer::join_round join_strategy;
31 boost::geometry::strategy::buffer::point_circle point_strategy;
32
33 // Declare/fill a multi linestring
34 boost::geometry::model::multi_linestring<linestring> ml;
35 boost::geometry::read_wkt("MULTILINESTRING((3 5,5 10,7 5),(7 7,11 10,15 7,19 10))", ml);
36
37 // Create the buffered geometry with flat ends
38 boost::geometry::model::multi_polygon<polygon> result;
39 boost::geometry::buffer(ml, result,
40 distance_strategy, side_strategy,
41 join_strategy, end_strategy, point_strategy);
42 /*<-*/ create_svg_buffer("buffer_end_flat.svg", ml, result); /*->*/
43
44 return 0;
45 }
46
47 //]
48