Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77308 - in trunk/boost/geometry: algorithms/detail/overlay strategies strategies/cartesian
From: barend.gehrels_at_[hidden]
Date: 2012-03-11 16:37:53


Author: barendgehrels
Date: 2012-03-11 16:37:51 EDT (Sun, 11 Mar 2012)
New Revision: 77308
URL: http://svn.boost.org/trac/boost/changeset/77308

Log:
[geometry] Finetuned robustness fixes of this weekend and fixed (again) for case #ggl_list_20110820_christophe
Text files modified:
   trunk/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp | 18 +++++++++++-------
   trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp | 20 ++++++++++++++++++++
   trunk/boost/geometry/strategies/side_info.hpp | 7 +++++++
   3 files changed, 38 insertions(+), 7 deletions(-)

Modified: trunk/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp (original)
+++ trunk/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp 2012-03-11 16:37:51 EDT (Sun, 11 Mar 2012)
@@ -589,14 +589,15 @@
 
             if (side_pk != side_p || side_qk != side_q)
             {
- //std::cout << " -> Collinear "
+ //std::cout << "ROBUSTNESS -> Collinear "
                 // << " arr: " << arrival
                 // << " prod: " << product
                 // << " dir: " << side_p << " " << side_q
                 // << " rev: " << side_pk << " " << side_qk
                 // << std::endl;
 
- handle_robustness(ti, product, side_p, side_q, side_pk, side_qk);
+ handle_robustness(ti, arrival, product,
+ side_p, side_q, side_pk, side_qk);
             }
             else
             {
@@ -607,16 +608,19 @@
     }
 
     static inline void handle_robustness(TurnInfo& ti,
- int product,
+ int arrival, int product,
                     int side_p, int side_q,
                     int side_pk, int side_qk)
     {
         bool take_ui = product == 1;
- if ((product == 1 && side_p == 1 && side_pk != 1)
- || (product == -1 && side_q == 1 && side_qk != 1))
+ if (product == arrival)
         {
- //std::cout << " -> Reverse" << std::endl;
- take_ui = ! take_ui;
+ if ((product == 1 && side_p == 1 && side_pk != 1)
+ || (product == -1 && side_q == 1 && side_qk != 1))
+ {
+ //std::cout << "ROBUSTNESS: -> Reverse" << std::endl;
+ take_ui = ! take_ui;
+ }
         }
 
         ui_else_iu(take_ui, ti);

Modified: trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp
==============================================================================
--- trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp (original)
+++ trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp 2012-03-11 16:37:51 EDT (Sun, 11 Mar 2012)
@@ -203,6 +203,26 @@
                                 promoted_type const zero = 0;
                                 promoted_type const one = 1;
                                 promoted_type const epsilon = std::numeric_limits<double>::epsilon();
+
+ if (sides.crossing() && math::abs(da-d) < 0.1)
+ {
+ // ROBUSTNESS: the r value can in epsilon-cases be 1.14, while (with perfect arithmetic)
+ // it should be one. If segments are crossing (we can see that with the sides)
+ // and one is inside the other, there must be an intersection point.
+ // We correct for that.
+ // TODO: find more cases (this only solves case called ggl_list_20110820_christophe in unit tests
+ if (r > one)
+ {
+ // std::cout << "ROBUSTNESS: correction of r " << r << std::endl;
+ r = one;
+ }
+ else if (r < zero)
+ {
+ // std::cout << "ROBUSTNESS: correction of r " << r << std::endl;
+ r = zero;
+ }
+ }
+
                                 if (r < zero)
                                 {
                                         if (r < -epsilon)

Modified: trunk/boost/geometry/strategies/side_info.hpp
==============================================================================
--- trunk/boost/geometry/strategies/side_info.hpp (original)
+++ trunk/boost/geometry/strategies/side_info.hpp 2012-03-11 16:37:51 EDT (Sun, 11 Mar 2012)
@@ -67,6 +67,13 @@
             && sides[1].second == 0;
     }
 
+ inline bool crossing() const
+ {
+ return sides[0].first * sides[0].second == -1
+ && sides[1].first * sides[1].second == -1;
+ }
+
+
     template <int Which>
     inline bool zero() const
     {


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