]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/convex_hull/convex_hull.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / convex_hull / convex_hull.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // This file was modified by Oracle on 2015.
9 // Modifications copyright (c) 2015 Oracle and/or its affiliates.
10
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
19
20 #include <cstddef>
21 #include <string>
22
23 #include "test_convex_hull.hpp"
24
25 #include <boost/geometry/geometries/geometries.hpp>
26 #include <boost/geometry/geometries/point_xy.hpp>
27
28
29 template <typename P>
30 void test_all()
31 {
32 typedef boost::geometry::strategies::convex_hull::cartesian<> strategy;
33
34 // from sample linestring
35 test_geometry<bg::model::linestring<P>, strategy >(
36 "linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", 5, 4, 3.8);
37
38 // rectangular, with concavity
39 test_geometry<bg::model::polygon<P>, strategy >(
40 "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))",
41 9, 5, 12.0);
42
43 // from sample polygon, with concavity
44 test_geometry<bg::model::polygon<P>, strategy >(
45 "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
46 ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
47 12, 8, 5.245);
48
49 test_geometry<bg::model::ring<P>, strategy >(
50 "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
51 ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
52 12, 8, 5.245);
53
54 test_geometry<bg::model::box<P>, strategy >("box(0 0,2 2)", 4, 5, 4);
55
56 // https://svn.boost.org/trac/boost/ticket/6443
57 {
58 test_geometry<bg::model::ring<P>, strategy >(
59 "polygon((0 0, 2 0))", // note that this polygon is very invalid
60 2, 4, 0, 4);
61 }
62
63 // degenerated hulls
64 test_geometry<bg::model::multi_point<P>, strategy >(
65 "multipoint(0 0)",
66 1, 4, 0, 0);
67 test_geometry<bg::model::multi_point<P>, strategy >(
68 "multipoint(0 0, 2 0)",
69 2, 4, 0, 4);
70 test_geometry<bg::model::linestring<P>, strategy >(
71 "linestring(0 0, 2 0)",
72 2, 4, 0, 4);
73
74 test_empty_input<bg::model::linestring<P> >();
75 test_empty_input<bg::model::ring<P> >();
76 test_empty_input<bg::model::polygon<P> >();
77 }
78
79
80 int test_main(int, char* [])
81 {
82 //test_all<bg::model::d2::point_xy<int> >();
83 test_all<bg::model::d2::point_xy<float> >();
84 test_all<bg::model::d2::point_xy<double> >();
85
86 return 0;
87 }