diff --git a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt index a141c22b2a5..a980f41e81e 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/demo/Linear_cell_complex/CMakeLists.txt @@ -37,6 +37,9 @@ include(${QT_USE_FILE}) include_directories(${QGLVIEWER_INCLUDE_DIR}) include_directories(BEFORE . ../../include/) +# Option allowing to profile each operation of the demo. +add_definitions(-DCGAL_PROFILE_LCC_DEMO) + # ui file, created wih Qt Designer qt4_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp index b31f4d8d28f..e6561b90132 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp @@ -22,6 +22,7 @@ #include #include #include "MainWindow.moc" +#include // Function defined in Linear_cell_complex_3_subivision.cpp void subdivide_lcc_3 (LCC & m); @@ -221,12 +222,24 @@ void MainWindow::on_actionAddOFF_triggered() void MainWindow::load_off (const QString & fileName, bool clear) { QApplication::setOverrideCursor (Qt::WaitCursor); - + if (clear) this->clear_all(); +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + std::ifstream ifs (qPrintable (fileName)); CGAL::import_from_polyhedron_3_flux < LCC > (*scene.lcc, ifs); + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to load off "<addToRecentFiles (fileName); @@ -247,6 +260,11 @@ void MainWindow::load_3DTDS (const QString & fileName, bool clear) if (clear) this->clear_all(); +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation; Triangulation T; @@ -255,6 +273,15 @@ void MainWindow::load_3DTDS (const QString & fileName, bool clear) T.insert (begin, end); CGAL::import_from_triangulation_3 < LCC, Triangulation >(*scene.lcc, T); + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to import the 3DTDS from "<showMessage (QString ("mesh created"),DELAY_STATUSMSG); emit (sceneChanged ()); @@ -368,7 +407,19 @@ void MainWindow::onCreateMeshOk() void MainWindow::on_actionSubdivide_triggered () { +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + subdivide_lcc_3 (*(scene.lcc)); + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to subdivide the current LCC: " + <showMessage (QString ("Objects were subdivided"), DELAY_STATUSMSG); @@ -391,6 +442,12 @@ void MainWindow::on_actionCompute_Voronoi_3D_triggered () if (fileName.isEmpty ()) return; this->clear_all(); + +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation; Triangulation T; @@ -459,6 +516,12 @@ void MainWindow::on_actionCompute_Voronoi_3D_triggered () CGAL_assertion(scene.lcc->is_whole_map_unmarked(mark_toremove)); scene.lcc->free_mark(mark_toremove); } + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to compute Voronor 3D from "<dual_points_at_barycenter(*duallcc); +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to compute the dual: " + <clear_all(); delete scene.lcc; scene.lcc = duallcc; @@ -491,6 +565,11 @@ void MainWindow::on_actionDual_3_triggered () void MainWindow::on_actionClose_volume_triggered() { +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + if ( scene.lcc->close(3) > 0 ) { init_all_new_volumes(); @@ -501,15 +580,25 @@ void MainWindow::on_actionClose_volume_triggered() else statusBar ()->showMessage (QString ("LCC already 3-closed"), DELAY_STATUSMSG); + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to 3-close the current lcc: " + <get_new_mark(); mark_all_filled_and_visible_volumes(mymark); +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + if ( scene.lcc->sew3_same_facets(mymark) > 0 ) { statusBar()->showMessage @@ -522,14 +611,22 @@ void MainWindow::on_actionSew3_same_facets_triggered() scene.lcc->free_mark(mymark); - // timer.stop(); - // std::cout<<"sew3_same_facets in "<darts().begin(); it!=scene.lcc->darts().end(); ++it) { @@ -539,6 +636,12 @@ void MainWindow::on_actionUnsew3_all_triggered() { scene.lcc->unsew<3>(it); ++nb; } } +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to unsew3 all filled volumes: " + < 0 ) { statusBar()->showMessage @@ -552,6 +655,11 @@ void MainWindow::on_actionUnsew3_all_triggered() void MainWindow::on_actionRemove_filled_volumes_triggered() { +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + unsigned int count = 0; for (LCC::Attribute_range<3>::type::iterator it=scene.lcc->attributes<3>().begin(), @@ -564,6 +672,13 @@ void MainWindow::on_actionRemove_filled_volumes_triggered() ++count; } } + +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to remove all filled volumes: " + < v; for (LCC::One_dart_per_cell_range<2>::iterator it(scene.lcc->one_dart_per_cell<2>().begin()); it.cont(); ++it) @@ -585,6 +705,12 @@ void MainWindow::on_actionTriangulate_all_facets_triggered() itv!=v.end(); ++itv) scene.lcc->insert_barycenter_in_cell<2>(*itv); +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to triangulate all filled faces: " + <showMessage (QString ("Facets of visible and filled volume(s) triangulated"), @@ -593,6 +719,11 @@ void MainWindow::on_actionTriangulate_all_facets_triggered() void MainWindow::on_actionMerge_all_volumes_triggered() { +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + Dart_handle prev = NULL; for (LCC::Dart_range::iterator it(scene.lcc->darts().begin()), itend=scene.lcc->darts().end(); it!=itend; ) @@ -610,6 +741,12 @@ void MainWindow::on_actionMerge_all_volumes_triggered() ++it; } +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to unsew3merge all filled volumes: " + <mengerLevel++; std::vector edges; @@ -1046,6 +1188,13 @@ void MainWindow::onMengerInc() split_vol_in_twentyseven(mengerVolumes[i]); } +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to increase the level of menger sponge (" + <mengerLevel-1<<" -> "<mengerLevel<<"): " + <is_valid() ); emit(sceneChanged()); @@ -1329,6 +1478,11 @@ void MainWindow::process_inter_slice(Dart_handle init, void MainWindow::onMengerDec() { +#ifdef CGAL_PROFILE_LCC_DEMO + CGAL::Timer timer; + timer.start(); +#endif + this->mengerLevel--; // We know here the number of Menger volume: 20^mengerLevel @@ -1438,6 +1592,13 @@ void MainWindow::onMengerDec() (scene.lcc)->free_mark(markVols); (scene.lcc)->free_mark(markVertices); +#ifdef CGAL_PROFILE_LCC_DEMO + timer.stop(); + std::cout<<"Time to decrease the level of menger sponge (" + <mengerLevel<<" -> "<mengerLevel+1<<"): " + <showMessage (QString ("Menger Dec"),DELAY_STATUSMSG); diff --git a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.h b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.h index fa603a4b1b5..3137d3f2388 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.h +++ b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.h @@ -151,7 +151,6 @@ protected: int markVols); Scene scene; - Timer timer; unsigned int nbcube; QLabel* statusMessage;