AABB tree: final polishing.

This commit is contained in:
Pierre Alliez 2009-07-13 18:58:28 +00:00
parent 4900013382
commit 0e25638992
8 changed files with 601 additions and 570 deletions

View File

@ -373,6 +373,14 @@ void MainWindow::on_actionBench_distances_vs_nbt_triggered()
QApplication::restoreOverrideCursor(); 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() void MainWindow::on_actionSave_snapshot_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);

View File

@ -49,6 +49,7 @@ public:
void on_actionClear_distance_function_triggered(); void on_actionClear_distance_function_triggered();
// algorithm menu // algorithm menu
void on_actionRefine_loop_triggered();
void on_actionEdge_points_triggered(); void on_actionEdge_points_triggered();
void on_actionInside_points_triggered(); void on_actionInside_points_triggered();
void on_actionBoundary_points_triggered(); void on_actionBoundary_points_triggered();

View File

@ -65,6 +65,7 @@
<string>Refine</string> <string>Refine</string>
</property> </property>
<addaction name="actionRefine_bisection" /> <addaction name="actionRefine_bisection" />
<addaction name="actionRefine_loop" />
</widget> </widget>
<addaction name="actionEdge_points" /> <addaction name="actionEdge_points" />
<addaction name="actionInside_points" /> <addaction name="actionInside_points" />
@ -253,6 +254,11 @@
<string>Copy snapshot</string> <string>Copy snapshot</string>
</property> </property>
</action> </action>
<action name="actionRefine_loop" >
<property name="text" >
<string>Loop subdivision</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -10,8 +10,10 @@
#include "Refiner.h" #include "Refiner.h"
#include "render_edges.h" #include "render_edges.h"
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Timer.h> #include <CGAL/Timer.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Subdivision_method_3.h>
Scene::Scene() Scene::Scene()
{ {
@ -180,6 +182,7 @@ void Scene::draw_unsigned_distance_function()
int i,j; int i,j;
const int nb_quads = 99; const int nb_quads = 99;
for(i=0;i<nb_quads;i++) for(i=0;i<nb_quads;i++)
{
for(j=0;j<nb_quads;j++) for(j=0;j<nb_quads;j++)
{ {
Point_distance& pd00 = m_distance_function[i][j]; Point_distance& pd00 = m_distance_function[i][j];
@ -207,6 +210,7 @@ void Scene::draw_unsigned_distance_function()
::glColor3ub(m_thermal_ramp.r(i10),m_thermal_ramp.g(i10),m_thermal_ramp.b(i10)); ::glColor3ub(m_thermal_ramp.r(i10),m_thermal_ramp.g(i10),m_thermal_ramp.b(i10));
::glVertex3d(p10.x(),p10.y(),p10.z()); ::glVertex3d(p10.x(),p10.y(),p10.z());
} }
}
::glEnd(); ::glEnd();
} }
@ -221,6 +225,7 @@ void Scene::draw_signed_distance_function()
int i,j; int i,j;
const int nb_quads = 99; const int nb_quads = 99;
for(i=0;i<nb_quads;i++) for(i=0;i<nb_quads;i++)
{
for(j=0;j<nb_quads;j++) for(j=0;j<nb_quads;j++)
{ {
Point_distance& pd00 = m_distance_function[i][j]; Point_distance& pd00 = m_distance_function[i][j];
@ -267,6 +272,7 @@ void Scene::draw_signed_distance_function()
::glColor3ub(m_blue_ramp.r(i10),m_blue_ramp.g(i10),m_blue_ramp.b(i10)); ::glColor3ub(m_blue_ramp.r(i10),m_blue_ramp.g(i10),m_blue_ramp.b(i10));
::glVertex3d(p10.x(),p10.y(),p10.z()); ::glVertex3d(p10.x(),p10.y(),p10.z());
} }
}
::glEnd(); ::glEnd();
} }
@ -666,3 +672,10 @@ void Scene::refine_bisection(const FT max_sqlen)
refiner(max_sqlen); refiner(max_sqlen);
std::cout << "done (" << m_pPolyhedron->size_of_facets() << " facets)" << std::endl; std::cout << "done (" << m_pPolyhedron->size_of_facets() << " facets)" << std::endl;
} }
void Scene::refine_loop()
{
std::cout << "Loop subdivision...";
CGAL::Subdivision_method_3::Loop_subdivision(*m_pPolyhedron, 1);
std::cout << "done (" << m_pPolyhedron->size_of_facets() << " facets)" << std::endl;
}

View File

@ -54,11 +54,11 @@ private:
// utility functions // utility functions
Vector random_vector(); Vector random_vector();
Ray random_ray(const Bbox& bbox); Ray random_ray(const Bbox& bbox);
FT random_in(const double a,const double b);
Line random_line(const Bbox& bbox); Line random_line(const Bbox& bbox);
Point random_point(const Bbox& bbox); Point random_point(const Bbox& bbox);
Plane random_plane(const Bbox& bbox); Plane random_plane(const Bbox& bbox);
Segment random_segment(const Bbox& bbox); Segment random_segment(const Bbox& bbox);
FT random_in(const double a,const double b);
public: public:
// file menu // file menu
@ -70,7 +70,6 @@ public:
void clear_distance_function() { m_max_distance_function = 0.0; } void clear_distance_function() { m_max_distance_function = 0.0; }
// algorithms // algorithms
void refine_bisection(const FT max_sqlen);
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_points); void generate_inside_points(const unsigned int nb_points);
void generate_boundary_points(const unsigned int nb_points); void generate_boundary_points(const unsigned int nb_points);
@ -78,6 +77,10 @@ public:
void generate_points_in(const unsigned int nb_points, void generate_points_in(const unsigned int nb_points,
const double min, const double max); const double min, const double max);
// algorithms/refine
void refine_loop();
void refine_bisection(const FT max_sqlen);
// distance functions // distance functions
void signed_distance_function(); void signed_distance_function();
void unsigned_distance_function(); void unsigned_distance_function();

View File

@ -1,11 +1,11 @@
\section{Performances} \section{Performances}
\label{AABB_tree_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} \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|} \begin{tabular}{|l|c|c|}
\hline \hline
@ -111,7 +111,7 @@ The surface triangle mesh chosen for benchmarking distances is again the knot mo
\subsection{Summary} \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} \begin{itemize}