diff --git a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp index b1083f387f1..22726ae3afe 100644 --- a/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp +++ b/Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp @@ -15,10 +15,11 @@ #include #include + //Timer #include - //filter{ +#include typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Surface_mesh Surface; @@ -34,7 +35,7 @@ namespace CGAL { namespace Surface_mesh_simplification { -template +template class Bounded_distance_placement { public: @@ -44,9 +45,8 @@ public: public: Bounded_distance_placement(const double sq_dist, - const Tree& tree, const Placement& placement = Placement() ) - : mPlacement(placement), tree(tree), threshold_sq_dist(sq_dist) + : mPlacement(placement), threshold_sq_dist(sq_dist) { } @@ -58,17 +58,35 @@ public: typedef typename Profile::Point Point; if(op){ const Point* p = boost::get(&op); - if(tree.squared_distance(*p) > threshold_sq_dist){ + const typename Profile::Triangle_vector& triangles = aProfile.triangles(); + typename Profile::Triangle_vector::const_iterator it = triangles.begin(); + bool does_intersect = false; + CGAL::Sphere_3 s(*p, threshold_sq_dist); + if(aProfile.left_face_exists()){ + ++it; + } + if(aProfile.right_face_exists()){ + ++it; + } + while(it!= triangles.end()){ + typename Profile::Triangle t = *it; + if(CGAL::do_intersect(t, s)){ + does_intersect = true; + break; + } + } + if(!does_intersect) + { return boost::none; } } return op; } + private: Placement mPlacement ; - const Tree& tree; double threshold_sq_dist; }; @@ -88,9 +106,9 @@ int main( int argc, char** argv ) // left in the surface mesh drops below the specified number (1000) SMS::Count_stop_predicate stop(num_halfedges(surface_mesh)/10); - typedef SMS::Bounded_distance_placement, Tree > Filtered_placement; + typedef SMS::Bounded_distance_placement > Filtered_placement; typedef SMS::LindstromTurk_placement Placement; - double copy_time, tree_time, placement1_time, placement2_time; + double placement1_time, placement2_time; std::cout<<"input has "<