diff --git a/AABB_tree/benchmark/AABB_tree/test.cpp b/AABB_tree/benchmark/AABB_tree/test.cpp index e01307974706..623b608da019 100644 --- a/AABB_tree/benchmark/AABB_tree/test.cpp +++ b/AABB_tree/benchmark/AABB_tree/test.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -19,12 +19,11 @@ typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::AABB_face_graph_triangle_primitive Primitive; typedef CGAL::AABB_traits_3 Traits; -//typedef CGAL::AABB_do_intersect_transform_traits Traits; typedef CGAL::AABB_tree Tree; namespace PMP = CGAL::Polygon_mesh_processing; -void naive_test(int k, const char* fname, +void naive_test(int k, const std::string& fname, int& nb_inter, int& nb_no_inter, int& nb_include) { std::ifstream input(fname); @@ -34,7 +33,7 @@ void naive_test(int k, const char* fname, CGAL::Aff_transformation_3 init1(CGAL::SCALING, 6.0); PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); - typedef CGAL::AABB_tree Tree; + Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( @@ -87,7 +86,8 @@ void naive_test(int k, const char* fname, T0 = CGAL::Aff_transformation_3(CGAL::TRANSLATION, -i*unit_vec); } } -void test_no_collision(int k, const char* fname, + +void test_no_collision(int k, const std::string &fname, int& nb_inter, int& nb_no_inter, int& nb_include) { std::ifstream input(fname); @@ -98,9 +98,11 @@ void test_no_collision(int k, const char* fname, PMP::transform(init1, tm); CGAL::Bbox_3 box = PMP::bbox(tm); Tree tmTree(tm.faces_begin(), tm.faces_end(), tm); + Tree tmTree2(tm2.faces_begin(), tm2.faces_end(), tm2); CGAL::Aff_transformation_3 init2(CGAL::TRANSLATION, - K::Vector_3( (box.xmax()-box.xmin()),0,0)); + PMP::transform(init2, tm2); tmTree.build(); @@ -114,6 +116,12 @@ void test_no_collision(int k, const char* fname, CGAL::Side_of_triangle_mesh sotm1(tmTree); + + CGAL::Rigid_triangle_mesh_collision_detection collision_detection; + + collision_detection.add_mesh(tm); + collision_detection.add_mesh(tm2); + for(int i=1; i T1 = CGAL::Aff_transformation_3(CGAL::TRANSLATION, i*unit_vec); CGAL::Aff_transformation_3 transfo = R*T1; - tmTree2.traits().set_transformation(transfo); - CGAL::Interval_nt_advanced::Protector protector; - if(tmTree2.do_intersect(tmTree)) + + collision_detection.set_transformation(1, transfo); + + std::vector< std::pair > res = collision_detection.get_all_intersections_and_inclusions(0); + + if (res.empty()) + nb_no_inter++; + else if(!res[0].second) ++nb_inter; else - { - if(sotm1(transfo.transform(vpm2[*tm2.vertices().begin()])) != CGAL::ON_UNBOUNDED_SIDE) - { - ++nb_include; - } - else - { - CGAL::Side_of_triangle_mesh sotm2(tmTree2); - if(sotm2(tm.point(*tm.vertices().begin())) != CGAL::ON_UNBOUNDED_SIDE) - ++nb_include; - else - ++nb_no_inter; - } - } + ++nb_include; } } int main(int argc, const char** argv) { - int k = (argc>1) ? atoi(argv[1]) : 10; - const char* path = (argc>2)?argv[2]:"data/handle" - ".off"; + int k = (argc>1) ? atoi(argv[1]) : 20; + std::string path = (argc>2)?argv[2]: CGAL::data_file_path("meshes/handle.off"); std::cout<< k<<" steps in "<(end - start).count() << "μs." << std::endl; + std::cout<<"Naive test : "<(end - start).count() << " ms." << std::endl; start = std::chrono::steady_clock::now(); test_no_collision(k, path,nb_inter, nb_no_inter, nb_include); end = std::chrono::steady_clock::now(); std::cout<<"With transform_traits: "<(end - start).count() << "μs." << std::endl; + <(end - start).count() << " ms." << std::endl; return 0; }