aabb tree: initial qt-based demo

This commit is contained in:
Pierre Alliez 2009-06-27 20:33:46 +00:00
parent 8f3cbf217e
commit 360f2a73d7
21 changed files with 8157 additions and 0 deletions

20
.gitattributes vendored
View File

@ -1,4 +1,24 @@
* text=auto !eol
AABB_tree/demo/AABB_demo.cpp -text
AABB_tree/demo/AABB_demo.qrc -text
AABB_tree/demo/CMakeLists.txt -text
AABB_tree/demo/MainWindow.cpp -text
AABB_tree/demo/MainWindow.h -text
AABB_tree/demo/MainWindow.ui -text
AABB_tree/demo/Scene.cpp -text
AABB_tree/demo/Scene.h -text
AABB_tree/demo/Viewer.cpp -text
AABB_tree/demo/Viewer.h -text
AABB_tree/demo/Viewer_moc.cpp -text
AABB_tree/demo/algorithms.cpp -text
AABB_tree/demo/data/anchor.off -text
AABB_tree/demo/data/couplingdown.off -text
AABB_tree/demo/normal.h -text
AABB_tree/demo/render.h -text
AABB_tree/demo/resources/about.html -text
AABB_tree/demo/resources/cgal_logo.xpm -text
AABB_tree/demo/types.h -text
AABB_tree/demo/ui_MainWindow.h -text
AABB_tree/doc_tex/AABB_tree/PkgDescription.tex -text
AABB_tree/doc_tex/AABB_tree/anchor.eps -text
AABB_tree/doc_tex/AABB_tree/anchor.jpg -text

View File

@ -0,0 +1,40 @@
#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 "Viewer.cpp"
# include "Viewer_moc.cpp"
# include "MainWindow.cpp"
# include "MainWindow_moc.cpp"

View File

@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/cgal/icons" >
<file>resources/cgal_logo.xpm</file>
</qresource>
<qresource prefix="/cgal/AABB_demo" >
<file alias="about.html" >resources/about.html</file>
</qresource>
</RCC>

View File

@ -0,0 +1,99 @@
# This is the CMake script for compiling the AABB tree demo.
project( AABB_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 ../../../AABB_tree/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_generate_moc( "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" Scene_moc.cpp )
add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" )
qt4_add_resources ( RESOURCE_FILES AABB_demo.qrc )
add_file_dependencies( AABB_demo.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
add_executable ( AABB_demo AABB_demo.cpp ${UI_FILES} ${RESOURCE_FILES} )
# Link with Qt libraries
target_link_libraries( AABB_demo ${QT_LIBRARIES} )
# Link with CGAL
target_link_libraries( AABB_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
# Link with libQGLViewer, OpenGL
target_link_libraries( AABB_demo ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS AABB_demo )
else (CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
set(POLYHEDRON_MISSING_DEPS "")
if(NOT CGAL_Qt4_FOUND)
set(AABB_MISSING_DEPS "the CGAL Qt4 library, ${POLYHEDRON_MISSING_DEPS}")
endif()
if(NOT QT4_FOUND)
set(AABB_MISSING_DEPS "Qt4, ${AABB_MISSING_DEPS}")
endif()
if(NOT OPENGL_FOUND)
set(AABB_MISSING_DEPS "OpenGL, ${AABB_MISSING_DEPS}")
endif()
if(NOT QGLVIEWER_FOUND)
set(AABB_MISSING_DEPS "QGLViewer, ${AABB_MISSING_DEPS}")
endif()
message(STATUS "NOTICE: This demo requires ${AABB_MISSING_DEPS}and will not be compiled.")
endif (CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)

View File

@ -0,0 +1,146 @@
#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 "ui_MainWindow.h"
MainWindow::MainWindow(QWidget* parent)
: CGAL::Qt::DemosMainWindow(parent)
{
ui = new Ui::MainWindow;
ui->setupUi(this);
// Save some pointers from ui, for latter use.
m_pViewer = ui->viewer;
// do not save the state of the viewer (anoying)
m_pViewer->setStateFileName(QString::null);
// accept drop events
setAcceptDrops(true);
// setup scene
m_pScene = new Scene;
m_pViewer->setScene(m_pScene);
// Connect 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(); // Among other things, the column widths are stored.
}
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()
{
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);
}
}
}
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);
}

View File

@ -0,0 +1,54 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtOpenGL/qgl.h>
#include <CGAL/Qt/DemosMainWindow.h>
class QDragEnterEvent;
class QDropEvent;
class Scene;
class Viewer;
namespace Ui {
class MainWindow;
}
#include "types.h"
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();
// load
void on_actionLoadPolyhedron_triggered();
// drag & drop
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void closeEvent(QCloseEvent *event);
private:
QString strippedName(const QString &fullFileName);
Scene* m_pScene;
Viewer* m_pViewer;
Ui::MainWindow* ui;
};
#endif // ifndef MAINWINDOW_H

View File

@ -0,0 +1,80 @@
<ui version="4.0" >
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>978</width>
<height>594</height>
</rect>
</property>
<property name="windowTitle" >
<string>CGAL AABB tree demo</string>
</property>
<property name="windowIcon" >
<iconset resource="AABB_demo.qrc" >
<normaloff>:/cgal/icons/resources/cgal_logo.xpm</normaloff>:/cgal/icons/resources/cgal_logo.xpm</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="1" >
<widget class="Viewer" native="1" name="viewer" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>978</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="actionQuit" />
<addaction name="actionLoadPolyhedron" />
</widget>
<widget class="QMenu" name="menuView" >
<property name="title" >
<string>&amp;View</string>
</property>
</widget>
<addaction name="menuFile" />
<addaction name="menuView" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<action name="actionQuit" >
<property name="text" >
<string>&amp;Quit</string>
</property>
<property name="shortcut" >
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionLoadPolyhedron" >
<property name="text" >
<string>Load polyhedron...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>Viewer</class>
<extends>QWidget</extends>
<header>Viewer.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="AABB_demo.qrc" />
</resources>
<connections/>
</ui>

74
AABB_tree/demo/Scene.cpp Normal file
View File

@ -0,0 +1,74 @@
#include "Scene.h"
#include <iostream>
#include <fstream>
#include <QString>
#include <QTextStream>
#include <QFileInfo>
#include <QGLWidget>
#include <QMessageBox>
#include <QEvent>
#include <QMouseEvent>
#include <QPainter>
#include <QApplication>
#include "render.h"
#include <CGAL/IO/Polyhedron_iostream.h>
Scene::Scene()
{
m_pPolyhedron = NULL;
}
Scene::~Scene()
{
delete m_pPolyhedron;
}
int
Scene::open(QString filename)
{
QTextStream cerr(stderr);
cerr << QString("Opening file \"%1\"...").arg(filename);
QApplication::setOverrideCursor(QCursor(::Qt::WaitCursor));
QFileInfo fileinfo(filename);
std::ifstream in(filename.toUtf8());
if(!in || !fileinfo.isFile() || ! fileinfo.isReadable())
{
std::cerr << "cannot open file" << std::endl;
QApplication::restoreOverrideCursor();
return -1;
}
// allocate new polyhedron
m_pPolyhedron = new Polyhedron;
in >> *m_pPolyhedron;
if(!in)
{
std::cerr << "file is not a valid OFF file" << std::endl;
QApplication::restoreOverrideCursor();
delete m_pPolyhedron;
m_pPolyhedron = NULL;
return -1;
}
QApplication::restoreOverrideCursor();
cerr << " Ok.\n";
return 0;
}
void Scene::draw()
{
if(m_pPolyhedron != NULL)
gl_render_facets(*m_pPolyhedron);
}

58
AABB_tree/demo/Scene.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef SCENE_H
#define SCENE_H
#include <QtOpenGL/qgl.h>
#include "types.h"
#include <iostream>
#include <cmath>
class Scene
{
public:
Scene();
~Scene();
Polyhedron* polyhedron() const;
void draw();
struct Bbox {
double xmin, ymin, zmin;
double xmax, ymax, zmax;
Bbox(const double _xmin,const double _ymin,const double _zmin,
const double _xmax,const double _ymax,const double _zmax)
: xmin(_xmin), ymin(_ymin), zmin(_zmin),
xmax(_xmax), ymax(_ymax), zmax(_zmax)
{
}
Bbox()
: xmin(0.0), ymin(0.0), zmin(0.0),
xmax(1.0), ymax(1.0), zmax(1.0)
{
}
};
double len_diagonal()
{
Bbox box = bbox();
double dx = box.xmax - box.xmin;
double dy = box.ymax - box.ymin;
double dz = box.zmax - box.zmin;
return std::sqrt(dx*dx + dy*dy + dz*dz);
}
// TO DEFINE
Bbox bbox() { return Bbox(); }
public:
int open(QString filename);
private:
Polyhedron *m_pPolyhedron;
}; // end class Scene
#endif // SCENE_H

51
AABB_tree/demo/Viewer.cpp Normal file
View File

@ -0,0 +1,51 @@
#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 == 0)
return;
::glLineWidth(1.0f);
::glPointSize(10.f);
::glEnable(GL_POLYGON_OFFSET_FILL);
::glPolygonOffset(1.0f,1.0f);
::glClearColor(1.0f,1.0f,1.0f,0.0f);
::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
if(true)
{
::glEnable(GL_BLEND);
::glEnable(GL_LINE_SMOOTH);
::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else
{
::glDisable(GL_BLEND);
::glDisable(GL_LINE_SMOOTH);
::glDisable(GL_POLYGON_SMOOTH_HINT);
::glBlendFunc(GL_ONE, GL_ZERO);
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
}
m_pScene->draw();
}
void Viewer::initializeGL()
{
QGLViewer::initializeGL();
}

26
AABB_tree/demo/Viewer.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef VIEWER_H
#define VIEWER_H
#include <QGLViewer/qglviewer.h>
// 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

View File

@ -0,0 +1,62 @@
/****************************************************************************
** Meta object code from reading C++ file 'Viewer.h'
**
** Created: Sat 27. Jun 22:22:12 2009
** by: The Qt Meta Object Compiler version 59 (Qt 4.4.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "Viewer.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'Viewer.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.4.3. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Viewer[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0 // eod
};
static const char qt_meta_stringdata_Viewer[] = {
"Viewer\0"
};
const QMetaObject Viewer::staticMetaObject = {
{ &QGLViewer::staticMetaObject, qt_meta_stringdata_Viewer,
qt_meta_data_Viewer, 0 }
};
const QMetaObject *Viewer::metaObject() const
{
return &staticMetaObject;
}
void *Viewer::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Viewer))
return static_cast<void*>(const_cast< Viewer*>(this));
return QGLViewer::qt_metacast(_clname);
}
int Viewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QGLViewer::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE

View File

@ -0,0 +1,19 @@
#include <QApplication>
#include "MainWindow.h"
#include "Scene.h"
#include "types.h"
void MainWindow::on_actionInsideOut_triggered()
{
// wait cursor
QApplication::setOverrideCursor(Qt::WaitCursor);
// get selected polyhedron
Polyhedron* pMesh = m_pScene->polyhedron();
// inside out
pMesh->inside_out();
// default cursor
QApplication::restoreOverrideCursor();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

45
AABB_tree/demo/normal.h Normal file
View File

@ -0,0 +1,45 @@
#ifndef _COMPUTE_NORMAL_
#define _COMPUTE_NORMAL_
template <class Facet, class Kernel>
typename Kernel::Vector_3 compute_facet_normal(Facet& f)
{
typedef typename Kernel::Point_3 Point;
typedef typename Kernel::Vector_3 Vector;
typedef typename Facet::Halfedge_around_facet_circulator HF_circulator;
Vector normal = CGAL::NULL_VECTOR;
HF_circulator he = f.facet_begin();
HF_circulator end = he;
CGAL_For_all(he,end)
{
const Point& prev = he->prev()->vertex()->point();
const Point& curr = he->vertex()->point();
const Point& next = he->next()->vertex()->point();
Vector n = CGAL::cross_product(next-curr,prev-curr);
normal = normal + (n / std::sqrt(n*n));
}
return normal / std::sqrt(normal * normal);
}
template <class Vertex, class Kernel>
typename Kernel::Vector_3 compute_vertex_normal(Vertex& v)
{
typedef typename Kernel::Point_3 Point;
typedef typename Kernel::Vector_3 Vector;
typedef typename Vertex::Halfedge_around_vertex_circulator HV_circulator;
typedef typename Vertex::Facet Facet;
Vector normal = CGAL::NULL_VECTOR;
HV_circulator he = v.vertex_begin();
HV_circulator end = he;
CGAL_For_all(he,end)
{
if(!he->is_border())
{
Vector n = compute_facet_normal<Facet,Kernel>(*he->facet());
normal = normal + (n / std::sqrt(n*n));
}
}
return normal / std::sqrt(normal * normal);
}
#endif // _COMPUTE_NORMAL_

66
AABB_tree/demo/render.h Normal file
View File

@ -0,0 +1,66 @@
#ifndef _GL_RENDER_
#define _GL_RENDER_
#include <CGAL/gl.h>
#include "normal.h"
template <class Polyhedron>
void gl_render_facets(Polyhedron& polyhedron)
{
typedef typename Polyhedron::Traits Kernel;
typedef typename Kernel::Point_3 Point;
typedef typename Kernel::Vector_3 Vector;
typedef typename Polyhedron::Facet Facet;
typedef typename Polyhedron::Facet_iterator Facet_iterator;
typedef typename Polyhedron::Halfedge_around_facet_circulator HF_circulator;
Facet_iterator f;
for(f = polyhedron.facets_begin();
f != polyhedron.facets_end();
f++)
{
::glBegin(GL_POLYGON);
// compute normal
Vector n = compute_facet_normal<Facet,Kernel>(*f);
::glNormal3d(n.x(),n.y(),n.z());
// revolve around current face to get vertices
HF_circulator he = f->facet_begin();
HF_circulator end = he;
CGAL_For_all(he,end)
{
const Point& p = he->vertex()->point();
::glVertex3d(p.x(),p.y(),p.z());
}
::glEnd();
}
} // end gl_render_facets
template <class Polyhedron>
void gl_render_edges(Polyhedron& polyhedron)
{
typedef typename Polyhedron::Traits Kernel;
typedef typename Kernel::Point_3 Point;
typedef typename Polyhedron::Edge_iterator Edge_iterator;
::glBegin(GL_LINES);
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();
} // end gl_render_edges
#endif // _GL_RENDER_

View File

@ -0,0 +1,30 @@
<html>
<body>
<h2>3D Polyhedral Surfaces</h2>
<p>Copyright &copy;2008
<a href="http://www.geometryfactory.com/">GeometryFactory</a>
and <a href="http://www-sop.inria.fr/">INRIA Sophia Antipolis - Mediterranee<a/></p>
<p>This application illustrates the 3D polyhedral surfaces
of <a href="http://www.cgal.org/">CGAL</a>, and operations and
algorithms that can be applied to.</p>
<p>See also the following chapters of the manual:
<ul>
<li><a href="http://www.cgal.org/Pkg/Polyhedron">
3D Polyhedral Surface</a>,
</li>
<li><a href="http://www.cgal.org/Pkg/Nef3">
3D Boolean Operations on Nef Polyhedra</a>,
</li>
<li><a href="http://www.cgal.org/Pkg/ConvexHull3">
3D Convex Hulls</a>,
</li>
<li><a href="http://www.cgal.org/Pkg/SurfaceSubdivisionMethods3">
3D Surface Subdivision Methods</a>,
</li>
<li><a href="http://www.cgal.org/Pkg/SurfaceMeshSimplification">
Triangulated Surface Mesh Simplification</a>.
</li>
</ul>
</p>
</body>
</html>

View File

@ -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 */
"................",
"...++++...++++..",
"..+....+.+....+.",
"..+......+......",
"..+......+..+++.",
"..+......+....+.",
"..+....+.+....+.",
"...++++...++++..",
"................",
"...++++...+.....",
"..+....+..+.....",
"..+....+..+.....",
"..++++++..+.....",
"..+....+..+.....",
"..+....+..+++++.",
"................"};

19
AABB_tree/demo/types.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef POLYHEDRON_TYPE_H
#define POLYHEDRON_TYPE_H
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Line_3 Line;
typedef Kernel::Point_3 Point;
typedef Kernel::Plane_3 Plane;
typedef Kernel::Sphere_3 Sphere;
typedef Kernel::Vector_3 Vector;
typedef Kernel::Triangle_3 Triangle;
typedef Kernel::Iso_cuboid_3 Iso_cuboid;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
#endif // POLYHEDRON_TYPE_H

View File

@ -0,0 +1,104 @@
/********************************************************************************
** Form generated from reading ui file 'MainWindow.ui'
**
** Created: Sat 27. Jun 22:31:39 2009
** by: Qt User Interface Compiler version 4.4.3
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QLocale>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QWidget>
#include "Viewer.h"
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QAction *actionQuit;
QAction *actionLoadPolyhedron;
QWidget *centralwidget;
QGridLayout *gridLayout;
Viewer *viewer;
QMenuBar *menubar;
QMenu *menuFile;
QMenu *menuView;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(978, 594);
QIcon icon;
icon.addPixmap(QPixmap(QString::fromUtf8(":/cgal/icons/resources/cgal_logo.xpm")), QIcon::Normal, QIcon::Off);
MainWindow->setWindowIcon(icon);
actionQuit = new QAction(MainWindow);
actionQuit->setObjectName(QString::fromUtf8("actionQuit"));
actionLoadPolyhedron = new QAction(MainWindow);
actionLoadPolyhedron->setObjectName(QString::fromUtf8("actionLoadPolyhedron"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
viewer = new Viewer(centralwidget);
viewer->setObjectName(QString::fromUtf8("viewer"));
viewer->setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
gridLayout->addWidget(viewer, 0, 1, 1, 1);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 978, 24));
menuFile = new QMenu(menubar);
menuFile->setObjectName(QString::fromUtf8("menuFile"));
menuView = new QMenu(menubar);
menuView->setObjectName(QString::fromUtf8("menuView"));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
menubar->addAction(menuFile->menuAction());
menubar->addAction(menuView->menuAction());
menuFile->addAction(actionQuit);
menuFile->addAction(actionLoadPolyhedron);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "CGAL AABB tree demo", 0, QApplication::UnicodeUTF8));
actionQuit->setText(QApplication::translate("MainWindow", "&Quit", 0, QApplication::UnicodeUTF8));
actionQuit->setShortcut(QApplication::translate("MainWindow", "Ctrl+Q", 0, QApplication::UnicodeUTF8));
actionLoadPolyhedron->setText(QApplication::translate("MainWindow", "Load polyhedron...", 0, QApplication::UnicodeUTF8));
menuFile->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
menuView->setTitle(QApplication::translate("MainWindow", "&View", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H