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)
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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_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)
|
||||
{
|
||||
QTime time;
|
||||
|
|
|
|||
|
|
@ -1,104 +1,106 @@
|
|||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "types.h"
|
||||
|
||||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "types.h"
|
||||
|
||||
#include <CGAL/AABB_tree.h>
|
||||
#include <CGAL/AABB_traits.h>
|
||||
#include <CGAL/AABB_polyhedron_segment_primitive.h>
|
||||
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
|
||||
|
||||
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<Point> m_points;
|
||||
std::list<Segment> 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<Point> m_points;
|
||||
std::list<Segment> m_segments;
|
||||
|
||||
// view options
|
||||
bool m_view_points;
|
||||
bool m_view_segments;
|
||||
bool m_view_polyhedron;
|
||||
|
||||
// types
|
||||
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Primitive;
|
||||
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
|
||||
typedef CGAL::AABB_tree<Traits> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue