mirror of https://github.com/CGAL/cgal
AABB tree: final polishing.
This commit is contained in:
parent
4900013382
commit
0e25638992
Binary file not shown.
Binary file not shown.
|
|
@ -373,6 +373,14 @@ void MainWindow::on_actionBench_distances_vs_nbt_triggered()
|
|||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRefine_loop_triggered()
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_pScene->refine_loop();
|
||||
QApplication::restoreOverrideCursor();
|
||||
m_pViewer->update();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSave_snapshot_triggered()
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public:
|
|||
void on_actionClear_distance_function_triggered();
|
||||
|
||||
// algorithm menu
|
||||
void on_actionRefine_loop_triggered();
|
||||
void on_actionEdge_points_triggered();
|
||||
void on_actionInside_points_triggered();
|
||||
void on_actionBoundary_points_triggered();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
<string>Refine</string>
|
||||
</property>
|
||||
<addaction name="actionRefine_bisection" />
|
||||
<addaction name="actionRefine_loop" />
|
||||
</widget>
|
||||
<addaction name="actionEdge_points" />
|
||||
<addaction name="actionInside_points" />
|
||||
|
|
@ -253,6 +254,11 @@
|
|||
<string>Copy snapshot</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefine_loop" >
|
||||
<property name="text" >
|
||||
<string>Loop subdivision</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -17,121 +17,124 @@
|
|||
class Scene
|
||||
{
|
||||
public:
|
||||
Scene();
|
||||
~Scene();
|
||||
Scene();
|
||||
~Scene();
|
||||
public:
|
||||
// types
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
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;
|
||||
// types
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
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;
|
||||
|
||||
public:
|
||||
void draw();
|
||||
void update_bbox();
|
||||
Bbox bbox() { return m_bbox; }
|
||||
void draw();
|
||||
void update_bbox();
|
||||
Bbox bbox() { return m_bbox; }
|
||||
|
||||
private:
|
||||
// member data
|
||||
Bbox m_bbox;
|
||||
Polyhedron *m_pPolyhedron;
|
||||
std::list<Point> m_points;
|
||||
std::list<Segment> m_segments;
|
||||
// member data
|
||||
Bbox m_bbox;
|
||||
Polyhedron *m_pPolyhedron;
|
||||
std::list<Point> m_points;
|
||||
std::list<Segment> m_segments;
|
||||
|
||||
// distance functions (simple 2D arrays)
|
||||
Color_ramp m_red_ramp;
|
||||
Color_ramp m_blue_ramp;
|
||||
Color_ramp m_thermal_ramp;
|
||||
FT m_max_distance_function;
|
||||
bool m_view_distance_function;
|
||||
bool m_signed_distance_function;
|
||||
typedef std::pair<Point,FT> Point_distance;
|
||||
Point_distance m_distance_function[100][100];
|
||||
// distance functions (simple 2D arrays)
|
||||
Color_ramp m_red_ramp;
|
||||
Color_ramp m_blue_ramp;
|
||||
Color_ramp m_thermal_ramp;
|
||||
FT m_max_distance_function;
|
||||
bool m_view_distance_function;
|
||||
bool m_signed_distance_function;
|
||||
typedef std::pair<Point,FT> Point_distance;
|
||||
Point_distance m_distance_function[100][100];
|
||||
|
||||
private:
|
||||
// utility functions
|
||||
Vector random_vector();
|
||||
Ray random_ray(const Bbox& bbox);
|
||||
FT random_in(const double a,const double b);
|
||||
Line random_line(const Bbox& bbox);
|
||||
Point random_point(const Bbox& bbox);
|
||||
Plane random_plane(const Bbox& bbox);
|
||||
Segment random_segment(const Bbox& bbox);
|
||||
// utility functions
|
||||
Vector random_vector();
|
||||
Ray random_ray(const Bbox& bbox);
|
||||
Line random_line(const Bbox& bbox);
|
||||
Point random_point(const Bbox& bbox);
|
||||
Plane random_plane(const Bbox& bbox);
|
||||
Segment random_segment(const Bbox& bbox);
|
||||
FT random_in(const double a,const double b);
|
||||
|
||||
public:
|
||||
// file menu
|
||||
int open(QString filename);
|
||||
// file menu
|
||||
int open(QString filename);
|
||||
|
||||
// edit menu
|
||||
void clear_points() { m_points.clear(); }
|
||||
void clear_segments() { m_segments.clear(); }
|
||||
void clear_distance_function() { m_max_distance_function = 0.0; }
|
||||
// edit menu
|
||||
void clear_points() { m_points.clear(); }
|
||||
void clear_segments() { m_segments.clear(); }
|
||||
void clear_distance_function() { m_max_distance_function = 0.0; }
|
||||
|
||||
// algorithms
|
||||
void refine_bisection(const FT max_sqlen);
|
||||
void generate_edge_points(const unsigned int nb_points);
|
||||
void generate_inside_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_points_in(const unsigned int nb_points,
|
||||
const double min, const double max);
|
||||
// algorithms
|
||||
void generate_edge_points(const unsigned int nb_points);
|
||||
void generate_inside_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_points_in(const unsigned int nb_points,
|
||||
const double min, const double max);
|
||||
|
||||
// distance functions
|
||||
void signed_distance_function();
|
||||
void unsigned_distance_function();
|
||||
void unsigned_distance_function_to_edges();
|
||||
// algorithms/refine
|
||||
void refine_loop();
|
||||
void refine_bisection(const FT max_sqlen);
|
||||
|
||||
// toggle view options
|
||||
void toggle_view_points();
|
||||
void toggle_view_segments();
|
||||
void toggle_view_poyhedron();
|
||||
void toggle_view_distance_function();
|
||||
// distance functions
|
||||
void signed_distance_function();
|
||||
void unsigned_distance_function();
|
||||
void unsigned_distance_function_to_edges();
|
||||
|
||||
// view options
|
||||
bool m_view_points;
|
||||
bool m_view_segments;
|
||||
bool m_view_polyhedron;
|
||||
// toggle view options
|
||||
void toggle_view_points();
|
||||
void toggle_view_segments();
|
||||
void toggle_view_poyhedron();
|
||||
void toggle_view_distance_function();
|
||||
|
||||
// benchmarks
|
||||
enum {DO_INTERSECT,
|
||||
ANY_INTERSECTION,
|
||||
NB_INTERSECTIONS,
|
||||
ALL_INTERSECTIONS,
|
||||
ANY_INTERSECTED_PRIMITIVE,
|
||||
ALL_INTERSECTED_PRIMITIVES};
|
||||
void bench_memory();
|
||||
void bench_construction();
|
||||
void bench_distances_vs_nbt();
|
||||
void bench_intersections_vs_nbt();
|
||||
void benchmark_intersections(const double duration);
|
||||
unsigned int nb_digits(const unsigned int value);
|
||||
// view options
|
||||
bool m_view_points;
|
||||
bool m_view_segments;
|
||||
bool m_view_polyhedron;
|
||||
|
||||
template <class Query>
|
||||
void bench_intersection(Facet_tree& tree,const int function,const double duration,
|
||||
char *query_name, const std::vector<Query>& queries, const int nb_queries);
|
||||
void bench_intersections(Facet_tree& tree, const double duration, const int function,
|
||||
char *function_name, const std::vector<Ray>& rays,
|
||||
const std::vector<Line>& lines, const std::vector<Plane>& planes,
|
||||
const std::vector<Segment>& segments, const int nb_queries);
|
||||
// benchmarks
|
||||
enum {DO_INTERSECT,
|
||||
ANY_INTERSECTION,
|
||||
NB_INTERSECTIONS,
|
||||
ALL_INTERSECTIONS,
|
||||
ANY_INTERSECTED_PRIMITIVE,
|
||||
ALL_INTERSECTED_PRIMITIVES};
|
||||
void bench_memory();
|
||||
void bench_construction();
|
||||
void bench_distances_vs_nbt();
|
||||
void bench_intersections_vs_nbt();
|
||||
void benchmark_intersections(const double duration);
|
||||
unsigned int nb_digits(const unsigned int value);
|
||||
|
||||
// distance benchmarks
|
||||
enum {SQ_DISTANCE,
|
||||
CLOSEST_POINT,
|
||||
CLOSEST_POINT_AND_PRIMITIVE_ID};
|
||||
void benchmark_distances(const double duration);
|
||||
void bench_closest_point(Facet_tree& tree,const double duration);
|
||||
void bench_squared_distance(Facet_tree& tree,const double duration);
|
||||
void bench_closest_point_and_primitive(Facet_tree& tree,const double duration);
|
||||
void bench_distance(Facet_tree& tree,const int function,const double duration);
|
||||
template <class Query>
|
||||
void bench_intersection(Facet_tree& tree,const int function,const double duration,
|
||||
char *query_name, const std::vector<Query>& queries, const int nb_queries);
|
||||
void bench_intersections(Facet_tree& tree, const double duration, const int function,
|
||||
char *function_name, const std::vector<Ray>& rays,
|
||||
const std::vector<Line>& lines, const std::vector<Plane>& planes,
|
||||
const std::vector<Segment>& segments, const int nb_queries);
|
||||
|
||||
// drawing
|
||||
void draw_points();
|
||||
void draw_segments();
|
||||
void draw_polyhedron();
|
||||
void draw_signed_distance_function();
|
||||
void draw_unsigned_distance_function();
|
||||
// distance benchmarks
|
||||
enum {SQ_DISTANCE,
|
||||
CLOSEST_POINT,
|
||||
CLOSEST_POINT_AND_PRIMITIVE_ID};
|
||||
void benchmark_distances(const double duration);
|
||||
void bench_closest_point(Facet_tree& tree,const double duration);
|
||||
void bench_squared_distance(Facet_tree& tree,const double duration);
|
||||
void bench_closest_point_and_primitive(Facet_tree& tree,const double duration);
|
||||
void bench_distance(Facet_tree& tree,const int function,const double duration);
|
||||
|
||||
// drawing
|
||||
void draw_points();
|
||||
void draw_segments();
|
||||
void draw_polyhedron();
|
||||
void draw_signed_distance_function();
|
||||
void draw_unsigned_distance_function();
|
||||
}; // end class Scene
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
\section{Performances}
|
||||
\label{AABB_tree_section_performances}
|
||||
|
||||
We provide some performance numbers for the case where the AABB tree contains a set of polyhedron triangle facets. We measure the tree construction time, the memory occupancy, and the number of queries per second for a variety of intersection and distance queries. The machine used is a PC running Windows XP64 with an Intel CPU Core2 Extreme clocked at 3.06 GHz with 4GB of RAM. By default the kernel used is \ccc{Simple_cartesian<double>} (the fastest in our experiments). The program has been compiled with Visual C++ 2005 compiler with the O2 option (maximize speed).
|
||||
We provide some performance numbers for the case where the AABB tree contains a set of polyhedron triangle facets. We measure the tree construction time, the memory occupancy and the number of queries per second for a variety of intersection and distance queries. The machine used is a PC running Windows XP64 with an Intel CPU Core2 Extreme clocked at 3.06 GHz with 4GB of RAM. By default the kernel used is \ccc{Simple_cartesian<double>} (the fastest in our experiments). The program has been compiled with Visual C++ 2005 compiler with the O2 option which maximizes speed.
|
||||
|
||||
\subsection{Construction}
|
||||
|
||||
The surface triangle mesh chosen for benchmarking the tree construction is the knot model (14,400 triangles) available in the demo data folder. We measure the tree construction time (both AABB tree alone and AABB tree with internal KD-tree) for this model as well as for three denser versions subdivided through the Loop subdivision scheme which increases the number of triangles by a factor of four.
|
||||
The surface triangle mesh chosen for benchmarking the tree construction is the knot model (14,400 triangles) depicted by Figure \ref{fig:AABB-tree-bench}. We measure the tree construction time (both AABB tree alone and AABB tree with internal KD-tree) for this model as well as for three denser versions subdivided through the Loop subdivision scheme which multiplies the number of triangles by four.
|
||||
|
||||
\begin{tabular}{|l|c|c|}
|
||||
\hline
|
||||
|
|
@ -111,7 +111,7 @@ The surface triangle mesh chosen for benchmarking distances is again the knot mo
|
|||
|
||||
\subsection{Summary}
|
||||
|
||||
The experiments described above are neither exhaustive nor conclusive as we have chosen one specific case where the input primitives are the facets of a triangle surface polyhedron. Nevertheless we provide the reader with some general observations and advices about how to put the AABB tree to use with satisfactory performances. While the tree construction times and memory occupancy do not fluctuate much in our experiments depending on the input surface triangle mesh, the performance expressed in number of queries varies greatly depending on a complex combination of criteria: type of kernel, number of input primitives, distribution of primitives in space, type of function queried, type of query, and location of query in space.
|
||||
The experiments described above are neither exhaustive nor conclusive as we have chosen one specific case where the input primitives are the facets of a triangle surface polyhedron. Nevertheless we now provide some general observations and advices about how to put the AABB tree to use with satisfactory performances. While the tree construction times and memory occupancy do not fluctuate much in our experiments depending on the input surface triangle mesh, the performance expressed in number of queries varies greatly depending on a complex combination of criteria: type of kernel, number of input primitives, distribution of primitives in space, type of function queried, type of query and location of query in space.
|
||||
|
||||
\begin{itemize}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue