mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
Merge pull request #762 from barendgehrels/test/robustness
[test] Update robustness tests:
This commit is contained in:
commit
6e5d9a136f
0
test/robustness/overlay/areal_areal/general_intersection_precision.cpp
Executable file → Normal file
0
test/robustness/overlay/areal_areal/general_intersection_precision.cpp
Executable file → Normal file
@ -1,28 +1,28 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
template <typename Polygon>
|
||||
inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index, int offset)
|
||||
@ -51,7 +51,7 @@ inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index,
|
||||
|
||||
|
||||
template <typename Polygon>
|
||||
void test_star_comb(int count_x, int count_y, int offset, p_q_settings const& settings)
|
||||
void test_star_comb(int index, int count_x, int count_y, int offset, p_q_settings const& settings)
|
||||
{
|
||||
Polygon p, q;
|
||||
|
||||
@ -59,7 +59,7 @@ void test_star_comb(int count_x, int count_y, int offset, p_q_settings const& se
|
||||
make_polygon(q, count_x, count_y, 1, offset);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "interior_triangles";
|
||||
out << "interior_triangles" << index;
|
||||
test_overlay_p_q
|
||||
<
|
||||
Polygon,
|
||||
@ -71,7 +71,7 @@ void test_star_comb(int count_x, int count_y, int offset, p_q_settings const& se
|
||||
template <typename T, bool Clockwise, bool Closed>
|
||||
void test_all(int count, int count_x, int count_y, int offset, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
typedef bg::model::polygon
|
||||
<
|
||||
@ -81,11 +81,13 @@ void test_all(int count, int count_x, int count_y, int offset, p_q_settings cons
|
||||
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
test_star_comb<polygon>(count_x, count_y, offset, settings);
|
||||
test_star_comb<polygon>(i, count_x, count_y, offset, settings);
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -129,19 +131,19 @@ int main(int argc, char** argv)
|
||||
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(count, count_x, count_y, offset, settings);
|
||||
test_all<default_test_type, false, false>(count, count_x, count_y, offset, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(count, count_x, count_y, offset, settings);
|
||||
test_all<default_test_type, false, true>(count, count_x, count_y, offset, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(count, count_x, count_y, offset, settings);
|
||||
test_all<default_test_type, true, false>(count, count_x, count_y, offset, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(count, count_x, count_y, offset, settings);
|
||||
test_all<default_test_type, true, true>(count, count_x, count_y, offset, settings);
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -11,12 +11,14 @@
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
#include <sstream>
|
||||
#include <chrono>
|
||||
|
||||
template <typename Polygon>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
template <typename Polygon, typename T>
|
||||
inline void make_pie(Polygon& polygon,
|
||||
int count, int offset, int offset_y, double factor1, int total_segment_count = 36)
|
||||
int count, int offset, int offset_y, T factor1, int total_segment_count = 36)
|
||||
{
|
||||
typedef typename bg::point_type<Polygon>::type p;
|
||||
typedef typename bg::select_most_precise
|
||||
@ -131,7 +133,7 @@ template <typename T, bool Clockwise, bool Closed>
|
||||
void test_pie(int total_segment_count, T factor_p, T factor_q,
|
||||
bool multi, bool single_selftangent, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
typedef bg::model::d2::point_xy<T> point_type;
|
||||
typedef bg::model::polygon<point_type, Clockwise, Closed> polygon;
|
||||
typedef bg::model::multi_polygon<polygon> multi_polygon;
|
||||
@ -221,8 +223,10 @@ void test_pie(int total_segment_count, T factor_p, T factor_q,
|
||||
}
|
||||
}
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< "Time: " << t.elapsed() << std::endl
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl
|
||||
<< "Good: " << good_count << std::endl
|
||||
<< "Bad: " << bad_count << std::endl;
|
||||
}
|
||||
@ -271,21 +275,20 @@ int main(int argc, char** argv)
|
||||
// template par's are: CoordinateType, Clockwise, Closed
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(multi, single_selftangent, settings);
|
||||
test_all<default_test_type, false, false>(multi, single_selftangent, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(multi, single_selftangent, settings);
|
||||
test_all<default_test_type, false, true>(multi, single_selftangent, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(multi, single_selftangent, settings);
|
||||
test_all<default_test_type, true, false>(multi, single_selftangent, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(multi, single_selftangent, settings);
|
||||
test_all<default_test_type, true, true>(multi, single_selftangent, settings);
|
||||
}
|
||||
//test_all<long double>();
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
{
|
||||
|
@ -1,21 +1,22 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
template <typename Polygon>
|
||||
inline void make_star(Polygon& polygon,
|
||||
@ -63,7 +64,7 @@ inline void make_star(Polygon& polygon,
|
||||
template <typename T, typename CalculationType>
|
||||
void test_star(int count, int min_points, int max_points, T rotation, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
typedef bg::model::d2::point_xy<T> point_type;
|
||||
typedef bg::model::polygon<point_type> polygon;
|
||||
|
||||
@ -73,9 +74,7 @@ void test_star(int count, int min_points, int max_points, T rotation, p_q_settin
|
||||
for (int i = min_points; i <= max_points; i++)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "_" << string_from_type<T>::name() << "_"
|
||||
<< string_from_type<CalculationType>::name() << "_"
|
||||
<< i << "_int";
|
||||
out << "stars_" << c << "_" << i;
|
||||
|
||||
polygon p;
|
||||
make_star(p, i * 2 + 1, 0.5, 1.0);
|
||||
@ -93,10 +92,12 @@ void test_star(int count, int min_points, int max_points, T rotation, p_q_settin
|
||||
n++;
|
||||
}
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< "polygons: " << n
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T, typename CalculationType>
|
||||
|
@ -1,28 +1,27 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2011-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
|
||||
template <typename MultiPolygon>
|
||||
@ -79,7 +78,7 @@ void test_intersects(int count_x, int count_y, int width_x, p_q_settings const&
|
||||
template <typename T, bool Clockwise, bool Closed>
|
||||
void test_all(int count, int count_x, int count_y, int width_x, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
typedef bg::model::polygon
|
||||
<
|
||||
@ -95,9 +94,11 @@ void test_all(int count, int count_x, int count_y, int width_x, p_q_settings con
|
||||
{
|
||||
test_intersects<multi_polygon>(count_x, count_y, width_x, settings);
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -140,19 +141,19 @@ int main(int argc, char** argv)
|
||||
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(count, count_x, count_y, width_x, settings);
|
||||
test_all<default_test_type, false, false>(count, count_x, count_y, width_x, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(count, count_x, count_y, width_x, settings);
|
||||
test_all<default_test_type, false, true>(count, count_x, count_y, width_x, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(count, count_x, count_y, width_x, settings);
|
||||
test_all<default_test_type, true, false>(count, count_x, count_y, width_x, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(count, count_x, count_y, width_x, settings);
|
||||
test_all<default_test_type, true, true>(count, count_x, count_y, width_x, settings);
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -9,11 +9,9 @@
|
||||
|
||||
#define BOOST_GEOMETRY_NO_BOOST_TEST
|
||||
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
@ -95,15 +93,14 @@ void test_star_ellipse(int seed, int index, star_params const& par_p,
|
||||
make_star(q, par_q);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "rse_" << seed << "_" << index;
|
||||
out << "star_ellipse_" << seed << "_" << index;
|
||||
test_overlay_p_q<polygon, T>(out.str(), p, q, settings);
|
||||
}
|
||||
|
||||
template <typename T, bool Clockwise, bool Closed>
|
||||
void test_type(int seed, int count, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
typedef boost::minstd_rand base_generator_type;
|
||||
|
||||
//boost::uniform_real<> random_factor(0.5, 1.2);
|
||||
@ -159,9 +156,11 @@ void test_type(int seed, int count, p_q_settings const& settings)
|
||||
location_generator(), location_generator(), rotation_generator()),
|
||||
settings);
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< "type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
template <bool Clockwise, bool Closed>
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -11,12 +11,14 @@
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <chrono>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
|
||||
template <typename Polygon, typename Generator>
|
||||
@ -109,7 +111,7 @@ bool test_recursive_boxes(MultiPolygon& result, int& index,
|
||||
template <typename T, bool Clockwise, bool Closed>
|
||||
void test_all(int seed, int count, int field_size, int level, bool triangular, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
typedef boost::minstd_rand base_generator_type;
|
||||
|
||||
@ -127,15 +129,23 @@ void test_all(int seed, int count, int field_size, int level, bool triangular, p
|
||||
|
||||
|
||||
int index = 0;
|
||||
int errors = 0;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
mp p;
|
||||
test_recursive_boxes<mp>(p, index, coordinate_generator, level, triangular, settings);
|
||||
if (! test_recursive_boxes<mp>(p, index, coordinate_generator, level, triangular, settings))
|
||||
{
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< "polygons: " << index
|
||||
<< "geometries: " << index
|
||||
<< " errors: " << errors
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -186,19 +196,19 @@ int main(int argc, char** argv)
|
||||
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(seed, count, field_size, level, triangular, settings);
|
||||
test_all<default_test_type, false, false>(seed, count, field_size, level, triangular, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(seed, count, field_size, level, triangular, settings);
|
||||
test_all<default_test_type, false, true>(seed, count, field_size, level, triangular, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(seed, count, field_size, level, triangular, settings);
|
||||
test_all<default_test_type, true, false>(seed, count, field_size, level, triangular, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(seed, count, field_size, level, triangular, settings);
|
||||
test_all<default_test_type, true, true>(seed, count, field_size, level, triangular, settings);
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -11,12 +11,15 @@
|
||||
|
||||
#include <test_overlay_p_q.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
#include <star_comb.hpp>
|
||||
|
||||
@ -30,15 +33,15 @@ void add(Polygon& polygon, double x, double y, int)
|
||||
|
||||
|
||||
template <typename Polygon>
|
||||
void test_star_comb(int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
|
||||
bool test_star_comb(int index, int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
|
||||
{
|
||||
Polygon star, comb;
|
||||
make_star(star, add<Polygon>, star_point_count, factor1, factor2);
|
||||
make_comb(comb, add<Polygon>, comb_comb_count);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "star_comb";
|
||||
test_overlay_p_q
|
||||
out << "star_comb_" << index;
|
||||
return test_overlay_p_q
|
||||
<
|
||||
Polygon,
|
||||
typename bg::coordinate_type<Polygon>::type
|
||||
@ -49,20 +52,28 @@ void test_star_comb(int star_point_count, int comb_comb_count, double factor1, d
|
||||
template <typename T, bool Clockwise, bool Closed>
|
||||
void test_all(int count, int star_point_count, int comb_comb_count, double factor1, double factor2, bool do_union, p_q_settings const& settings)
|
||||
{
|
||||
boost::timer t;
|
||||
auto const t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
typedef bg::model::polygon
|
||||
<
|
||||
bg::model::d2::point_xy<T>, Clockwise, Closed
|
||||
> polygon;
|
||||
|
||||
int errors = 0;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
test_star_comb<polygon>(star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
if (! test_star_comb<polygon>(i, star_point_count, comb_comb_count, factor1, factor2, do_union, settings))
|
||||
{
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
auto const t = std::chrono::high_resolution_clock::now();
|
||||
auto const elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count();
|
||||
std::cout
|
||||
<< "geometries: " << count
|
||||
<< " errors: " << errors
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << t.elapsed() << std::endl;
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@ -109,19 +120,19 @@ int main(int argc, char** argv)
|
||||
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
test_all<default_test_type, false, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
test_all<default_test_type, false, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
test_all<default_test_type, true, false>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
test_all<default_test_type, true, true>(count, star_point_count, comb_comb_count, factor1, factor2, do_union, settings);
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -13,7 +14,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/timer.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
// Robustness Test
|
||||
//
|
||||
// Copyright (c) 2009-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2009-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -16,8 +16,6 @@
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
|
||||
//#define BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
// For mixing int/float
|
||||
@ -76,8 +74,8 @@ struct verify_area
|
||||
{
|
||||
for (Iterator it = begin; it != end; ++it)
|
||||
{
|
||||
double const area = bg::area(*it);
|
||||
if (fabs(area) < 0.01)
|
||||
auto const area = bg::area(*it);
|
||||
if (bg::math::abs(area) < 0.01)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -134,9 +132,9 @@ static bool test_overlay_p_q(std::string const& caseid,
|
||||
bg::union_(p, q, out_u);
|
||||
CalculationType area_u = p_q_area(out_u);
|
||||
|
||||
double sum = (area_p + area_q) - area_u - area_i;
|
||||
auto const sum = (area_p + area_q) - area_u - area_i;
|
||||
|
||||
bool wrong = std::abs(sum) > settings.tolerance;
|
||||
bool wrong = bg::math::abs(sum) > settings.tolerance;
|
||||
|
||||
if (settings.also_difference)
|
||||
{
|
||||
@ -144,10 +142,10 @@ static bool test_overlay_p_q(std::string const& caseid,
|
||||
bg::difference(q, p, out_d2);
|
||||
area_d1 = p_q_area(out_d1);
|
||||
area_d2 = p_q_area(out_d2);
|
||||
double sum_d1 = (area_u - area_q) - area_d1;
|
||||
double sum_d2 = (area_u - area_p) - area_d2;
|
||||
bool wrong_d1 = std::abs(sum_d1) > settings.tolerance;
|
||||
bool wrong_d2 = std::abs(sum_d2) > settings.tolerance;
|
||||
auto sum_d1 = (area_u - area_q) - area_d1;
|
||||
auto sum_d2 = (area_u - area_p) - area_d2;
|
||||
bool wrong_d1 = bg::math::abs(sum_d1) > settings.tolerance;
|
||||
bool wrong_d2 = bg::math::abs(sum_d2) > settings.tolerance;
|
||||
|
||||
if (wrong_d1 || wrong_d2)
|
||||
{
|
||||
@ -249,8 +247,16 @@ static bool test_overlay_p_q(std::string const& caseid,
|
||||
{
|
||||
std::ostringstream filename;
|
||||
filename << "overlay_" << caseid << "_"
|
||||
<< string_from_type<coordinate_type>::name()
|
||||
<< string_from_type<CalculationType>::name()
|
||||
<< string_from_type<coordinate_type>::name();
|
||||
if (!std::is_same<coordinate_type, CalculationType>::value)
|
||||
{
|
||||
filename << string_from_type<CalculationType>::name();
|
||||
}
|
||||
|
||||
filename
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING)
|
||||
<< "_rescaled"
|
||||
#endif
|
||||
<< ".svg";
|
||||
|
||||
std::ofstream svg(filename.str().c_str());
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Robustness Test
|
||||
|
||||
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2012-2020 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2015.
|
||||
// Modifications copyright (c) 2015 Oracle and/or its affiliates.
|
||||
@ -19,11 +19,10 @@
|
||||
# pragma warning( disable : 4267 )
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
@ -91,8 +90,8 @@ bool verify(std::string const& caseid, MultiPolygon const& mp, MultiPolygon cons
|
||||
bool result = true;
|
||||
|
||||
// Area of buffer must be larger than of original polygon
|
||||
double area_mp = bg::area(mp);
|
||||
double area_buf = bg::area(buffer);
|
||||
auto const area_mp = bg::area(mp);
|
||||
auto const area_buf = bg::area(buffer);
|
||||
|
||||
if (area_buf < area_mp)
|
||||
{
|
||||
@ -138,7 +137,10 @@ bool verify(std::string const& caseid, MultiPolygon const& mp, MultiPolygon cons
|
||||
{
|
||||
std::ostringstream filename;
|
||||
filename << caseid << "_"
|
||||
<< typeid(typename bg::coordinate_type<MultiPolygon>::type).name()
|
||||
<< string_from_type<typename bg::coordinate_type<MultiPolygon>::type>::name()
|
||||
#if defined(BOOST_GEOMETRY_USE_RESCALING)
|
||||
<< "_rescaled"
|
||||
#endif
|
||||
<< ".svg";
|
||||
create_svg(filename.str(), mp, buffer);
|
||||
}
|
||||
@ -284,7 +286,7 @@ void test_all(int seed, int count, int level, Settings const& settings)
|
||||
std::cout
|
||||
<< "geometries: " << index
|
||||
<< " errors: " << errors
|
||||
<< " type: " << typeid(T).name()
|
||||
<< " type: " << string_from_type<T>::name()
|
||||
<< " time: " << elapsed_ms / 1000.0 << std::endl;
|
||||
}
|
||||
|
||||
@ -309,6 +311,7 @@ int main(int argc, char** argv)
|
||||
("help", "Help message")
|
||||
("seed", po::value<int>(&seed), "Initialization seed for random generator")
|
||||
("count", po::value<int>(&count)->default_value(1), "Number of tests")
|
||||
("validity", po::value<bool>(&settings.check_validity)->default_value(true), "Include testing on validity")
|
||||
("level", po::value<int>(&level)->default_value(3), "Level to reach (higher->slower)")
|
||||
("distance", po::value<double>(&settings.distance)->default_value(1.0), "Distance (1.0)")
|
||||
("form", po::value<std::string>(&form)->default_value("box"), "Form of the polygons (box, triangle)")
|
||||
@ -318,7 +321,6 @@ int main(int argc, char** argv)
|
||||
("size", po::value<int>(&settings.field_size)->default_value(10), "Size of the field")
|
||||
("wkt", po::value<bool>(&settings.wkt)->default_value(false), "Create a WKT of the inputs, for all tests")
|
||||
("svg", po::value<bool>(&settings.svg)->default_value(false), "Create a SVG for all tests")
|
||||
("check_validity", po::value<bool>(&settings.check_validity)->default_value(true), "Check validity")
|
||||
;
|
||||
|
||||
po::variables_map varmap;
|
||||
@ -339,19 +341,19 @@ int main(int argc, char** argv)
|
||||
|
||||
if (ccw && open)
|
||||
{
|
||||
test_all<double, false, false>(seed, count, level, settings);
|
||||
test_all<default_test_type, false, false>(seed, count, level, settings);
|
||||
}
|
||||
else if (ccw)
|
||||
{
|
||||
test_all<double, false, true>(seed, count, level, settings);
|
||||
test_all<default_test_type, false, true>(seed, count, level, settings);
|
||||
}
|
||||
else if (open)
|
||||
{
|
||||
test_all<double, true, false>(seed, count, level, settings);
|
||||
test_all<default_test_type, true, false>(seed, count, level, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
test_all<double, true, true>(seed, count, level, settings);
|
||||
test_all<default_test_type, true, true>(seed, count, level, settings);
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user