Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69604 - trunk/libs/geometry/test/algorithms/overlay/robustness
From: barend.gehrels_at_[hidden]
Date: 2011-03-06 08:38:42


Author: barendgehrels
Date: 2011-03-06 08:38:37 EST (Sun, 06 Mar 2011)
New Revision: 69604
URL: http://svn.boost.org/trac/boost/changeset/69604

Log:
Refreshed intersection_stars.cpp as well now, with program_options and overlay_p_q
Text files modified:
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.cpp | 165 ++++++++++++++++++++++-----------------
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.vcproj | 52 +++++++++++
   2 files changed, 141 insertions(+), 76 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.cpp 2011-03-06 08:38:37 EST (Sun, 06 Mar 2011)
@@ -16,17 +16,16 @@
 #endif
 
 
+#include <boost/program_options.hpp>
 
-#include <algorithms/test_intersection.hpp>
-#include <algorithms/test_overlay.hpp>
+//#include <algorithms/test_intersection.hpp>
+//#include <algorithms/test_overlay.hpp>
 
-#include <boost/timer.hpp>
-#include <boost/lexical_cast.hpp>
 
-#include <boost/geometry/geometries/adapted/std_as_linestring.hpp>
+#include <boost/timer.hpp>
 
-#include <test_common/test_point.hpp>
-#include <test_common/with_pointer.hpp>
+#include <boost/geometry/geometry.hpp>
+#include <test_overlay_p_q.hpp>
 
 
 
@@ -59,7 +58,6 @@
     coordinate_type pi = boost::math::constants::pi<long double>();
     coordinate_type delta = pi * two / coordinate_type(count - 1);
     coordinate_type angle = coordinate_type(offset) * delta;
- std::cout << "Start with angle: " << angle << std::endl;
     for (int i = 0; i < count - 1; i++, angle += delta)
     {
         bool even = i % 2 == 0;
@@ -75,69 +73,67 @@
 
 
 template <typename T, typename CalculationType>
-void test_star(std::string const& p_type, std::string const& c_type,
- std::string const& p_selection, std::string const& c_selection,
- int min_points, int max_points, T rotation)
+void test_star(int count, int min_points, int max_points, T rotation, p_q_settings const& settings)
 {
- if ((! p_selection.empty() && p_selection != p_type)
- || (! c_selection.empty() && c_selection != c_type))
- {
- return;
- }
-
- std::cout << "TESTING case "
- << p_type << " (" << sizeof(T) << ") "
- << c_type << " (" << sizeof(CalculationType) << ")"
- << std::endl;
     boost::timer t;
     typedef bg::model::d2::point_xy<T> point_type;
     typedef bg::model::polygon<point_type> polygon;
 
- T area_i = 0;
- T area_a = 0;
- T area_b = 0;
- //T area_u = 0;
-
- for (int p = min_points; p <= max_points; p++)
- {
- std::ostringstream out;
- out << "_" << p_type << "_" << c_type << "_" << p << "_int";
-
- polygon a;
- make_star(a, p * 2 + 1, 0.5, 1.0);
- polygon b;
- make_star(b, p * 2 + 1, 0.5, 1.0, rotation);
-
- area_i += test_intersection<polygon, CalculationType>(out.str(), a, b);
- area_a += bg::area(a);
- area_b += bg::area(b);
+ int n = 0;
+ for (int c = 0; c < count; c++)
+ {
+ 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";
+
+ polygon p;
+ make_star(p, i * 2 + 1, 0.5, 1.0);
+ polygon q;
+ make_star(q, i * 2 + 1, 0.5, 1.0, rotation);
+
+ if (! test_overlay_p_q
+ <
+ polygon,
+ CalculationType
+ >(out.str(), p, q, settings))
+ {
+ return;
+ }
+ n++;
+ }
     }
-
     std::cout
- << " time: " << t.elapsed() << std::endl
- << " area: " << area_i << std::endl
- << " area a: " << area_a << std::endl
- << " area b: " << area_b << std::endl
- << " diff: " << (area_i - area_a) << std::endl
- ;
+ << "polygons: " << n
+ << " type: " << string_from_type<T>::name()
+ << " time: " << t.elapsed() << std::endl;
 }
 
-template <typename T>
-void test_all(std::string const& p_type,
- std::string const& p_selection,
- std::string const& c_selection,
- int min_points, int max_points, long double rotation)
+template <typename T, typename CalculationType>
+void test_type(int count, int min_points, int max_points, T rotation, p_q_settings const& settings)
 {
- test_star<T, float>(p_type, "f", p_selection, c_selection,
- min_points, max_points, rotation);
- test_star<T, double>(p_type, "d", p_selection, c_selection,
- min_points, max_points, rotation);
- test_star<T, long double>(p_type, "e", p_selection, c_selection,
- min_points, max_points, rotation);
+ test_star<T, CalculationType>(count, min_points, max_points, rotation, settings);
+}
 
+template <typename T>
+void test_all(std::string const& type, int count, int min_points, int max_points, T rotation, p_q_settings settings)
+{
+ if (type == "float")
+ {
+ settings.tolerance = 1.0e-3;
+ test_type<float, float>(count, min_points, max_points, rotation, settings);
+ }
+ else if (type == "double")
+ {
+ test_type<double, double>(count, min_points, max_points, rotation, settings);
+ }
 #if defined(HAVE_TTMATH)
- test_star<T, ttmath_big>(p_type, "t",
- p_selection, c_selection, min_points, max_points, rotation);
+ else if (type == "ttmath")
+ {
+ test_type<ttmath_big, ttmath_big>(count, min_points, max_points, rotation, settings);
+ }
 #endif
 }
 
@@ -145,20 +141,45 @@
 {
     try
     {
- std::string p_selection = argc > 1 ? argv[1] : "";
- std::string c_selection = argc > 2 ? argv[2] : "";
- int min_points = argc > 3 ? boost::lexical_cast<int>(argv[3]) : 9;
- int max_points = argc > 4 ? boost::lexical_cast<int>(argv[4]) : min_points;
- long double rotation = argc > 5 ? boost::lexical_cast<long double>(argv[5]) : 1e-15;
-
- test_all<float>("f", p_selection, c_selection, min_points, max_points, rotation);
- test_all<double>("d", p_selection, c_selection, min_points, max_points, rotation);
- test_all<long double>("e", p_selection, c_selection, min_points, max_points, rotation);
+ namespace po = boost::program_options;
+ po::options_description description("=== recursive_polygons ===\nAllowed options");
 
-#if defined(HAVE_TTMATH)
- test_all<ttmath_big>("t",
- p_selection, c_selection, min_points, max_points, rotation);
-#endif
+ int count = 1;
+ //int seed = static_cast<unsigned int>(std::time(0));
+ std::string type = "float";
+ int min_points = 9;
+ int max_points = 9;
+ bool ccw = false;
+ bool open = false;
+ double rotation = 1.0e-13;
+ p_q_settings settings;
+
+ description.add_options()
+ ("help", "Help message")
+ //("seed", po::value<int>(&seed), "Initialization seed for random generator")
+ ("count", po::value<int>(&count)->default_value(1), "Number of tests")
+ ("diff", po::value<bool>(&settings.also_difference)->default_value(false), "Include testing on difference")
+ ("min_points", po::value<int>(&min_points)->default_value(9), "Minimum number of points")
+ ("max_points", po::value<int>(&max_points)->default_value(9), "Maximum number of points")
+ ("rotation", po::value<double>(&rotation)->default_value(1.0e-13), "Rotation angle")
+ ("ccw", po::value<bool>(&ccw)->default_value(false), "Counter clockwise polygons")
+ ("open", po::value<bool>(&open)->default_value(false), "Open polygons")
+ ("type", po::value<std::string>(&type)->default_value("float"), "Type (float,double)")
+ ("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")
+ ;
+
+ po::variables_map varmap;
+ po::store(po::parse_command_line(argc, argv, description), varmap);
+ po::notify(varmap);
+
+ if (varmap.count("help"))
+ {
+ std::cout << description << std::endl;
+ return 1;
+ }
+
+ test_all(type, count, min_points, max_points, rotation, settings);
     }
     catch(std::exception const& e)
     {

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.vcproj
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.vcproj (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.vcproj 2011-03-06 08:38:37 EST (Sun, 06 Mar 2011)
@@ -41,8 +41,8 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
- AdditionalIncludeDirectories="&quot;c:\gmp\gmp-dynamic&quot;;c:\svn\numeric_adaptor;../../../../../..;../../.."
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;TEST_WITH_SVG"
+ AdditionalIncludeDirectories="../../../../../..;."
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;BOOST_ALL_NO_LIB"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="1"
                                 UsePrecompiledHeader="0"
@@ -117,8 +117,8 @@
                         />
                         <Tool
                                 Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;c:\gmp\gmp-dynamic&quot;;c:\svn\numeric_adaptor;../../../../../..;../../.."
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ AdditionalIncludeDirectories="../../../../../..;."
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;BOOST_ALL_NO_LIB"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
                                 Detect64BitPortabilityProblems="true"
@@ -169,6 +169,50 @@
         <References>
         </References>
         <Files>
+ <Filter
+ Name="program options"
+ >
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\cmdline.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\config_file.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\convert.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\options_description.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\parsers.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\positional_options.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\split.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\utf8_codecvt_facet.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\value_semantic.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\program_options\src\variables_map.cpp"
+ >
+ </File>
+ </Filter>
                 <File
                         RelativePath=".\intersection_stars.cpp"
>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk