• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3 
4 // Copyright (c) 2014, Oracle and/or its affiliates
5 
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10 
11 //[num_segments
12 //` Get the number of segments in a geometry
13 
14 #include <iostream>
15 
16 #include <boost/geometry.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 
19 
main()20 int main()
21 {
22     boost::geometry::model::multi_polygon
23         <
24             boost::geometry::model::polygon
25                 <
26                     boost::geometry::model::d2::point_xy<double>, true, false // cw, open polygon
27                 >
28         > mp;
29     boost::geometry::read_wkt("MULTIPOLYGON(((0 0,0 10,10 0),(1 1,8 1,1 8)),((10 10,10 20,20 10)))", mp);
30     std::cout << "Number of segments: " << boost::geometry::num_segments(mp) << std::endl;
31     return 0;
32 }
33 
34 //]
35 
36 
37 //[num_segments_output
38 /*`
39 Output:
40 [pre
41  Number of segments: 9
42 ]
43 */
44 //]
45