# Boost-Commit :

Subject: [Boost-commit] svn:boost r69611 - trunk/boost/geometry/strategies/cartesian
From: barend.gehrels_at_[hidden]
Date: 2011-03-06 16:15:23

Author: barendgehrels
Date: 2011-03-06 16:15:21 EST (Sun, 06 Mar 2011)
New Revision: 69611
URL: http://svn.boost.org/trac/boost/changeset/69611

Log:
Fixed robustness problem for case called "ggl_list_20110306_javier"
Text files modified:
trunk/boost/geometry/strategies/cartesian/cart_intersect.hpp | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)

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 2011-03-06 16:15:21 EST (Sun, 06 Mar 2011)
@@ -336,7 +336,29 @@
// For case 5-8: b_1 < (a_1 or a_2) < b_2, two intersections are equal to segment A
if (has_common_points)
{
- bool const a_in_b = (b_1 < a_1 && a_1 < b_2) || (b_1 < a_2 && a_2 < b_2);
+ // Either A is in B, or B is in A, or (in case of robustness/equals)
+ // both are true, see below
+ bool a_in_b = (b_1 < a_1 && a_1 < b_2) || (b_1 < a_2 && a_2 < b_2);
+ bool b_in_a = (a_1 < b_1 && b_1 < a_2) || (a_1 < b_2 && b_2 < a_2);
+
+ if (a_in_b && b_in_a)
+ {
+ // testcase "ggl_list_20110306_javier"
+ // In robustness it can occur that a point of A is inside B AND a point of B is inside A,
+ // still while has_common_points is true (so one point equals the other).
+ // If that is the case we select on length.
+ coordinate_type const length_a = abs(a_1 - a_2);
+ coordinate_type const length_b = abs(b_1 - b_2);
+ if (length_a > length_b)
+ {
+ a_in_b = false;
+ }
+ else
+ {
+ b_in_a = false;
+ }
+ }
+
int const arrival_a = a_in_b ? 1 : -1;
if (a2_eq_b2) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, 0, 0, false);
if (a1_eq_b2) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, arrival_a, 0, true);