From 563203363d59db1cf4b97b9213d40bebafa2186d Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Thu, 24 May 2012 12:19:58 +0000 Subject: [PATCH] Fixed longstanding bug (in some degenerate cases, the cutoff was too small). --- Matrix_search/include/CGAL/rectangular_3_center_2.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Matrix_search/include/CGAL/rectangular_3_center_2.h b/Matrix_search/include/CGAL/rectangular_3_center_2.h index c91845879c7..79a1cde94ba 100644 --- a/Matrix_search/include/CGAL/rectangular_3_center_2.h +++ b/Matrix_search/include/CGAL/rectangular_3_center_2.h @@ -1136,7 +1136,8 @@ rectangular_3_center_2_type2( // now s_b corresponds to the first moment in [s, m+1) // where q_t and q_r cover B - + CGAL_optimisation_assertion_code(bool loopcheck = false;) +CGAL_3CENTER_REPEAT_CHECK: // place q_t and q_r q_t = op.place_x_square(q_t_afap, r, op.delta()(*s_b)); q_r = op.place_y_square(q_r_afap, r, op.delta()(*s_b)); @@ -1157,7 +1158,15 @@ rectangular_3_center_2_type2( (!Q_t_empty && op.compute_x_distance(q_t, Q_t) > op.delta()(*s_b)) || (!Q_r_empty && op.compute_y_distance(q_r, Q_r) > op.delta()(*s_b))) { // no covering - CGAL_optimisation_assertion(b1 - s >= cutoff); + if (b1 - s < cutoff) { + // in degenerate situations it can happen that the number of + // points in R is too small => decrease radius and check again + --s_b; + CGAL_optimisation_assertion(!loopcheck); + CGAL_optimisation_assertion(s != s_b); + CGAL_optimisation_assertion_code(loopcheck = true;) + goto CGAL_3CENTER_REPEAT_CHECK; + } s = b1; rho_min = op.delta()(*s_b); q_t_at_rho_min = q_t, q_r_at_rho_min = q_r;