From 349d976629ee63141f9ecdfc7da4bd9b13f20c02 Mon Sep 17 00:00:00 2001 From: Pierre Alliez Date: Fri, 31 Jul 2009 12:37:20 +0000 Subject: [PATCH] PCA demo: skeleton in place. --- .gitattributes | 4 + .../CMakeLists.txt | 95 +++++++ .../MainWindow.cpp | 184 ++++++++++++++ .../Principal_component_analysis/MainWindow.h | 61 +++++ .../MainWindow.ui | 240 ++++++++++++++++++ .../Principal_component_analysis/PCA_demo.cpp | 64 +++++ .../Principal_component_analysis/PCA_demo.qrc | 8 + .../Principal_component_analysis/Scene.cpp | 126 +++++++++ .../demo/Principal_component_analysis/Scene.h | 50 ++++ .../Principal_component_analysis/Viewer.cpp | 30 +++ .../Principal_component_analysis/Viewer.h | 26 ++ .../Principal_component_analysis/cleanup.bat | 1 + .../render_edges.h | 30 +++ .../resources/about.html | 17 ++ .../resources/cgal_logo.xpm | 24 ++ .../demo/Principal_component_analysis/types.h | 20 ++ 16 files changed, 980 insertions(+) create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/MainWindow.h create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/MainWindow.ui create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.qrc create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/Scene.h create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/Viewer.cpp create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/Viewer.h create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/cleanup.bat create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/render_edges.h create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/resources/about.html create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/resources/cgal_logo.xpm create mode 100644 Principal_component_analysis/demo/Principal_component_analysis/types.h diff --git a/.gitattributes b/.gitattributes index a965dd7a89e..d31c473deb5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2976,6 +2976,9 @@ Polytope_distance_d/test/Polytope_distance_d/test_PD_data/two_numbers.data -text Polytope_distance_d/test/Polytope_distance_d/test_PD_data/two_squares.data -text Polytope_distance_d/test/Polytope_distance_d/wilms_bug.cpp -text Polytope_distance_d/test/Polytope_distance_d/zwick_bug.cpp -text +Principal_component_analysis/demo/Principal_component_analysis/MainWindow.ui -text +Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.qrc -text +Principal_component_analysis/demo/Principal_component_analysis/cleanup.bat eol=crlf Principal_component_analysis/demo/Principal_component_analysis/data/cylinder_iso1_locally_refined.off -text Principal_component_analysis/demo/Principal_component_analysis/data/cylinder_iso2.off -text Principal_component_analysis/demo/Principal_component_analysis/data/ellipsoid.off -text @@ -2983,6 +2986,7 @@ Principal_component_analysis/demo/Principal_component_analysis/data/mushroom-19v Principal_component_analysis/demo/Principal_component_analysis/data/mushroom-651v.off -text Principal_component_analysis/demo/Principal_component_analysis/data/mushroom-81v.off -text Principal_component_analysis/demo/Principal_component_analysis/data/mushroom.off -text +Principal_component_analysis/demo/Principal_component_analysis/resources/about.html svneol=native#text/html Principal_component_analysis/doc_tex/Principal_component_analysis/examples.tex -text Principal_component_analysis/doc_tex/Principal_component_analysis/fit.eps -text svneol=unset#application/postscript Principal_component_analysis/doc_tex/Principal_component_analysis/fit.jpg -text diff --git a/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt new file mode 100644 index 00000000000..360b2bf4095 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/CMakeLists.txt @@ -0,0 +1,95 @@ +# This is the CMake script for compiling the PCA demo. + +project( PCA_demo ) + +cmake_minimum_required(VERSION 2.4.5) + +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) +endif(COMMAND cmake_policy) + +foreach(INCDIR ../../include ../../../STL_Extension/include ../../../GraphicsView/include ../../../filtered_kernel/include ) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}") + include_directories (BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}") + endif() +endforeach() + +include_directories( ./ ) + +# Find CGAL and CGAL Qt4 +find_package(CGAL COMPONENTS Qt4) +include( ${CGAL_USE_FILE} ) + +# Find Qt4 itself +set( QT_USE_QTXML TRUE ) +set( QT_USE_QTMAIN TRUE ) +set( QT_USE_QTSCRIPT TRUE ) +set( QT_USE_QTOPENGL TRUE ) +find_package(Qt4) + +# Find OpenGL +find_package(OpenGL) + +# Find QGLViewer +if(QT4_FOUND) + include(${QT_USE_FILE}) + find_package(QGLViewer ) +endif(QT4_FOUND) + +if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) + + include_directories ( ${QGLVIEWER_INCLUDE_DIR} ) + + qt4_wrap_ui( UI_FILES MainWindow.ui ) + + include(AddFileDependencies) + + qt4_generate_moc( "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h" MainWindow_moc.cpp ) + add_file_dependencies( MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h" ) + + qt4_generate_moc( "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" Viewer_moc.cpp ) + add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" ) + + qt4_add_resources ( RESOURCE_FILES PCA_demo.qrc ) + + add_file_dependencies( PCA_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" + "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" ) + add_executable ( PCA_demo PCA_demo.cpp ${UI_FILES} ${RESOURCE_FILES} ) + + # Link with Qt libraries + target_link_libraries( PCA_demo ${QT_LIBRARIES} ) + + # Link with CGAL + target_link_libraries( PCA_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ) + + # Link with libQGLViewer, OpenGL + target_link_libraries( PCA_demo ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) + + add_to_cached_list( CGAL_EXECUTABLE_TARGETS PCA_demo ) + + +else (CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) + + set(PCA_MISSING_DEPS "") + + if(NOT CGAL_Qt4_FOUND) + set(PCA_MISSING_DEPS "the CGAL Qt4 library, ${PCA_MISSING_DEPS}") + endif() + + if(NOT QT4_FOUND) + set(PCA_MISSING_DEPS "Qt4, ${PCA_MISSING_DEPS}") + endif() + + if(NOT OPENGL_FOUND) + set(PCA_MISSING_DEPS "OpenGL, ${PCA_MISSING_DEPS}") + endif() + + if(NOT QGLVIEWER_FOUND) + set(PCA_MISSING_DEPS "QGLViewer, ${PCA_MISSING_DEPS}") + endif() + + message(STATUS "NOTICE: This demo requires ${PCA_MISSING_DEPS} and will not be compiled.") + +endif (CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) diff --git a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp new file mode 100644 index 00000000000..8db82a969d7 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.cpp @@ -0,0 +1,184 @@ +#include "MainWindow.h" +#include "Scene.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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); + + // 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::on_actionView_polyhedron_triggered() +{ + m_pScene->toggle_view_poyhedron(); + m_pViewer->update(); +} + +void MainWindow::on_actionRefine_loop_triggered() +{ + QApplication::setOverrideCursor(Qt::WaitCursor); + m_pScene->refine_loop(); + QApplication::restoreOverrideCursor(); + m_pViewer->update(); +} + + +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_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(); +} diff --git a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.h b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.h new file mode 100644 index 00000000000..3aa2c9f65f0 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.h @@ -0,0 +1,61 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +class QDragEnterEvent; +class QDropEvent; +class Scene; +class Viewer; +namespace Ui { + class MainWindow; +} + + +class MainWindow : + public CGAL::Qt::DemosMainWindow +{ + Q_OBJECT +public: + MainWindow(QWidget* parent = 0); + ~MainWindow(); + + public slots: + void updateViewerBBox(); + void open(QString filename); + void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers); + + protected slots: + + // settings + void quit(); + void readSettings(); + void writeSettings(); + + // drag & drop + void dropEvent(QDropEvent *event); + void closeEvent(QCloseEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + // file menu + void on_actionLoadPolyhedron_triggered(); + + // edit menu + void on_actionSave_snapshot_triggered(); + void on_actionCopy_snapshot_triggered(); + + // algorithm menu + void on_actionRefine_loop_triggered(); + + + // view menu + void on_actionView_polyhedron_triggered(); + +private: + Scene* m_pScene; + Viewer* m_pViewer; + Ui::MainWindow* ui; +}; + +#endif // ifndef MAINWINDOW_H diff --git a/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.ui b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.ui new file mode 100644 index 00000000000..70403d46573 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/MainWindow.ui @@ -0,0 +1,240 @@ + + MainWindow + + + + 0 + 0 + 638 + 495 + + + + CGAL - PCA tree demo + + + + :/cgal/icons/resources/cgal_logo.xpm:/cgal/icons/resources/cgal_logo.xpm + + + + + + + + + + + + + + + + + + + 0 + 0 + 638 + 24 + + + + + &File + + + + + + + + &View + + + + + + Algorithms + + + + Refine + + + + + + + + + Edit + + + + + + + + + + + + + &Quit + + + Ctrl+Q + + + + + Load polyhedron... + + + + + Inside points... + + + + + Distances + + + + + Unsigned distance function to facets + + + + + Unsigned distance function to edges + + + + + Signed distance function to facets + + + + + Polyhedron + + + P + + + + + Points + + + + + Clear points + + + + + Boundary segments... + + + + + Boundary points... + + + + + Clear segments + + + + + Segments + + + + + Edge points... + + + + + Intersections + + + + + Distance function + + + + + Clear distance function + + + + + Longest edge bisection + + + + + Loop subdivision + + + + + Memory + + + + + Construction + + + + + Intersections + + + + + Distances + + + + + Points in interval... + + + + + Save snapshot + + + + + Copy snapshot + + + + + Loop subdivision + + + + + + Viewer + QWidget +
Viewer.h
+
+
+ + + + +
diff --git a/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp new file mode 100644 index 00000000000..131f9c297a2 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.cpp @@ -0,0 +1,64 @@ +// 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 +// +//****************************************************************************** +// File Description : demo of PCA component on polyhedron surface primitives +// +//****************************************************************************** + +#include "MainWindow.h" +#include + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + app.setOrganizationDomain("inria.fr"); + app.setOrganizationName("INRIA"); + app.setApplicationName("PCA 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 "Viewer.cpp" +# include "Viewer_moc.cpp" +# include "MainWindow.cpp" +# include "MainWindow_moc.cpp" + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.qrc b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.qrc new file mode 100644 index 00000000000..a4370b8273f --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/PCA_demo.qrc @@ -0,0 +1,8 @@ + + + resources/cgal_logo.xpm + + + resources/about.html + + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp b/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp new file mode 100644 index 00000000000..3e62c9af964 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/Scene.cpp @@ -0,0 +1,126 @@ +#include "Scene.h" + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "render_edges.h" + +Scene::Scene() +{ + m_pPolyhedron = NULL; + + // view options + m_view_polyhedron = true; +} + +Scene::~Scene() +{ + delete m_pPolyhedron; +} + +int Scene::open(QString filename) +{ + QTextStream cerr(stderr); + cerr << QString("Opening file \"%1\"\n").arg(filename); + QApplication::setOverrideCursor(QCursor(::Qt::WaitCursor)); + + QFileInfo fileinfo(filename); + std::ifstream in(filename.toUtf8()); + + if(!in || !fileinfo.isFile() || ! fileinfo.isReadable()) + { + std::cerr << "unable to open file" << std::endl; + QApplication::restoreOverrideCursor(); + return -1; + } + + if(m_pPolyhedron != NULL) + delete m_pPolyhedron; + + // allocate new polyhedron + m_pPolyhedron = new Polyhedron; + in >> *m_pPolyhedron; + if(!in) + { + std::cerr << "invalid OFF file" << std::endl; + QApplication::restoreOverrideCursor(); + + delete m_pPolyhedron; + m_pPolyhedron = NULL; + + return -1; + } + + QApplication::restoreOverrideCursor(); + return 0; +} + +void Scene::update_bbox() +{ + std::cout << "Compute bbox..."; + m_bbox = Bbox(); + + if(m_pPolyhedron == NULL) + { + std::cout << "failed (no polyhedron)." << std::endl; + return; + } + + if(m_pPolyhedron->empty()) + { + std::cout << "failed (empty polyhedron)." << std::endl; + return; + } + + Polyhedron::Point_iterator it = m_pPolyhedron->points_begin(); + m_bbox = (*it).bbox(); + for(; it != m_pPolyhedron->points_end();it++) + m_bbox = m_bbox + (*it).bbox(); + std::cout << "done (" << m_pPolyhedron->size_of_facets() + << " facets)" << std::endl; +} + +void Scene::draw() +{ + if(m_view_polyhedron) + draw_polyhedron(); +} + +void Scene::draw_polyhedron() +{ + // draw black edges + if(m_pPolyhedron != NULL) + { + ::glDisable(GL_LIGHTING); + ::glColor3ub(0,0,0); + ::glLineWidth(1.0f); + gl_render_edges(*m_pPolyhedron); + } +} + +void Scene::refine_loop() +{ + if(m_pPolyhedron == NULL) + { + std::cout << "Load polyhedron first." << std::endl; + return; + } + std::cout << "Loop subdivision..."; + CGAL::Subdivision_method_3::Loop_subdivision(*m_pPolyhedron, 1); + std::cout << "done (" << m_pPolyhedron->size_of_facets() << " facets)" << std::endl; +} + +void Scene::toggle_view_poyhedron() +{ + m_view_polyhedron = !m_view_polyhedron; +} + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/Scene.h b/Principal_component_analysis/demo/Principal_component_analysis/Scene.h new file mode 100644 index 00000000000..244bd896f25 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/Scene.h @@ -0,0 +1,50 @@ +#ifndef SCENE_H +#define SCENE_H + +#include +#include +#include + +#include "types.h" + + +class Scene +{ +public: + Scene(); + ~Scene(); +public: + // types + typedef CGAL::Bbox_3 Bbox; + +public: + void draw(); + void update_bbox(); + Bbox bbox() { return m_bbox; } + +private: + // member data + Bbox m_bbox; + Polyhedron *m_pPolyhedron; + +private: + +public: + // file menu + int open(QString filename); + + // toggle view options + void toggle_view_poyhedron(); + + // view options + bool m_view_polyhedron; + + // refinement + void refine_loop(); + + // drawing + void draw_polyhedron(); +}; // end class Scene + + +#endif // SCENE_H diff --git a/Principal_component_analysis/demo/Principal_component_analysis/Viewer.cpp b/Principal_component_analysis/demo/Principal_component_analysis/Viewer.cpp new file mode 100644 index 00000000000..ede6ff45682 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/Viewer.cpp @@ -0,0 +1,30 @@ +#include "Viewer.h" +#include "Scene.h" + +Viewer::Viewer(QWidget* parent) + : QGLViewer(parent), + m_pScene(NULL) +{ + setBackgroundColor(::Qt::white); +} + +void Viewer::setScene(Scene* pScene) +{ + this->m_pScene = pScene; +} + +void Viewer::draw() +{ + QGLViewer::draw(); + if(m_pScene != NULL) + { + ::glClearColor(1.0f,1.0f,1.0f,0.0f); + m_pScene->draw(); + } +} + +void Viewer::initializeGL() +{ + QGLViewer::initializeGL(); +} + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/Viewer.h b/Principal_component_analysis/demo/Principal_component_analysis/Viewer.h new file mode 100644 index 00000000000..69800d79588 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/Viewer.h @@ -0,0 +1,26 @@ +#ifndef VIEWER_H +#define VIEWER_H + +#include + +// forward declarations +class QWidget; +class Scene; + +class Viewer : public QGLViewer { + + Q_OBJECT + +public: + Viewer(QWidget * parent); + + // overload several QGLViewer virtual functions + void draw(); + void initializeGL(); + void setScene(Scene* pScene); + +private: + Scene* m_pScene; +}; // end class Viewer + +#endif // VIEWER_H diff --git a/Principal_component_analysis/demo/Principal_component_analysis/cleanup.bat b/Principal_component_analysis/demo/Principal_component_analysis/cleanup.bat new file mode 100644 index 00000000000..61efa756007 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/cleanup.bat @@ -0,0 +1 @@ +del *.vcproj* *.user *.cmake ZERO* *.ncb *.sln AABB_demo.suo CMakeCache.txt *_moc.* qrc* ui_*.h /Q \ No newline at end of file diff --git a/Principal_component_analysis/demo/Principal_component_analysis/render_edges.h b/Principal_component_analysis/demo/Principal_component_analysis/render_edges.h new file mode 100644 index 00000000000..899232d79d3 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/render_edges.h @@ -0,0 +1,30 @@ +#ifndef _GL_RENDER_EDGES_ +#define _GL_RENDER_EDGES_ + +#include + +template +void gl_render_edges(Polyhedron& polyhedron) +{ + typedef typename Polyhedron::Traits Kernel; + typedef typename Kernel::Point_3 Point; + + ::glBegin(GL_LINES); + typename Polyhedron::Edge_iterator he; + for(he = polyhedron.edges_begin(); + he != polyhedron.edges_end(); + he++) + { + const Point& a = he->vertex()->point(); + const Point& b = he->opposite()->vertex()->point(); + ::glVertex3d(a.x(),a.y(),a.z()); + ::glVertex3d(b.x(),b.y(),b.z()); + } + ::glEnd(); +} + +#endif // _GL_RENDER_EDGES_ + + + + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/resources/about.html b/Principal_component_analysis/demo/Principal_component_analysis/resources/about.html new file mode 100644 index 00000000000..7e4e51c5c91 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/resources/about.html @@ -0,0 +1,17 @@ + + +

AABB Tree Demo

+

Copyright ©2009 + INRIA Sophia Antipolis - Mediterranee

+

This application illustrates the AABB tree component + of CGAL, applied to polyhedron + facets and edges.

+

See also the following chapters of the manual: +

+

+ + diff --git a/Principal_component_analysis/demo/Principal_component_analysis/resources/cgal_logo.xpm b/Principal_component_analysis/demo/Principal_component_analysis/resources/cgal_logo.xpm new file mode 100644 index 00000000000..6a69b3d67e1 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/resources/cgal_logo.xpm @@ -0,0 +1,24 @@ +/* XPM */ +const char * demoicon_xpm[] = { +/* columns rows colors chars-per-pixel */ +"16 16 3 1", +" c None", +". c #FFFF00", +"+ c #000000", +/* pixels */ +"................", +"...++++...++++..", +"..+....+.+....+.", +"..+......+......", +"..+......+..+++.", +"..+......+....+.", +"..+....+.+....+.", +"...++++...++++..", +"................", +"...++++...+.....", +"..+....+..+.....", +"..+....+..+.....", +"..++++++..+.....", +"..+....+..+.....", +"..+....+..+++++.", +"................"}; diff --git a/Principal_component_analysis/demo/Principal_component_analysis/types.h b/Principal_component_analysis/demo/Principal_component_analysis/types.h new file mode 100644 index 00000000000..b5ab00920f1 --- /dev/null +++ b/Principal_component_analysis/demo/Principal_component_analysis/types.h @@ -0,0 +1,20 @@ +#ifndef PCA_DEMO_TYPES_H +#define PCA_DEMO_TYPES_H + +#include + +typedef CGAL::Simple_cartesian 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; + +#include +typedef CGAL::Polyhedron_3 Polyhedron; + +#endif // PCA_DEMO_TYPES_H