+ 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
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.ppt -text svneol=unset#application/vnd.ms-powerpoint
AABB_tree/demo/AABB_tree/AABB_demo.qrc -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/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/data/hand.off -text svneol=unset#application/octet-stream
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/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/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/details.tex -text
AABB_tree/doc_tex/AABB_tree/examples.tex -text

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,97 +1,97 @@
#ifndef SCENE_H
#define SCENE_H
#include <QtOpenGL/qgl.h>
#include <iostream>
#include <cmath>
#include <CGAL/AABB_intersections.h>
#include "types.h"
#include "Color_ramp.h"
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_polyhedron_segment_primitive.h>
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
#include <QtCore/qglobal.h>
#include <QGLViewer/manipulatedFrame.h>
#include <QGLViewer/qglviewer.h>
class Scene : public QObject
{
Q_OBJECT
public:
Scene();
virtual ~Scene();
public:
// types
typedef CGAL::Bbox_3 Bbox;
#ifndef SCENE_H
#define SCENE_H
#include <QtOpenGL/qgl.h>
#include <iostream>
#include <cmath>
#include <CGAL/AABB_intersections.h>
#include "types.h"
#include "Color_ramp.h"
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_polyhedron_segment_primitive.h>
#include <CGAL/AABB_polyhedron_triangle_primitive.h>
#include <QtCore/qglobal.h>
#include <QGLViewer/manipulatedFrame.h>
#include <QGLViewer/qglviewer.h>
class Scene : public QObject
{
Q_OBJECT
public:
Scene();
virtual ~Scene();
public:
// types
typedef CGAL::Bbox_3 Bbox;
private:
typedef CGAL::AABB_polyhedron_triangle_primitive<Kernel,Polyhedron> Facet_Primitive;
typedef CGAL::AABB_traits<Kernel, Facet_Primitive> Facet_Traits;
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:
void draw();
void update_bbox();
Bbox bbox() { return m_bbox; }
ManipulatedFrame* manipulatedFrame() const { return m_frame; }
private:
// member data
Bbox m_bbox;
Polyhedron *m_pPolyhedron;
std::list<Point> m_points;
std::list<Segment> m_segments;
std::vector<Segment> m_cut_segments;
// distance functions (simple 2D arrays)
Color_ramp m_red_ramp;
Color_ramp m_blue_ramp;
Color_ramp m_thermal_ramp;
FT m_max_distance_function;
typedef std::pair<Point,FT> Point_distance;
Point_distance m_distance_function[100][100];
// frame
ManipulatedFrame* m_frame;
bool m_view_plane;
public:
void draw();
void update_bbox();
Bbox bbox() { return m_bbox; }
ManipulatedFrame* manipulatedFrame() const { return m_frame; }
private:
// member data
Bbox m_bbox;
Polyhedron *m_pPolyhedron;
std::list<Point> m_points;
std::list<Segment> m_segments;
std::vector<Segment> m_cut_segments;
// distance functions (simple 2D arrays)
Color_ramp m_red_ramp;
Color_ramp m_blue_ramp;
Color_ramp m_thermal_ramp;
FT m_max_distance_function;
typedef std::pair<Point,FT> Point_distance;
Point_distance m_distance_function[100][100];
// frame
ManipulatedFrame* m_frame;
bool m_view_plane;
int m_grid_size;
bool m_fast_distance;
// 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:
// utility functions
Vector random_vector();
Ray random_ray(const Bbox& bbox);
Line random_line(const Bbox& bbox);
Point random_point(const Bbox& bbox);
Plane random_plane(const Bbox& bbox);
Segment random_segment(const Bbox& bbox);
FT random_in(const double a,const double b);
Plane frame_plane() const;
private:
// utility functions
Vector random_vector();
Ray random_ray(const Bbox& bbox);
Line random_line(const Bbox& bbox);
Point random_point(const Bbox& bbox);
Plane random_plane(const Bbox& bbox);
Segment random_segment(const Bbox& bbox);
FT random_in(const double a,const double b);
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>
@ -99,96 +99,96 @@ private:
template <typename Tree>
void sign_distance_function(const Tree& tree);
public:
// file menu
int open(QString filename);
// edit menu
void clear_points() { m_points.clear(); }
void clear_segments() { m_segments.clear(); }
void clear_cutting_plane();
public:
// file menu
int open(QString filename);
// edit menu
void clear_points() { m_points.clear(); }
void clear_segments() { m_segments.clear(); }
void clear_cutting_plane();
// fast distance setter
void set_fast_distance(bool b) { m_fast_distance = b; update_grid_size(); }
// algorithms
void generate_edge_points(const unsigned int nb_points);
void generate_inside_points(const unsigned int nb_points);
void generate_boundary_points(const unsigned int nb_points);
void generate_boundary_segments(const unsigned int nb_slices);
void generate_points_in(const unsigned int nb_points,
const double min, const double max);
// algorithms/refine
void refine_loop();
void refine_bisection(const FT max_sqlen);
// distance functions
void signed_distance_function();
void unsigned_distance_function();
void unsigned_distance_function_to_edges();
// algorithms
void generate_edge_points(const unsigned int nb_points);
void generate_inside_points(const unsigned int nb_points);
void generate_boundary_points(const unsigned int nb_points);
void generate_boundary_segments(const unsigned int nb_slices);
void generate_points_in(const unsigned int nb_points,
const double min, const double max);
// algorithms/refine
void refine_loop();
void refine_bisection(const FT max_sqlen);
// distance functions
void signed_distance_function();
void unsigned_distance_function();
void unsigned_distance_function_to_edges();
void cut_segment_plane();
// toggle view options
void toggle_view_points();
void toggle_view_segments();
void toggle_view_poyhedron();
void toggle_view_plane();
// view options
bool m_view_points;
bool m_view_segments;
bool m_view_polyhedron;
// benchmarks
enum {DO_INTERSECT,
ANY_INTERSECTION,
NB_INTERSECTIONS,
ALL_INTERSECTIONS,
ANY_INTERSECTED_PRIMITIVE,
ALL_INTERSECTED_PRIMITIVES};
void bench_memory();
void bench_construction();
void bench_distances_vs_nbt();
void bench_intersections_vs_nbt();
void benchmark_intersections(const double duration);
unsigned int nb_digits(const unsigned int value);
template <class Query>
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);
void bench_intersections(Facet_tree& tree, const double duration, const int function,
const char *function_name, const std::vector<Ray>& rays,
const std::vector<Line>& lines, const std::vector<Plane>& planes,
const std::vector<Segment>& segments, const int nb_queries);
// distance benchmarks
enum {SQ_DISTANCE,
CLOSEST_POINT,
CLOSEST_POINT_AND_PRIMITIVE_ID};
void benchmark_distances(const double duration);
void bench_closest_point(Facet_tree& tree,const double duration);
void bench_squared_distance(Facet_tree& tree,const double duration);
void bench_closest_point_and_primitive(Facet_tree& tree,const double duration);
void bench_distance(Facet_tree& tree,const int function,const double duration);
// drawing
void draw_points();
void draw_segments();
void draw_polyhedron();
// toggle view options
void toggle_view_points();
void toggle_view_segments();
void toggle_view_poyhedron();
void toggle_view_plane();
// view options
bool m_view_points;
bool m_view_segments;
bool m_view_polyhedron;
// benchmarks
enum {DO_INTERSECT,
ANY_INTERSECTION,
NB_INTERSECTIONS,
ALL_INTERSECTIONS,
ANY_INTERSECTED_PRIMITIVE,
ALL_INTERSECTED_PRIMITIVES};
void bench_memory();
void bench_construction();
void bench_distances_vs_nbt();
void bench_intersections_vs_nbt();
void benchmark_intersections(const double duration);
unsigned int nb_digits(const unsigned int value);
template <class Query>
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);
void bench_intersections(Facet_tree& tree, const double duration, const int function,
const char *function_name, const std::vector<Ray>& rays,
const std::vector<Line>& lines, const std::vector<Plane>& planes,
const std::vector<Segment>& segments, const int nb_queries);
// distance benchmarks
enum {SQ_DISTANCE,
CLOSEST_POINT,
CLOSEST_POINT_AND_PRIMITIVE_ID};
void benchmark_distances(const double duration);
void bench_closest_point(Facet_tree& tree,const double duration);
void bench_squared_distance(Facet_tree& tree,const double duration);
void bench_closest_point_and_primitive(Facet_tree& tree,const double duration);
void bench_distance(Facet_tree& tree,const int function,const double duration);
// drawing
void draw_points();
void draw_segments();
void draw_polyhedron();
void draw_distance_function(const Color_ramp& ramp_pos,
const Color_ramp& ramp_neg) const;
void draw_cut_segment_plane() const;
// cutting plane activation/deactivation
void activate_cutting_plane();
void deactivate_cutting_plane();
public slots:
// cutting plane
void cutting_plane();
}; // end class Scene
#endif // SCENE_H
// cutting plane activation/deactivation
void activate_cutting_plane();
void deactivate_cutting_plane();
public slots:
// cutting plane
void cutting_plane();
}; // end class Scene
#endif // SCENE_H

View File

@ -1,21 +1,21 @@
#ifndef AABB_DEMO_TYPES_H
#define AABB_DEMO_TYPES_H
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel; // fastest in experiments
typedef Kernel::FT FT;
typedef Kernel::Ray_3 Ray;
typedef Kernel::Line_3 Line;
typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane;
typedef Kernel::Vector_3 Vector;
typedef Kernel::Segment_3 Segment;
typedef Kernel::Triangle_3 Triangle;
typedef Kernel::Aff_transformation_3 Aff_transformation;
#include <CGAL/Polyhedron_3.h>
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
#endif // AABB_DEMO_TYPES_H
#ifndef AABB_DEMO_TYPES_H
#define AABB_DEMO_TYPES_H
#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel; // fastest in experiments
typedef Kernel::FT FT;
typedef Kernel::Ray_3 Ray;
typedef Kernel::Line_3 Line;
typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane;
typedef Kernel::Vector_3 Vector;
typedef Kernel::Segment_3 Segment;
typedef Kernel::Triangle_3 Triangle;
typedef Kernel::Aff_transformation_3 Aff_transformation;
#include <CGAL/Polyhedron_3.h>
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
#endif // AABB_DEMO_TYPES_H