mirror of https://github.com/CGAL/cgal
simplification: added timer and output
This commit is contained in:
parent
6ee113f820
commit
1a4079f2f8
|
|
@ -15,34 +15,35 @@ void MainWindow::on_actionSimplify_triggered()
|
||||||
int index = getSelectedPolygonIndex();
|
int index = getSelectedPolygonIndex();
|
||||||
Polyhedron* pMesh = scene->polyhedron(index);
|
Polyhedron* pMesh = scene->polyhedron(index);
|
||||||
|
|
||||||
// simplify
|
// get option (#edges)
|
||||||
bool ok;
|
bool ok;
|
||||||
const unsigned int nb_edges =
|
const unsigned int nb_edges =
|
||||||
QInputDialog::getInteger(this, tr("Stop condition"),
|
QInputDialog::getInteger(this, tr("Stop condition"),
|
||||||
tr("Number of edges:"),
|
tr("Number of edges:"),
|
||||||
pMesh->size_of_halfedges () / 4,
|
pMesh->size_of_halfedges () / 4,
|
||||||
// current value: nb of edges /2
|
// current value: nb of edges /2
|
||||||
10, // min
|
3, // min
|
||||||
pMesh->size_of_halfedges(), // max
|
pMesh->size_of_halfedges(), // max
|
||||||
1, // step for the spinbox
|
1, // step for the spinbox
|
||||||
&ok);
|
&ok);
|
||||||
if(!ok) return;
|
if(!ok) return;
|
||||||
|
|
||||||
1000; // TODO: should be an option
|
// simplify
|
||||||
namespace SMS = CGAL::Surface_mesh_simplification;
|
QTime time;
|
||||||
|
time.start();
|
||||||
// wait cursor
|
std::cout << "Simplify...";
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
namespace SMS = CGAL::Surface_mesh_simplification;
|
||||||
SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges
|
SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges
|
||||||
SMS::edge_collapse( *pMesh, stop,
|
SMS::edge_collapse( *pMesh, stop,
|
||||||
CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh))
|
CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh))
|
||||||
.edge_index_map(boost::get(CGAL::edge_external_index,*pMesh)));
|
.edge_index_map(boost::get(CGAL::edge_external_index,*pMesh)));
|
||||||
|
|
||||||
|
std::cout << "ok (" << time.elapsed() << " ms, "
|
||||||
|
<< pMesh->size_of_halfedges() / 2 << " edges)" << std::endl;
|
||||||
|
|
||||||
// update scene
|
// update scene
|
||||||
scene->polyhedronChanged(index);
|
scene->polyhedronChanged(index);
|
||||||
|
|
||||||
// default cursor
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ void MainWindow::on_actionLoop_triggered()
|
||||||
{
|
{
|
||||||
Polyhedron* poly = getSelectedPolygon();
|
Polyhedron* poly = getSelectedPolygon();
|
||||||
if(!poly) return;
|
if(!poly) return;
|
||||||
CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
|
//CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
|
||||||
scene->polyhedronChanged(poly);
|
scene->polyhedronChanged(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ void MainWindow::on_actionCatmullClark_triggered()
|
||||||
{
|
{
|
||||||
Polyhedron* poly = getSelectedPolygon();
|
Polyhedron* poly = getSelectedPolygon();
|
||||||
if(!poly) return;
|
if(!poly) return;
|
||||||
CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
|
//CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
|
||||||
scene->polyhedronChanged(poly);
|
scene->polyhedronChanged(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ void MainWindow::on_actionSqrt3_triggered()
|
||||||
{
|
{
|
||||||
Polyhedron* poly = getSelectedPolygon();
|
Polyhedron* poly = getSelectedPolygon();
|
||||||
if(!poly) return;
|
if(!poly) return;
|
||||||
CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
|
//CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
|
||||||
scene->polyhedronChanged(poly);
|
scene->polyhedronChanged(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,12 @@ Scene::open(QString filename)
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
cerr << QString("\n");
|
cerr << QString("\n");
|
||||||
destroy(poly);
|
destroy(poly);
|
||||||
|
|
||||||
|
delete poly;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << QString("ok\n");
|
||||||
addPolyhedron(poly, fileinfo.baseName());
|
addPolyhedron(poly, fileinfo.baseName());
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue