diff --git a/AABB_tree/demo/AABB_tree/CMakeLists.txt b/AABB_tree/demo/AABB_tree/CMakeLists.txt index 60e4d1a239a..99a1a0182e7 100644 --- a/AABB_tree/demo/AABB_tree/CMakeLists.txt +++ b/AABB_tree/demo/AABB_tree/CMakeLists.txt @@ -10,7 +10,7 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) -foreach(INCDIR ../include ../../../STL_Extension/include ../../../GraphicsView/include ../../../filtered_kernel/include ) +foreach(INCDIR ../../include ../../../../STL_Extension/include ../../../GraphicsView/include ../../../filtered_kernel/include ) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}") include_directories (BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}") endif() diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index e4f8782c241..0df56851dc9 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -312,8 +312,62 @@ void Scene::benchmark_intersections() bench_nb_intersections(tree); bench_any_intersection(tree); bench_all_intersections(tree); + bench_all_intersected_primitives(tree); } +void Scene::bench_all_intersected_primitives(Facet_tree& tree) +{ + std::list primitive_ids; + + QTime time; + time.start(); + std::cout << "Benchmark all_intersected_primitives" << std::endl; + + // with ray + unsigned int nb = 0; + while(time.elapsed() < 1000) + { + Point p = random_point(); + Point q = random_point(); + Ray ray(p,q); + tree.all_intersected_primitives(ray,std::back_inserter(primitive_ids)); + nb++; + } + double speed = 1000.0 * nb / time.elapsed(); + std::cout << speed << " queries/s with ray" << std::endl; + primitive_ids.clear(); + + // with line + nb = 0; + time.start(); + while(time.elapsed() < 1000) + { + Point p = random_point(); + Point q = random_point(); + Line line(p,q); + tree.all_intersected_primitives(line,std::back_inserter(primitive_ids)); + nb++; + } + speed = 1000.0 * nb / time.elapsed(); + std::cout << speed << " queries/s with line" << std::endl; + primitive_ids.clear(); + + // with segment + nb = 0; + time.start(); + while(time.elapsed() < 1000) + { + Point p = random_point(); + Point q = random_point(); + Segment segment(p,q); + tree.all_intersected_primitives(segment,std::back_inserter(primitive_ids)); + nb++; + } + speed = 1000.0 * nb / time.elapsed(); + std::cout << speed << " queries/s with segment" << std::endl; +} + + void Scene::bench_do_intersect(Facet_tree& tree) { QTime time; diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index 7600b5869ab..a4570e8b515 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -1,104 +1,106 @@ -#ifndef SCENE_H -#define SCENE_H - -#include -#include -#include -#include "types.h" - +#ifndef SCENE_H +#define SCENE_H + +#include +#include +#include +#include "types.h" + #include #include #include #include - -class Scene -{ -public: - Scene(); - ~Scene(); - - Polyhedron* polyhedron() const; - - void draw(); - - struct Bbox { - double xmin, ymin, zmin; - double xmax, ymax, zmax; - Bbox(const double _xmin,const double _ymin,const double _zmin, - const double _xmax,const double _ymax,const double _zmax) - : xmin(_xmin), ymin(_ymin), zmin(_zmin), - xmax(_xmax), ymax(_ymax), zmax(_zmax) - { - } - Bbox() - : xmin(0.0), ymin(0.0), zmin(0.0), - xmax(1.0), ymax(1.0), zmax(1.0) - { - } - }; - - double len_diagonal() - { - Bbox box = bbox(); - double dx = box.xmax - box.xmin; - double dy = box.ymax - box.ymin; - double dz = box.zmax - box.zmin; - return std::sqrt(dx*dx + dy*dy + dz*dz); - } - - // TODO - Bbox bbox() { return Bbox(); } - -public: - - // utility functions - Point random_point(); - Vector random_vector(); - - // file menu functions - int open(QString filename); - - // edit menus functions - void clear_points() { m_points.clear(); } - void clear_segments() { m_segments.clear(); } - - // benchmark menu functions - void benchmark_intersections(); - void benchmark_distances(); - - // algorithms - void generate_edge_points(const unsigned int nb_points); - void generate_inside_points(const unsigned int nb_trials); - void generate_boundary_points(const unsigned int nb_points); - void generate_boundary_segments(const unsigned int nb_slices); - - // toggle view options - void toggle_view_points(); - void toggle_view_segments(); - void toggle_view_poyhedron(); - -private: - // member data - Polyhedron *m_pPolyhedron; - std::list m_points; - std::list m_segments; - - // view options - bool m_view_points; - bool m_view_segments; - bool m_view_polyhedron; - - // types + +class Scene +{ +public: + Scene(); + ~Scene(); + + Polyhedron* polyhedron() const; + + void draw(); + + struct Bbox { + double xmin, ymin, zmin; + double xmax, ymax, zmax; + Bbox(const double _xmin,const double _ymin,const double _zmin, + const double _xmax,const double _ymax,const double _zmax) + : xmin(_xmin), ymin(_ymin), zmin(_zmin), + xmax(_xmax), ymax(_ymax), zmax(_zmax) + { + } + Bbox() + : xmin(0.0), ymin(0.0), zmin(0.0), + xmax(1.0), ymax(1.0), zmax(1.0) + { + } + }; + + double len_diagonal() + { + Bbox box = bbox(); + double dx = box.xmax - box.xmin; + double dy = box.ymax - box.ymin; + double dz = box.zmax - box.zmin; + return std::sqrt(dx*dx + dy*dy + dz*dz); + } + + // TODO + Bbox bbox() { return Bbox(); } + +public: + + // utility functions + Point random_point(); + Vector random_vector(); + + // file menu functions + int open(QString filename); + + // edit menus functions + void clear_points() { m_points.clear(); } + void clear_segments() { m_segments.clear(); } + + // benchmark menu functions + void benchmark_intersections(); + void benchmark_distances(); + + // algorithms + void generate_edge_points(const unsigned int nb_points); + void generate_inside_points(const unsigned int nb_trials); + void generate_boundary_points(const unsigned int nb_points); + void generate_boundary_segments(const unsigned int nb_slices); + + // toggle view options + void toggle_view_points(); + void toggle_view_segments(); + void toggle_view_poyhedron(); + +private: + // member data + Polyhedron *m_pPolyhedron; + std::list m_points; + std::list m_segments; + + // view options + bool m_view_points; + bool m_view_segments; + bool m_view_polyhedron; + + // types typedef CGAL::AABB_polyhedron_triangle_primitive Primitive; typedef CGAL::AABB_traits Traits; typedef CGAL::AABB_tree Facet_tree; typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id; + typedef Facet_tree::Primitive_id Primitive_id; void bench_do_intersect(Facet_tree& tree); void bench_nb_intersections(Facet_tree& tree); void bench_any_intersection(Facet_tree& tree); void bench_all_intersections(Facet_tree& tree); -}; // end class Scene - - -#endif // SCENE_H + void bench_all_intersected_primitives(Facet_tree& tree); +}; // end class Scene + + +#endif // SCENE_H