+ Use LF(Unix) end-of-line character and set svn:eol-style property to native.

+ Code is the same
This commit is contained in:
Stéphane Tayeb 2010-05-19 07:36:24 +00:00
parent 38ae830e13
commit 6b1e3d3091
6 changed files with 1339 additions and 1348 deletions

9
.gitattributes vendored
View File

@ -1,25 +1,16 @@
* text=auto !eol * text=auto !eol
AABB_tree/demo/AABB_tree/AABB_demo.cpp -text
AABB_tree/demo/AABB_tree/AABB_demo.pdf -text svneol=unset#application/pdf AABB_tree/demo/AABB_tree/AABB_demo.pdf -text svneol=unset#application/pdf
AABB_tree/demo/AABB_tree/AABB_demo.ppt -text svneol=unset#application/vnd.ms-powerpoint AABB_tree/demo/AABB_tree/AABB_demo.ppt -text svneol=unset#application/vnd.ms-powerpoint
AABB_tree/demo/AABB_tree/AABB_demo.qrc -text AABB_tree/demo/AABB_tree/AABB_demo.qrc -text
AABB_tree/demo/AABB_tree/CMakeLists.txt -text AABB_tree/demo/AABB_tree/CMakeLists.txt -text
AABB_tree/demo/AABB_tree/MainWindow.cpp -text
AABB_tree/demo/AABB_tree/MainWindow.h -text
AABB_tree/demo/AABB_tree/MainWindow.ui -text AABB_tree/demo/AABB_tree/MainWindow.ui -text
AABB_tree/demo/AABB_tree/Scene.cpp -text
AABB_tree/demo/AABB_tree/Scene.h -text
AABB_tree/demo/AABB_tree/Viewer.cpp -text
AABB_tree/demo/AABB_tree/Viewer.h -text
AABB_tree/demo/AABB_tree/cleanup.bat eol=crlf AABB_tree/demo/AABB_tree/cleanup.bat eol=crlf
AABB_tree/demo/AABB_tree/data/hand.off -text svneol=unset#application/octet-stream AABB_tree/demo/AABB_tree/data/hand.off -text svneol=unset#application/octet-stream
AABB_tree/demo/AABB_tree/data/knot.off -text AABB_tree/demo/AABB_tree/data/knot.off -text
AABB_tree/demo/AABB_tree/data/part.off -text svneol=unset#application/octet-stream AABB_tree/demo/AABB_tree/data/part.off -text svneol=unset#application/octet-stream
AABB_tree/demo/AABB_tree/data/u.off -text svneol=unset#application/octet-stream AABB_tree/demo/AABB_tree/data/u.off -text svneol=unset#application/octet-stream
AABB_tree/demo/AABB_tree/render_edges.h -text
AABB_tree/demo/AABB_tree/resources/about.html -text AABB_tree/demo/AABB_tree/resources/about.html -text
AABB_tree/demo/AABB_tree/resources/cgal_logo.xpm -text AABB_tree/demo/AABB_tree/resources/cgal_logo.xpm -text
AABB_tree/demo/AABB_tree/types.h -text
AABB_tree/doc_tex/AABB_tree/PkgDescription.tex -text AABB_tree/doc_tex/AABB_tree/PkgDescription.tex -text
AABB_tree/doc_tex/AABB_tree/details.tex -text AABB_tree/doc_tex/AABB_tree/details.tex -text
AABB_tree/doc_tex/AABB_tree/examples.tex -text AABB_tree/doc_tex/AABB_tree/examples.tex -text

View File

@ -1,66 +1,66 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (France). // Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// All rights reserved. // All rights reserved.
// //
// This file is part of CGAL (www.cgal.org); you may redistribute it under // This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0. // the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL. // See the file LICENSE.QPL distributed with CGAL.
// //
// Licensees holding a valid commercial license may use this file in // Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software. // accordance with the commercial license agreement provided with the software.
// //
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL: $ // $URL: $
// $Id: $ // $Id: $
// //
// //
// Author(s) : Pierre Alliez, Camille Wormser // Author(s) : Pierre Alliez, Camille Wormser
// //
//****************************************************************************** //******************************************************************************
// File Description : demo of AABB tree on polyhedral edge and facet primitives // File Description : demo of AABB tree on polyhedral edge and facet primitives
// //
//****************************************************************************** //******************************************************************************
#include "MainWindow.h" #include "MainWindow.h"
#include <QApplication> #include <QApplication>
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
app.setOrganizationDomain("inria.fr"); app.setOrganizationDomain("inria.fr");
app.setOrganizationName("INRIA"); app.setOrganizationName("INRIA");
app.setApplicationName("AABB tree demo"); app.setApplicationName("AABB tree demo");
// Import resources from libCGALQt4. // Import resources from libCGALQt4.
// See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE // See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE
Q_INIT_RESOURCE(File); Q_INIT_RESOURCE(File);
Q_INIT_RESOURCE(Triangulation_2); Q_INIT_RESOURCE(Triangulation_2);
Q_INIT_RESOURCE(Input); Q_INIT_RESOURCE(Input);
Q_INIT_RESOURCE(CGAL); Q_INIT_RESOURCE(CGAL);
MainWindow mainWindow; MainWindow mainWindow;
mainWindow.show(); mainWindow.show();
QStringList args = app.arguments(); QStringList args = app.arguments();
args.removeAt(0); args.removeAt(0);
if(!args.empty() && args[0] == "--use-meta") if(!args.empty() && args[0] == "--use-meta")
{ {
mainWindow.setAddKeyFrameKeyboardModifiers(::Qt::MetaModifier); mainWindow.setAddKeyFrameKeyboardModifiers(::Qt::MetaModifier);
args.removeAt(0); args.removeAt(0);
} }
Q_FOREACH(QString filename, args) Q_FOREACH(QString filename, args)
mainWindow.open(filename); mainWindow.open(filename);
return app.exec(); return app.exec();
} }
# include "Scene.cpp" # include "Scene.cpp"
# include "Scene_moc.cpp" # include "Scene_moc.cpp"
# include "benchmarks.cpp" # include "benchmarks.cpp"
# include "Viewer.cpp" # include "Viewer.cpp"
# include "Viewer_moc.cpp" # include "Viewer_moc.cpp"
# include "MainWindow.cpp" # include "MainWindow.cpp"
# include "MainWindow_moc.cpp" # include "MainWindow_moc.cpp"

View File

@ -1,423 +1,423 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "Scene.h" #include "Scene.h"
#include <CGAL/Qt/debug.h> #include <CGAL/Qt/debug.h>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDropEvent> #include <QDropEvent>
#include <QTextStream> #include <QTextStream>
#include <QUrl> #include <QUrl>
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QHeaderView> #include <QHeaderView>
#include <QClipboard> #include <QClipboard>
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget* parent) MainWindow::MainWindow(QWidget* parent)
: CGAL::Qt::DemosMainWindow(parent) : CGAL::Qt::DemosMainWindow(parent)
{ {
ui = new Ui::MainWindow; ui = new Ui::MainWindow;
ui->setupUi(this); ui->setupUi(this);
// saves some pointers from ui, for latter use. // saves some pointers from ui, for latter use.
m_pViewer = ui->viewer; m_pViewer = ui->viewer;
// does not save the state of the viewer // does not save the state of the viewer
m_pViewer->setStateFileName(QString::null); m_pViewer->setStateFileName(QString::null);
// accepts drop events // accepts drop events
setAcceptDrops(true); setAcceptDrops(true);
// setups scene // setups scene
m_pScene = new Scene; m_pScene = new Scene;
m_pViewer->setScene(m_pScene); m_pViewer->setScene(m_pScene);
m_pViewer->setManipulatedFrame(m_pScene->manipulatedFrame()); m_pViewer->setManipulatedFrame(m_pScene->manipulatedFrame());
// connects actionQuit (Ctrl+Q) and qApp->quit() // connects actionQuit (Ctrl+Q) and qApp->quit()
connect(ui->actionQuit, SIGNAL(triggered()), connect(ui->actionQuit, SIGNAL(triggered()),
this, SLOT(quit())); this, SLOT(quit()));
this->addRecentFiles(ui->menuFile, ui->actionQuit); this->addRecentFiles(ui->menuFile, ui->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)), connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString))); this, SLOT(open(QString)));
readSettings(); readSettings();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
delete ui; delete ui;
} }
void MainWindow::dragEnterEvent(QDragEnterEvent *event) void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{ {
if (event->mimeData()->hasFormat("text/uri-list")) if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction(); event->acceptProposedAction();
} }
void MainWindow::dropEvent(QDropEvent *event) void MainWindow::dropEvent(QDropEvent *event)
{ {
Q_FOREACH(QUrl url, event->mimeData()->urls()) { Q_FOREACH(QUrl url, event->mimeData()->urls()) {
QString filename = url.toLocalFile(); QString filename = url.toLocalFile();
if(!filename.isEmpty()) { if(!filename.isEmpty()) {
QTextStream(stderr) << QString("dropEvent(\"%1\")\n").arg(filename); QTextStream(stderr) << QString("dropEvent(\"%1\")\n").arg(filename);
open(filename); open(filename);
} }
} }
event->acceptProposedAction(); event->acceptProposedAction();
} }
void MainWindow::updateViewerBBox() void MainWindow::updateViewerBBox()
{ {
m_pScene->update_bbox(); m_pScene->update_bbox();
const Scene::Bbox bbox = m_pScene->bbox(); const Scene::Bbox bbox = m_pScene->bbox();
const double xmin = bbox.xmin(); const double xmin = bbox.xmin();
const double ymin = bbox.ymin(); const double ymin = bbox.ymin();
const double zmin = bbox.zmin(); const double zmin = bbox.zmin();
const double xmax = bbox.xmax(); const double xmax = bbox.xmax();
const double ymax = bbox.ymax(); const double ymax = bbox.ymax();
const double zmax = bbox.zmax(); const double zmax = bbox.zmax();
qglviewer::Vec qglviewer::Vec
vec_min(xmin, ymin, zmin), vec_min(xmin, ymin, zmin),
vec_max(xmax, ymax, zmax); vec_max(xmax, ymax, zmax);
m_pViewer->setSceneBoundingBox(vec_min,vec_max); m_pViewer->setSceneBoundingBox(vec_min,vec_max);
m_pViewer->camera()->showEntireScene(); m_pViewer->camera()->showEntireScene();
} }
void MainWindow::open(QString filename) void MainWindow::open(QString filename)
{ {
QFileInfo fileinfo(filename); QFileInfo fileinfo(filename);
if(fileinfo.isFile() && fileinfo.isReadable()) if(fileinfo.isFile() && fileinfo.isReadable())
{ {
int index = m_pScene->open(filename); int index = m_pScene->open(filename);
if(index >= 0) if(index >= 0)
{ {
QSettings settings; QSettings settings;
settings.setValue("OFF open directory", settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath()); fileinfo.absoluteDir().absolutePath());
this->addToRecentFiles(filename); this->addToRecentFiles(filename);
// update bbox // update bbox
updateViewerBBox(); updateViewerBBox();
m_pViewer->update(); m_pViewer->update();
} }
} }
} }
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
this->readState("MainWindow", Size|State); this->readState("MainWindow", Size|State);
} }
void MainWindow::writeSettings() void MainWindow::writeSettings()
{ {
this->writeState("MainWindow"); this->writeState("MainWindow");
std::cerr << "Write setting... done.\n"; std::cerr << "Write setting... done.\n";
} }
void MainWindow::quit() void MainWindow::quit()
{ {
writeSettings(); writeSettings();
close(); close();
} }
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
writeSettings(); writeSettings();
event->accept(); event->accept();
} }
void MainWindow::on_actionLoadPolyhedron_triggered() void MainWindow::on_actionLoadPolyhedron_triggered()
{ {
QSettings settings; QSettings settings;
QString directory = settings.value("OFF open directory", QString directory = settings.value("OFF open directory",
QDir::current().dirName()).toString(); QDir::current().dirName()).toString();
QStringList filenames = QStringList filenames =
QFileDialog::getOpenFileNames(this, QFileDialog::getOpenFileNames(this,
tr("Load polyhedron..."), tr("Load polyhedron..."),
directory, directory,
tr("OFF files (*.off)\n" tr("OFF files (*.off)\n"
"All files (*)")); "All files (*)"));
if(!filenames.isEmpty()) { if(!filenames.isEmpty()) {
Q_FOREACH(QString filename, filenames) { Q_FOREACH(QString filename, filenames) {
open(filename); open(filename);
} }
} }
} }
void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m) void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m)
{ {
m_pViewer->setAddKeyFrameKeyboardModifiers(m); m_pViewer->setAddKeyFrameKeyboardModifiers(m);
} }
void MainWindow::on_actionInside_points_triggered() void MainWindow::on_actionInside_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = (unsigned)
QInputDialog::getInteger(NULL, "#Points", QInputDialog::getInteger(NULL, "#Points",
"#Points:",10000,1,100000000,9,&ok); "#Points:",10000,1,100000000,9,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->generate_inside_points(nb_points); m_pScene->generate_inside_points(nb_points);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionPoints_in_interval_triggered() void MainWindow::on_actionPoints_in_interval_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = (unsigned)
QInputDialog::getInteger(NULL, "#Points", QInputDialog::getInteger(NULL, "#Points",
"#Points:",10000,1,100000000,9,&ok); "#Points:",10000,1,100000000,9,&ok);
if(!ok) if(!ok)
return; return;
const double min = const double min =
QInputDialog::getDouble(NULL, "min", QInputDialog::getDouble(NULL, "min",
"Min:",-0.1,-1000.0,1000.0,9,&ok); "Min:",-0.1,-1000.0,1000.0,9,&ok);
if(!ok) if(!ok)
return; return;
const double max = const double max =
QInputDialog::getDouble(NULL, "max", QInputDialog::getDouble(NULL, "max",
"Max:",0.1,-1000.0,1000.0,9,&ok); "Max:",0.1,-1000.0,1000.0,9,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->generate_points_in(nb_points,min,max); m_pScene->generate_points_in(nb_points,min,max);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionBoundary_segments_triggered() void MainWindow::on_actionBoundary_segments_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_slices = (unsigned) const unsigned int nb_slices = (unsigned)
QInputDialog::getInteger(NULL, "#Slices", QInputDialog::getInteger(NULL, "#Slices",
"Slices:",100,1,1000000,8,&ok); "Slices:",100,1,1000000,8,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->generate_boundary_segments(nb_slices); m_pScene->generate_boundary_segments(nb_slices);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionBoundary_points_triggered() void MainWindow::on_actionBoundary_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = (unsigned)
QInputDialog::getInteger(NULL, "#Points", QInputDialog::getInteger(NULL, "#Points",
"Points:",1000,1,10000000,8,&ok); "Points:",1000,1,10000000,8,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->generate_boundary_points(nb_points); m_pScene->generate_boundary_points(nb_points);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionEdge_points_triggered() void MainWindow::on_actionEdge_points_triggered()
{ {
bool ok; bool ok;
const unsigned int nb_points = (unsigned) const unsigned int nb_points = (unsigned)
QInputDialog::getInteger(NULL, "#Points", QInputDialog::getInteger(NULL, "#Points",
"Points:",1000,1,10000000,8,&ok); "Points:",1000,1,10000000,8,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->generate_edge_points(nb_points); m_pScene->generate_edge_points(nb_points);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionBench_distances_triggered() void MainWindow::on_actionBench_distances_triggered()
{ {
bool ok; bool ok;
const double duration = QInputDialog::getDouble(NULL, "Duration", const double duration = QInputDialog::getDouble(NULL, "Duration",
"Duration (s):",1.0,0.01,1000,8,&ok); "Duration (s):",1.0,0.01,1000,8,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
std::cout << std::endl << "Benchmark distances" << std::endl; std::cout << std::endl << "Benchmark distances" << std::endl;
m_pScene->benchmark_distances(duration); m_pScene->benchmark_distances(duration);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionBench_intersections_triggered() void MainWindow::on_actionBench_intersections_triggered()
{ {
bool ok; bool ok;
const double duration = QInputDialog::getDouble(NULL, "Duration", const double duration = QInputDialog::getDouble(NULL, "Duration",
"Duration (s):",1.0,0.01,1000.0,8,&ok); "Duration (s):",1.0,0.01,1000.0,8,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
std::cout << std::endl << "Benchmark intersections" << std::endl; std::cout << std::endl << "Benchmark intersections" << std::endl;
m_pScene->benchmark_intersections(duration); m_pScene->benchmark_intersections(duration);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
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->activate_cutting_plane();
m_pScene->unsigned_distance_function(); m_pScene->unsigned_distance_function();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
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->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();
} }
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->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_actionIntersection_cutting_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->cut_segment_plane(); m_pScene->cut_segment_plane();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionCutting_plane_none_triggered() void MainWindow::on_actionCutting_plane_none_triggered()
{ {
m_pScene->clear_cutting_plane(); m_pScene->clear_cutting_plane();
m_pViewer->update(); 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();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionView_points_triggered() void MainWindow::on_actionView_points_triggered()
{ {
m_pScene->toggle_view_points(); m_pScene->toggle_view_points();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionView_segments_triggered() void MainWindow::on_actionView_segments_triggered()
{ {
m_pScene->toggle_view_segments(); m_pScene->toggle_view_segments();
m_pViewer->update(); 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();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionClear_points_triggered() void MainWindow::on_actionClear_points_triggered()
{ {
m_pScene->clear_points(); m_pScene->clear_points();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionClear_segments_triggered() void MainWindow::on_actionClear_segments_triggered()
{ {
m_pScene->clear_segments(); m_pScene->clear_segments();
m_pViewer->update(); 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();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionRefine_bisection_triggered() void MainWindow::on_actionRefine_bisection_triggered()
{ {
bool ok; bool ok;
const double max_len = const double max_len =
QInputDialog::getDouble(NULL, "Max edge len", QInputDialog::getDouble(NULL, "Max edge len",
"Max edge len:",0.1,0.001,100.0,9,&ok); "Max edge len:",0.1,0.001,100.0,9,&ok);
if(!ok) if(!ok)
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->refine_bisection(max_len * max_len); m_pScene->refine_bisection(max_len * max_len);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionBench_memory_triggered() void MainWindow::on_actionBench_memory_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->bench_memory(); m_pScene->bench_memory();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionBench_construction_triggered() void MainWindow::on_actionBench_construction_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->bench_construction(); m_pScene->bench_construction();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionBench_intersections_vs_nbt_triggered() void MainWindow::on_actionBench_intersections_vs_nbt_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->bench_intersections_vs_nbt(); m_pScene->bench_intersections_vs_nbt();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionBench_distances_vs_nbt_triggered() void MainWindow::on_actionBench_distances_vs_nbt_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->bench_distances_vs_nbt(); m_pScene->bench_distances_vs_nbt();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionRefine_loop_triggered() void MainWindow::on_actionRefine_loop_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pScene->refine_loop(); m_pScene->refine_loop();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
m_pViewer->update(); m_pViewer->update();
} }
void MainWindow::on_actionSave_snapshot_triggered() void MainWindow::on_actionSave_snapshot_triggered()
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_pViewer->saveSnapshot(QString("snapshot.png")); m_pViewer->saveSnapshot(QString("snapshot.png"));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void MainWindow::on_actionCopy_snapshot_triggered() void MainWindow::on_actionCopy_snapshot_triggered()
{ {
// copy snapshot to clipboard // copy snapshot to clipboard
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
QClipboard *qb = QApplication::clipboard(); QClipboard *qb = QApplication::clipboard();
m_pViewer->makeCurrent(); m_pViewer->makeCurrent();
m_pViewer->raise(); m_pViewer->raise();
QImage snapshot = m_pViewer->grabFrameBuffer(true); QImage snapshot = m_pViewer->grabFrameBuffer(true);
qb->setImage(snapshot); qb->setImage(snapshot);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,97 +1,97 @@
#ifndef SCENE_H #ifndef SCENE_H
#define SCENE_H #define SCENE_H
#include <QtOpenGL/qgl.h> #include <QtOpenGL/qgl.h>
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include <CGAL/AABB_intersections.h> #include <CGAL/AABB_intersections.h>
#include "types.h" #include "types.h"
#include "Color_ramp.h" #include "Color_ramp.h"
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
#include <CGAL/AABB_polyhedron_segment_primitive.h> #include <CGAL/AABB_polyhedron_segment_primitive.h>
#include <CGAL/AABB_polyhedron_triangle_primitive.h> #include <CGAL/AABB_polyhedron_triangle_primitive.h>
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QGLViewer/manipulatedFrame.h> #include <QGLViewer/manipulatedFrame.h>
#include <QGLViewer/qglviewer.h> #include <QGLViewer/qglviewer.h>
class Scene : public QObject class Scene : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Scene(); Scene();
virtual ~Scene(); virtual ~Scene();
public: public:
// types // types
typedef CGAL::Bbox_3 Bbox; typedef CGAL::Bbox_3 Bbox;
private: private:
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Facet_Primitive; typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Facet_Primitive;
typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits; typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits;
typedef CGAL::AABB_tree<Facet_Traits> Facet_tree; typedef CGAL::AABB_tree<Facet_Traits> Facet_tree;
typedef CGAL::AABB_polyhedron_segment_primitive<Kernel,Polyhedron> Edge_Primitive; typedef CGAL::AABB_polyhedron_segment_primitive<Kernel,Polyhedron> Edge_Primitive;
typedef CGAL::AABB_traits<Kernel, Edge_Primitive> Edge_Traits; typedef CGAL::AABB_traits<Kernel, Edge_Primitive> Edge_Traits;
typedef CGAL::AABB_tree<Edge_Traits> Edge_tree; typedef CGAL::AABB_tree<Edge_Traits> Edge_tree;
typedef qglviewer::ManipulatedFrame ManipulatedFrame; typedef qglviewer::ManipulatedFrame ManipulatedFrame;
enum Cut_planes_types { enum Cut_planes_types {
NONE, UNSIGNED_FACETS, SIGNED_FACETS, UNSIGNED_EDGES, CUT_SEGMENTS NONE, UNSIGNED_FACETS, SIGNED_FACETS, UNSIGNED_EDGES, CUT_SEGMENTS
}; };
public: public:
void draw(); void draw();
void update_bbox(); void update_bbox();
Bbox bbox() { return m_bbox; } Bbox bbox() { return m_bbox; }
ManipulatedFrame* manipulatedFrame() const { return m_frame; } ManipulatedFrame* manipulatedFrame() const { return m_frame; }
private: private:
// member data // member data
Bbox m_bbox; Bbox m_bbox;
Polyhedron *m_pPolyhedron; Polyhedron *m_pPolyhedron;
std::list<Point> m_points; std::list<Point> m_points;
std::list<Segment> m_segments; std::list<Segment> m_segments;
std::vector<Segment> m_cut_segments; std::vector<Segment> m_cut_segments;
// distance functions (simple 2D arrays) // distance functions (simple 2D arrays)
Color_ramp m_red_ramp; Color_ramp m_red_ramp;
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;
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; int m_grid_size;
bool m_fast_distance; bool m_fast_distance;
// An aabb_tree indexing polyhedron facets/segments // An aabb_tree indexing polyhedron facets/segments
Facet_tree m_facet_tree; Facet_tree m_facet_tree;
Edge_tree m_edge_tree; Edge_tree m_edge_tree;
Cut_planes_types m_cut_plane; Cut_planes_types m_cut_plane;
private: private:
// utility functions // utility functions
Vector random_vector(); Vector random_vector();
Ray random_ray(const Bbox& bbox); Ray random_ray(const Bbox& bbox);
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); FT random_in(const double a,const double b);
Plane frame_plane() const; Plane frame_plane() const;
Aff_transformation frame_transformation() const; Aff_transformation frame_transformation() const;
FT bbox_diag() const; FT bbox_diag() const;
void build_facet_tree(); void build_facet_tree();
void build_edge_tree(); void build_edge_tree();
void clear_internal_data(); void clear_internal_data();
void update_grid_size(); void update_grid_size();
template <typename Tree> template <typename Tree>
@ -99,96 +99,96 @@ private:
template <typename Tree> template <typename Tree>
void sign_distance_function(const Tree& tree); void sign_distance_function(const Tree& tree);
public: public:
// file menu // file menu
int open(QString filename); int open(QString filename);
// 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_cutting_plane(); void clear_cutting_plane();
// fast distance setter // fast distance setter
void set_fast_distance(bool b) { m_fast_distance = b; update_grid_size(); } 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);
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);
void generate_boundary_segments(const unsigned int nb_slices); void generate_boundary_segments(const unsigned int nb_slices);
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 // algorithms/refine
void refine_loop(); void refine_loop();
void refine_bisection(const FT max_sqlen); 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();
void unsigned_distance_function_to_edges(); void unsigned_distance_function_to_edges();
void cut_segment_plane(); 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_plane(); void toggle_view_plane();
// view options // view options
bool m_view_points; bool m_view_points;
bool m_view_segments; bool m_view_segments;
bool m_view_polyhedron; bool m_view_polyhedron;
// benchmarks // benchmarks
enum {DO_INTERSECT, enum {DO_INTERSECT,
ANY_INTERSECTION, ANY_INTERSECTION,
NB_INTERSECTIONS, NB_INTERSECTIONS,
ALL_INTERSECTIONS, ALL_INTERSECTIONS,
ANY_INTERSECTED_PRIMITIVE, ANY_INTERSECTED_PRIMITIVE,
ALL_INTERSECTED_PRIMITIVES}; ALL_INTERSECTED_PRIMITIVES};
void bench_memory(); void bench_memory();
void bench_construction(); void bench_construction();
void bench_distances_vs_nbt(); void bench_distances_vs_nbt();
void bench_intersections_vs_nbt(); void bench_intersections_vs_nbt();
void benchmark_intersections(const double duration); void benchmark_intersections(const double duration);
unsigned int nb_digits(const unsigned int value); unsigned int nb_digits(const unsigned int value);
template <class Query> template <class Query>
void bench_intersection(Facet_tree& tree,const int function,const double duration, void bench_intersection(Facet_tree& tree,const int function,const double duration,
const char *query_name, const std::vector<Query>& queries, const int nb_queries); const char *query_name, const std::vector<Query>& queries, const int nb_queries);
void bench_intersections(Facet_tree& tree, const double duration, const int function, void bench_intersections(Facet_tree& tree, const double duration, const int function,
const char *function_name, const std::vector<Ray>& rays, const char *function_name, const std::vector<Ray>& rays,
const std::vector<Line>& lines, const std::vector<Plane>& planes, const std::vector<Line>& lines, const std::vector<Plane>& planes,
const std::vector<Segment>& segments, const int nb_queries); const std::vector<Segment>& segments, const int nb_queries);
// distance benchmarks // distance benchmarks
enum {SQ_DISTANCE, enum {SQ_DISTANCE,
CLOSEST_POINT, CLOSEST_POINT,
CLOSEST_POINT_AND_PRIMITIVE_ID}; CLOSEST_POINT_AND_PRIMITIVE_ID};
void benchmark_distances(const double duration); void benchmark_distances(const double duration);
void bench_closest_point(Facet_tree& tree,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_squared_distance(Facet_tree& tree,const double duration);
void bench_closest_point_and_primitive(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); void bench_distance(Facet_tree& tree,const int function,const double duration);
// drawing // drawing
void draw_points(); void draw_points();
void draw_segments(); void draw_segments();
void draw_polyhedron(); void draw_polyhedron();
void draw_distance_function(const Color_ramp& ramp_pos, void draw_distance_function(const Color_ramp& ramp_pos,
const Color_ramp& ramp_neg) const; const Color_ramp& ramp_neg) const;
void draw_cut_segment_plane() const; void draw_cut_segment_plane() const;
// cutting plane activation/deactivation // cutting plane activation/deactivation
void activate_cutting_plane(); void activate_cutting_plane();
void deactivate_cutting_plane(); void deactivate_cutting_plane();
public slots: public slots:
// cutting plane // cutting plane
void cutting_plane(); void cutting_plane();
}; // end class Scene }; // end class Scene
#endif // SCENE_H #endif // SCENE_H

View File

@ -1,21 +1,21 @@
#ifndef AABB_DEMO_TYPES_H #ifndef AABB_DEMO_TYPES_H
#define AABB_DEMO_TYPES_H #define AABB_DEMO_TYPES_H
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel; // fastest in experiments typedef CGAL::Simple_cartesian<double> Kernel; // fastest in experiments
typedef Kernel::FT FT; typedef Kernel::FT FT;
typedef Kernel::Ray_3 Ray; typedef Kernel::Ray_3 Ray;
typedef Kernel::Line_3 Line; typedef Kernel::Line_3 Line;
typedef Kernel::Point_3 Point; typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane; 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; 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;
#endif // AABB_DEMO_TYPES_H #endif // AABB_DEMO_TYPES_H