mirror of https://github.com/CGAL/cgal
AABB tree demo:
- added color ramps for signed and unsigned distance functions (thermal for unsigned, and red/blue for signed) - fix moc warning issue (thanks Manuel Caroli) - fix strange value in performance section of user manual (we now understand that the KD-tree is making something really nasty only for large point sets - and we'll investigate the KD tree more)
This commit is contained in:
parent
7efd70e693
commit
ef1864d6af
|
|
@ -52,9 +52,6 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
|||
qt4_generate_moc( "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" Viewer_moc.cpp )
|
||||
add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" )
|
||||
|
||||
qt4_generate_moc( "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" Scene_moc.cpp )
|
||||
add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" )
|
||||
|
||||
qt4_add_resources ( RESOURCE_FILES AABB_demo.qrc )
|
||||
|
||||
add_file_dependencies( AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
|
||||
|
|
|
|||
|
|
@ -88,6 +88,27 @@ public:
|
|||
rebuild();
|
||||
}
|
||||
|
||||
void build_red()
|
||||
{
|
||||
reset();
|
||||
m_colors[3][0] = 1;m_colors[0][0] = 128;m_colors[1][0] = 0;m_colors[2][0] = 0;
|
||||
m_colors[3][80] = 1;m_colors[0][80] = 255;m_colors[1][80] = 0;m_colors[2][80] = 0;
|
||||
m_colors[3][160] = 1;m_colors[0][160] = 255;m_colors[1][160] = 128;m_colors[2][160] = 0;
|
||||
m_colors[3][255] = 1;m_colors[0][255] = 255;m_colors[1][255] = 255;m_colors[2][255] = 255;
|
||||
rebuild();
|
||||
}
|
||||
|
||||
void build_blue()
|
||||
{
|
||||
reset();
|
||||
m_colors[3][0] = 1;m_colors[0][0] = 0;m_colors[1][0] = 0;m_colors[2][0] = 128;
|
||||
m_colors[3][80] = 1;m_colors[0][80] = 0;m_colors[1][80] = 0;m_colors[2][80] = 255;
|
||||
m_colors[3][160] = 1;m_colors[0][160] = 0;m_colors[1][160] = 255;m_colors[2][160] = 255;
|
||||
m_colors[3][255] = 1;m_colors[0][255] = 255;m_colors[1][255] = 255;m_colors[2][255] = 255;
|
||||
rebuild();
|
||||
}
|
||||
|
||||
|
||||
void build_fire()
|
||||
{
|
||||
reset();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ Scene::Scene()
|
|||
// distance functions
|
||||
m_max_distance_function = (FT)0.0;
|
||||
m_signed_distance_function = false;
|
||||
|
||||
m_red_ramp.build_red();
|
||||
m_blue_ramp.build_blue();
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
|
@ -175,13 +178,13 @@ void Scene::draw_unsigned_distance_function()
|
|||
unsigned int i01 = 255-(unsigned int)(255.0 * d01 / m_max_distance_function);
|
||||
unsigned int i11 = 255-(unsigned int)(255.0 * d11 / m_max_distance_function);
|
||||
unsigned int i10 = 255-(unsigned int)(255.0 * d10 / m_max_distance_function);
|
||||
::glColor3ub(m_ramp.r(i00),m_ramp.g(i00),m_ramp.b(i00));
|
||||
::glColor3ub(m_thermal_ramp.r(i00),m_thermal_ramp.g(i00),m_thermal_ramp.b(i00));
|
||||
::glVertex3d(p00.x(),p00.y(),p00.z());
|
||||
::glColor3ub(m_ramp.r(i01),m_ramp.g(i01),m_ramp.b(i01));
|
||||
::glColor3ub(m_thermal_ramp.r(i01),m_thermal_ramp.g(i01),m_thermal_ramp.b(i01));
|
||||
::glVertex3d(p01.x(),p01.y(),p01.z());
|
||||
::glColor3ub(m_ramp.r(i11),m_ramp.g(i11),m_ramp.b(i11));
|
||||
::glColor3ub(m_thermal_ramp.r(i11),m_thermal_ramp.g(i11),m_thermal_ramp.b(i11));
|
||||
::glVertex3d(p11.x(),p11.y(),p11.z());
|
||||
::glColor3ub(m_ramp.r(i10),m_ramp.g(i10),m_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());
|
||||
}
|
||||
::glEnd();
|
||||
|
|
@ -214,32 +217,34 @@ void Scene::draw_signed_distance_function()
|
|||
FT& d10 = pd10.second;
|
||||
|
||||
// determines grey level
|
||||
double g00 = (double)std::fabs(d00) / m_max_distance_function;
|
||||
double g01 = (double)std::fabs(d01) / m_max_distance_function;
|
||||
double g11 = (double)std::fabs(d11) / m_max_distance_function;
|
||||
double g10 = (double)std::fabs(d10) / m_max_distance_function;
|
||||
|
||||
// determines color (red vs blue for inside vs outside)
|
||||
double r00 = d00 < 0.0 ? g00 : 0.0;
|
||||
double b00 = d00 > 0.0 ? g00 : 0.0;
|
||||
|
||||
double r01 = d01 < 0.0 ? g01 : 0.0;
|
||||
double b01 = d01 > 0.0 ? g01 : 0.0;
|
||||
|
||||
double r11 = d11 < 0.0 ? g11 : 0.0;
|
||||
double b11 = d11 > 0.0 ? g11 : 0.0;
|
||||
|
||||
double r10 = d10 < 0.0 ? g10 : 0.0;
|
||||
double b10 = d10 > 0.0 ? g10 : 0.0;
|
||||
unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function);
|
||||
unsigned int i01 = 255-(unsigned)(255.0 * (double)std::fabs(d01) / m_max_distance_function);
|
||||
unsigned int i11 = 255-(unsigned)(255.0 * (double)std::fabs(d11) / m_max_distance_function);
|
||||
unsigned int i10 = 255-(unsigned)(255.0 * (double)std::fabs(d10) / m_max_distance_function);
|
||||
|
||||
// assembles one quad
|
||||
::glColor3d(r00,0.0,b00);
|
||||
if(d00 > 0.0)
|
||||
::glColor3ub(m_red_ramp.r(i00),m_red_ramp.g(i00),m_red_ramp.b(i00));
|
||||
else
|
||||
::glColor3ub(m_blue_ramp.r(i00),m_blue_ramp.g(i00),m_blue_ramp.b(i00));
|
||||
::glVertex3d(p00.x(),p00.y(),p00.z());
|
||||
::glColor3d(r01,0.0,b01);
|
||||
|
||||
if(d01 > 0.0)
|
||||
::glColor3ub(m_red_ramp.r(i01),m_red_ramp.g(i01),m_red_ramp.b(i01));
|
||||
else
|
||||
::glColor3ub(m_blue_ramp.r(i01),m_blue_ramp.g(i01),m_blue_ramp.b(i01));
|
||||
::glVertex3d(p01.x(),p01.y(),p01.z());
|
||||
::glColor3d(r11,0.0,b11);
|
||||
|
||||
if(d11 > 0)
|
||||
::glColor3ub(m_red_ramp.r(i11),m_red_ramp.g(i11),m_red_ramp.b(i11));
|
||||
else
|
||||
::glColor3ub(m_blue_ramp.r(i11),m_blue_ramp.g(i11),m_blue_ramp.b(i11));
|
||||
::glVertex3d(p11.x(),p11.y(),p11.z());
|
||||
::glColor3d(r10,0.0,b10);
|
||||
|
||||
if(d10 > 0)
|
||||
::glColor3ub(m_red_ramp.r(i10),m_red_ramp.g(i10),m_red_ramp.b(i10));
|
||||
else
|
||||
::glColor3ub(m_blue_ramp.r(i10),m_blue_ramp.g(i10),m_blue_ramp.b(i10));
|
||||
::glVertex3d(p10.x(),p10.y(),p10.z());
|
||||
}
|
||||
::glEnd();
|
||||
|
|
@ -429,9 +434,9 @@ void Scene::benchmark_distances()
|
|||
tree.accelerate_distance_queries();
|
||||
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
||||
|
||||
// (cache experiments)
|
||||
std::cout << "First call to populate the cache:" << std::endl;
|
||||
bench_closest_point(tree);
|
||||
// TODO: check what the KD-tree is doing in there for large models.
|
||||
std::cout << "One single call to initialize KD-tree" << std::endl;
|
||||
tree.closest_point(CGAL::ORIGIN);
|
||||
|
||||
std::cout << "------- Now, the real benchmark -------" << std::endl;
|
||||
bench_closest_point(tree);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,9 @@ private:
|
|||
bool m_signed_distance_function;
|
||||
typedef std::pair<Point,FT> Point_distance;
|
||||
Point_distance m_distance_function[100][100];
|
||||
Color_ramp m_ramp;
|
||||
Color_ramp m_thermal_ramp;
|
||||
Color_ramp m_red_ramp;
|
||||
Color_ramp m_blue_ramp;
|
||||
|
||||
// view options
|
||||
bool m_view_points;
|
||||
|
|
|
|||
|
|
@ -63,11 +63,8 @@ The surface triangle mesh chosen for benchmarking distances is again the knot mo
|
|||
14,400 & 157 & 31,472 & 33,529 & 34,817 \\
|
||||
57,600 & 330 & 15,602 & 16,355 & 17,106 \\
|
||||
230,400 & 1,203 & 6,528 & 8,287 & 8,683 \\
|
||||
921,600 & 5,047 & 563 & 4,221 & 4,424 \\
|
||||
921,600 & 5,047 & 4,399 & 4,221 & 4,424 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
% TOFIX: understand why we mesure 563 above (measure is repeatable).
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue