void Polyhedron_demo_mesh_simplification_plugin::on_actionSimplify_triggered() { const CGAL::Three::Scene_interface::Item_id index = scene->mainSelectionIndex(); Scene_polyhedron_item* item = qobject_cast<Scene_polyhedron_item*>(scene->item(index)); if(item) { Polyhedron* pMesh = item->polyhedron(); // get option (#edges) bool ok; const int nb_edges = QInputDialog::getInt(mw, tr("Stop condition"), tr("Number of edges:"), (int)(pMesh->size_of_halfedges () / 4), // default value: current #edges / 2 3, // min = one triangle (int)pMesh->size_of_halfedges(), // max #edges 1, // step for the spinbox &ok); // check user cancellation if(!ok) return; // 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::parameters::vertex_index_map(get(CGAL::vertex_external_index,*pMesh)) .halfedge_index_map(get(CGAL::halfedge_external_index,*pMesh))); std::cout << "ok (" << time.elapsed() << " ms, " << pMesh->size_of_halfedges() / 2 << " edges)" << std::endl; // update scene item->invalidateOpenGLBuffers(); scene->itemChanged(index); QApplication::restoreOverrideCursor(); } }
void Polyhedron_demo_subdivision_methods_plugin::on_actionLoop_triggered() { CGAL::Three::Scene_interface::Item_id index = scene->mainSelectionIndex(); Scene_polyhedron_item* item = qobject_cast<Scene_polyhedron_item*>(scene->item(index)); if(!item) return; Polyhedron* poly = item->polyhedron(); QTime time; time.start(); std::cout << "Loop subdivision..."; QApplication::setOverrideCursor(Qt::WaitCursor); CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1); std::cout << "ok (" << time.elapsed() << " ms)" << std::endl; QApplication::restoreOverrideCursor(); item->invalidateOpenGLBuffers(); scene->itemChanged(item); }