]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/robustness/overlay/areal_areal/interior_triangles.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #define BOOST_GEOMETRY_NO_BOOST_TEST
12 #include <test_overlay_p_q.hpp>
21 #include <boost/program_options.hpp>
22 #include <boost/random/linear_congruential.hpp>
23 #include <boost/random/uniform_int.hpp>
24 #include <boost/random/uniform_real.hpp>
25 #include <boost/random/variate_generator.hpp>
27 template <typename Polygon
>
28 inline void make_polygon(Polygon
& polygon
, int count_x
, int count_y
, int index
, int offset
)
30 typedef typename
bg::point_type
<Polygon
>::type point_type
;
31 bg::exterior_ring(polygon
).push_back(point_type(0, 0));
32 bg::exterior_ring(polygon
).push_back(point_type(0, count_y
* 10));
33 bg::exterior_ring(polygon
).push_back(point_type(count_x
* 10 + 10, count_y
* 10));
34 bg::exterior_ring(polygon
).push_back(point_type(count_x
* 10 + 10, 0));
35 bg::exterior_ring(polygon
).push_back(point_type(0, 0));
37 for(int j
= 0; j
< count_x
; ++j
)
39 for(int k
= 0; k
< count_y
; ++k
)
41 polygon
.inners().push_back(typename
Polygon::inner_container_type::value_type());
42 polygon
.inners().back().push_back(point_type(offset
+ j
* 10 + 1, k
* 10 + 1));
43 polygon
.inners().back().push_back(point_type(offset
+ j
* 10 + 7, k
* 10 + 5 + index
));
44 polygon
.inners().back().push_back(point_type(offset
+ j
* 10 + 5 + index
, k
* 10 + 7));
45 polygon
.inners().back().push_back(point_type(offset
+ j
* 10 + 1, k
* 10 + 1));
53 template <typename Polygon
>
54 void test_star_comb(int index
, int count_x
, int count_y
, int offset
, p_q_settings
const& settings
)
58 make_polygon(p
, count_x
, count_y
, 0, 0);
59 make_polygon(q
, count_x
, count_y
, 1, offset
);
61 std::ostringstream out
;
62 out
<< "interior_triangles" << index
;
66 typename
bg::coordinate_type
<Polygon
>::type
67 >(out
.str(), p
, q
, settings
);
71 template <typename T
, bool Clockwise
, bool Closed
>
72 void test_all(int count
, int count_x
, int count_y
, int offset
, p_q_settings
const& settings
)
74 auto const t0
= std::chrono::high_resolution_clock::now();
76 typedef bg::model::polygon
78 bg::model::d2::point_xy
<T
>, Clockwise
, Closed
82 for(int i
= 0; i
< count
; i
++)
84 test_star_comb
<polygon
>(i
, count_x
, count_y
, offset
, settings
);
86 auto const t
= std::chrono::high_resolution_clock::now();
87 auto const elapsed_ms
= std::chrono::duration_cast
<std::chrono::milliseconds
>(t
- t0
).count();
89 << " type: " << string_from_type
<T
>::name()
90 << " time: " << elapsed_ms
/ 1000.0 << std::endl
;
93 int main(int argc
, char** argv
)
95 BoostGeometryWriteTestConfiguration();
98 namespace po
= boost::program_options
;
99 po::options_description
description("=== interior_triangles ===\nAllowed options");
107 p_q_settings settings
;
109 description
.add_options()
110 ("help", "Help message")
111 ("count", po::value
<int>(&count
)->default_value(1), "Number of tests")
112 ("count_x", po::value
<int>(&count_x
)->default_value(10), "Triangle count in x-direction")
113 ("count_y", po::value
<int>(&count_y
)->default_value(10), "Triangle count in y-direction")
114 ("offset", po::value
<int>(&offset
)->default_value(0), "Offset of second triangle in x-direction")
115 ("diff", po::value
<bool>(&settings
.also_difference
)->default_value(false), "Include testing on difference")
116 ("ccw", po::value
<bool>(&ccw
)->default_value(false), "Counter clockwise polygons")
117 ("open", po::value
<bool>(&open
)->default_value(false), "Open polygons")
118 ("wkt", po::value
<bool>(&settings
.wkt
)->default_value(false), "Create a WKT of the inputs, for all tests")
119 ("svg", po::value
<bool>(&settings
.svg
)->default_value(false), "Create a SVG for all tests")
122 po::variables_map varmap
;
123 po::store(po::parse_command_line(argc
, argv
, description
), varmap
);
126 if (varmap
.count("help"))
128 std::cout
<< description
<< std::endl
;
134 test_all
<default_test_type
, false, false>(count
, count_x
, count_y
, offset
, settings
);
138 test_all
<default_test_type
, false, true>(count
, count_x
, count_y
, offset
, settings
);
142 test_all
<default_test_type
, true, false>(count
, count_x
, count_y
, offset
, settings
);
146 test_all
<default_test_type
, true, true>(count
, count_x
, count_y
, offset
, settings
);
149 catch(std::exception
const& e
)
151 std::cout
<< "Exception " << e
.what() << std::endl
;
155 std::cout
<< "Other exception" << std::endl
;