1 // Boost.Geometry
2 // QuickBook Example
3
4 // Copyright (c) 2018, Oracle and/or its affiliates
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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 //[densify
12 //` Shows how to densify a polygon
13
14 #include <iostream>
15
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/geometry/geometries/polygon.hpp>
19
main()20 int main()
21 {
22 typedef boost::geometry::model::d2::point_xy<double> point_type;
23 typedef boost::geometry::model::polygon<point_type> polygon_type;
24
25 polygon_type poly;
26 boost::geometry::read_wkt(
27 "POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,4 1,4 4,1 4,1 1))", poly);
28
29 polygon_type res;
30
31 boost::geometry::densify(poly, res, 6.0);
32
33 std::cout << "densified: " << boost::geometry::wkt(res) << std::endl;
34
35 return 0;
36 }
37
38 //]
39
40 //[densify_output
41 /*`
42 Output:
43 [pre
44 densified: POLYGON((0 0,0 5,0 10,5 10,10 10,10 5,10 0,5 0,0 0),(1 1,4 1,4 4,1 4,1 1))
45 ]
46 */
47 //]
48