Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82020 - in trunk: boost/geometry/algorithms/detail/overlay libs/geometry/test/algorithms/overlay libs/geometry/test/multi/algorithms/overlay
From: barend.gehrels_at_[hidden]
Date: 2012-12-16 08:26:22


Author: barendgehrels
Date: 2012-12-16 08:26:21 EST (Sun, 16 Dec 2012)
New Revision: 82020
URL: http://svn.boost.org/trac/boost/changeset/82020

Log:
[geometry] updated traverse to avoid output of nearly empty rings, like in convert_rings. This also affects unit tests
Text files modified:
   trunk/boost/geometry/algorithms/detail/overlay/traverse.hpp | 16 ++++++++++++++--
   trunk/libs/geometry/test/algorithms/overlay/traverse.cpp | 13 ++++++++-----
   trunk/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp | 2 +-
   3 files changed, 23 insertions(+), 8 deletions(-)

Modified: trunk/boost/geometry/algorithms/detail/overlay/traverse.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/traverse.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/traverse.hpp 2012-12-16 08:26:21 EST (Sun, 16 Dec 2012)
@@ -17,7 +17,9 @@
 #include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/closure.hpp>
 #include <boost/geometry/core/coordinate_dimension.hpp>
 #include <boost/geometry/geometries/concepts/check.hpp>
 
@@ -233,6 +235,7 @@
                 detail::overlay::operation_type operation,
                 Turns& turns, Rings& rings)
     {
+ typedef typename boost::range_value<Rings>::type ring_type;
         typedef typename boost::range_iterator<Turns>::type turn_iterator;
         typedef typename boost::range_value<Turns>::type turn_type;
         typedef typename boost::range_iterator
@@ -240,6 +243,12 @@
                 typename turn_type::container_type
>::type turn_operation_iterator_type;
 
+ std::size_t const min_num_points
+ = core_detail::closure::minimum_ring_size
+ <
+ geometry::closure<ring_type>::value
+ >::value;
+
         std::size_t size_at_start = boost::size(rings);
 
         typename Backtrack::state_type state;
@@ -267,7 +276,7 @@
                         {
                             set_visited_for_continue(*it, *iit);
 
- typename boost::range_value<Rings>::type current_output;
+ ring_type current_output;
                             detail::overlay::append_no_duplicates(current_output,
                                         it->point, true);
 
@@ -376,7 +385,10 @@
                                 {
                                     iit->visited.set_finished();
                                     detail::overlay::debug_traverse(*current, *iit, "->Finished");
- rings.push_back(current_output);
+ if (geometry::num_points(current_output) >= min_num_points)
+ {
+ rings.push_back(current_output);
+ }
                                 }
                             }
                         }

Modified: trunk/libs/geometry/test/algorithms/overlay/traverse.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/traverse.cpp (original)
+++ trunk/libs/geometry/test/algorithms/overlay/traverse.cpp 2012-12-16 08:26:21 EST (Sun, 16 Dec 2012)
@@ -7,9 +7,10 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#define BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
+// #define BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE
 // #define BOOST_GEOMETRY_OVERLAY_NO_THROW
 // #define TEST_WITH_SVG
+// #define HAVE_TTMATH
 
 #include <iostream>
 #include <iomanip>
@@ -633,8 +634,7 @@
             2, 16, case_53[0], case_53[2]);
     if (test_self_tangencies)
     {
- // The st_st version might generate one ring with area zero, which is OK
- test_traverse<polygon, polygon, operation_union>::apply("54_st_st", 3, 20, case_54[0], case_54[2]);
+ test_traverse<polygon, polygon, operation_union>::apply("54_st_st", 2, 20, case_54[0], case_54[2]);
         test_traverse<polygon, polygon, operation_union>::apply("54_st_iet", 2, 20, case_54[0], case_54[3]);
         test_traverse<polygon, polygon, operation_union>::apply("54_iet_st", 2, 20, case_54[1], case_54[2]);
     }
@@ -786,6 +786,7 @@
     // the chance is 50% that the segments are not sorted correctly and the wrong
     // decision is taken.
     // Solved now (by sorting on sides in those cases)
+ if (! is_float_on_non_msvc)
     {
         test_traverse<polygon, polygon, operation_intersection>::apply("dz_1",
                 3, 16.887537949472005, dz_1[0], dz_1[1]);
@@ -884,8 +885,10 @@
 
 #if defined(_MSC_VER)
         double const expected = if_typed_tt<T>(3.63794e-17, 0.0);
+ int expected_count = if_typed_tt<T>(1, 0);
 #else
         double const expected = if_typed<T, long double>(2.77555756156289135106e-17, 0.0);
+ int expected_count = if_typed<T, long double>(1, 0);
 #endif
 
         // Calculate intersection/union of two triangles. Robustness case.
@@ -893,7 +896,7 @@
         // (which is even not accomplished by SQL Server/PostGIS)
         std::string const caseid = "ggl_list_20110820_christophe";
         test_traverse<polygon, polygon, operation_intersection>::apply(caseid,
- 1, expected,
+ expected_count, expected,
             ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1]);
         test_traverse<polygon, polygon, operation_union>::apply(caseid,
             1, 67.3550722317627,
@@ -905,7 +908,7 @@
         buffer_rt_f[0], buffer_rt_f[1]);
     test_traverse<polygon, polygon, operation_intersection>::apply("buffer_rt_f",
         1, 0.0002943725152286,
- buffer_rt_f[0], buffer_rt_f[1]);
+ buffer_rt_f[0], buffer_rt_f[1], 0.01);
 
     test_traverse<polygon, polygon, operation_union>::apply("buffer_rt_g",
         1, 16.571,

Modified: trunk/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/overlay/multi_traverse.cpp 2012-12-16 08:26:21 EST (Sun, 16 Dec 2012)
@@ -386,7 +386,7 @@
 
     test_traverse_union::apply
         (
- "case_recursive_boxes_3", 8, 49.5,
+ "case_recursive_boxes_3", 7, 49.5,
             case_recursive_boxes_3[0], case_recursive_boxes_3[1]
         );
 


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