From 55caf376ab464778ff51dab6f08e009f50e66507 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 11 Jun 2010 13:55:14 +0000 Subject: [PATCH] Add inversion of normals --- .../MainWindow.ui | 368 +++++++++--------- .../PS_demo_normal_estimation_plugin.cpp | 31 +- 2 files changed, 221 insertions(+), 178 deletions(-) diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/MainWindow.ui b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/MainWindow.ui index 886cd8d185d..fe03e0b5096 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/MainWindow.ui +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/MainWindow.ui @@ -1,7 +1,8 @@ - + + MainWindow - - + + 0 0 @@ -9,18 +10,19 @@ 578 - + CGAL Point Set demo - - :/cgal/icons/resources/cgal_logo.xpm + + + :/cgal/icons/resources/cgal_logo.xpm:/cgal/icons/resources/cgal_logo.xpm - - + + - - - + + + 0 1 @@ -28,140 +30,144 @@ - + - - + + 0 0 636 - 27 + 26 - - + + &File - - - - - - + + + + + + - - + + &Edit - - - - - - - + + + + + + + - - + + &View - - + + Dock windows - + - - - + + + - - + + Analysis - - + + - - + + Processing - - - - + + + + + - - + + Reconstruction - - - + + + - - - - - - + + + + + + - - - - + + + + - + Point sets and surfaces - + 1 - - - - + + + + - + - - + + + - - :/cgal/icons/plus + + + :/cgal/icons/plus:/cgal/icons/plus - - + + - - - :/cgal/icons/minus + + + :/cgal/icons/minus:/cgal/icons/minus - - + + ... - - :/cgal/icons/duplicate + + + :/cgal/icons/duplicate:/cgal/icons/duplicate - + Qt::Horizontal - + 40 20 @@ -172,14 +178,14 @@ - - - QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::NoEditTriggers|QAbstractItemView::SelectedClicked + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - + true - + 0 @@ -189,21 +195,21 @@ - - - Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::TopDockWidgetArea + + + Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::TopDockWidgetArea - + Console - + 8 - - + + - - + + true @@ -211,195 +217,203 @@ - - + + &Quit - + Ctrl+Q - - + + &Simplification - - - :/cgal/icons/plus + + + + :/cgal/icons/plus:/cgal/icons/plus - + &Open... - + Ctrl+O - - - :/cgal/icons/minus + + + + :/cgal/icons/minus:/cgal/icons/minus - + &Close - + Ctrl+W - - - :/cgal/icons/duplicate + + + + :/cgal/icons/duplicate:/cgal/icons/duplicate - + &Duplicate - + Ctrl+D - - + + true - + &Antialiasing - - + + n/a - - + + &Close All - - + + &Options... - - + + Save &as... - + Ctrl+Alt+S - - + + &Save - - + + Save a&ll - - + + Mer&ge all - - + + &Merge - - + + Select &all - - + + Select &none - - + + &Invert selection - - + + Show/Hide - + Ctrl+Space - - + + Inside-out - - + + APSS Reconstruction - - + + Point radius from density - - + + Outlier removal - - + + Jet smoothing - - + + Normal estimation - - + + true - + Draw two sides - - + + Convert to Point Set - + Convert Mesh to Point Set - - + + Delete Selection - + Del - - + + Reset Selection - - + + Poisson reconstruction - - + + Average spacing + + + Normal inversion + + @@ -409,7 +423,7 @@ - + diff --git a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp index 8d2dd8f7011..1f14f56f7d7 100644 --- a/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp +++ b/Surface_reconstruction_points_3/demo/Surface_reconstruction_points_3/PS_demo_normal_estimation_plugin.cpp @@ -26,6 +26,7 @@ class PS_demo_normal_estimation_plugin : Q_OBJECT Q_INTERFACES(Polyhedron_demo_plugin_interface) QAction* actionNormalEstimation; + QAction* actionNormalInversion; public: void init(QMainWindow* mainWindow, Scene_interface* scene_interface) { @@ -36,14 +37,21 @@ public: connect(actionNormalEstimation, SIGNAL(triggered()), this, SLOT(on_actionNormalEstimation_triggered())); } + + actionNormalInversion = this->getActionFromMainWindow(mw, "actionNormalInversion"); + if(actionNormalInversion) { + connect(actionNormalInversion, SIGNAL(triggered()), + this, SLOT(on_actionNormalInversion_triggered())); + } } QList actions() const { - return QList() << actionNormalEstimation; + return QList() << actionNormalEstimation << actionNormalInversion; } public slots: void on_actionNormalEstimation_triggered(); + void on_actionNormalInversion_triggered(); }; // end PS_demo_smoothing_plugin @@ -63,6 +71,27 @@ class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::Norm int orientationNbNeighbors() const { return m_inputNbNeighborsOrientation->value(); } }; + +void PS_demo_normal_estimation_plugin::on_actionNormalInversion_triggered() +{ + const Scene_interface::Item_id index = scene->mainSelectionIndex(); + + Point_set_scene_item* item = + qobject_cast(scene->item(index)); + + if(item) + { + // Gets point set + Point_set* points = item->point_set(); + if(points == NULL) + return; + + for(Point_set::iterator it = points->begin(); it != points->end(); ++it){ + it->normal() = -1 * it->normal(); + } + } +} + void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered() { const Scene_interface::Item_id index = scene->mainSelectionIndex();