From e12f9febe88e42ecc20859770f14310432434dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 12 Feb 2022 01:32:34 +0100 Subject: [PATCH] Fix bad initialization get_max_distance() does not yield a good hint for the lower value Also it requires an extra traversal of the tree. --- ...traversal_traits_with_Hausdorff_distance.h | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h index 7912bafd616..64378199ad0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h @@ -358,27 +358,15 @@ public: // Set initial tight bounds. CGAL_assertion(primitive.id() != Face_handle_1()); - std::pair fpair; - const FT max_dist = get_maximum_distance(primitive.id(), fpair); - CGAL_assertion(max_dist >= FT(0)); - CGAL_assertion(fpair.first == primitive.id()); - - Bounds initial_bounds(m_infinity_value); - initial_bounds.lower = max_dist + m_error_bound; - initial_bounds.upper = max_dist + m_error_bound; - initial_bounds.tm2_lface = fpair.second; - initial_bounds.tm2_uface = fpair.second; + Face_handle_1 tm1_lface = primitive.id(); // Call Culling on B with the single triangle found. - TM2_hd_traits traversal_traits_tm2( - m_tm2_tree.traits(), m_tm2, m_vpm2, - initial_bounds, // tighter bounds, in the paper, they start from infinity, see below - // Bounds(m_infinity_value), // starting from infinity - m_infinity_value, - m_infinity_value, - m_infinity_value); + Bounds initial_bounds(m_infinity_value); + TM2_hd_traits traversal_traits_tm2(m_tm2_tree.traits(), m_tm2, m_vpm2, + initial_bounds, + m_infinity_value, m_infinity_value, m_infinity_value); - const Triangle_3 triangle = get(m_face_to_triangle_map, fpair.first); + const Triangle_3 triangle = get(m_face_to_triangle_map, tm1_lface); m_tm2_tree.traversal_with_priority(triangle, traversal_traits_tm2); // Update global Hausdorff bounds according to the obtained local bounds. @@ -394,7 +382,7 @@ public: if(local_bounds.lower > h_global_bounds.lower) // it is (6) in the paper, see also Algorithm 1 { h_global_bounds.lower = local_bounds.lower; - h_global_bounds.lpair.first = fpair.first; + h_global_bounds.lpair.first = tm1_lface; h_global_bounds.lpair.second = local_bounds.tm2_lface; } @@ -402,14 +390,14 @@ public: if(local_bounds.upper > h_global_bounds.upper) // it is (6) in the paper, see also Algorithm 1 { h_global_bounds.upper = local_bounds.upper; - h_global_bounds.upair.first = fpair.first; + h_global_bounds.upair.first = tm1_lface; h_global_bounds.upair.second = local_bounds.tm2_uface; } CGAL_assertion(h_global_bounds.upper >= h_global_bounds.lower); // Store the triangle given as primitive here as candidate triangle // together with the local bounds it obtained to send it to subdivision later. - m_candidate_triangles.push(Candidate(triangle, local_bounds, fpair.first)); + m_candidate_triangles.emplace(triangle, local_bounds, tm1_lface); } // Determine whether child nodes will still contribute to a larger