From c5654c95e3c5ef2666c48c92c017a4231140fe50 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 16 Jul 2008 11:08:06 +0000 Subject: [PATCH] - Rename several actions, to remove all "_" in their names. - Add several "&" in action texts. - NEW files: - "Polyhedron_type.h" defines the Kernel and Polyhedron types, - "Polyhedron_type_fwd.h" can be used for a forward declaration of the type "Polyhedron". - New functions in Scene: int selectionAndex(); int selectionBindex(); Boolean operations now use those functions to get the indices of the polyhedra. - The Exact_polyhedron is now only defined in MainWindow_boolean_operations.cp, to reduce compilation times. - The min/max problem is handled better, in MainWindow_pca.cpp (quote the macros with () instead of using #undef). - MainWindow_simplify.cpp now works!! - Scene.h and Scene.cpp has been splitted in several parts, to decrease compilation times: - Scene_rendering.h declares: void gl_render_facets(Polyhedron* poly); void gl_render_edges(Polyhedron *poly); - Scene_rendering.cpp defines those two functions by using - Scene_polyhedron_operations.cpp contains operations that create/delete/load/save polyhedra. That way, Scene.h and Scene.cpp are CGAL-agnostic. --- .gitignore | 2 + Polyhedron/demo/Polyhedron/CMakeLists.txt | 16 ++++- Polyhedron/demo/Polyhedron/MainWindow.cpp | 2 +- Polyhedron/demo/Polyhedron/MainWindow.h | 25 +++---- Polyhedron/demo/Polyhedron/MainWindow.ui | 71 +++++++++---------- .../MainWindow_boolean_operations.cpp | 21 +++--- .../MainWindow_curvature_estimation.cpp | 2 + Polyhedron/demo/Polyhedron/MainWindow_pca.cpp | 10 +-- .../MainWindow_self_intersection.cpp | 2 +- .../demo/Polyhedron/MainWindow_simplify.cpp | 11 ++- Polyhedron/demo/Polyhedron/Polyhedron_type.h | 29 ++++++++ .../demo/Polyhedron/Polyhedron_type_fwd.h | 31 ++++++++ Polyhedron/demo/Polyhedron/Scene.cpp | 61 ++++++---------- Polyhedron/demo/Polyhedron/Scene.h | 44 ++++++------ .../Scene_polyhedron_operations.cpp | 57 +++++++++++++++ .../demo/Polyhedron/Scene_rendering.cpp | 12 ++++ Polyhedron/demo/Polyhedron/Scene_rendering.h | 4 ++ Polyhedron/demo/Polyhedron/main.cpp | 3 - 18 files changed, 260 insertions(+), 143 deletions(-) create mode 100644 Polyhedron/demo/Polyhedron/Polyhedron_type.h create mode 100644 Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h create mode 100644 Polyhedron/demo/Polyhedron/Scene_polyhedron_operations.cpp create mode 100644 Polyhedron/demo/Polyhedron/Scene_rendering.cpp create mode 100644 Polyhedron/demo/Polyhedron/Scene_rendering.h diff --git a/.gitignore b/.gitignore index 8c73d68ac86..b2748eab160 100644 --- a/.gitignore +++ b/.gitignore @@ -237,6 +237,8 @@ Optimisation_doc/doc_ps Polyhedron/demo/Polyhedron/*.cpp_parameters Polyhedron/demo/Polyhedron/*.dir Polyhedron/demo/Polyhedron/*.exe +Polyhedron/demo/Polyhedron/*.ii +Polyhedron/demo/Polyhedron/*.s Polyhedron/demo/Polyhedron/*.sln Polyhedron/demo/Polyhedron/*.ui Polyhedron/demo/Polyhedron/*.vcproj diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index cc98720e097..0f9d23735fe 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -9,7 +9,7 @@ endif(COMMAND cmake_policy) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) -foreach(INCDIR ./include ../../../GraphicsView/include) +foreach(INCDIR ./include ../../../GraphicsView/include ../../../Nef_3/include) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}) include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR}) endif() @@ -52,7 +52,19 @@ add_file_dependencies( Scene_moc.cpp Scene.h ) qt4_add_resources ( RESOURCE_FILES Polyhedron_3.qrc ) -add_executable ( Polyhedron_3 MainWindow_moc.cpp Scene_moc.cpp Viewer_moc.cpp main.cpp Viewer.cpp ${UI_FILES} ${RESOURCE_FILES} ) +add_executable ( Polyhedron_3 MainWindow.cpp + MainWindow_boolean_operations.cpp + main.cpp + Viewer.cpp + Scene.cpp + Scene_polyhedron_operations.cpp + Scene_rendering.cpp + + MainWindow_moc.cpp + Scene_moc.cpp + Viewer_moc.cpp + + ${UI_FILES} ${RESOURCE_FILES} ) # Link with Qt libraries target_link_libraries( Polyhedron_3 ${QT_LIBRARIES} ) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 9a8169fbde8..001bf6f0518 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -279,7 +279,7 @@ void MainWindow::on_actionLoadPolyhedron_triggered() } } -void MainWindow::on_actionSave_as_triggered() +void MainWindow::on_actionSaveAs_triggered() { if(!onePolygonIsSelected()) return; diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index 2ee20c9d5d8..f3a282200e4 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -8,7 +8,9 @@ class QDragEnterEvent; class QDropEvent; class Scene; -struct Polyhedron; + +#include "Polyhedron_type_fwd.h" +// #include "Scene.h" class MainWindow : public CGAL::Qt::DemosMainWindow, @@ -18,10 +20,6 @@ class MainWindow : public: MainWindow(QWidget* parent = 0); -enum { BOOLEAN_UNION, - BOOLEAN_INTERSECTION, - BOOLEAN_DIFFERENCE}; - public slots: void updateViewerBBox(); void open(QString filename); @@ -43,7 +41,7 @@ protected slots: // save // TODO: save all, save current (do we store the current file name?) - void on_actionSave_as_triggered(); // save selected polyhedron as... + void on_actionSaveAs_triggered(); // save selected polyhedron as... // merge (TODO) @@ -66,20 +64,23 @@ protected slots: void on_actionIntersection_triggered(); void on_actionDifference_triggered(); - // curvature estimation + // curvature estimation, in MainWindow_curvature_estimation.cpp void on_actionEstimateCurvature_triggered(); - // PCA + // PCA, in MainWindow_pca.cpp void on_actionFitPlane_triggered(); void on_actionFitLine_triggered(); - // self intersection - void on_actionSelf_intersection_triggered(); + // self intersection, in MainWindow_self_intersection.cpp + void on_actionSelfIntersection_triggered(); protected: - void boolean_operation(const int operation); + enum Boolean_operation { BOOLEAN_UNION, + BOOLEAN_INTERSECTION, + BOOLEAN_DIFFERENCE }; + // define in MainWindow_boolean_operations.cpp + void boolean_operation(const Boolean_operation operation); -protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); void closeEvent(QCloseEvent *event); diff --git a/Polyhedron/demo/Polyhedron/MainWindow.ui b/Polyhedron/demo/Polyhedron/MainWindow.ui index 3e3482daae8..297e065980e 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.ui +++ b/Polyhedron/demo/Polyhedron/MainWindow.ui @@ -16,9 +16,9 @@ 0 - 24 + 29 978 - 548 + 540 @@ -37,9 +37,9 @@ 0 - 22 + 23 354 - 508 + 499 @@ -122,7 +122,7 @@ 0 0 978 - 24 + 29 @@ -131,11 +131,11 @@ - + - - + + @@ -156,7 +156,7 @@ - + @@ -210,9 +210,9 @@ 0 - 572 + 569 978 - 22 + 25 @@ -312,7 +312,7 @@ true - Antialiasing + &Antialiasing Ctrl+A @@ -325,72 +325,67 @@ - Convex hull + &Convex hull - + - Erase all + &Erase all - Options... + &Options... - Loop + &Loop - + - Save as... + Save &as... - Save + &Save - + - Save all + Save a&ll - + - Merge all + Mer&ge all - Merge + &Merge - + - Self-intersection + Self-&intersection - + - Selections + Select &all - + - Select all + Select &none - + - Select none - - - - - Invert selection + &Invert selection diff --git a/Polyhedron/demo/Polyhedron/MainWindow_boolean_operations.cpp b/Polyhedron/demo/Polyhedron/MainWindow_boolean_operations.cpp index 3a4b2f92477..dfb534d97f0 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_boolean_operations.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_boolean_operations.cpp @@ -1,8 +1,17 @@ #include "MainWindow.h" #include "Scene.h" +#include "Polyhedron_type.h" #include #include +#include + +#include +#include + +// Boolean operations work only with exact kernel +typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_Kernel; +typedef CGAL::Polyhedron_3 Exact_polyhedron; // quick hacks to convert polyhedra from exact to inexact and vice-versa @@ -39,22 +48,18 @@ void MainWindow::on_actionDifference_triggered() boolean_operation(BOOLEAN_DIFFERENCE); } -void MainWindow::boolean_operation(const int operation) +void MainWindow::boolean_operation(const Boolean_operation operation) { QApplication::setOverrideCursor(Qt::WaitCursor); - // PA: to be done by LR? - //int indexA = scene->getPolygonAIndex(); - //int indexB = scene->getPolygonBIndex(); - - // to remove - int indexA = 0; - int indexB = 1; + const int indexA = scene->selectionAindex(); + const int indexB = scene->selectionBindex(); Polyhedron* polyA = scene->polyhedron(indexA); Polyhedron* polyB = scene->polyhedron(indexB); if(!polyA) return; if(!polyB) return; + if(polyA == polyB) return; typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; diff --git a/Polyhedron/demo/Polyhedron/MainWindow_curvature_estimation.cpp b/Polyhedron/demo/Polyhedron/MainWindow_curvature_estimation.cpp index 54f43f11ea9..931304b27a1 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_curvature_estimation.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_curvature_estimation.cpp @@ -1,7 +1,9 @@ #include "MainWindow.h" #include "Scene.h" +#include "Polyhedron_type.h" #include #include +#include void MainWindow::on_actionEstimateCurvature_triggered() { diff --git a/Polyhedron/demo/Polyhedron/MainWindow_pca.cpp b/Polyhedron/demo/Polyhedron/MainWindow_pca.cpp index b50c120a231..e6355e717a8 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_pca.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_pca.cpp @@ -1,16 +1,12 @@ #include "MainWindow.h" #include "Scene.h" +#include "Polyhedron_type.h" #include #include #include #include // for plane fitting #include // for line fitting -// for Visual C++ (which defines min/max macros) -#undef min -#undef max - - void MainWindow::on_actionFitPlane_triggered() { if(onePolygonIsSelected()) @@ -47,8 +43,8 @@ void MainWindow::on_actionFitPlane_triggered() Iso_cuboid bbox = CGAL::bounding_box(pMesh->points_begin(),pMesh->points_end()); // compute scale for rendering using diagonal of bbox - Point cmin = bbox.min(); - Point cmax = bbox.max(); + Point cmin = (bbox.min)(); + Point cmax = (bbox.max)(); FT diag = std::sqrt(CGAL::squared_distance(cmin,cmax)); Vector u1 = plane.base1(); u1 = u1 / std::sqrt(u1*u1); diff --git a/Polyhedron/demo/Polyhedron/MainWindow_self_intersection.cpp b/Polyhedron/demo/Polyhedron/MainWindow_self_intersection.cpp index 28e545a82d7..ddadedd2032 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_self_intersection.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_self_intersection.cpp @@ -8,7 +8,7 @@ #include #include -void MainWindow::on_actionSelf_intersection_triggered() +void MainWindow::on_actionSelfIntersection_triggered() { if(onePolygonIsSelected()) { diff --git a/Polyhedron/demo/Polyhedron/MainWindow_simplify.cpp b/Polyhedron/demo/Polyhedron/MainWindow_simplify.cpp index 72a5477b53e..f4593d43957 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_simplify.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_simplify.cpp @@ -17,14 +17,13 @@ void MainWindow::on_actionSimplify_triggered() Polyhedron* pMesh = scene->polyhedron(index); // simplify - unsigned int nb_edges = 1000; // TODO: should be an option + const unsigned int nb_edges = 1000; // TODO: should be an option namespace SMS = CGAL::Surface_mesh_simplification; - // DOES NOT COMPILE - //SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges - //SMS::edge_collapse( *pMesh, stop, - // CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh)) - // .edge_index_map(boost::get(CGAL::edge_external_index,*pMesh))); + SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges + SMS::edge_collapse( *pMesh, stop, + CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh)) + .edge_index_map(boost::get(CGAL::edge_external_index,*pMesh))); // update scene scene->polyhedronChanged(index); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_type.h b/Polyhedron/demo/Polyhedron/Polyhedron_type.h new file mode 100644 index 00000000000..97af039f3f2 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Polyhedron_type.h @@ -0,0 +1,29 @@ +#ifndef POLYHEDRON_TYPE_H +#define POLYHEDRON_TYPE_H + +// CGAL +#include + +// kernel +#include +#include + +// surface mesh +#include + +#include "Polyhedron_type_fwd.h" + +struct Kernel : public CGAL::Exact_predicates_inexact_constructions_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; + +// struct Polyhedron : public CGAL::Polyhedron_3 {}; +typedef CGAL::Polyhedron_3 Polyhedron; + +#endif // POLYHEDRON_TYPE_H diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h b/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h new file mode 100644 index 00000000000..2482099f8c3 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h @@ -0,0 +1,31 @@ +#ifndef POLYHEDRON_TYPE_FWD_H +#define POLYHEDRON_TYPE_FWD_H + +#include + +struct Kernel; +namespace CGAL { + struct Polyhedron_items_3; + +#ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM + template < class T, class I, class A> +#endif + struct HalfedgeDS_default; + + template < class PolyhedronTraits_3, + class PolyhedronItems_3, +#ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM + template < class T, class I, class A> +#endif + class T_HDS, + class Alloc + > + class Polyhedron_3; +} + +typedef CGAL::Polyhedron_3 > Polyhedron; + +#endif // POLYHEDRON_TYPE_FWD_H diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index ed837686dd6..5dff1975f76 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -1,5 +1,4 @@ #include "Scene.h" -#include #include #include @@ -13,8 +12,9 @@ #include #include #include +#include -#include +#include "Scene_rendering.h" namespace { void CGALglcolor(QColor c) @@ -39,7 +39,7 @@ Scene::~Scene() poly_it = polyhedra.begin(), poly_end = polyhedra.end(); poly_it != poly_end; ++poly_it) { - delete poly_it->polyhedron_ptr; + this->destroy(poly_it->polyhedron_ptr); } polyhedra.clear(); } @@ -64,9 +64,9 @@ Scene::open(QString filename) return -1; } - // allocate new polyhedron - Polyhedron* poly = new Polyhedron; - in >> *poly; + // allocate new polyhedron + Polyhedron* poly = this->new_polyhedron(); + this->load_polyhedron(poly, in); if(!in) { QMessageBox::critical(qobject_cast(QObject::parent()), @@ -74,14 +74,13 @@ Scene::open(QString filename) tr("File %1 is not a valid OFF file.").arg(filename)); QApplication::restoreOverrideCursor(); cerr << QString("\n"); - delete poly; + destroy(poly); return -1; } addPolyhedron(poly, fileinfo.baseName()); QApplication::restoreOverrideCursor(); - cerr << QString("ok (%1 vertices)\n").arg(poly->size_of_vertices()); return polyhedra.size() - 1; } @@ -109,7 +108,7 @@ bool Scene::save(int index, return false; } - out << *poly; + this->save_polyhedron(poly, out); cerr << QString("ok\n"); QApplication::restoreOverrideCursor(); @@ -140,7 +139,7 @@ void Scene::addPolyhedron(Polyhedron* p, int Scene::erase(int polyhedron_index) { - delete polyhedra[polyhedron_index].polyhedron_ptr; + this->destroy(polyhedra[polyhedron_index].polyhedron_ptr); polyhedra.removeAt(polyhedron_index--); selected_item = -1; @@ -158,7 +157,7 @@ int Scene::duplicate(int polyhedron_index) { const Polyhedron_entry& entry = polyhedra[polyhedron_index]; - Polyhedron* poly = new Polyhedron(*entry.polyhedron_ptr); + Polyhedron* poly = this->copy_polyhedron(entry.polyhedron_ptr); addPolyhedron(poly, tr("%1 (copy)").arg(entry.name), @@ -168,34 +167,6 @@ Scene::duplicate(int polyhedron_index) return polyhedra.size() - 1; } -CGAL::Bbox_3 -Scene::bbox() -{ - if(polyhedra.empty()) { - return CGAL::Bbox_3(0.0, 0.0, 0.0, - 1.0, 1.0, 1.0); - } - else - { - Point p = polyhedra.begin()->polyhedron_ptr->vertices_begin()->point(); - CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z()); - for(Polyhedra::iterator - poly_it = polyhedra.begin(), - poly_end = polyhedra.end(); - poly_it != poly_end; ++poly_it) - { - for(Polyhedron::Vertex_iterator - v = poly_it->polyhedron_ptr->vertices_begin(), - v_end = poly_it->polyhedron_ptr->vertices_end(); - v != v_end; ++v) - { - bbox = bbox + v->point().bbox(); - } - } - return bbox; - } -} - void Scene::draw() { @@ -213,7 +184,7 @@ Scene::draw() else CGALglcolor(entry.color); - gl_render_facets(*poly); + gl_render_facets(poly); } if(index == selected_item) @@ -223,7 +194,7 @@ Scene::draw() // superimpose edges ::glDisable(GL_LIGHTING); - gl_render_edges(*poly); + gl_render_edges(poly); } } } @@ -423,6 +394,14 @@ Scene::RenderingMode Scene::polyhedronRenderingMode(int index) return polyhedra[index].rendering_mode; } +int Scene::selectionAindex() const { + return item_A; +} + +int Scene::selectionBindex() const { + return item_B; +} + QItemSelection Scene::createSelection(int i) { return QItemSelection(QAbstractItemModel::createIndex(i, 0), diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 016634af014..112635cf11f 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -10,31 +10,10 @@ #include #include -// CGAL -#include +#include "Polyhedron_type_fwd.h" +#include -// kernel -#include -#include - -// surface mesh -#include - -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; - -// Boolean operations work only with exact kernel -typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_Kernel; -typedef CGAL::Polyhedron_3 Exact_polyhedron; - -struct Polyhedron : public CGAL::Polyhedron_3 {}; +#include class QEvent; class QMouseEvent; @@ -85,12 +64,16 @@ public: QString polyhedronName(int); bool isPolyhedronActivated(int); RenderingMode polyhedronRenderingMode(int); + int selectionAindex() const; + int selectionBindex() const; // for backward compatibility Polyhedron* getPolyhedron(int i) { return polyhedron(i); } // draw() is called by Viewer::draw() void draw(); + + // defined in Scene_polyhedron_operations.cpp CGAL::Bbox_3 bbox(); // QAbstractItemModel functions @@ -115,6 +98,19 @@ signals: void updated_bbox(); void updated(); +private: + // functions that need to know the type Polyhedron + // defined in Scene_polyhedron_operations.cpp + Polyhedron* new_polyhedron(); + Polyhedron* copy_polyhedron(Polyhedron* poly); + void destroy(Polyhedron*); + bool load_polyhedron(Polyhedron* poly, std::istream& in); // return true + // iif the + // loading is ok. + bool save_polyhedron(Polyhedron* poly, std::ostream& out); // return true + // iif the + // save is ok. + private: static const QColor defaultColor; // defined in Scene.cpp diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_operations.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_operations.cpp new file mode 100644 index 00000000000..6783136d169 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_operations.cpp @@ -0,0 +1,57 @@ +#include "Scene.h" +#include "Polyhedron_type.h" +#include + +Polyhedron* Scene::new_polyhedron() +{ + return new Polyhedron; +} + +Polyhedron* Scene::copy_polyhedron(Polyhedron* poly) +{ + return new Polyhedron(*poly); +} + +void Scene::destroy(Polyhedron* poly) +{ + delete poly; +} + +bool Scene::load_polyhedron(Polyhedron* poly, std::istream& in) +{ + in >> *poly; + return in; +} + +bool Scene::save_polyhedron(Polyhedron* poly, std::ostream& out) +{ + out << *poly; + return out; +} + +CGAL::Bbox_3 +Scene::bbox() +{ + if(polyhedra.empty()) { + return CGAL::Bbox_3(0.0, 0.0, 0.0, + 1.0, 1.0, 1.0); + } + else + { + Point p = polyhedra.begin()->polyhedron_ptr->vertices_begin()->point(); + CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z()); + for(Polyhedra::iterator + poly_it = polyhedra.begin(), + poly_end = polyhedra.end(); + poly_it != poly_end; ++poly_it) { + for(Polyhedron::Vertex_iterator + v = poly_it->polyhedron_ptr->vertices_begin(), + v_end = poly_it->polyhedron_ptr->vertices_end(); + v != v_end; ++v) + { + bbox = bbox + v->point().bbox(); + } + } + return bbox; + } +} diff --git a/Polyhedron/demo/Polyhedron/Scene_rendering.cpp b/Polyhedron/demo/Polyhedron/Scene_rendering.cpp new file mode 100644 index 00000000000..45e8480f56d --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Scene_rendering.cpp @@ -0,0 +1,12 @@ +#include "Polyhedron_type.h" +#include + +void gl_render_facets(Polyhedron* poly) +{ + gl_render_facets(*poly); +} + +void gl_render_edges(Polyhedron *poly) +{ + gl_render_edges(*poly); +} diff --git a/Polyhedron/demo/Polyhedron/Scene_rendering.h b/Polyhedron/demo/Polyhedron/Scene_rendering.h new file mode 100644 index 00000000000..059ff1e76cc --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Scene_rendering.h @@ -0,0 +1,4 @@ +#include "Polyhedron_type_fwd.h" + +void gl_render_facets(Polyhedron* poly); +void gl_render_edges(Polyhedron *poly); diff --git a/Polyhedron/demo/Polyhedron/main.cpp b/Polyhedron/demo/Polyhedron/main.cpp index 25e3a71fda4..4f83bbdd9f0 100644 --- a/Polyhedron/demo/Polyhedron/main.cpp +++ b/Polyhedron/demo/Polyhedron/main.cpp @@ -24,11 +24,8 @@ int main(int argc, char **argv) return app.exec(); } -#include "MainWindow.cpp" -#include "Scene.cpp" #include "MainWindow_curvature_estimation.cpp" #include "MainWindow_subdivision_methods.cpp" -#include "MainWindow_boolean_operations.cpp" #include "MainWindow_self_intersection.cpp" #include "MainWindow_convex_hull.cpp" #include "MainWindow_simplify.cpp"