]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/is_valid_message.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / is_valid_message.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2015, 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 //[is_valid_message
12 //` Checks whether a geometry is valid and, if not valid, prints a message describing the reason
13
14 #include <iostream>
15 #include <string>
16
17 #include <boost/geometry.hpp>
18 #include <boost/geometry/geometries/point_xy.hpp>
19 #include <boost/geometry/geometries/polygon.hpp>
20 /*<-*/ #include "create_svg_one.hpp" /*->*/
21
22 int main()
23 {
24 typedef boost::geometry::model::d2::point_xy<double> point_type;
25 typedef boost::geometry::model::polygon<point_type> polygon_type;
26
27 polygon_type poly;
28 boost::geometry::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 2,0 0),(0 0,2 9,1 9,0 0),(2 9,9 2,9 9,2 9))", poly);
29
30 std::string message;
31 bool valid = boost::geometry::is_valid(poly, message);
32 std::cout << "is valid? " << (valid ? "yes" : "no") << std::endl;
33 if (! valid)
34 {
35 std::cout << "why not valid? " << message << std::endl;
36 }
37 /*<-*/ create_svg("is_valid_example.svg", poly); /*->*/
38 return 0;
39 }
40
41 //]
42
43 //[is_valid_message_output
44 /*`
45 Output:
46 [pre
47 is valid? no
48 why not valid? Geometry has disconnected interior
49
50 [$img/algorithms/is_valid_example.png]
51
52 ]
53
54 */
55 //]