From fd43d44fa538ca8d697e6c0b55ee5d6264f1dea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 30 Sep 2019 18:18:06 +0200 Subject: [PATCH] do an initial try with the closest point since do_intersect is with a sphere and not a ball --- .../Edge_collapse/Bounded_distance_placement.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h index c2b7ab08750..35d1dec66db 100644 --- a/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h +++ b/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h @@ -53,10 +53,24 @@ public: typedef typename Profile::Point Point; typedef typename CGAL::Kernel_traits< Point >::Kernel Kernel; if(op){ + + CGAL_assertion(!tree.empty()); + const Point* p = boost::get(&op); + tree.accelerate_distance_queries(); + Point cp = tree.best_hint(*p).first; // requires accelerate distance query to be called. + // We could do better by having access to the internal kd-tree + // and call search_any_point with a fuzzy_sphere. - if(tree.do_intersect(CGAL::Sphere_3(*p, threshold_dist*threshold_dist))){ + const double sqtd = threshold_dist*threshold_dist; + + // if no input vertex is closer than the threshold, then + // any face closer than the threshold is intersected by + // the sphere (avoid the inclusion of the mesh into the threshold sphere) + if( CGAL::compare_squared_distance(*p,cp, sqtd)!=LARGER || + tree.do_intersect(CGAL::Sphere_3(*p, sqtd))) + { return op; } return boost::none;