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;