mirror of https://github.com/CGAL/cgal
Add timers in LCC demo.
This commit is contained in:
parent
bdb8619c5a
commit
71c334496c
|
|
@ -37,6 +37,9 @@ include(${QT_USE_FILE})
|
||||||
include_directories(${QGLVIEWER_INCLUDE_DIR})
|
include_directories(${QGLVIEWER_INCLUDE_DIR})
|
||||||
include_directories(BEFORE . ../../include/)
|
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
|
# ui file, created wih Qt Designer
|
||||||
qt4_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui)
|
qt4_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include <CGAL/Delaunay_triangulation_3.h>
|
#include <CGAL/Delaunay_triangulation_3.h>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "MainWindow.moc"
|
#include "MainWindow.moc"
|
||||||
|
#include <CGAL/Timer.h>
|
||||||
|
|
||||||
// Function defined in Linear_cell_complex_3_subivision.cpp
|
// Function defined in Linear_cell_complex_3_subivision.cpp
|
||||||
void subdivide_lcc_3 (LCC & m);
|
void subdivide_lcc_3 (LCC & m);
|
||||||
|
|
@ -224,9 +225,21 @@ void MainWindow::load_off (const QString & fileName, bool clear)
|
||||||
|
|
||||||
if (clear) this->clear_all();
|
if (clear) this->clear_all();
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
std::ifstream ifs (qPrintable (fileName));
|
std::ifstream ifs (qPrintable (fileName));
|
||||||
|
|
||||||
CGAL::import_from_polyhedron_3_flux < LCC > (*scene.lcc, ifs);
|
CGAL::import_from_polyhedron_3_flux < LCC > (*scene.lcc, ifs);
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to load off "<<qPrintable(fileName)<<": "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
init_all_new_volumes();
|
init_all_new_volumes();
|
||||||
|
|
||||||
this->addToRecentFiles (fileName);
|
this->addToRecentFiles (fileName);
|
||||||
|
|
@ -247,6 +260,11 @@ void MainWindow::load_3DTDS (const QString & fileName, bool clear)
|
||||||
|
|
||||||
if (clear) this->clear_all();
|
if (clear) this->clear_all();
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation;
|
typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation;
|
||||||
Triangulation T;
|
Triangulation T;
|
||||||
|
|
||||||
|
|
@ -255,6 +273,15 @@ void MainWindow::load_3DTDS (const QString & fileName, bool clear)
|
||||||
T.insert (begin, end);
|
T.insert (begin, end);
|
||||||
|
|
||||||
CGAL::import_from_triangulation_3 < LCC, Triangulation >(*scene.lcc, T);
|
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 "<<qPrintable(fileName)<<": "
|
||||||
|
<<timer.time()
|
||||||
|
<<" seconds (counting the time to compute denaulay triangulation)."
|
||||||
|
<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
init_all_new_volumes();
|
init_all_new_volumes();
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor ();
|
QApplication::restoreOverrideCursor ();
|
||||||
|
|
@ -351,6 +378,11 @@ void MainWindow::on_actionCreate_mesh_triggered ()
|
||||||
|
|
||||||
void MainWindow::onCreateMeshOk()
|
void MainWindow::onCreateMeshOk()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int x=0; x<dialogmesh.getX(); ++x)
|
for (int x=0; x<dialogmesh.getX(); ++x)
|
||||||
for (int y=0; y<dialogmesh.getY(); ++y)
|
for (int y=0; y<dialogmesh.getY(); ++y)
|
||||||
for (int z=0; z<dialogmesh.getZ(); ++z)
|
for (int z=0; z<dialogmesh.getZ(); ++z)
|
||||||
|
|
@ -361,6 +393,13 @@ void MainWindow::onCreateMeshOk()
|
||||||
}
|
}
|
||||||
nbcube+=dialogmesh.getX();
|
nbcube+=dialogmesh.getX();
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to create mesh ("<<dialogmesh.getX()<<", "
|
||||||
|
<<dialogmesh.getY()<<", "<<dialogmesh.getZ()<<"): "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
statusBar ()->showMessage (QString ("mesh created"),DELAY_STATUSMSG);
|
statusBar ()->showMessage (QString ("mesh created"),DELAY_STATUSMSG);
|
||||||
|
|
||||||
emit (sceneChanged ());
|
emit (sceneChanged ());
|
||||||
|
|
@ -368,7 +407,19 @@ void MainWindow::onCreateMeshOk()
|
||||||
|
|
||||||
void MainWindow::on_actionSubdivide_triggered ()
|
void MainWindow::on_actionSubdivide_triggered ()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
subdivide_lcc_3 (*(scene.lcc));
|
subdivide_lcc_3 (*(scene.lcc));
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to subdivide the current LCC: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
emit (sceneChanged ());
|
emit (sceneChanged ());
|
||||||
statusBar ()->showMessage (QString ("Objects were subdivided"),
|
statusBar ()->showMessage (QString ("Objects were subdivided"),
|
||||||
DELAY_STATUSMSG);
|
DELAY_STATUSMSG);
|
||||||
|
|
@ -391,6 +442,12 @@ void MainWindow::on_actionCompute_Voronoi_3D_triggered ()
|
||||||
if (fileName.isEmpty ()) return;
|
if (fileName.isEmpty ()) return;
|
||||||
|
|
||||||
this->clear_all();
|
this->clear_all();
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation;
|
typedef CGAL::Delaunay_triangulation_3 < LCC::Traits > Triangulation;
|
||||||
Triangulation T;
|
Triangulation T;
|
||||||
|
|
||||||
|
|
@ -460,6 +517,12 @@ void MainWindow::on_actionCompute_Voronoi_3D_triggered ()
|
||||||
scene.lcc->free_mark(mark_toremove);
|
scene.lcc->free_mark(mark_toremove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to compute Voronor 3D from "<<qPrintable(fileName)<<": "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
init_all_new_volumes();
|
init_all_new_volumes();
|
||||||
emit (sceneChanged ());
|
emit (sceneChanged ());
|
||||||
statusBar ()->showMessage (QString ("Voronoi 3D of points in ") + fileName,
|
statusBar ()->showMessage (QString ("Voronoi 3D of points in ") + fileName,
|
||||||
|
|
@ -476,9 +539,20 @@ void MainWindow::on_actionDual_3_triggered ()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
LCC* duallcc = new LCC;
|
LCC* duallcc = new LCC;
|
||||||
scene.lcc->dual_points_at_barycenter(*duallcc);
|
scene.lcc->dual_points_at_barycenter(*duallcc);
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to compute the dual: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
this->clear_all();
|
this->clear_all();
|
||||||
delete scene.lcc;
|
delete scene.lcc;
|
||||||
scene.lcc = duallcc;
|
scene.lcc = duallcc;
|
||||||
|
|
@ -491,6 +565,11 @@ void MainWindow::on_actionDual_3_triggered ()
|
||||||
|
|
||||||
void MainWindow::on_actionClose_volume_triggered()
|
void MainWindow::on_actionClose_volume_triggered()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( scene.lcc->close(3) > 0 )
|
if ( scene.lcc->close(3) > 0 )
|
||||||
{
|
{
|
||||||
init_all_new_volumes();
|
init_all_new_volumes();
|
||||||
|
|
@ -501,15 +580,25 @@ void MainWindow::on_actionClose_volume_triggered()
|
||||||
else
|
else
|
||||||
statusBar ()->showMessage
|
statusBar ()->showMessage
|
||||||
(QString ("LCC already 3-closed"), DELAY_STATUSMSG);
|
(QString ("LCC already 3-closed"), DELAY_STATUSMSG);
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to 3-close the current lcc: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSew3_same_facets_triggered()
|
void MainWindow::on_actionSew3_same_facets_triggered()
|
||||||
{
|
{
|
||||||
// timer.reset();
|
|
||||||
// timer.start();
|
|
||||||
int mymark = scene.lcc->get_new_mark();
|
int mymark = scene.lcc->get_new_mark();
|
||||||
mark_all_filled_and_visible_volumes(mymark);
|
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 )
|
if ( scene.lcc->sew3_same_facets(mymark) > 0 )
|
||||||
{
|
{
|
||||||
statusBar()->showMessage
|
statusBar()->showMessage
|
||||||
|
|
@ -522,14 +611,22 @@ void MainWindow::on_actionSew3_same_facets_triggered()
|
||||||
|
|
||||||
scene.lcc->free_mark(mymark);
|
scene.lcc->free_mark(mymark);
|
||||||
|
|
||||||
// timer.stop();
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
// std::cout<<"sew3_same_facets in "<<timer.time()<<" seconds."<<std::endl;
|
timer.stop();
|
||||||
|
std::cout<<"Time to sew3 all same facets: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionUnsew3_all_triggered()
|
void MainWindow::on_actionUnsew3_all_triggered()
|
||||||
{
|
{
|
||||||
unsigned int nb=0;
|
unsigned int nb=0;
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
for (LCC::Dart_range::iterator it=scene.lcc->darts().begin();
|
for (LCC::Dart_range::iterator it=scene.lcc->darts().begin();
|
||||||
it!=scene.lcc->darts().end(); ++it)
|
it!=scene.lcc->darts().end(); ++it)
|
||||||
{
|
{
|
||||||
|
|
@ -539,6 +636,12 @@ void MainWindow::on_actionUnsew3_all_triggered()
|
||||||
{ scene.lcc->unsew<3>(it); ++nb; }
|
{ scene.lcc->unsew<3>(it); ++nb; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to unsew3 all filled volumes: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( nb > 0 )
|
if ( nb > 0 )
|
||||||
{
|
{
|
||||||
statusBar()->showMessage
|
statusBar()->showMessage
|
||||||
|
|
@ -552,6 +655,11 @@ void MainWindow::on_actionUnsew3_all_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionRemove_filled_volumes_triggered()
|
void MainWindow::on_actionRemove_filled_volumes_triggered()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
for (LCC::Attribute_range<3>::type::iterator
|
for (LCC::Attribute_range<3>::type::iterator
|
||||||
it=scene.lcc->attributes<3>().begin(),
|
it=scene.lcc->attributes<3>().begin(),
|
||||||
|
|
@ -564,6 +672,13 @@ void MainWindow::on_actionRemove_filled_volumes_triggered()
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to remove all filled volumes: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
recreate_whole_volume_list();
|
recreate_whole_volume_list();
|
||||||
emit(sceneChanged());
|
emit(sceneChanged());
|
||||||
|
|
||||||
|
|
@ -574,6 +689,11 @@ void MainWindow::on_actionRemove_filled_volumes_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionTriangulate_all_facets_triggered()
|
void MainWindow::on_actionTriangulate_all_facets_triggered()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<LCC::Dart_handle> v;
|
std::vector<LCC::Dart_handle> v;
|
||||||
for (LCC::One_dart_per_cell_range<2>::iterator
|
for (LCC::One_dart_per_cell_range<2>::iterator
|
||||||
it(scene.lcc->one_dart_per_cell<2>().begin()); it.cont(); ++it)
|
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)
|
itv!=v.end(); ++itv)
|
||||||
scene.lcc->insert_barycenter_in_cell<2>(*itv);
|
scene.lcc->insert_barycenter_in_cell<2>(*itv);
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to triangulate all filled faces: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
emit (sceneChanged ());
|
emit (sceneChanged ());
|
||||||
statusBar()->showMessage
|
statusBar()->showMessage
|
||||||
(QString ("Facets of visible and filled volume(s) triangulated"),
|
(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()
|
void MainWindow::on_actionMerge_all_volumes_triggered()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
Dart_handle prev = NULL;
|
Dart_handle prev = NULL;
|
||||||
for (LCC::Dart_range::iterator it(scene.lcc->darts().begin()),
|
for (LCC::Dart_range::iterator it(scene.lcc->darts().begin()),
|
||||||
itend=scene.lcc->darts().end(); it!=itend; )
|
itend=scene.lcc->darts().end(); it!=itend; )
|
||||||
|
|
@ -610,6 +741,12 @@ void MainWindow::on_actionMerge_all_volumes_triggered()
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to unsew3merge all filled volumes: "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
recreate_whole_volume_list();
|
recreate_whole_volume_list();
|
||||||
|
|
||||||
emit (sceneChanged ());
|
emit (sceneChanged ());
|
||||||
|
|
@ -974,6 +1111,11 @@ void MainWindow::onMengerChange(int newLevel)
|
||||||
|
|
||||||
void MainWindow::onMengerInc()
|
void MainWindow::onMengerInc()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
this->mengerLevel++;
|
this->mengerLevel++;
|
||||||
|
|
||||||
std::vector<Dart_handle> edges;
|
std::vector<Dart_handle> edges;
|
||||||
|
|
@ -1046,6 +1188,13 @@ void MainWindow::onMengerInc()
|
||||||
split_vol_in_twentyseven(mengerVolumes[i]);
|
split_vol_in_twentyseven(mengerVolumes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to increase the level of menger sponge ("
|
||||||
|
<<this->mengerLevel-1<<" -> "<<this->mengerLevel<<"): "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
assert( (scene.lcc)->is_valid() );
|
assert( (scene.lcc)->is_valid() );
|
||||||
|
|
||||||
emit(sceneChanged());
|
emit(sceneChanged());
|
||||||
|
|
@ -1329,6 +1478,11 @@ void MainWindow::process_inter_slice(Dart_handle init,
|
||||||
|
|
||||||
void MainWindow::onMengerDec()
|
void MainWindow::onMengerDec()
|
||||||
{
|
{
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
CGAL::Timer timer;
|
||||||
|
timer.start();
|
||||||
|
#endif
|
||||||
|
|
||||||
this->mengerLevel--;
|
this->mengerLevel--;
|
||||||
|
|
||||||
// We know here the number of Menger volume: 20^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(markVols);
|
||||||
(scene.lcc)->free_mark(markVertices);
|
(scene.lcc)->free_mark(markVertices);
|
||||||
|
|
||||||
|
#ifdef CGAL_PROFILE_LCC_DEMO
|
||||||
|
timer.stop();
|
||||||
|
std::cout<<"Time to decrease the level of menger sponge ("
|
||||||
|
<<this->mengerLevel<<" -> "<<this->mengerLevel+1<<"): "
|
||||||
|
<<timer.time()<<" seconds."<<std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
recreate_whole_volume_list();
|
recreate_whole_volume_list();
|
||||||
|
|
||||||
statusBar ()->showMessage (QString ("Menger Dec"),DELAY_STATUSMSG);
|
statusBar ()->showMessage (QString ("Menger Dec"),DELAY_STATUSMSG);
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,6 @@ protected:
|
||||||
int markVols);
|
int markVols);
|
||||||
|
|
||||||
Scene scene;
|
Scene scene;
|
||||||
Timer timer;
|
|
||||||
|
|
||||||
unsigned int nbcube;
|
unsigned int nbcube;
|
||||||
QLabel* statusMessage;
|
QLabel* statusMessage;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue