From afe06c0b69f083c1232bd72e19cc4d1927e359a2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 5 Feb 2014 12:04:11 +0100 Subject: [PATCH] Fix the testsuite of AABB tree That is a followup to the following commit: | commit 3e93d0bfc6725a8b10cea3a624ede49d62a2b5e0 | Author: Laurent Rineau | Date: Tue Dec 31 15:15:24 2013 +0100 | | Fix test of AABB_tree (use of an epsilon) | | The test 'aabb_naive_vs_tree_distance_triangle_test' failed | something. It was due to a test using an epsilon, with a too-low epsilon | value (1e-8). I managed to reproduce the bug, and the quantity compared | to the epsilon value was about 1.8e-8. I increase the epsilon value to | 1e-7, and add a few lines that show the compared values, when the test | fails. 1/ There was one more epsilon value with 1e-8 in the tests. 2/ There was a test that check the equality of two points, in a case, but the test cannot be fully correct with a non-exact kernel. --- AABB_tree/test/AABB_tree/AABB_test_util.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/AABB_tree/test/AABB_tree/AABB_test_util.h b/AABB_tree/test/AABB_tree/AABB_test_util.h index ae5ee127d3a..5ba4fd3a665 100644 --- a/AABB_tree/test/AABB_tree/AABB_test_util.h +++ b/AABB_tree/test/AABB_tree/AABB_test_util.h @@ -822,18 +822,26 @@ private: Point_and_primitive_id point_tree = tree.closest_point_and_primitive(query); tree_timer.stop(); - if ( point_naive.second == point_tree.second ) - { - // Points should be the same - assert(point_naive.first == point_tree.first); - } - else + // Laurent Rineau, 2014/02/05: With a non exact kernel, there is no + // reason that the points are equal! + // if ( point_naive.second == point_tree.second ) + // { + // // Points should be the same + // assert(point_naive.first == point_tree.first); + // } + // else { // Compare distance FT dist_naive = CGAL::squared_distance(query, point_naive.first); FT dist_tree = CGAL::squared_distance(query, point_tree.first); - const FT epsilon = FT(1e-8); + const FT epsilon = FT(1e-7); + if (CGAL::abs(dist_naive - dist_tree) > epsilon) { + std::cerr.precision(17); + std::cerr << "dist_tree: " << dist_tree + << "\ndist_naive: " << dist_naive + << "\ndifference: " << (dist_naive - dist_tree) << std::endl; + } assert( (dist_naive - dist_tree) <= epsilon ); assert( (dist_naive - dist_tree) >= (-1. * epsilon) ); }