Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / geometry / doc / src / examples / algorithms / is_valid.cpp
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 //[is_valid
12 //` Checks whether a geometry is valid
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 /*<-*/ #include "create_svg_one.hpp" /*->*/
20
21 int main()
22 {
23     typedef boost::geometry::model::d2::point_xy<double> point_type;
24     typedef boost::geometry::model::polygon<point_type> polygon_type;
25
26     polygon_type poly;
27     boost::geometry::read_wkt(
28         "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))"
29             , poly);
30
31     std::cout << "is valid? " << (boost::geometry::is_valid(poly) ? "yes" : "no") << std::endl;
32     /*<-*/ create_svg("is_valid_example.svg", poly); /*->*/
33     return 0;
34 }
35
36 //]
37
38 //[is_valid_output
39 /*`
40 Output:
41 [pre
42 is valid? no
43
44 [$img/algorithms/is_valid_example.png]
45
46 ]
47
48 */
49 //]