simplification: added timer and output

This commit is contained in:
Pierre Alliez 2008-07-16 14:02:22 +00:00
parent 6ee113f820
commit 1a4079f2f8
3 changed files with 16 additions and 12 deletions

View File

@ -15,34 +15,35 @@ void MainWindow::on_actionSimplify_triggered()
int index = getSelectedPolygonIndex();
Polyhedron* pMesh = scene->polyhedron(index);
// simplify
// get option (#edges)
bool ok;
const unsigned int nb_edges =
QInputDialog::getInteger(this, tr("Stop condition"),
tr("Number of edges:"),
pMesh->size_of_halfedges () / 4,
// current value: nb of edges /2
10, // min
3, // min
pMesh->size_of_halfedges(), // max
1, // step for the spinbox
&ok);
if(!ok) return;
1000; // TODO: should be an option
namespace SMS = CGAL::Surface_mesh_simplification;
// wait cursor
// simplify
QTime time;
time.start();
std::cout << "Simplify...";
QApplication::setOverrideCursor(Qt::WaitCursor);
namespace SMS = CGAL::Surface_mesh_simplification;
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)));
std::cout << "ok (" << time.elapsed() << " ms, "
<< pMesh->size_of_halfedges() / 2 << " edges)" << std::endl;
// update scene
scene->polyhedronChanged(index);
// default cursor
QApplication::restoreOverrideCursor();
}
}

View File

@ -8,7 +8,7 @@ void MainWindow::on_actionLoop_triggered()
{
Polyhedron* poly = getSelectedPolygon();
if(!poly) return;
CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
//CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
scene->polyhedronChanged(poly);
}
@ -16,7 +16,7 @@ void MainWindow::on_actionCatmullClark_triggered()
{
Polyhedron* poly = getSelectedPolygon();
if(!poly) return;
CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
//CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
scene->polyhedronChanged(poly);
}
@ -24,7 +24,7 @@ void MainWindow::on_actionSqrt3_triggered()
{
Polyhedron* poly = getSelectedPolygon();
if(!poly) return;
CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
//CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
scene->polyhedronChanged(poly);
}

View File

@ -75,9 +75,12 @@ Scene::open(QString filename)
QApplication::restoreOverrideCursor();
cerr << QString("\n");
destroy(poly);
delete poly;
return -1;
}
cerr << QString("ok\n");
addPolyhedron(poly, fileinfo.baseName());
QApplication::restoreOverrideCursor();