diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 1c573c0d911..cf14d711d34 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -2,7 +2,7 @@ include( polyhedron_demo_macros ) if(EIGEN3_FOUND) polyhedron_demo_plugin(jet_fitting_plugin Jet_fitting_plugin) - target_link_libraries(jet_fitting_plugin scene_polyhedron_item scene_polylines_item) + target_link_libraries(jet_fitting_plugin scene_polyhedron_item scene_surface_mesh_item scene_polylines_item) else(EIGEN3_FOUND) message(STATUS "NOTICE: Eigen 3.1 (or greater) was not found. Jet fitting plugin will not be available.") diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Jet_fitting_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Jet_fitting_plugin.cpp index da5b1cf26c4..26cb1212eed 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Jet_fitting_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Jet_fitting_plugin.cpp @@ -1,6 +1,7 @@ #include #include "Polyhedron_type.h" #include "Scene_polyhedron_item.h" +#include "Scene_surface_mesh_item.h" #include "Scene_polylines_item.h" #include @@ -39,7 +40,8 @@ public: } bool applicable(QAction*) const { - return qobject_cast(scene->item(scene->mainSelectionIndex())); + return qobject_cast(scene->item(scene->mainSelectionIndex())) || + qobject_cast(scene->item(scene->mainSelectionIndex())); } public Q_SLOTS: @@ -61,15 +63,14 @@ void compute(Poly* pMesh, typedef Kernel::Point_3 Point; - Polyhedron::Vertex_iterator v; - for(v = pMesh->vertices_begin(); - v != pMesh->vertices_end(); - v++) + typename boost::property_map::type vpmap = get(CGAL::vertex_point, *pMesh); + + BOOST_FOREACH(boost::graph_traits::vertex_descriptor v, vertices(*pMesh)) { std::vector points; // pick central point - const Point& central_point = v->point(); + const Point& central_point = get(vpmap,v); points.push_back(central_point); // compute min edge len around central vertex @@ -78,11 +79,9 @@ void compute(Poly* pMesh, typedef Kernel::FT FT; FT min_edge_len = std::numeric_limits::infinity(); - Polyhedron::Halfedge_around_vertex_circulator he = v->vertex_begin(); - Polyhedron::Halfedge_around_vertex_circulator end = he; - CGAL_For_all(he,end) + BOOST_FOREACH(boost::graph_traits::halfedge_descriptor he, halfedges_around_target(v, *pMesh)) { - const Point& p = he->opposite()->vertex()->point(); + const Point& p = get( vpmap, target(opposite(he, *pMesh ), *pMesh)); points.push_back(p); FT edge_len = std::sqrt(CGAL::squared_distance(central_point,p)); min_edge_len = edge_len < min_edge_len ? edge_len : min_edge_len; // avoids #undef min @@ -125,26 +124,33 @@ void Polyhedron_demo_jet_fitting_plugin::on_actionEstimateCurvature_triggered() { // get active polyhedron const CGAL::Three::Scene_interface::Item_id index = scene->mainSelectionIndex(); + QString name = scene->item(index)->name(); Scene_polyhedron_item* poly_item = qobject_cast(scene->item(index)); - if(!poly_item) + Scene_surface_mesh_item* sm_item = + qobject_cast(scene->item(index)); + if((!poly_item) && (! sm_item)){ return; - + } // wait cursor QApplication::setOverrideCursor(Qt::WaitCursor); - Polyhedron* pMesh = poly_item->polyhedron(); - // types Scene_polylines_item* max_curv = new Scene_polylines_item; max_curv->setColor(Qt::red); - max_curv->setName(tr("%1 (max curvatures)").arg(poly_item->name())); + max_curv->setName(tr("%1 (max curvatures)").arg(name)); Scene_polylines_item* min_curv = new Scene_polylines_item; min_curv->setColor(Qt::green); - min_curv->setName(tr("%1 (min curvatures)").arg(poly_item->name())); - - compute(pMesh,min_curv, max_curv); + min_curv->setName(tr("%1 (min curvatures)").arg(name)); + if(poly_item){ + Polyhedron* pMesh = poly_item->polyhedron(); + compute(pMesh, min_curv, max_curv); + } else { + + Scene_surface_mesh_item::SMesh* pMesh = sm_item->polyhedron(); + compute(pMesh, min_curv, max_curv); + } scene->addItem(max_curv); scene->addItem(min_curv); max_curv->invalidateOpenGLBuffers();