Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67488 - in sandbox/geometry/libs/geometry/test: algorithms algorithms/overlay/robustness extensions/gis/io/wkt
From: barend.gehrels_at_[hidden]
Date: 2010-12-29 08:59:14


Author: barendgehrels
Date: 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
New Revision: 67488
URL: http://svn.boost.org/trac/boost/changeset/67488

Log:
Update testcases for difference
Removed todo for dissolve, it is solved now

Text files modified:
   sandbox/geometry/libs/geometry/test/algorithms/difference.cpp | 40 +++++++++++-----------------------------
   sandbox/geometry/libs/geometry/test/algorithms/dissolve.cpp | 5 -----
   sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp | 21 +++++++++++++--------
   sandbox/geometry/libs/geometry/test/algorithms/test_overlay.hpp | 4 ++++
   sandbox/geometry/libs/geometry/test/extensions/gis/io/wkt/wkt.cpp | 10 ++++++++++
   5 files changed, 38 insertions(+), 42 deletions(-)

Modified: sandbox/geometry/libs/geometry/test/algorithms/difference.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/difference.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/difference.cpp 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
@@ -24,13 +24,10 @@
 {
     typedef bg::model::polygon<P> polygon;
 
- //goto wrong;
-
     test_one<polygon, polygon, polygon>(
             "star_ring", example_star, example_ring,
             5, 22, 1.1901714,
             5, 27, 1.6701714);
-//return;
 
     test_one<polygon, polygon, polygon>("two_bends",
         two_bends[0], two_bends[1],
@@ -52,17 +49,24 @@
         1, 10, 7.0,
         1, 10, 14.0);
 
- //TODO: erroneous in assemble
- /*
     test_one<polygon, polygon, polygon>("fitting",
         fitting[0], fitting[1],
         1, 0, 21.0,
         1, 0, 4.0);
+
+ test_one<polygon, polygon, polygon>("crossed",
+ crossed[0], crossed[1],
+ 1, 0, 19.5,
+ 1, 0, 2.5);
+ test_one<polygon, polygon, polygon>("first_within_second",
+ first_within_second[1], first_within_second[0],
+ 1, 1, 24,
+ 0, 0, 0);
+
     test_one<polygon, polygon, polygon>("intersect_holes_disjoint",
         intersect_holes_disjoint[0], intersect_holes_disjoint[1],
         2, 15, 16.0,
         2, 15, 6.0);
- */
 
     test_one<polygon, polygon, polygon>("intersect_holes_intersect",
         intersect_holes_intersect[0], intersect_holes_intersect[1],
@@ -80,18 +84,7 @@
             7, 27, 3.18452380952381);
 
     /***
- Test is not relevant
- test_one<polygon, polygon, polygon>(
- "positive_negative",
- "POLYGON((0 0,0 4,4 4,4 0,0 0))",
- //"POLYGON((2 2,6 2,6 3,2 3,2 2))",
- "POLYGON((2 2,2 3,6 3,6 2,2 2))",
- 5, 22, 1.1901714,
- 5, 27, 1.6701714);
- ***/
-
- /***
- Experimental, does not work:
+ Experimental (cut), does not work:
     test_one<polygon, polygon, polygon>(
             "polygon_pseudo_line",
             "POLYGON((0 0,0 4,4 4,4 0,0 0))",
@@ -99,17 +92,6 @@
             5, 22, 1.1901714,
             5, 27, 1.6701714);
     ***/
-
- /***
- Test can be omitted, polygons are CCW
- test_one<polygon, polygon, polygon>(
- "reverse",
- "POLYGON((0 0,4 0,4 4,0 4,0 0))",
- "POLYGON((2 2,2 3,6 3,6 2,2 2))",
- 5, 22, 1.1901714,
- 5, 27, 1.6701714);
- ***/
-
 }
 
 

Modified: sandbox/geometry/libs/geometry/test/algorithms/dissolve.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/dissolve.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/dissolve.cpp 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
@@ -63,20 +63,15 @@
         "POLYGON((0 0,0 1,0 1,0 1,0 2,0 2,0 3,0 3,0 3,0 3,0 4,2 4,2 4,4 4,4 0,4 0,3 0,3 0,3 0,3 0,3 0,0 0))",
         0, 10, 16);
 
-
     // Hole: interior tangent to exterior
     test_one<polygon, polygon>("h1",
         "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 2,2 4,3 2,1 2))",
         0, 6, 16);
 
     // Hole: interior intersecting exterior
- // TODO: fix this one
- /*
     test_one<polygon, polygon>("h2",
         "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,5 4,1 1))",
         0, 8, 16.25);
- */
-
 
     // Hole: two intersecting holes
     test_one<polygon, polygon>("h3",

Modified: sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/overlay/robustness/test_overlay_p_q.hpp 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
@@ -11,6 +11,9 @@
 #include <fstream>
 #include <iomanip>
 
+// #define BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
+
+
 // For mixing int/float
 #if defined(_MSC_VER)
 #pragma warning( disable : 4244 )
@@ -19,6 +22,7 @@
 
 
 #include <boost/geometry/geometry.hpp>
+#include <boost/geometry/multi/multi.hpp>
 
 #include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
 
@@ -53,7 +57,7 @@
 
     bool wrong = std::abs(sum) > tolerance;
 
-#ifdef USE_DIFFERENCE
+#ifdef BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
     bg::difference(p, q, out_d);
     CalculationType area_d = bg::area(out_d);
     double sum_d = (area_u - area_q) - area_d;
@@ -82,7 +86,7 @@
             << " area p: " << area_p
             << " area q: " << area_q
             << " sum: " << sum
-#ifdef USE_DIFFERENCE
+#ifdef BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
             << " area d: " << area_d
             << " sum d: " << sum_d
 #endif
@@ -127,6 +131,13 @@
         mapper.map(q, "fill-opacity:0.3;fill:rgb(51,51,153);"
                 "stroke:rgb(51,51,153);stroke-width:3");
 
+#ifdef BOOST_GEOMETRY_ROBUSTNESS_USE_DIFFERENCE
+ for (BOOST_AUTO(it, out_d.begin()); it != out_d.end(); ++it)
+ {
+ mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,255,0);"
+ "stroke:rgb(255,255,0);stroke-width:4");
+ }
+#else
         for (BOOST_AUTO(it, out_i.begin()); it != out_i.end(); ++it)
         {
             mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,0,0);"
@@ -137,12 +148,6 @@
             mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,0,0);"
                     "stroke:rgb(255,0,255);stroke-width:4");
         }
-#ifdef USE_DIFFERENCE
- for (BOOST_AUTO(it, out_d.begin()); it != out_d.end(); ++it)
- {
- mapper.map(*it, "fill-opacity:0.1;stroke-opacity:0.4;fill:rgb(255,255,0);"
- "stroke:rgb(255,255,0);stroke-width:4");
- }
 #endif
     }
     return result;

Modified: sandbox/geometry/libs/geometry/test/algorithms/test_overlay.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/test_overlay.hpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/test_overlay.hpp 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
@@ -123,6 +123,10 @@
     {"POLYGON((0 0,0 5,5 5,5 0,0 0),(4 1,3 4,1 2,4 1))",
     "POLYGON((1 2,3 4,4 1,1 2))"};
 
+static std::string crossed[2] =
+ {"POLYGON((0 0,0 5,5 5,5 0,0 0),(4 1,3 4,1 2,4 1))",
+ "POLYGON((2 1,1 4,4 3,2 1))"};
+
 // == case 53
 static std::string wrapped[3] = {
         "POLYGON((2 2,2 3,3 3,3 2,2 2))",

Modified: sandbox/geometry/libs/geometry/test/extensions/gis/io/wkt/wkt.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/gis/io/wkt/wkt.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/gis/io/wkt/wkt.cpp 2010-12-29 08:59:09 EST (Wed, 29 Dec 2010)
@@ -103,6 +103,14 @@
                 << start << " Got:" << e << " with WKT: " << wkt);
 }
 
+template <typename G>
+void test_wkt_output_iterator(std::string const& wkt)
+{
+ G geometry;
+ bg::read_wkt<G>(wkt, std::back_inserter(geometry));
+}
+
+
 
 #ifndef GEOMETRY_TEST_MULTI
 template <typename T>
@@ -168,6 +176,8 @@
         test_wkt<P>("POINT(1.1 2.1)", 1);
     }
 
+ test_wkt_output_iterator<bg::model::linestring<P> >("LINESTRING(1 1,2 2,3 3)");
+ test_wkt_output_iterator<bg::model::linear_ring<P> >("POLYGON((1 1,2 2,3 3))");
 }
 #endif
 


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