mirror of https://github.com/CGAL/cgal
aabb tree demo:
- shorter code for benchmarking - benchmarking duration made as an option
This commit is contained in:
parent
514f1e8973
commit
dffabd3115
|
|
@ -202,15 +202,29 @@ void MainWindow::on_actionEdge_points_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionBench_distances_triggered()
|
void MainWindow::on_actionBench_distances_triggered()
|
||||||
{
|
{
|
||||||
|
bool ok;
|
||||||
|
const int duration = QInputDialog::getInteger(NULL, "Duration",
|
||||||
|
"Duration (ms):",1000,1,1000000,8,&ok);
|
||||||
|
if(!ok)
|
||||||
|
return;
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
m_pScene->benchmark_distances();
|
std::cout << std::endl << "Benchmark distances" << std::endl;
|
||||||
|
m_pScene->benchmark_distances(duration);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionBench_intersections_triggered()
|
void MainWindow::on_actionBench_intersections_triggered()
|
||||||
{
|
{
|
||||||
|
bool ok;
|
||||||
|
const int duration = QInputDialog::getInteger(NULL, "Duration",
|
||||||
|
"Duration (ms):",1000,1,1000000,8,&ok);
|
||||||
|
if(!ok)
|
||||||
|
return;
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
m_pScene->benchmark_intersections();
|
std::cout << std::endl << "Benchmark intersections" << std::endl;
|
||||||
|
m_pScene->benchmark_intersections(duration);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,6 @@ public:
|
||||||
void clear_segments() { m_segments.clear(); }
|
void clear_segments() { m_segments.clear(); }
|
||||||
void clear_distance_function() { m_max_distance_function = 0.0; }
|
void clear_distance_function() { m_max_distance_function = 0.0; }
|
||||||
|
|
||||||
// benchmarks
|
|
||||||
void benchmark_distances();
|
|
||||||
void benchmark_intersections();
|
|
||||||
|
|
||||||
// algorithms
|
// algorithms
|
||||||
void generate_edge_points(const unsigned int nb_points);
|
void generate_edge_points(const unsigned int nb_points);
|
||||||
void generate_inside_points(const unsigned int nb_trials);
|
void generate_inside_points(const unsigned int nb_trials);
|
||||||
|
|
@ -95,14 +91,33 @@ public:
|
||||||
typedef Facet_tree::Primitive_id Primitive_id;
|
typedef Facet_tree::Primitive_id Primitive_id;
|
||||||
|
|
||||||
// benchmarks
|
// benchmarks
|
||||||
void bench_do_intersect(Facet_tree& tree);
|
enum {DO_INTERSECT,
|
||||||
void bench_closest_point(Facet_tree& tree);
|
ANY_INTERSECTION,
|
||||||
void bench_squared_distance(Facet_tree& tree);
|
NB_INTERSECTIONS,
|
||||||
void bench_nb_intersections(Facet_tree& tree);
|
ALL_INTERSECTIONS,
|
||||||
void bench_any_intersection(Facet_tree& tree);
|
ALL_INTERSECTED_PRIMITIVES};
|
||||||
void bench_all_intersections(Facet_tree& tree);
|
void benchmark_intersections(const int duration);
|
||||||
void bench_closest_point_and_primitive(Facet_tree& tree);
|
void bench_intersection_rays(Facet_tree& tree,const int function,const int duration);
|
||||||
void bench_all_intersected_primitives(Facet_tree& tree);
|
void bench_intersection_lines(Facet_tree& tree,const int function,const int duration);
|
||||||
|
void bench_intersection_planes(Facet_tree& tree,const int function,const int duration);
|
||||||
|
void bench_intersection_segments(Facet_tree& tree,const int function,const int duration);
|
||||||
|
|
||||||
|
// distance benchmarks
|
||||||
|
enum {SQ_DISTANCE,
|
||||||
|
CLOSEST_POINT,
|
||||||
|
CLOSEST_POINT_AND_PRIMITIVE_ID};
|
||||||
|
void benchmark_distances(const int duration);
|
||||||
|
void bench_closest_point(Facet_tree& tree,const int duration);
|
||||||
|
void bench_squared_distance(Facet_tree& tree,const int duration);
|
||||||
|
void bench_closest_point_and_primitive(Facet_tree& tree,const int duration);
|
||||||
|
void bench_distance(Facet_tree& tree,const int function,const int duration);
|
||||||
|
|
||||||
|
// intersection benchmarks
|
||||||
|
void bench_do_intersect(Facet_tree& tree,const int duration);
|
||||||
|
void bench_nb_intersections(Facet_tree& tree,const int duration);
|
||||||
|
void bench_any_intersection(Facet_tree& tree,const int duration);
|
||||||
|
void bench_all_intersections(Facet_tree& tree,const int duration);
|
||||||
|
void bench_all_intersected_primitives(Facet_tree& tree,const int duration);
|
||||||
|
|
||||||
// drawing
|
// drawing
|
||||||
void draw_points();
|
void draw_points();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
void Scene::benchmark_intersections()
|
void Scene::benchmark_intersections(const int duration)
|
||||||
{
|
{
|
||||||
QTime time;
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
|
|
@ -9,18 +9,18 @@ void Scene::benchmark_intersections()
|
||||||
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
||||||
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
||||||
|
|
||||||
bench_do_intersect(tree);
|
bench_do_intersect(tree,duration);
|
||||||
bench_nb_intersections(tree);
|
bench_nb_intersections(tree,duration);
|
||||||
bench_any_intersection(tree);
|
bench_any_intersection(tree,duration);
|
||||||
bench_all_intersections(tree);
|
bench_all_intersections(tree,duration);
|
||||||
bench_all_intersected_primitives(tree);
|
bench_all_intersected_primitives(tree,duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::benchmark_distances()
|
void Scene::benchmark_distances(const int duration)
|
||||||
{
|
{
|
||||||
QTime time;
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
std::cout << "Construct AABB tree...";
|
std::cout << "Construct AABB tree and internal KD tree...";
|
||||||
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
||||||
tree.accelerate_distance_queries();
|
tree.accelerate_distance_queries();
|
||||||
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
||||||
|
|
@ -30,348 +30,257 @@ void Scene::benchmark_distances()
|
||||||
tree.closest_point(CGAL::ORIGIN);
|
tree.closest_point(CGAL::ORIGIN);
|
||||||
|
|
||||||
// benchmark
|
// benchmark
|
||||||
bench_closest_point(tree);
|
bench_closest_point(tree,duration);
|
||||||
bench_squared_distance(tree);
|
bench_squared_distance(tree,duration);
|
||||||
bench_closest_point_and_primitive(tree);
|
bench_closest_point_and_primitive(tree,duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// BENCH INTERSECTIONS
|
// BENCH INTERSECTIONS
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Scene::bench_all_intersected_primitives(Facet_tree& tree)
|
void Scene::bench_intersection_rays(Facet_tree& tree,
|
||||||
|
const int function,
|
||||||
|
const int duration)
|
||||||
{
|
{
|
||||||
|
QTime time;
|
||||||
|
time.start();
|
||||||
|
unsigned int nb = 0;
|
||||||
std::list<Primitive_id> primitive_ids;
|
std::list<Primitive_id> primitive_ids;
|
||||||
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark all_intersected_primitives" << std::endl;
|
|
||||||
|
|
||||||
// with ray
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Ray ray = random_ray();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Line line = random_line();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Segment segment = random_segment();
|
|
||||||
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;
|
|
||||||
|
|
||||||
// with segment
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Plane plane = random_plane();
|
|
||||||
tree.all_intersected_primitives(plane,std::back_inserter(primitive_ids));
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with plane" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Scene::bench_do_intersect(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark do_intersect" << std::endl;
|
|
||||||
|
|
||||||
// with ray
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Ray ray = random_ray();
|
|
||||||
tree.do_intersect(ray);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with ray" << std::endl;
|
|
||||||
|
|
||||||
// with line
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Line line = random_line();
|
|
||||||
tree.do_intersect(line);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with line" << std::endl;
|
|
||||||
|
|
||||||
// with segment
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Segment segment = random_segment();
|
|
||||||
tree.do_intersect(segment);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with segment" << std::endl;
|
|
||||||
|
|
||||||
// with plane
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Plane plane = random_plane();
|
|
||||||
tree.do_intersect(plane);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with plane" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::bench_nb_intersections(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark number_of_intersected_primitives" << std::endl;
|
|
||||||
|
|
||||||
// with ray
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Ray ray = random_ray();
|
|
||||||
tree.number_of_intersected_primitives(ray);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with ray" << std::endl;
|
|
||||||
|
|
||||||
// with line
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Line line = random_line();
|
|
||||||
tree.number_of_intersected_primitives(line);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with line" << std::endl;
|
|
||||||
|
|
||||||
// with segment
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Segment segment = random_segment();
|
|
||||||
tree.number_of_intersected_primitives(segment);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with segment" << std::endl;
|
|
||||||
|
|
||||||
// with plane
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Plane plane = random_plane();
|
|
||||||
tree.number_of_intersected_primitives(plane);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with plane" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::bench_any_intersection(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark any_intersection" << std::endl;
|
|
||||||
|
|
||||||
// with ray
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Ray ray = random_ray();
|
|
||||||
tree.any_intersection(ray);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with ray" << std::endl;
|
|
||||||
|
|
||||||
// with line
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Line line = random_line();
|
|
||||||
tree.any_intersection(line);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with line" << std::endl;
|
|
||||||
|
|
||||||
// with segment
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Segment segment = random_segment();
|
|
||||||
tree.any_intersection(segment);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with segment" << std::endl;
|
|
||||||
|
|
||||||
// with plane
|
|
||||||
nb = 0;
|
|
||||||
time.start();
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Plane plane = random_plane();
|
|
||||||
tree.any_intersection(plane);
|
|
||||||
nb++;
|
|
||||||
}
|
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s with plane" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::bench_all_intersections(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
std::list<Object_and_primitive_id> intersections;
|
std::list<Object_and_primitive_id> intersections;
|
||||||
|
while(time.elapsed() < duration)
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark all_intersections" << std::endl;
|
|
||||||
|
|
||||||
// with ray
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
{
|
||||||
Ray ray = random_ray();
|
Ray ray = random_ray();
|
||||||
|
switch(function)
|
||||||
|
{
|
||||||
|
case DO_INTERSECT:
|
||||||
|
tree.do_intersect(ray);
|
||||||
|
break;
|
||||||
|
case ANY_INTERSECTION:
|
||||||
|
tree.any_intersection(ray);
|
||||||
|
break;
|
||||||
|
case NB_INTERSECTIONS:
|
||||||
|
tree.number_of_intersected_primitives(ray);
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTIONS:
|
||||||
tree.all_intersections(ray,std::back_inserter(intersections));
|
tree.all_intersections(ray,std::back_inserter(intersections));
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTED_PRIMITIVES:
|
||||||
|
tree.all_intersected_primitives(ray,std::back_inserter(primitive_ids));
|
||||||
|
break;
|
||||||
|
}
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
double speed = 1000.0 * nb / time.elapsed();
|
||||||
std::cout << speed << " queries/s with ray" << std::endl;
|
std::cout << speed << " queries/s with ray" << std::endl;
|
||||||
intersections.clear();
|
}
|
||||||
|
|
||||||
// with line
|
void Scene::bench_intersection_lines(Facet_tree& tree,
|
||||||
nb = 0;
|
const int function,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
while(time.elapsed() < 1000)
|
unsigned int nb = 0;
|
||||||
|
std::list<Primitive_id> primitive_ids;
|
||||||
|
std::list<Object_and_primitive_id> intersections;
|
||||||
|
while(time.elapsed() < duration)
|
||||||
{
|
{
|
||||||
Line line = random_line();
|
Line line = random_line();
|
||||||
|
switch(function)
|
||||||
|
{
|
||||||
|
case DO_INTERSECT:
|
||||||
|
tree.do_intersect(line);
|
||||||
|
break;
|
||||||
|
case ANY_INTERSECTION:
|
||||||
|
tree.any_intersection(line);
|
||||||
|
break;
|
||||||
|
case NB_INTERSECTIONS:
|
||||||
|
tree.number_of_intersected_primitives(line);
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTIONS:
|
||||||
tree.all_intersections(line,std::back_inserter(intersections));
|
tree.all_intersections(line,std::back_inserter(intersections));
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTED_PRIMITIVES:
|
||||||
|
tree.all_intersected_primitives(line,std::back_inserter(primitive_ids));
|
||||||
|
break;
|
||||||
|
}
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
double speed = 1000.0 * nb / time.elapsed();
|
||||||
std::cout << speed << " queries/s with line" << std::endl;
|
std::cout << speed << " queries/s with ray" << std::endl;
|
||||||
intersections.clear();
|
}
|
||||||
|
|
||||||
// with segment
|
void Scene::bench_intersection_segments(Facet_tree& tree,
|
||||||
nb = 0;
|
const int function,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
while(time.elapsed() < 1000)
|
unsigned int nb = 0;
|
||||||
|
std::list<Primitive_id> primitive_ids;
|
||||||
|
std::list<Object_and_primitive_id> intersections;
|
||||||
|
while(time.elapsed() < duration)
|
||||||
{
|
{
|
||||||
Segment segment = random_segment();
|
Segment segment = random_segment();
|
||||||
|
switch(function)
|
||||||
|
{
|
||||||
|
case DO_INTERSECT:
|
||||||
|
tree.do_intersect(segment);
|
||||||
|
break;
|
||||||
|
case ANY_INTERSECTION:
|
||||||
|
tree.any_intersection(segment);
|
||||||
|
break;
|
||||||
|
case NB_INTERSECTIONS:
|
||||||
|
tree.number_of_intersected_primitives(segment);
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTIONS:
|
||||||
tree.all_intersections(segment,std::back_inserter(intersections));
|
tree.all_intersections(segment,std::back_inserter(intersections));
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTED_PRIMITIVES:
|
||||||
|
tree.all_intersected_primitives(segment,std::back_inserter(primitive_ids));
|
||||||
|
break;
|
||||||
|
}
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
double speed = 1000.0 * nb / time.elapsed();
|
||||||
std::cout << speed << " queries/s with segment" << std::endl;
|
std::cout << speed << " queries/s with ray" << std::endl;
|
||||||
intersections.clear();
|
}
|
||||||
|
|
||||||
// with plane
|
void Scene::bench_intersection_planes(Facet_tree& tree,
|
||||||
nb = 0;
|
const int function,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
while(time.elapsed() < 1000)
|
unsigned int nb = 0;
|
||||||
|
std::list<Primitive_id> primitive_ids;
|
||||||
|
std::list<Object_and_primitive_id> intersections;
|
||||||
|
while(time.elapsed() < duration)
|
||||||
{
|
{
|
||||||
Plane plane = random_plane();
|
Plane plane = random_plane();
|
||||||
|
switch(function)
|
||||||
|
{
|
||||||
|
case DO_INTERSECT:
|
||||||
|
tree.do_intersect(plane);
|
||||||
|
break;
|
||||||
|
case ANY_INTERSECTION:
|
||||||
|
tree.any_intersection(plane);
|
||||||
|
break;
|
||||||
|
case NB_INTERSECTIONS:
|
||||||
|
tree.number_of_intersected_primitives(plane);
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTIONS:
|
||||||
tree.all_intersections(plane,std::back_inserter(intersections));
|
tree.all_intersections(plane,std::back_inserter(intersections));
|
||||||
|
break;
|
||||||
|
case ALL_INTERSECTED_PRIMITIVES:
|
||||||
|
tree.all_intersected_primitives(plane,std::back_inserter(primitive_ids));
|
||||||
|
break;
|
||||||
|
}
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
speed = 1000.0 * nb / time.elapsed();
|
double speed = 1000.0 * nb / time.elapsed();
|
||||||
std::cout << speed << " queries/s with plane" << std::endl;
|
std::cout << speed << " queries/s with plane" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::bench_do_intersect(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark do_intersect" << std::endl;
|
||||||
|
bench_intersection_segments(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_rays(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_lines(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_planes(tree,DO_INTERSECT,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_any_intersection(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark any_intersection" << std::endl;
|
||||||
|
bench_intersection_segments(tree,ANY_INTERSECTION,duration);
|
||||||
|
bench_intersection_rays(tree,ANY_INTERSECTION,duration);
|
||||||
|
bench_intersection_lines(tree,ANY_INTERSECTION,duration);
|
||||||
|
bench_intersection_planes(tree,ANY_INTERSECTION,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_nb_intersections(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark nb_intersections" << std::endl;
|
||||||
|
bench_intersection_segments(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_rays(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_lines(tree,DO_INTERSECT,duration);
|
||||||
|
bench_intersection_planes(tree,DO_INTERSECT,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_all_intersected_primitives(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark all_intersected_primitives" << std::endl;
|
||||||
|
bench_intersection_segments(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||||
|
bench_intersection_rays(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||||
|
bench_intersection_lines(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||||
|
bench_intersection_planes(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_all_intersections(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark all_intersections" << std::endl;
|
||||||
|
bench_intersection_segments(tree,ALL_INTERSECTIONS,duration);
|
||||||
|
bench_intersection_rays(tree,ALL_INTERSECTIONS,duration);
|
||||||
|
bench_intersection_lines(tree,ALL_INTERSECTIONS,duration);
|
||||||
|
bench_intersection_planes(tree,ALL_INTERSECTIONS,duration);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// BENCH DISTANCES
|
// BENCH DISTANCES
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Scene::bench_squared_distance(Facet_tree& tree)
|
void Scene::bench_distance(Facet_tree& tree,
|
||||||
|
const int function,
|
||||||
|
const int duration)
|
||||||
{
|
{
|
||||||
QTime time;
|
QTime time;
|
||||||
time.start();
|
time.start();
|
||||||
std::cout << "Benchmark squared distance" << std::endl;
|
|
||||||
|
|
||||||
unsigned int nb = 0;
|
unsigned int nb = 0;
|
||||||
while(time.elapsed() < 1000)
|
while(time.elapsed() < duration)
|
||||||
{
|
{
|
||||||
Point query = random_point();
|
Point query = random_point();
|
||||||
|
switch(function)
|
||||||
|
{
|
||||||
|
case SQ_DISTANCE:
|
||||||
tree.squared_distance(query);
|
tree.squared_distance(query);
|
||||||
nb++;
|
break;
|
||||||
}
|
case CLOSEST_POINT:
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Scene::bench_closest_point(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark closest point" << std::endl;
|
|
||||||
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Point query = random_point();
|
|
||||||
tree.closest_point(query);
|
tree.closest_point(query);
|
||||||
nb++;
|
break;
|
||||||
}
|
case CLOSEST_POINT_AND_PRIMITIVE_ID:
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
|
||||||
std::cout << speed << " queries/s" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scene::bench_closest_point_and_primitive(Facet_tree& tree)
|
|
||||||
{
|
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
std::cout << "Benchmark closest point and primitive" << std::endl;
|
|
||||||
|
|
||||||
unsigned int nb = 0;
|
|
||||||
while(time.elapsed() < 1000)
|
|
||||||
{
|
|
||||||
Point query = random_point();
|
|
||||||
tree.closest_point_and_primitive(query);
|
tree.closest_point_and_primitive(query);
|
||||||
|
}
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
double speed = 1000.0 * nb / time.elapsed();
|
double speed = 1000.0 * nb / time.elapsed();
|
||||||
std::cout << speed << " queries/s" << std::endl;
|
std::cout << speed << " queries/s" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::bench_squared_distance(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark squared distance" << std::endl;
|
||||||
|
bench_distance(tree,SQ_DISTANCE,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_closest_point(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark closest point" << std::endl;
|
||||||
|
bench_distance(tree,CLOSEST_POINT,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::bench_closest_point_and_primitive(Facet_tree& tree,
|
||||||
|
const int duration)
|
||||||
|
{
|
||||||
|
std::cout << "Benchmark closest point and primitive" << std::endl;
|
||||||
|
bench_distance(tree,CLOSEST_POINT_AND_PRIMITIVE_ID,duration);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue