mirror of https://github.com/CGAL/cgal
more on AABB demo
This commit is contained in:
parent
aa4dcf9b6f
commit
1dfddba18a
|
|
@ -10,7 +10,7 @@ if(COMMAND cmake_policy)
|
||||||
cmake_policy(SET CMP0003 NEW)
|
cmake_policy(SET CMP0003 NEW)
|
||||||
endif(COMMAND cmake_policy)
|
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}")
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}")
|
||||||
include_directories (BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}")
|
include_directories (BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -312,8 +312,62 @@ void Scene::benchmark_intersections()
|
||||||
bench_nb_intersections(tree);
|
bench_nb_intersections(tree);
|
||||||
bench_any_intersection(tree);
|
bench_any_intersection(tree);
|
||||||
bench_all_intersections(tree);
|
bench_all_intersections(tree);
|
||||||
|
bench_all_intersected_primitives(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::bench_all_intersected_primitives(Facet_tree& tree)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
void Scene::bench_do_intersect(Facet_tree& tree)
|
||||||
{
|
{
|
||||||
QTime time;
|
QTime time;
|
||||||
|
|
|
||||||
|
|
@ -1,104 +1,106 @@
|
||||||
#ifndef SCENE_H
|
#ifndef SCENE_H
|
||||||
#define SCENE_H
|
#define SCENE_H
|
||||||
|
|
||||||
#include <QtOpenGL/qgl.h>
|
#include <QtOpenGL/qgl.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#include <CGAL/AABB_tree.h>
|
#include <CGAL/AABB_tree.h>
|
||||||
#include <CGAL/AABB_traits.h>
|
#include <CGAL/AABB_traits.h>
|
||||||
#include <CGAL/AABB_polyhedron_segment_primitive.h>
|
#include <CGAL/AABB_polyhedron_segment_primitive.h>
|
||||||
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
|
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
|
||||||
|
|
||||||
class Scene
|
class Scene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Scene();
|
Scene();
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|
||||||
Polyhedron* polyhedron() const;
|
Polyhedron* polyhedron() const;
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
struct Bbox {
|
struct Bbox {
|
||||||
double xmin, ymin, zmin;
|
double xmin, ymin, zmin;
|
||||||
double xmax, ymax, zmax;
|
double xmax, ymax, zmax;
|
||||||
Bbox(const double _xmin,const double _ymin,const double _zmin,
|
Bbox(const double _xmin,const double _ymin,const double _zmin,
|
||||||
const double _xmax,const double _ymax,const double _zmax)
|
const double _xmax,const double _ymax,const double _zmax)
|
||||||
: xmin(_xmin), ymin(_ymin), zmin(_zmin),
|
: xmin(_xmin), ymin(_ymin), zmin(_zmin),
|
||||||
xmax(_xmax), ymax(_ymax), zmax(_zmax)
|
xmax(_xmax), ymax(_ymax), zmax(_zmax)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Bbox()
|
Bbox()
|
||||||
: xmin(0.0), ymin(0.0), zmin(0.0),
|
: xmin(0.0), ymin(0.0), zmin(0.0),
|
||||||
xmax(1.0), ymax(1.0), zmax(1.0)
|
xmax(1.0), ymax(1.0), zmax(1.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
double len_diagonal()
|
double len_diagonal()
|
||||||
{
|
{
|
||||||
Bbox box = bbox();
|
Bbox box = bbox();
|
||||||
double dx = box.xmax - box.xmin;
|
double dx = box.xmax - box.xmin;
|
||||||
double dy = box.ymax - box.ymin;
|
double dy = box.ymax - box.ymin;
|
||||||
double dz = box.zmax - box.zmin;
|
double dz = box.zmax - box.zmin;
|
||||||
return std::sqrt(dx*dx + dy*dy + dz*dz);
|
return std::sqrt(dx*dx + dy*dy + dz*dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
Bbox bbox() { return Bbox(); }
|
Bbox bbox() { return Bbox(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
Point random_point();
|
Point random_point();
|
||||||
Vector random_vector();
|
Vector random_vector();
|
||||||
|
|
||||||
// file menu functions
|
// file menu functions
|
||||||
int open(QString filename);
|
int open(QString filename);
|
||||||
|
|
||||||
// edit menus functions
|
// edit menus functions
|
||||||
void clear_points() { m_points.clear(); }
|
void clear_points() { m_points.clear(); }
|
||||||
void clear_segments() { m_segments.clear(); }
|
void clear_segments() { m_segments.clear(); }
|
||||||
|
|
||||||
// benchmark menu functions
|
// benchmark menu functions
|
||||||
void benchmark_intersections();
|
void benchmark_intersections();
|
||||||
void benchmark_distances();
|
void benchmark_distances();
|
||||||
|
|
||||||
// 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);
|
||||||
void generate_boundary_points(const unsigned int nb_points);
|
void generate_boundary_points(const unsigned int nb_points);
|
||||||
void generate_boundary_segments(const unsigned int nb_slices);
|
void generate_boundary_segments(const unsigned int nb_slices);
|
||||||
|
|
||||||
// toggle view options
|
// toggle view options
|
||||||
void toggle_view_points();
|
void toggle_view_points();
|
||||||
void toggle_view_segments();
|
void toggle_view_segments();
|
||||||
void toggle_view_poyhedron();
|
void toggle_view_poyhedron();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// member data
|
// member data
|
||||||
Polyhedron *m_pPolyhedron;
|
Polyhedron *m_pPolyhedron;
|
||||||
std::list<Point> m_points;
|
std::list<Point> m_points;
|
||||||
std::list<Segment> m_segments;
|
std::list<Segment> m_segments;
|
||||||
|
|
||||||
// view options
|
// view options
|
||||||
bool m_view_points;
|
bool m_view_points;
|
||||||
bool m_view_segments;
|
bool m_view_segments;
|
||||||
bool m_view_polyhedron;
|
bool m_view_polyhedron;
|
||||||
|
|
||||||
// types
|
// types
|
||||||
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Primitive;
|
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Primitive;
|
||||||
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
|
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
|
||||||
typedef CGAL::AABB_tree<Traits> Facet_tree;
|
typedef CGAL::AABB_tree<Traits> Facet_tree;
|
||||||
typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id;
|
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_do_intersect(Facet_tree& tree);
|
||||||
void bench_nb_intersections(Facet_tree& tree);
|
void bench_nb_intersections(Facet_tree& tree);
|
||||||
void bench_any_intersection(Facet_tree& tree);
|
void bench_any_intersection(Facet_tree& tree);
|
||||||
void bench_all_intersections(Facet_tree& tree);
|
void bench_all_intersections(Facet_tree& tree);
|
||||||
}; // end class Scene
|
void bench_all_intersected_primitives(Facet_tree& tree);
|
||||||
|
}; // end class Scene
|
||||||
|
|
||||||
#endif // SCENE_H
|
|
||||||
|
#endif // SCENE_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue