Add inversion of normals

This commit is contained in:
Andreas Fabri 2010-06-11 13:55:14 +00:00
parent 86ed389470
commit 55caf376ab
2 changed files with 221 additions and 178 deletions

View File

@ -1,7 +1,8 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,18 +10,19 @@
<height>578</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>CGAL Point Set demo</string>
</property>
<property name="windowIcon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/resources/cgal_logo.xpm</iconset>
<property name="windowIcon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/resources/cgal_logo.xpm</normaloff>:/cgal/icons/resources/cgal_logo.xpm</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" >
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout">
<item>
<widget class="Viewer" native="1" name="viewer" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<widget class="Viewer" name="viewer" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
@ -28,140 +30,144 @@
</widget>
</item>
<item>
<widget class="QLabel" name="infoLabel" />
<widget class="QLabel" name="infoLabel"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>636</width>
<height>27</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
<property name="title" >
<widget class="QMenu" name="menuFile">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionFileOpen" />
<addaction name="actionFileClose" />
<addaction name="actionFileCloseAll" />
<addaction name="actionSaveAs" />
<addaction name="separator" />
<addaction name="actionQuit" />
<addaction name="actionFileOpen"/>
<addaction name="actionFileClose"/>
<addaction name="actionFileCloseAll"/>
<addaction name="actionSaveAs"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuEdit" >
<property name="title" >
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>&amp;Edit</string>
</property>
<addaction name="actionShowHide" />
<addaction name="actionDuplicate" />
<addaction name="separator" />
<addaction name="actionDeleteSelection" />
<addaction name="actionResetSelection" />
<addaction name="separator" />
<addaction name="actionConvertToPointSet" />
<addaction name="actionShowHide"/>
<addaction name="actionDuplicate"/>
<addaction name="separator"/>
<addaction name="actionDeleteSelection"/>
<addaction name="actionResetSelection"/>
<addaction name="separator"/>
<addaction name="actionConvertToPointSet"/>
</widget>
<widget class="QMenu" name="menuView" >
<property name="title" >
<widget class="QMenu" name="menuView">
<property name="title">
<string>&amp;View</string>
</property>
<widget class="QMenu" name="menuDockWindows" >
<property name="title" >
<widget class="QMenu" name="menuDockWindows">
<property name="title">
<string>Dock windows</string>
</property>
<addaction name="dummyAction" />
<addaction name="dummyAction"/>
</widget>
<addaction name="actionAntiAliasing" />
<addaction name="actionDraw_two_sides" />
<addaction name="menuDockWindows" />
<addaction name="actionAntiAliasing"/>
<addaction name="actionDraw_two_sides"/>
<addaction name="menuDockWindows"/>
</widget>
<widget class="QMenu" name="menuAnalysis" >
<property name="title" >
<widget class="QMenu" name="menuAnalysis">
<property name="title">
<string>Analysis</string>
</property>
<addaction name="actionAverageSpacing" />
<addaction name="actionRadiusFromDensity" />
<addaction name="actionAverageSpacing"/>
<addaction name="actionRadiusFromDensity"/>
</widget>
<widget class="QMenu" name="menuProcessing" >
<property name="title" >
<widget class="QMenu" name="menuProcessing">
<property name="title">
<string>Processing</string>
</property>
<addaction name="actionSimplify" />
<addaction name="actionOutlierRemoval" />
<addaction name="actionJetSmoothing" />
<addaction name="actionNormalEstimation" />
<addaction name="actionSimplify"/>
<addaction name="actionOutlierRemoval"/>
<addaction name="actionJetSmoothing"/>
<addaction name="actionNormalEstimation"/>
<addaction name="actionNormalInversion"/>
</widget>
<widget class="QMenu" name="menuReconstruction" >
<property name="title" >
<widget class="QMenu" name="menuReconstruction">
<property name="title">
<string>Reconstruction</string>
</property>
<addaction name="actionPoissonReconstruction" />
<addaction name="actionAPSSReconstruction" />
<addaction name="actionInsideOut" />
<addaction name="actionPoissonReconstruction"/>
<addaction name="actionAPSSReconstruction"/>
<addaction name="actionInsideOut"/>
</widget>
<addaction name="menuFile" />
<addaction name="menuEdit" />
<addaction name="menuAnalysis" />
<addaction name="menuProcessing" />
<addaction name="menuReconstruction" />
<addaction name="menuView" />
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuAnalysis"/>
<addaction name="menuProcessing"/>
<addaction name="menuReconstruction"/>
<addaction name="menuView"/>
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QDockWidget" name="sceneDockWidget" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="sceneDockWidget">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Point sets and surfaces</string>
</property>
<attribute name="dockWidgetArea" >
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContent" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<widget class="QWidget" name="dockWidgetContent">
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout" >
<layout class="QHBoxLayout">
<item>
<widget class="QToolButton" name="addButton" >
<property name="text" >
<widget class="QToolButton" name="addButton">
<property name="text">
<string>+</string>
</property>
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/plus</iconset>
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/plus</normaloff>:/cgal/icons/plus</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeButton" >
<property name="text" >
<widget class="QToolButton" name="removeButton">
<property name="text">
<string>-</string>
</property>
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/minus</iconset>
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/minus</normaloff>:/cgal/icons/minus</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="duplicateButton" >
<property name="text" >
<widget class="QToolButton" name="duplicateButton">
<property name="text">
<string>...</string>
</property>
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/duplicate</iconset>
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/duplicate</normaloff>:/cgal/icons/duplicate</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
@ -172,14 +178,14 @@
</layout>
</item>
<item>
<widget class="QTreeView" name="treeView" >
<property name="editTriggers" >
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::NoEditTriggers|QAbstractItemView::SelectedClicked</set>
<widget class="QTreeView" name="treeView">
<property name="editTriggers">
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="alternatingRowColors" >
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="indentation" >
<property name="indentation">
<number>0</number>
</property>
</widget>
@ -189,21 +195,21 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="consoleDockWidget" >
<property name="allowedAreas" >
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::TopDockWidgetArea</set>
<widget class="QDockWidget" name="consoleDockWidget">
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Console</string>
</property>
<attribute name="dockWidgetArea" >
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents" >
<layout class="QVBoxLayout" >
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout">
<item>
<widget class="QTextEdit" name="consoleTextEdit" >
<property name="readOnly" >
<widget class="QTextEdit" name="consoleTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
@ -211,195 +217,203 @@
</layout>
</widget>
</widget>
<action name="actionQuit" >
<property name="text" >
<action name="actionQuit">
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionSimplify" >
<property name="text" >
<action name="actionSimplify">
<property name="text">
<string>&amp;Simplification</string>
</property>
</action>
<action name="actionFileOpen" >
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/plus</iconset>
<action name="actionFileOpen">
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/plus</normaloff>:/cgal/icons/plus</iconset>
</property>
<property name="text" >
<property name="text">
<string>&amp;Open...</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="actionFileClose" >
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/minus</iconset>
<action name="actionFileClose">
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/minus</normaloff>:/cgal/icons/minus</iconset>
</property>
<property name="text" >
<property name="text">
<string>&amp;Close</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+W</string>
</property>
</action>
<action name="actionDuplicate" >
<property name="icon" >
<iconset resource="Point_set_demo.qrc" >:/cgal/icons/duplicate</iconset>
<action name="actionDuplicate">
<property name="icon">
<iconset resource="Point_set_demo.qrc">
<normaloff>:/cgal/icons/duplicate</normaloff>:/cgal/icons/duplicate</iconset>
</property>
<property name="text" >
<property name="text">
<string>&amp;Duplicate</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="actionAntiAliasing" >
<property name="checkable" >
<action name="actionAntiAliasing">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text" >
<property name="text">
<string>&amp;Antialiasing</string>
</property>
</action>
<action name="dummyAction" >
<property name="text" >
<action name="dummyAction">
<property name="text">
<string>n/a</string>
</property>
</action>
<action name="actionFileCloseAll" >
<property name="text" >
<action name="actionFileCloseAll">
<property name="text">
<string>&amp;Close All</string>
</property>
</action>
<action name="actionOptions" >
<property name="text" >
<action name="actionOptions">
<property name="text">
<string>&amp;Options...</string>
</property>
</action>
<action name="actionSaveAs" >
<property name="text" >
<action name="actionSaveAs">
<property name="text">
<string>Save &amp;as...</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+Alt+S</string>
</property>
</action>
<action name="actionSave" >
<property name="text" >
<action name="actionSave">
<property name="text">
<string>&amp;Save</string>
</property>
</action>
<action name="actionSaveAll" >
<property name="text" >
<action name="actionSaveAll">
<property name="text">
<string>Save a&amp;ll</string>
</property>
</action>
<action name="actionMergeAll" >
<property name="text" >
<action name="actionMergeAll">
<property name="text">
<string>Mer&amp;ge all</string>
</property>
</action>
<action name="actionMerge" >
<property name="text" >
<action name="actionMerge">
<property name="text">
<string>&amp;Merge</string>
</property>
</action>
<action name="actionSelectAll" >
<property name="text" >
<action name="actionSelectAll">
<property name="text">
<string>Select &amp;all</string>
</property>
</action>
<action name="actionSelectNone" >
<property name="text" >
<action name="actionSelectNone">
<property name="text">
<string>Select &amp;none</string>
</property>
</action>
<action name="actionSelectInvert" >
<property name="text" >
<action name="actionSelectInvert">
<property name="text">
<string>&amp;Invert selection</string>
</property>
</action>
<action name="actionShowHide" >
<property name="text" >
<action name="actionShowHide">
<property name="text">
<string>Show/Hide</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Ctrl+Space</string>
</property>
</action>
<action name="actionInsideOut" >
<property name="text" >
<action name="actionInsideOut">
<property name="text">
<string>Inside-out</string>
</property>
</action>
<action name="actionAPSSReconstruction" >
<property name="text" >
<action name="actionAPSSReconstruction">
<property name="text">
<string>APSS Reconstruction</string>
</property>
</action>
<action name="actionRadiusFromDensity" >
<property name="text" >
<action name="actionRadiusFromDensity">
<property name="text">
<string>Point radius from density</string>
</property>
</action>
<action name="actionOutlierRemoval" >
<property name="text" >
<action name="actionOutlierRemoval">
<property name="text">
<string>Outlier removal</string>
</property>
</action>
<action name="actionJetSmoothing" >
<property name="text" >
<action name="actionJetSmoothing">
<property name="text">
<string>Jet smoothing</string>
</property>
</action>
<action name="actionNormalEstimation" >
<property name="text" >
<action name="actionNormalEstimation">
<property name="text">
<string>Normal estimation</string>
</property>
</action>
<action name="actionDraw_two_sides" >
<property name="checkable" >
<action name="actionDraw_two_sides">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text" >
<property name="text">
<string>Draw two sides</string>
</property>
</action>
<action name="actionConvertToPointSet" >
<property name="text" >
<action name="actionConvertToPointSet">
<property name="text">
<string>Convert to Point Set</string>
</property>
<property name="toolTip" >
<property name="toolTip">
<string>Convert Mesh to Point Set</string>
</property>
</action>
<action name="actionDeleteSelection" >
<property name="text" >
<action name="actionDeleteSelection">
<property name="text">
<string>Delete Selection</string>
</property>
<property name="shortcut" >
<property name="shortcut">
<string>Del</string>
</property>
</action>
<action name="actionResetSelection" >
<property name="text" >
<action name="actionResetSelection">
<property name="text">
<string>Reset Selection</string>
</property>
</action>
<action name="actionPoissonReconstruction" >
<property name="text" >
<action name="actionPoissonReconstruction">
<property name="text">
<string>Poisson reconstruction</string>
</property>
</action>
<action name="actionAverageSpacing" >
<property name="text" >
<action name="actionAverageSpacing">
<property name="text">
<string>Average spacing</string>
</property>
</action>
<action name="actionNormalInversion">
<property name="text">
<string>Normal inversion</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -409,7 +423,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="Point_set_demo.qrc" />
<include location="Point_set_demo.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -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<QAction*> actions() const {
return QList<QAction*>() << actionNormalEstimation;
return QList<QAction*>() << 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<Point_set_scene_item*>(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();