Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76858 - trunk/libs/geometry/test/algorithms/overlay/robustness
From: barend.gehrels_at_[hidden]
Date: 2012-02-03 16:02:54


Author: barendgehrels
Date: 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
New Revision: 76858
URL: http://svn.boost.org/trac/boost/changeset/76858

Log:
Reorganized robustness test include orders, which fixes compiler error (w.r.t. point_xy), and fixed empty_input_exceptions which could occur in some tests
Text files modified:
   trunk/libs/geometry/test/algorithms/overlay/robustness/interior_triangles.cpp | 10 --------
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp | 10 +-------
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_stars.cpp | 15 -------------
   trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp | 9 -------
   trunk/libs/geometry/test/algorithms/overlay/robustness/random_ellipses_stars.cpp | 15 +------------
   trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp | 17 +--------------
   trunk/libs/geometry/test/algorithms/overlay/robustness/star_comb.cpp | 15 +------------
   trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp | 41 ++++++++++++++++++++++++---------------
   8 files changed, 36 insertions(+), 96 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/interior_triangles.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/interior_triangles.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/interior_triangles.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -17,6 +17,7 @@
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 #define BOOST_GEOMETRY_TIME_OVERLAY
 
+#include <test_overlay_p_q.hpp>
 
 #include <boost/program_options.hpp>
 #include <boost/random/linear_congruential.hpp>
@@ -25,15 +26,6 @@
 #include <boost/random/variate_generator.hpp>
 #include <boost/timer.hpp>
 
-#include <test_overlay_p_q.hpp>
-
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/multi/multi.hpp>
-#include <boost/geometry/multi/geometries/multi_polygon.hpp>
-#include <boost/geometry/io/wkt/wkt.hpp>
-#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
-
-
 template <typename Polygon>
 inline void make_polygon(Polygon& polygon, int count_x, int count_y, int index, int offset)
 {

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersection_pies.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -7,20 +7,14 @@
 // 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_REPORT_OVERLAY_ERROR
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 
-#include <boost/program_options.hpp>
-#include <boost/timer.hpp>
-
 #include <test_overlay_p_q.hpp>
 
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/multi/multi.hpp>
-
+#include <boost/program_options.hpp>
+#include <boost/timer.hpp>
 
 template <typename Polygon>
 inline void make_pie(Polygon& polygon,

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 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -12,25 +12,12 @@
 
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 
-// For mixing int/float
-#if defined(_MSC_VER)
-#pragma warning( disable : 4267 )
-#endif
 
+#include <test_overlay_p_q.hpp>
 
 #include <boost/program_options.hpp>
-
-//#include <algorithms/test_intersection.hpp>
-//#include <algorithms/test_overlay.hpp>
-
-
 #include <boost/timer.hpp>
 
-#include <boost/geometry/geometry.hpp>
-#include <test_overlay_p_q.hpp>
-
-
-
 template <typename Polygon>
 inline void make_star(Polygon& polygon,
     int count, double factor1, double factor2, long double offset = 0)

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -17,6 +17,7 @@
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 //#define BOOST_GEOMETRY_TIME_OVERLAY
 
+#include <test_overlay_p_q.hpp>
 
 #include <boost/program_options.hpp>
 #include <boost/random/linear_congruential.hpp>
@@ -25,14 +26,6 @@
 #include <boost/random/variate_generator.hpp>
 #include <boost/timer.hpp>
 
-#include <test_overlay_p_q.hpp>
-
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/multi/multi.hpp>
-#include <boost/geometry/multi/geometries/multi_polygon.hpp>
-#include <boost/geometry/io/wkt/wkt.hpp>
-#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
-
 
 template <typename MultiPolygon>
 inline void make_polygon(MultiPolygon& mp, int count_x, int count_y, int index, int width_x)

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/random_ellipses_stars.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/random_ellipses_stars.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/random_ellipses_stars.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -7,16 +7,12 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <iomanip>
-#include <string>
-
 #define BOOST_GEOMETRY_REPORT_OVERLAY_ERROR
 #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>
@@ -25,13 +21,6 @@
 #include <boost/random/variate_generator.hpp>
 
 
-#include <test_overlay_p_q.hpp>
-
-#include <boost/geometry/geometry.hpp>
-
-#include <boost/geometry/geometries/point_xy.hpp>
-
-
 struct star_params
 {
     int count; // points of ellipse, not of star

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/recursive_polygons.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -7,15 +7,10 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <iomanip>
-#include <string>
-
 #define BOOST_GEOMETRY_REPORT_OVERLAY_ERROR
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 
+#include <test_overlay_p_q.hpp>
 
 #include <boost/program_options.hpp>
 #include <boost/random/linear_congruential.hpp>
@@ -24,15 +19,6 @@
 #include <boost/random/variate_generator.hpp>
 #include <boost/timer.hpp>
 
-#include <test_overlay_p_q.hpp>
-
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/multi/multi.hpp>
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/multi/geometries/multi_polygon.hpp>
-#include <boost/geometry/io/wkt/wkt.hpp>
-#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
-
 
 template <typename Polygon, typename Generator>
 inline void make_polygon(Polygon& polygon, Generator& generator, bool triangular)
@@ -98,6 +84,7 @@
 
     std::ostringstream out;
     out << "recursive_box_" << index++ << "_" << level;
+
     if (! test_overlay_p_q
         <
             polygon,

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/star_comb.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/star_comb.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/star_comb.cpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -7,17 +7,14 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <iomanip>
-#include <string>
 
 #define BOOST_GEOMETRY_REPORT_OVERLAY_ERROR
 #define BOOST_GEOMETRY_NO_BOOST_TEST
 #define BOOST_GEOMETRY_TIME_OVERLAY
 
 
+#include <test_overlay_p_q.hpp>
+
 #include <boost/program_options.hpp>
 #include <boost/random/linear_congruential.hpp>
 #include <boost/random/uniform_int.hpp>
@@ -26,14 +23,6 @@
 #include <boost/timer.hpp>
 
 #include <star_comb.hpp>
-#include <test_overlay_p_q.hpp>
-
-#include <boost/geometry/geometry.hpp>
-#include <boost/geometry/multi/multi.hpp>
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/multi/geometries/multi_polygon.hpp>
-#include <boost/geometry/io/wkt/wkt.hpp>
-#include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
 
 
 template <typename Polygon>

Modified: trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp 2012-02-03 16:02:52 EST (Fri, 03 Feb 2012)
@@ -15,6 +15,8 @@
 //#define BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
 
 
+#include <geometry_test_common.hpp>
+
 // For mixing int/float
 #if defined(_MSC_VER)
 #pragma warning( disable : 4244 )
@@ -22,19 +24,13 @@
 #endif
 
 
-#include <boost/geometry/geometry.hpp>
-
-#include <boost/geometry/io/wkt/wkt.hpp>
-
-#include <boost/geometry/multi/multi.hpp>
+#include <boost/geometry.hpp>
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
 #include <boost/geometry/multi/geometries/multi_polygon.hpp>
-#include <boost/geometry/multi/io/wkt/wkt.hpp>
-
-#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
 #include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
 
-#include <geometry_test_common.hpp>
-
+#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
 
 struct p_q_settings
 {
@@ -51,6 +47,19 @@
     {}
 };
 
+template <typename Geometry>
+inline typename bg::default_area_result<Geometry>::type p_q_area(Geometry const& g)
+{
+ try
+ {
+ return bg::area(g);
+ }
+ catch(bg::empty_input_exception const&)
+ {
+ return 0;
+ }
+}
+
 template <typename OutputType, typename CalculationType, typename G1, typename G2>
 static bool test_overlay_p_q(std::string const& caseid,
             G1 const& p, G2 const& q,
@@ -63,15 +72,15 @@
 
     bg::model::multi_polygon<OutputType> out_i, out_u, out_d, out_d2;
 
- CalculationType area_p = bg::area(p);
- CalculationType area_q = bg::area(q);
+ CalculationType area_p = p_q_area(p);
+ CalculationType area_q = p_q_area(q);
     CalculationType area_d1 = 0, area_d2 = 0;
 
     bg::intersection(p, q, out_i);
- CalculationType area_i = bg::area(out_i);
+ CalculationType area_i = p_q_area(out_i);
 
     bg::union_(p, q, out_u);
- CalculationType area_u = bg::area(out_u);
+ CalculationType area_u = p_q_area(out_u);
 
     double sum = (area_p + area_q) - area_u - area_i;
 
@@ -81,8 +90,8 @@
     {
         bg::difference(p, q, out_d);
         bg::difference(q, p, out_d2);
- area_d1 = bg::area(out_d);
- area_d2 = bg::area(out_d2);
+ area_d1 = p_q_area(out_d);
+ 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;


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