+ AABB demo: use a moving plane for distance functions

This commit is contained in:
Stéphane Tayeb 2010-05-19 06:35:59 +00:00
parent 1297288d46
commit d8e443c68e
9 changed files with 438 additions and 379 deletions

View File

@ -268,6 +268,7 @@ void MainWindow::on_actionBench_intersections_triggered()
void MainWindow::on_actionUnsigned_distance_function_to_facets_triggered() void MainWindow::on_actionUnsigned_distance_function_to_facets_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->activate_cutting_plane();
m_pScene->unsigned_distance_function(); m_pScene->unsigned_distance_function();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
@ -276,6 +277,7 @@ void MainWindow::on_actionUnsigned_distance_function_to_facets_triggered()
void MainWindow::on_actionUnsigned_distance_function_to_edges_triggered() void MainWindow::on_actionUnsigned_distance_function_to_edges_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->activate_cutting_plane();
m_pScene->unsigned_distance_function_to_edges(); m_pScene->unsigned_distance_function_to_edges();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
@ -284,20 +286,27 @@ void MainWindow::on_actionUnsigned_distance_function_to_edges_triggered()
void MainWindow::on_actionSigned_distance_function_to_facets_triggered() void MainWindow::on_actionSigned_distance_function_to_facets_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->activate_cutting_plane();
m_pScene->signed_distance_function(); m_pScene->signed_distance_function();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionCutting_plane_triggered() void MainWindow::on_actionIntersection_cutting_plane_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->activate_cutting_plane(); m_pScene->activate_cutting_plane();
m_pScene->cutting_plane(); m_pScene->cut_segment_plane();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionCutting_plane_none_triggered()
{
m_pScene->deactivate_cutting_plane();
m_pViewer->update();
}
void MainWindow::on_actionView_polyhedron_triggered() void MainWindow::on_actionView_polyhedron_triggered()
{ {
m_pScene->toggle_view_poyhedron(); m_pScene->toggle_view_poyhedron();
@ -316,12 +325,6 @@ void MainWindow::on_actionView_segments_triggered()
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionView_distance_function_triggered()
{
m_pScene->toggle_view_distance_function();
m_pViewer->update();
}
void MainWindow::on_actionView_cutting_plane_triggered() void MainWindow::on_actionView_cutting_plane_triggered()
{ {
m_pScene->toggle_view_plane(); m_pScene->toggle_view_plane();
@ -340,12 +343,6 @@ void MainWindow::on_actionClear_segments_triggered()
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionClear_distance_function_triggered()
{
m_pScene->clear_distance_function();
m_pViewer->update();
}
void MainWindow::on_actionClear_cutting_plane_triggered() void MainWindow::on_actionClear_cutting_plane_triggered()
{ {
m_pScene->clear_cutting_plane(); m_pScene->clear_cutting_plane();

View File

@ -46,7 +46,6 @@ public:
void on_actionCopy_snapshot_triggered(); void on_actionCopy_snapshot_triggered();
void on_actionClear_points_triggered(); void on_actionClear_points_triggered();
void on_actionClear_segments_triggered(); void on_actionClear_segments_triggered();
void on_actionClear_distance_function_triggered();
void on_actionClear_cutting_plane_triggered(); void on_actionClear_cutting_plane_triggered();
// algorithm menu // algorithm menu
@ -60,7 +59,8 @@ public:
void on_actionSigned_distance_function_to_facets_triggered(); void on_actionSigned_distance_function_to_facets_triggered();
void on_actionUnsigned_distance_function_to_edges_triggered(); void on_actionUnsigned_distance_function_to_edges_triggered();
void on_actionUnsigned_distance_function_to_facets_triggered(); void on_actionUnsigned_distance_function_to_facets_triggered();
void on_actionCutting_plane_triggered(); void on_actionIntersection_cutting_plane_triggered();
void on_actionCutting_plane_none_triggered();
// benchmark menu // benchmark menu
void on_actionBench_memory_triggered(); void on_actionBench_memory_triggered();
@ -76,7 +76,6 @@ public:
void on_actionView_points_triggered(); void on_actionView_points_triggered();
void on_actionView_segments_triggered(); void on_actionView_segments_triggered();
void on_actionView_polyhedron_triggered(); void on_actionView_polyhedron_triggered();
void on_actionView_distance_function_triggered();
void on_actionView_cutting_plane_triggered(); void on_actionView_cutting_plane_triggered();
private: private:

View File

@ -1,7 +1,7 @@
<ui version="4.0" > <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" > <widget class="QMainWindow" name="MainWindow">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,282 +9,280 @@
<height>495</height> <height>495</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>CGAL AABB tree demo</string> <string>CGAL AABB tree demo</string>
</property> </property>
<property name="windowIcon" > <property name="windowIcon">
<iconset resource="AABB_demo.qrc" > <iconset resource="AABB_demo.qrc">
<normaloff>:/cgal/icons/resources/cgal_logo.xpm</normaloff>:/cgal/icons/resources/cgal_logo.xpm</iconset> <normaloff>:/cgal/icons/resources/cgal_logo.xpm</normaloff>:/cgal/icons/resources/cgal_logo.xpm</iconset>
</property> </property>
<property name="locale" > <property name="locale">
<locale country="UnitedStates" language="English" /> <locale language="English" country="UnitedStates"/>
</property> </property>
<widget class="QWidget" name="centralwidget" > <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout" > <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" > <item row="0" column="1">
<widget class="Viewer" native="1" name="viewer" > <widget class="Viewer" name="viewer" native="true">
<property name="locale" > <property name="locale">
<locale country="UnitedStates" language="English" /> <locale language="English" country="UnitedStates"/>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menubar" > <widget class="QMenuBar" name="menubar">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>638</width> <width>638</width>
<height>21</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile" > <widget class="QMenu" name="menuFile">
<property name="title" > <property name="title">
<string>&amp;File</string> <string>&amp;File</string>
</property> </property>
<addaction name="actionLoadPolyhedron" /> <addaction name="actionLoadPolyhedron"/>
<addaction name="separator" /> <addaction name="separator"/>
<addaction name="actionQuit" /> <addaction name="actionQuit"/>
</widget> </widget>
<widget class="QMenu" name="menuView" > <widget class="QMenu" name="menuView">
<property name="title" > <property name="title">
<string>&amp;View</string> <string>&amp;View</string>
</property> </property>
<addaction name="actionView_points" /> <addaction name="actionView_points"/>
<addaction name="actionView_cutting_plane" /> <addaction name="actionView_cutting_plane"/>
<addaction name="actionView_segments" /> <addaction name="actionView_segments"/>
<addaction name="actionView_polyhedron" /> <addaction name="actionView_polyhedron"/>
<addaction name="actionView_distance_function" />
</widget> </widget>
<widget class="QMenu" name="menuAlgorithms" > <widget class="QMenu" name="menuAlgorithms">
<property name="title" > <property name="title">
<string>Algorithms</string> <string>Algorithms</string>
</property> </property>
<widget class="QMenu" name="menuRefine" > <widget class="QMenu" name="menuRefine">
<property name="title" > <property name="title">
<string>Refine</string> <string>Refine</string>
</property> </property>
<addaction name="actionRefine_bisection" /> <addaction name="actionRefine_bisection"/>
<addaction name="actionRefine_loop" /> <addaction name="actionRefine_loop"/>
</widget> </widget>
<widget class="QMenu" name="menuCut_plane" > <widget class="QMenu" name="menuCut_plane">
<property name="title" > <property name="title">
<string>Cut plane</string> <string>Cut plane</string>
</property> </property>
<addaction name="actionNone" /> <addaction name="actionCutting_plane_none"/>
<addaction name="actionCutting_plane" /> <addaction name="actionIntersection_cutting_plane"/>
<addaction name="actionSigned_distance_function_to_facets" /> <addaction name="actionSigned_distance_function_to_facets"/>
<addaction name="actionUnsigned_distance_function_to_facets" /> <addaction name="actionUnsigned_distance_function_to_facets"/>
<addaction name="actionUnsigned_distance_function_to_edges" /> <addaction name="actionUnsigned_distance_function_to_edges"/>
</widget> </widget>
<addaction name="actionEdge_points" /> <addaction name="actionEdge_points"/>
<addaction name="actionInside_points" /> <addaction name="actionInside_points"/>
<addaction name="actionPoints_in_interval" /> <addaction name="actionPoints_in_interval"/>
<addaction name="actionBoundary_points" /> <addaction name="actionBoundary_points"/>
<addaction name="actionBoundary_segments" /> <addaction name="actionBoundary_segments"/>
<addaction name="separator" /> <addaction name="separator"/>
<addaction name="menuCut_plane" /> <addaction name="menuCut_plane"/>
<addaction name="menuRefine" /> <addaction name="menuRefine"/>
</widget> </widget>
<widget class="QMenu" name="menuBenchmarks" > <widget class="QMenu" name="menuBenchmarks">
<property name="title" > <property name="title">
<string>Benchmark</string> <string>Benchmark</string>
</property> </property>
<widget class="QMenu" name="menuAgainst_triangles" > <widget class="QMenu" name="menuAgainst_triangles">
<property name="title" > <property name="title">
<string>Against #triangles</string> <string>Against #triangles</string>
</property> </property>
<addaction name="actionBench_memory" /> <addaction name="actionBench_memory"/>
<addaction name="actionBench_construction" /> <addaction name="actionBench_construction"/>
<addaction name="actionBench_intersections_vs_nbt" /> <addaction name="actionBench_intersections_vs_nbt"/>
<addaction name="actionBench_distances_vs_nbt" /> <addaction name="actionBench_distances_vs_nbt"/>
</widget> </widget>
<addaction name="actionBench_distances" /> <addaction name="actionBench_distances"/>
<addaction name="actionBench_intersections" /> <addaction name="actionBench_intersections"/>
<addaction name="menuAgainst_triangles" /> <addaction name="menuAgainst_triangles"/>
</widget> </widget>
<widget class="QMenu" name="menuEdit" > <widget class="QMenu" name="menuEdit">
<property name="title" > <property name="title">
<string>Edit</string> <string>Edit</string>
</property> </property>
<addaction name="actionClear_points" /> <addaction name="actionClear_points"/>
<addaction name="actionClear_segments" /> <addaction name="actionClear_segments"/>
<addaction name="actionClear_distance_function" /> <addaction name="actionClear_cutting_plane"/>
<addaction name="actionClear_cutting_plane" /> <addaction name="separator"/>
<addaction name="separator" /> <addaction name="actionCopy_snapshot"/>
<addaction name="actionCopy_snapshot" /> <addaction name="actionSave_snapshot"/>
<addaction name="actionSave_snapshot" />
</widget> </widget>
<addaction name="menuFile" /> <addaction name="menuFile"/>
<addaction name="menuEdit" /> <addaction name="menuEdit"/>
<addaction name="menuAlgorithms" /> <addaction name="menuAlgorithms"/>
<addaction name="menuView" /> <addaction name="menuView"/>
<addaction name="menuBenchmarks" /> <addaction name="menuBenchmarks"/>
</widget> </widget>
<action name="actionQuit" > <action name="actionQuit">
<property name="text" > <property name="text">
<string>&amp;Quit</string> <string>&amp;Quit</string>
</property> </property>
<property name="shortcut" > <property name="shortcut">
<string>Ctrl+Q</string> <string>Ctrl+Q</string>
</property> </property>
</action> </action>
<action name="actionLoadPolyhedron" > <action name="actionLoadPolyhedron">
<property name="text" > <property name="text">
<string>Load polyhedron...</string> <string>Load polyhedron...</string>
</property> </property>
</action> </action>
<action name="actionInside_points" > <action name="actionInside_points">
<property name="text" > <property name="text">
<string>Inside points...</string> <string>Inside points...</string>
</property> </property>
</action> </action>
<action name="actionBench_distances" > <action name="actionBench_distances">
<property name="text" > <property name="text">
<string>Distances</string> <string>Distances</string>
</property> </property>
</action> </action>
<action name="actionUnsigned_distance_function_to_facets" > <action name="actionUnsigned_distance_function_to_facets">
<property name="text" > <property name="text">
<string>Unsigned distance function to facets</string> <string>Unsigned distance function to facets</string>
</property> </property>
</action> </action>
<action name="actionUnsigned_distance_function_to_edges" > <action name="actionUnsigned_distance_function_to_edges">
<property name="text" > <property name="text">
<string>Unsigned distance function to edges</string> <string>Unsigned distance function to edges</string>
</property> </property>
</action> </action>
<action name="actionSigned_distance_function_to_facets" > <action name="actionSigned_distance_function_to_facets">
<property name="text" > <property name="text">
<string>Signed distance function to facets</string> <string>Signed distance function to facets</string>
</property> </property>
</action> </action>
<action name="actionView_polyhedron" > <action name="actionView_polyhedron">
<property name="text" > <property name="text">
<string>Polyhedron</string> <string>Polyhedron</string>
</property> </property>
<property name="shortcut" > <property name="shortcut">
<string>P</string> <string>P</string>
</property> </property>
</action> </action>
<action name="actionView_points" > <action name="actionView_points">
<property name="text" > <property name="text">
<string>Points</string> <string>Points</string>
</property> </property>
</action> </action>
<action name="actionClear_points" > <action name="actionClear_points">
<property name="text" > <property name="text">
<string>Clear points</string> <string>Clear points</string>
</property> </property>
</action> </action>
<action name="actionBoundary_segments" > <action name="actionBoundary_segments">
<property name="text" > <property name="text">
<string>Boundary segments...</string> <string>Boundary segments...</string>
</property> </property>
</action> </action>
<action name="actionBoundary_points" > <action name="actionBoundary_points">
<property name="text" > <property name="text">
<string>Boundary points...</string> <string>Boundary points...</string>
</property> </property>
</action> </action>
<action name="actionClear_segments" > <action name="actionClear_segments">
<property name="text" > <property name="text">
<string>Clear segments</string> <string>Clear segments</string>
</property> </property>
</action> </action>
<action name="actionView_segments" > <action name="actionView_segments">
<property name="text" > <property name="text">
<string>Segments</string> <string>Segments</string>
</property> </property>
</action> </action>
<action name="actionEdge_points" > <action name="actionEdge_points">
<property name="text" > <property name="text">
<string>Edge points...</string> <string>Edge points...</string>
</property> </property>
</action> </action>
<action name="actionBench_intersections" > <action name="actionBench_intersections">
<property name="text" > <property name="text">
<string>Intersections</string> <string>Intersections</string>
</property> </property>
</action> </action>
<action name="actionView_distance_function" > <action name="actionView_distance_function">
<property name="text" > <property name="text">
<string>Distance function</string> <string>Distance function</string>
</property> </property>
</action> </action>
<action name="actionClear_distance_function" > <action name="actionClear_distance_function">
<property name="text" > <property name="text">
<string>Clear distance function</string> <string>Clear distance function</string>
</property> </property>
</action> </action>
<action name="actionRefine_bisection" > <action name="actionRefine_bisection">
<property name="text" > <property name="text">
<string>Longest edge bisection</string> <string>Longest edge bisection</string>
</property> </property>
</action> </action>
<action name="actionLoop_subdivision" > <action name="actionLoop_subdivision">
<property name="text" > <property name="text">
<string>Loop subdivision</string> <string>Loop subdivision</string>
</property> </property>
</action> </action>
<action name="actionBench_memory" > <action name="actionBench_memory">
<property name="text" > <property name="text">
<string>Memory</string> <string>Memory</string>
</property> </property>
</action> </action>
<action name="actionBench_construction" > <action name="actionBench_construction">
<property name="text" > <property name="text">
<string>Construction</string> <string>Construction</string>
</property> </property>
</action> </action>
<action name="actionBench_intersections_vs_nbt" > <action name="actionBench_intersections_vs_nbt">
<property name="text" > <property name="text">
<string>Intersections</string> <string>Intersections</string>
</property> </property>
</action> </action>
<action name="actionBench_distances_vs_nbt" > <action name="actionBench_distances_vs_nbt">
<property name="text" > <property name="text">
<string>Distances</string> <string>Distances</string>
</property> </property>
</action> </action>
<action name="actionPoints_in_interval" > <action name="actionPoints_in_interval">
<property name="text" > <property name="text">
<string>Points in interval...</string> <string>Points in interval...</string>
</property> </property>
</action> </action>
<action name="actionSave_snapshot" > <action name="actionSave_snapshot">
<property name="text" > <property name="text">
<string>Save snapshot</string> <string>Save snapshot</string>
</property> </property>
</action> </action>
<action name="actionCopy_snapshot" > <action name="actionCopy_snapshot">
<property name="text" > <property name="text">
<string>Copy snapshot</string> <string>Copy snapshot</string>
</property> </property>
</action> </action>
<action name="actionRefine_loop" > <action name="actionRefine_loop">
<property name="text" > <property name="text">
<string>Loop subdivision</string> <string>Loop subdivision</string>
</property> </property>
</action> </action>
<action name="actionCutting_plane" > <action name="actionIntersection_cutting_plane">
<property name="text" > <property name="text">
<string>Intersection</string> <string>Intersection</string>
</property> </property>
</action> </action>
<action name="actionView_cutting_plane" > <action name="actionView_cutting_plane">
<property name="text" > <property name="text">
<string>Cut plane</string> <string>Cut plane</string>
</property> </property>
</action> </action>
<action name="actionClear_cutting_plane" > <action name="actionClear_cutting_plane">
<property name="text" > <property name="text">
<string>Clear cutting plane</string> <string>Clear cutting plane</string>
</property> </property>
</action> </action>
<action name="actionNone" > <action name="actionCutting_plane_none">
<property name="text" > <property name="text">
<string>None</string> <string>None</string>
</property> </property>
</action> </action>
@ -297,7 +295,7 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="AABB_demo.qrc" /> <include location="AABB_demo.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -16,9 +16,16 @@
#include <CGAL/IO/Polyhedron_iostream.h> #include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Subdivision_method_3.h> #include <CGAL/Subdivision_method_3.h>
// constants
const double slow_distance_grid_size = 100;
const double fast_distance_grid_size = 20;
Scene::Scene() Scene::Scene()
: m_frame (new ManipulatedFrame()) : m_frame (new ManipulatedFrame())
, m_view_plane(false) , m_view_plane(false)
, m_grid_size(slow_distance_grid_size)
, m_cut_plane(NONE)
{ {
m_pPolyhedron = NULL; m_pPolyhedron = NULL;
@ -26,13 +33,11 @@ Scene::Scene()
m_view_points = true; m_view_points = true;
m_view_segments = true; m_view_segments = true;
m_view_polyhedron = true; m_view_polyhedron = true;
m_view_distance_function = true;
// distance function // distance function
m_red_ramp.build_red(); m_red_ramp.build_red();
m_blue_ramp.build_blue(); m_blue_ramp.build_blue();
m_max_distance_function = (FT)0.0; m_max_distance_function = (FT)0.0;
m_signed_distance_function = false;
} }
Scene::~Scene() Scene::~Scene()
@ -122,17 +127,23 @@ void Scene::draw()
if(m_view_segments) if(m_view_segments)
draw_segments(); draw_segments();
if(m_view_distance_function) if (m_view_plane)
{ {
if(m_signed_distance_function) switch( m_cut_plane )
draw_signed_distance_function(); {
else case UNSIGNED_EDGES:
draw_unsigned_distance_function(); case UNSIGNED_FACETS:
} draw_distance_function(m_thermal_ramp, m_thermal_ramp);
break;
if (m_view_plane) case SIGNED_FACETS:
{ draw_distance_function(m_red_ramp, m_blue_ramp);
draw_plane(); break;
case CUT_SEGMENTS:
draw_cut_segment_plane();
break;
case NONE: // do nothing
break;
}
} }
} }
@ -188,117 +199,71 @@ void Scene::draw_points()
} }
} }
void Scene::draw_unsigned_distance_function() void Scene::draw_distance_function(const Color_ramp& ramp_pos,
const Color_ramp& ramp_neg) const
{ {
if(m_max_distance_function == (FT)0.0)
return;
::glDisable(GL_LIGHTING); ::glDisable(GL_LIGHTING);
::glShadeModel(GL_SMOOTH); if ( m_fast_distance ) { ::glShadeModel(GL_FLAT); }
else { ::glShadeModel(GL_SMOOTH); }
::glBegin(GL_QUADS); ::glBegin(GL_QUADS);
int i,j; int i,j;
const int nb_quads = 99; const int nb_quads = m_grid_size-1;
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]; const Point_distance& pd00 = m_distance_function[i][j];
Point_distance& pd01 = m_distance_function[i][j+1]; const Point_distance& pd01 = m_distance_function[i][j+1];
Point_distance& pd11 = m_distance_function[i+1][j+1]; const Point_distance& pd11 = m_distance_function[i+1][j+1];
Point_distance& pd10 = m_distance_function[i+1][j]; const Point_distance& pd10 = m_distance_function[i+1][j];
Point& p00 = pd00.first; const Point& p00 = pd00.first;
Point& p01 = pd01.first; const Point& p01 = pd01.first;
Point& p11 = pd11.first; const Point& p11 = pd11.first;
Point& p10 = pd10.first; const Point& p10 = pd10.first;
FT& d00 = pd00.second; const FT& d00 = pd00.second;
FT& d01 = pd01.second; const FT& d01 = pd01.second;
FT& d11 = pd11.second; const FT& d11 = pd11.second;
FT& d10 = pd10.second; const FT& d10 = pd10.second;
unsigned int i00 = 255-(unsigned int)(255.0 * d00 / m_max_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_thermal_ramp.r(i00),m_thermal_ramp.g(i00),m_thermal_ramp.b(i00));
::glVertex3d(p00.x(),p00.y(),p00.z());
::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_thermal_ramp.r(i11),m_thermal_ramp.g(i11),m_thermal_ramp.b(i11));
::glVertex3d(p11.x(),p11.y(),p11.z());
::glColor3ub(m_thermal_ramp.r(i10),m_thermal_ramp.g(i10),m_thermal_ramp.b(i10));
::glVertex3d(p10.x(),p10.y(),p10.z());
}
}
::glEnd();
}
void Scene::draw_signed_distance_function()
{
if(m_max_distance_function == (FT)0.0)
return;
::glDisable(GL_LIGHTING);
::glShadeModel(GL_SMOOTH);
::glBegin(GL_QUADS);
int i,j;
const int nb_quads = 99;
for(i=0;i<nb_quads;i++)
{
for(j=0;j<nb_quads;j++)
{
Point_distance& pd00 = m_distance_function[i][j];
Point_distance& pd01 = m_distance_function[i][j+1];
Point_distance& pd11 = m_distance_function[i+1][j+1];
Point_distance& pd10 = m_distance_function[i+1][j];
Point& p00 = pd00.first;
Point& p01 = pd01.first;
Point& p11 = pd11.first;
Point& p10 = pd10.first;
FT& d00 = pd00.second;
FT& d01 = pd01.second;
FT& d11 = pd11.second;
FT& d10 = pd10.second;
// determines grey level // determines grey level
unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function); 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 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 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); unsigned int i10 = 255-(unsigned)(255.0 * (double)std::fabs(d10) / m_max_distance_function);
// assembles one quad // assembles one quad
if(d00 > 0.0) if(d00 > 0.0)
::glColor3ub(m_red_ramp.r(i00),m_red_ramp.g(i00),m_red_ramp.b(i00)); ::glColor3ub(ramp_pos.r(i00),ramp_pos.g(i00),ramp_pos.b(i00));
else else
::glColor3ub(m_blue_ramp.r(i00),m_blue_ramp.g(i00),m_blue_ramp.b(i00)); ::glColor3ub(ramp_neg.r(i00),ramp_neg.g(i00),ramp_neg.b(i00));
::glVertex3d(p00.x(),p00.y(),p00.z()); ::glVertex3d(p00.x(),p00.y(),p00.z());
if(d01 > 0.0) if(d01 > 0.0)
::glColor3ub(m_red_ramp.r(i01),m_red_ramp.g(i01),m_red_ramp.b(i01)); ::glColor3ub(ramp_pos.r(i01),ramp_pos.g(i01),ramp_pos.b(i01));
else else
::glColor3ub(m_blue_ramp.r(i01),m_blue_ramp.g(i01),m_blue_ramp.b(i01)); ::glColor3ub(ramp_neg.r(i01),ramp_neg.g(i01),ramp_neg.b(i01));
::glVertex3d(p01.x(),p01.y(),p01.z()); ::glVertex3d(p01.x(),p01.y(),p01.z());
if(d11 > 0) if(d11 > 0)
::glColor3ub(m_red_ramp.r(i11),m_red_ramp.g(i11),m_red_ramp.b(i11)); ::glColor3ub(ramp_pos.r(i11),ramp_pos.g(i11),ramp_pos.b(i11));
else else
::glColor3ub(m_blue_ramp.r(i11),m_blue_ramp.g(i11),m_blue_ramp.b(i11)); ::glColor3ub(ramp_neg.r(i11),ramp_neg.g(i11),ramp_neg.b(i11));
::glVertex3d(p11.x(),p11.y(),p11.z()); ::glVertex3d(p11.x(),p11.y(),p11.z());
if(d10 > 0) if(d10 > 0)
::glColor3ub(m_red_ramp.r(i10),m_red_ramp.g(i10),m_red_ramp.b(i10)); ::glColor3ub(ramp_pos.r(i10),ramp_pos.g(i10),ramp_pos.b(i10));
else else
::glColor3ub(m_blue_ramp.r(i10),m_blue_ramp.g(i10),m_blue_ramp.b(i10)); ::glColor3ub(ramp_neg.r(i10),ramp_neg.g(i10),ramp_neg.b(i10));
::glVertex3d(p10.x(),p10.y(),p10.z()); ::glVertex3d(p10.x(),p10.y(),p10.z());
} }
} }
::glEnd(); ::glEnd();
} }
void Scene::draw_plane() void Scene::draw_cut_segment_plane() const
{ {
double dx = m_bbox.xmax()-m_bbox.xmin(); float diag = .6f * float(bbox_diag());
double dy = m_bbox.ymax()-m_bbox.ymin();
double dz = m_bbox.zmax()-m_bbox.zmin();
float diag = .6f * float(std::sqrt(dx*dx + dy*dy + dz*dz));
::glDisable(GL_LIGHTING); ::glDisable(GL_LIGHTING);
::glLineWidth(1.0f); ::glLineWidth(1.0f);
@ -314,7 +279,7 @@ void Scene::draw_plane()
::glLineWidth(2.0f); ::glLineWidth(2.0f);
::glColor3f(1.f, 0.f, 0.f); ::glColor3f(1.f, 0.f, 0.f);
::glBegin(GL_LINES); ::glBegin(GL_LINES);
for ( std::vector<Segment>::iterator it = m_cut_segments.begin(), for ( std::vector<Segment>::const_iterator it = m_cut_segments.begin(),
end = m_cut_segments.end() ; it != end ; ++it ) end = m_cut_segments.end() ; it != end ; ++it )
{ {
const Point& a = it->source(); const Point& a = it->source();
@ -402,6 +367,25 @@ Plane Scene::frame_plane() const
return Plane(n[0], n[1], n[2], - n * pos); return Plane(n[0], n[1], n[2], - n * pos);
} }
Aff_transformation Scene::frame_transformation() const
{
const ::GLdouble* m = m_frame->matrix();
// OpenGL matrices are row-major matrices
return Aff_transformation (m[0], m[4], m[8], m[12],
m[1], m[5], m[9], m[13],
m[2], m[6], m[10], m[14]);
}
FT Scene::bbox_diag() const
{
double dx = m_bbox.xmax()-m_bbox.xmin();
double dy = m_bbox.ymax()-m_bbox.ymin();
double dz = m_bbox.zmax()-m_bbox.zmin();
return FT(std::sqrt(dx*dx + dy*dy + dz*dz));
}
void Scene::build_facet_tree() void Scene::build_facet_tree()
{ {
if ( NULL == m_pPolyhedron ) if ( NULL == m_pPolyhedron )
@ -416,27 +400,56 @@ void Scene::build_facet_tree()
// build tree // build tree
CGAL::Timer timer; CGAL::Timer timer;
timer.start(); timer.start();
std::cout << "Construct AABB tree..."; std::cout << "Construct Facet AABB tree...";
m_facet_tree.rebuild(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end()); m_facet_tree.rebuild(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
m_facet_tree.accelerate_distance_queries();
std::cout << "done (" << timer.time() << " s)" << std::endl; std::cout << "done (" << timer.time() << " s)" << std::endl;
} }
void Scene::build_edge_tree()
{
if ( NULL == m_pPolyhedron )
{
std::cerr << "Build edge tree failed: load polyhedron first." << std::endl;
return;
}
// ensure tree is empty
m_edge_tree.clear();
// build tree
CGAL::Timer timer;
timer.start();
std::cout << "Construct Edge AABB tree...";
m_edge_tree.rebuild(m_pPolyhedron->edges_begin(),m_pPolyhedron->edges_end());
m_edge_tree.accelerate_distance_queries();
std::cout << "done (" << timer.time() << " s)" << std::endl;
}
void Scene::clear_internal_data() void Scene::clear_internal_data()
{ {
m_facet_tree.clear(); m_facet_tree.clear();
m_edge_tree.clear();
clear_points(); clear_points();
clear_segments(); clear_segments();
clear_distance_function();
clear_cutting_plane(); clear_cutting_plane();
} }
void Scene::clear_cutting_plane() void Scene::clear_cutting_plane()
{ {
m_cut_segments.clear(); m_cut_segments.clear();
m_cut_plane = NONE;
deactivate_cutting_plane(); deactivate_cutting_plane();
} }
void Scene::update_grid_size()
{
m_grid_size = m_fast_distance ? fast_distance_grid_size
: slow_distance_grid_size;
}
void Scene::generate_points_in(const unsigned int nb_points, void Scene::generate_points_in(const unsigned int nb_points,
const double min, const double min,
const double max) const double max)
@ -679,147 +692,121 @@ void Scene::generate_edge_points(const unsigned int nb_points)
std::cout << nb_planes << " plane queries, " << timer.time() << " s." << std::endl; std::cout << nb_planes << " plane queries, " << timer.time() << " s." << std::endl;
} }
void Scene::unsigned_distance_function()
template <typename Tree>
void Scene::compute_distance_function(const Tree& tree)
{ {
if(m_pPolyhedron == NULL) // Get transformation
Aff_transformation t = frame_transformation();
m_max_distance_function = FT(0);
FT diag = bbox_diag();
const FT dx = diag;
const FT dy = diag;
const FT z (0);
for(int i=0 ; i<m_grid_size ; ++i)
{ {
std::cout << "Load polyhedron first." << std::endl; FT x = -diag/FT(2) + FT(i)/FT(m_grid_size) * dx;
return;
for(int j=0 ; j<m_grid_size ; ++j)
{
FT y = -diag/FT(2) + FT(j)/FT(m_grid_size) * dy;
Point query = t( Point(x,y,z) );
FT dist = CGAL::sqrt( tree.squared_distance(query) );
m_distance_function[i][j] = Point_distance(query,dist);
m_max_distance_function = (std::max)(dist, m_max_distance_function);
}
} }
}
CGAL::Timer timer; template <typename Tree>
timer.start(); void Scene::sign_distance_function(const Tree& tree)
std::cout << "Construct AABB tree..."; {
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end()); Vector random_vec = random_vector();
tree.accelerate_distance_queries();
std::cout << "done (" << timer.time() << " s)" << std::endl; for(int i=0 ; i<m_grid_size ; ++i)
m_max_distance_function = (FT)0.0;
int i,j;
const double dx = m_bbox.xmax() - m_bbox.xmin();
const double dy = m_bbox.ymax() - m_bbox.ymin();
const double z = 0.5 * (m_bbox.zmax() + m_bbox.zmin());
for(i=0;i<100;i++)
{ {
FT x = m_bbox.xmin() + (FT)((double)i/100.0 * dx); for(int j=0 ; j<m_grid_size ; ++j)
for(j=0;j<100;j++)
{ {
FT y = m_bbox.ymin() + (FT)((double)j/100.0 * dy); const Point& p = m_distance_function[i][j].first;
Point query(x,y,z); const FT unsigned_distance = m_distance_function[i][j].second;
FT sq_distance = tree.squared_distance(query);
FT distance = std::sqrt(sq_distance); // get sign through ray casting (random vector)
m_distance_function[i][j] = Point_distance(query,distance); Ray ray(p, random_vec);
m_max_distance_function = distance > m_max_distance_function ? unsigned int nbi = tree.number_of_intersected_primitives(ray);
distance : m_max_distance_function;
FT sign ( (nbi&1) == 0 ? 1 : -1);
m_distance_function[i][j].second = sign * unsigned_distance;
} }
} }
m_signed_distance_function = false;
} }
void Scene::unsigned_distance_function_to_edges()
void Scene::unsigned_distance_function()
{ {
if(m_pPolyhedron == NULL) // Build tree if needed
if ( m_facet_tree.empty() )
{ {
std::cout << "Load polyhedron first." << std::endl; build_facet_tree();
return;
} }
compute_distance_function(m_facet_tree);
m_cut_plane = UNSIGNED_FACETS;
}
typedef CGAL::AABB_polyhedron_segment_primitive<Kernel,Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Edge_tree;
CGAL::Timer timer; void Scene::unsigned_distance_function_to_edges()
timer.start(); {
std::cout << "Construct AABB tree from edges..."; // Build tree if needed
Edge_tree tree(m_pPolyhedron->edges_begin(),m_pPolyhedron->edges_end()); if ( m_edge_tree.empty() )
tree.accelerate_distance_queries();
std::cout << "done (" << timer.time() << " s)" << std::endl;
m_max_distance_function = (FT)0.0;
const double dx = m_bbox.xmax() - m_bbox.xmin();
const double dy = m_bbox.ymax() - m_bbox.ymin();
const double z = 0.5 * (m_bbox.zmax() + m_bbox.zmin());
int i,j;
for(i=0;i<100;i++)
{ {
FT x = m_bbox.xmin() + (FT)((double)i/100.0 * dx); build_edge_tree();
for(j=0;j<100;j++)
{
FT y = m_bbox.ymin() + (FT)((double)j/100.0 * dy);
Point query(x,y,z);
FT sq_distance = tree.squared_distance(query);
FT distance = std::sqrt(sq_distance);
m_distance_function[i][j] = Point_distance(query,distance);
m_max_distance_function = distance > m_max_distance_function ?
distance : m_max_distance_function;
}
} }
m_signed_distance_function = false;
compute_distance_function(m_edge_tree);
m_cut_plane = UNSIGNED_EDGES;
} }
void Scene::signed_distance_function() void Scene::signed_distance_function()
{ {
if(m_pPolyhedron == NULL) // Build tree if needed
if ( m_facet_tree.empty() )
{ {
std::cout << "Load polyhedron first." << std::endl; build_facet_tree();
return;
} }
compute_distance_function(m_facet_tree);
sign_distance_function(m_facet_tree);
CGAL::Timer timer; m_cut_plane = SIGNED_FACETS;
timer.start(); }
std::cout << "Construct AABB tree...";
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
tree.accelerate_distance_queries();
std::cout << "done (" << timer.time() << " s)" << std::endl;
m_max_distance_function = (FT)0.0;
Vector vec = random_vector();
const double dx = m_bbox.xmax() - m_bbox.xmin(); void Scene::cut_segment_plane()
const double dy = m_bbox.ymax() - m_bbox.ymin();
const double z = 0.5 * (m_bbox.zmax() + m_bbox.zmin());
int i,j;
for(i=0;i<100;i++)
{
FT x = m_bbox.xmin() + (FT)((double)i/100.0 * dx);
for(j=0;j<100;j++)
{
FT y = m_bbox.ymin() + (FT)((double)j/100.0 * dy);
Point query(x,y,z);
FT sq_distance = tree.squared_distance(query);
FT unsigned_distance = std::sqrt(sq_distance);
// get sign through ray casting (random vector)
Ray ray(query,vec);
unsigned int nbi = tree.number_of_intersected_primitives(ray);
FT sign = nbi%2 == 0 ? (FT)1.0 : (FT)-1.0;
FT signed_distance = sign * unsigned_distance;
m_distance_function[i][j] = Point_distance(query,signed_distance);
m_max_distance_function = unsigned_distance > m_max_distance_function ?
unsigned_distance : m_max_distance_function;
}
}
m_signed_distance_function = true;
}
void Scene::cutting_plane()
{ {
// Build tree if needed // Build tree if needed
if ( m_facet_tree.empty() ) if ( m_facet_tree.empty() )
{ {
build_facet_tree(); build_facet_tree();
} }
Plane plane = frame_plane(); Plane plane = frame_plane();
// Compute intersections // Compute intersections
std::vector<Object_and_primitive_id> intersections; typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
Intersections intersections;
m_facet_tree.all_intersections(plane, std::back_inserter(intersections)); m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
// Fill data structure // Fill data structure
m_cut_segments.clear(); m_cut_segments.clear();
for ( std::vector<Object_and_primitive_id>::iterator it = intersections.begin(), for ( Intersections::iterator it = intersections.begin(),
end = intersections.end() ; it != end ; ++it ) end = intersections.end() ; it != end ; ++it )
{ {
const Segment* inter_seg = CGAL::object_cast<Segment>(&(it->first)); const Segment* inter_seg = CGAL::object_cast<Segment>(&(it->first));
@ -829,8 +816,31 @@ void Scene::cutting_plane()
m_cut_segments.push_back(*inter_seg); m_cut_segments.push_back(*inter_seg);
} }
} }
m_cut_plane = CUT_SEGMENTS;
} }
void Scene::cutting_plane()
{
switch( m_cut_plane )
{
case UNSIGNED_FACETS:
return unsigned_distance_function();
case SIGNED_FACETS:
return signed_distance_function();
case UNSIGNED_EDGES:
return unsigned_distance_function_to_edges();
case CUT_SEGMENTS:
return cut_segment_plane();
case NONE: // do nothing
return;
}
// Should not be here
std::cerr << "Unknown cut_plane type" << std::endl;
CGAL_assertion(false);
}
void Scene::toggle_view_poyhedron() void Scene::toggle_view_poyhedron()
{ {
m_view_polyhedron = !m_view_polyhedron; m_view_polyhedron = !m_view_polyhedron;
@ -846,11 +856,6 @@ void Scene::toggle_view_points()
m_view_points = !m_view_points; m_view_points = !m_view_points;
} }
void Scene::toggle_view_distance_function()
{
m_view_distance_function = !m_view_distance_function;
}
void Scene::toggle_view_plane() void Scene::toggle_view_plane()
{ {
m_view_plane = !m_view_plane; m_view_plane = !m_view_plane;

View File

@ -27,13 +27,21 @@ public:
public: public:
// types // types
typedef CGAL::Bbox_3 Bbox; typedef CGAL::Bbox_3 Bbox;
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits; private:
typedef CGAL::AABB_tree<Traits> Facet_tree; typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Facet_Primitive;
typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id; typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits;
typedef Facet_tree::Primitive_id Primitive_id; typedef CGAL::AABB_tree<Facet_Traits> Facet_tree;
typedef CGAL::AABB_polyhedron_segment_primitive<Kernel,Polyhedron> Edge_Primitive;
typedef CGAL::AABB_traits<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_tree<Edge_Traits> Edge_tree;
typedef qglviewer::ManipulatedFrame ManipulatedFrame; typedef qglviewer::ManipulatedFrame ManipulatedFrame;
enum Cut_planes_types {
NONE, UNSIGNED_FACETS, SIGNED_FACETS, UNSIGNED_EDGES, CUT_SEGMENTS
};
public: public:
void draw(); void draw();
@ -54,17 +62,20 @@ private:
Color_ramp m_blue_ramp; Color_ramp m_blue_ramp;
Color_ramp m_thermal_ramp; Color_ramp m_thermal_ramp;
FT m_max_distance_function; FT m_max_distance_function;
bool m_view_distance_function;
bool m_signed_distance_function;
typedef std::pair<Point,FT> Point_distance; typedef std::pair<Point,FT> Point_distance;
Point_distance m_distance_function[100][100]; Point_distance m_distance_function[100][100];
// frame // frame
ManipulatedFrame* m_frame; ManipulatedFrame* m_frame;
bool m_view_plane; bool m_view_plane;
int m_grid_size;
bool m_fast_distance;
// An aabb_tree indexing polyhedron facets // An aabb_tree indexing polyhedron facets/segments
Facet_tree m_facet_tree; Facet_tree m_facet_tree;
Edge_tree m_edge_tree;
Cut_planes_types m_cut_plane;
private: private:
// utility functions // utility functions
@ -76,8 +87,18 @@ private:
Segment random_segment(const Bbox& bbox); Segment random_segment(const Bbox& bbox);
FT random_in(const double a,const double b); FT random_in(const double a,const double b);
Plane frame_plane() const; Plane frame_plane() const;
Aff_transformation frame_transformation() const;
FT bbox_diag() const;
void build_facet_tree(); void build_facet_tree();
void build_edge_tree();
void clear_internal_data(); void clear_internal_data();
void update_grid_size();
template <typename Tree>
void compute_distance_function(const Tree& tree);
template <typename Tree>
void sign_distance_function(const Tree& tree);
public: public:
// file menu // file menu
@ -86,8 +107,10 @@ public:
// edit menu // edit menu
void clear_points() { m_points.clear(); } void clear_points() { m_points.clear(); }
void clear_segments() { m_segments.clear(); } void clear_segments() { m_segments.clear(); }
void clear_distance_function() { m_max_distance_function = 0.0; }
void clear_cutting_plane(); void clear_cutting_plane();
// fast distance setter
void set_fast_distance(bool b) { m_fast_distance = b; update_grid_size(); }
// algorithms // algorithms
void generate_edge_points(const unsigned int nb_points); void generate_edge_points(const unsigned int nb_points);
@ -105,12 +128,12 @@ public:
void signed_distance_function(); void signed_distance_function();
void unsigned_distance_function(); void unsigned_distance_function();
void unsigned_distance_function_to_edges(); void unsigned_distance_function_to_edges();
void cut_segment_plane();
// 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();
void toggle_view_distance_function();
void toggle_view_plane(); void toggle_view_plane();
// view options // view options
@ -154,9 +177,9 @@ public:
void draw_points(); void draw_points();
void draw_segments(); void draw_segments();
void draw_polyhedron(); void draw_polyhedron();
void draw_signed_distance_function(); void draw_distance_function(const Color_ramp& ramp_pos,
void draw_unsigned_distance_function(); const Color_ramp& ramp_neg) const;
void draw_plane(); void draw_cut_segment_plane() const;
// cutting plane activation/deactivation // cutting plane activation/deactivation
void activate_cutting_plane(); void activate_cutting_plane();

View File

@ -1,9 +1,11 @@
#include "Viewer.h" #include "Viewer.h"
#include "Scene.h" #include "Scene.h"
#include <QMouseEvent>
Viewer::Viewer(QWidget* parent) Viewer::Viewer(QWidget* parent)
: QGLViewer(parent), : QGLViewer(parent),
m_pScene(NULL) m_pScene(NULL),
m_custom_mouse(false)
{ {
setBackgroundColor(::Qt::white); setBackgroundColor(::Qt::white);
} }
@ -28,3 +30,32 @@ void Viewer::initializeGL()
QGLViewer::initializeGL(); QGLViewer::initializeGL();
} }
void Viewer::mousePressEvent(QMouseEvent* e)
{
if ( e->modifiers() == Qt::ControlModifier )
{
m_pScene->set_fast_distance(true);
m_custom_mouse = true;
}
QGLViewer::mousePressEvent(e);
}
void Viewer::mouseReleaseEvent(QMouseEvent* e)
{
if ( m_custom_mouse )
{
m_pScene->set_fast_distance(false);
// Recompute distance function
QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->cutting_plane();
QApplication::restoreOverrideCursor();
m_custom_mouse = false;
}
QGLViewer::mouseReleaseEvent(e);
}

View File

@ -19,8 +19,13 @@ public:
void initializeGL(); void initializeGL();
void setScene(Scene* pScene); void setScene(Scene* pScene);
protected:
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
private: private:
Scene* m_pScene; Scene* m_pScene;
bool m_custom_mouse;
}; // end class Viewer }; // end class Viewer
#endif // VIEWER_H #endif // VIEWER_H

View File

@ -204,7 +204,7 @@ void Scene::bench_intersections_vs_nbt()
// calls ray queries // calls ray queries
CGAL::Timer timer; CGAL::Timer timer;
timer.start(); timer.start();
std::list<Object_and_primitive_id> intersections; std::list<Facet_tree::Object_and_primitive_id> intersections;
for(int i=0;i<nb_queries;i++) for(int i=0;i<nb_queries;i++)
tree.all_intersections(queries[i],std::back_inserter(intersections)); tree.all_intersections(queries[i],std::back_inserter(intersections));
double duration = timer.time(); double duration = timer.time();
@ -268,8 +268,8 @@ void Scene::bench_intersection(Facet_tree& tree,
CGAL::Timer timer; CGAL::Timer timer;
timer.start(); timer.start();
unsigned int nb = 0; unsigned int nb = 0;
std::list<Primitive_id> primitive_ids; std::list<Facet_tree::Primitive_id> primitive_ids;
std::list<Object_and_primitive_id> intersections; std::list<Facet_tree::Object_and_primitive_id> intersections;
while(timer.time() < duration) while(timer.time() < duration)
{ {
const Query& query = queries[nb % nb_queries]; // loop over vector const Query& query = queries[nb % nb_queries]; // loop over vector

View File

@ -13,6 +13,7 @@ typedef Kernel::Plane_3 Plane;
typedef Kernel::Vector_3 Vector; typedef Kernel::Vector_3 Vector;
typedef Kernel::Segment_3 Segment; typedef Kernel::Segment_3 Segment;
typedef Kernel::Triangle_3 Triangle; typedef Kernel::Triangle_3 Triangle;
typedef Kernel::Aff_transformation_3 Aff_transformation;
#include <CGAL/Polyhedron_3.h> #include <CGAL/Polyhedron_3.h>
typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef CGAL::Polyhedron_3<Kernel> Polyhedron;