mirror of https://github.com/CGAL/cgal
PMP: Make jet_fitting_plugin work for Surface_mesh
This commit is contained in:
parent
98f533d9c6
commit
8b1d00585e
|
|
@ -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.")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Three/Polyhedron_demo_plugin_interface.h>
|
||||
#include "Polyhedron_type.h"
|
||||
#include "Scene_polyhedron_item.h"
|
||||
#include "Scene_surface_mesh_item.h"
|
||||
#include "Scene_polylines_item.h"
|
||||
|
||||
#include <limits>
|
||||
|
|
@ -39,7 +40,8 @@ public:
|
|||
}
|
||||
|
||||
bool applicable(QAction*) const {
|
||||
return qobject_cast<Scene_polyhedron_item*>(scene->item(scene->mainSelectionIndex()));
|
||||
return qobject_cast<Scene_polyhedron_item*>(scene->item(scene->mainSelectionIndex())) ||
|
||||
qobject_cast<Scene_surface_mesh_item*>(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<Poly, CGAL::vertex_point_t>::type vpmap = get(CGAL::vertex_point, *pMesh);
|
||||
|
||||
BOOST_FOREACH(boost::graph_traits<Poly>::vertex_descriptor v, vertices(*pMesh))
|
||||
{
|
||||
std::vector<Point> 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<FT>::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<Poly>::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_polyhedron_item*>(scene->item(index));
|
||||
if(!poly_item)
|
||||
Scene_surface_mesh_item* sm_item =
|
||||
qobject_cast<Scene_surface_mesh_item*>(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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue