Commit e6f05a9c authored by Pierre Kraemer's avatar Pierre Kraemer

update some nameOfType + SCHNApps: differential properties plugin

parent 7e9a2472
...@@ -8,16 +8,19 @@ INCLUDE_DIRECTORIES( ...@@ -8,16 +8,19 @@ INCLUDE_DIRECTORIES(
SET( PLUGIN_SRC SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/differentialProperties.cpp ${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/differentialProperties.cpp
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/computeNormalsDialog.cpp ${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/computeNormalDialog.cpp
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/computeCurvatureDialog.cpp
) )
SET( PLUGIN_H SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/differentialProperties.h ${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/differentialProperties.h
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/computeNormalsDialog.h ${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/computeNormalDialog.h
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/computeCurvatureDialog.h
) )
SET( PLUGIN_FORM SET( PLUGIN_FORM
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/forms/computeNormalsDialog.ui ${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/forms/computeNormalDialog.ui
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/forms/computeCurvatureDialog.ui
) )
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ComputeNormalsDialog</class> <class>ComputeNormalDialog</class>
<widget class="QDialog" name="ComputeNormalsDialog"> <widget class="QDialog" name="ComputeNormalDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>287</width> <width>447</width>
<height>228</height> <height>311</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Compute Normals</string> <string>Compute Normal</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QListWidget" name="mapList"/> <widget class="QListWidget" name="mapList"/>
</item> </item>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<item> <item>
<widget class="QComboBox" name="combo_positionAttribute"> <widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -39,27 +39,53 @@ ...@@ -39,27 +39,53 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QGroupBox" name="groupBox">
<item> <property name="title">
<widget class="QLabel" name="label"> <string>Normal attribute</string>
<property name="text">
<string>Normal attribute name :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="attributeName"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_createVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_normalAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>New attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="attributeName"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_createVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
...@@ -94,7 +120,7 @@ ...@@ -94,7 +120,7 @@
<connection> <connection>
<sender>button_ok</sender> <sender>button_ok</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver> <receiver>ComputeNormalDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
...@@ -110,7 +136,7 @@ ...@@ -110,7 +136,7 @@
<connection> <connection>
<sender>button_cancel</sender> <sender>button_cancel</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver> <receiver>ComputeNormalDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
......
#ifndef _COMPUTENORMALS_DIALOG_H_ #ifndef _COMPUTENORMAL_DIALOG_H_
#define _COMPUTENORMALS_DIALOG_H_ #define _COMPUTENORMAL_DIALOG_H_
#include "ui_computeNormalsDialog.h" #include "ui_computeNormalDialog.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -11,12 +11,12 @@ namespace SCHNApps ...@@ -11,12 +11,12 @@ namespace SCHNApps
class Window; class Window;
class ComputeNormalsDialog : public QDialog, public Ui::ComputeNormalsDialog class ComputeNormalDialog : public QDialog, public Ui::ComputeNormalDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
ComputeNormalsDialog(Window* w); ComputeNormalDialog(Window* w);
void init(); void init();
public slots: public slots:
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
#include "plugin.h" #include "plugin.h"
#include "computeNormalsDialog.h" #include "computeNormalDialog.h"
#include "computeCurvatureDialog.h"
#include "Topology/generic/functor.h" #include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
...@@ -21,6 +22,7 @@ struct PFP: public PFP_STANDARD ...@@ -21,6 +22,7 @@ struct PFP: public PFP_STANDARD
}; };
typedef PFP::MAP MAP; typedef PFP::MAP MAP;
typedef PFP::REAL REAL;
typedef PFP::VEC3 VEC3; typedef PFP::VEC3 VEC3;
...@@ -58,13 +60,17 @@ public: ...@@ -58,13 +60,17 @@ public:
virtual void mapUnlinked(View* view, MapHandlerGen* m) {} virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
public slots: public slots:
void cb_openComputeNormalsDialog(); void cb_openComputeNormalDialog();
void cb_computeNormals(); void cb_openComputeCurvatureDialog();
void cb_computeNormal();
void cb_computeCurvature();
private: private:
ComputeNormalsDialog* m_computeNormalsDialog; ComputeNormalDialog* m_computeNormalDialog;
ComputeCurvatureDialog* m_computeCurvatureDialog;
QAction* computeNormalsAction; QAction* computeNormalAction;
QAction* computeCurvatureAction; QAction* computeCurvatureAction;
}; };
......
#include "computeNormalsDialog.h" #include "computeNormalDialog.h"
#include "differentialProperties.h" #include "differentialProperties.h"
#include "window.h" #include "window.h"
...@@ -10,28 +10,30 @@ namespace CGoGN ...@@ -10,28 +10,30 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
ComputeNormalsDialog::ComputeNormalsDialog(Window* w) : m_window(w) ComputeNormalDialog::ComputeNormalDialog(Window* w) : m_window(w)
{ {
setupUi(this); setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged())); connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
} }
void ComputeNormalsDialog::init() void ComputeNormalDialog::init()
{ {
mapList->clear(); mapList->clear();
combo_positionAttribute->clear(); combo_positionAttribute->clear();
combo_normalAttribute->clear();
attributeName->setText("normal"); attributeName->setText("normal");
const QList<MapHandlerGen*>& maps = m_window->getMapsList(); const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps) foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName()); mapList->addItem(map->getName());
} }
void ComputeNormalsDialog::cb_selectedMapChanged() void ComputeNormalDialog::cb_selectedMapChanged()
{ {
QList<QListWidgetItem*> currentItems = mapList->selectedItems(); QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
combo_positionAttribute->clear(); combo_positionAttribute->clear();
combo_normalAttribute->clear();
const QString& mapname = currentItems[0]->text(); const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname); MapHandlerGen* mh = m_window->getMap(mapname);
GenericMap* map = mh->getGenericMap(); GenericMap* map = mh->getGenericMap();
...@@ -48,8 +50,13 @@ void ComputeNormalsDialog::cb_selectedMapChanged() ...@@ -48,8 +50,13 @@ void ComputeNormalsDialog::cb_selectedMapChanged()
if(types[i] == vec3TypeName) if(types[i] == vec3TypeName)
{ {
combo_positionAttribute->addItem(QString::fromStdString(names[i])); combo_positionAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "position") // try to select an attribute named "position" if(names[i] == "position") // try to select a position attribute named "position"
combo_positionAttribute->setCurrentIndex(j); combo_positionAttribute->setCurrentIndex(j);
combo_normalAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->setCurrentIndex(j);
++j; ++j;
} }
} }
......
...@@ -7,40 +7,54 @@ ...@@ -7,40 +7,54 @@
bool DifferentialPropertiesPlugin::enable() bool DifferentialPropertiesPlugin::enable()
{ {
m_computeNormalsDialog = new ComputeNormalsDialog(m_window); m_computeNormalDialog = new ComputeNormalDialog(m_window);
m_computeCurvatureDialog = new ComputeCurvatureDialog(m_window);
computeNormalsAction = new QAction("Compute Normals", this); computeNormalAction = new QAction("Compute Normal", this);
computeCurvatureAction = new QAction("Compute Curvature", this); computeCurvatureAction = new QAction("Compute Curvature", this);
addMenuAction("Surface;Differential Properties;Compute Normals", computeNormalsAction); addMenuAction("Surface;Differential Properties;Compute Normal", computeNormalAction);
addMenuAction("Surface;Differential Properties;Compute Curvature", computeCurvatureAction); addMenuAction("Surface;Differential Properties;Compute Curvature", computeCurvatureAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog())); connect(computeNormalAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalDialog()));
connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog())); connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeCurvatureDialog()));
connect(m_computeNormalsDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormals())); connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormal()));
connect(m_computeNormalsDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeNormals())); connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeNormal()));
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(cb_computeCurvature()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeCurvature()));
return true; return true;
} }
void DifferentialPropertiesPlugin::cb_openComputeNormalsDialog() void DifferentialPropertiesPlugin::cb_openComputeNormalDialog()
{
m_computeNormalDialog->init();
m_computeNormalDialog->show();
}
void DifferentialPropertiesPlugin::cb_openComputeCurvatureDialog()
{ {
m_computeNormalsDialog->init(); m_computeCurvatureDialog->init();
m_computeNormalsDialog->show(); m_computeCurvatureDialog->show();
} }
void DifferentialPropertiesPlugin::cb_computeNormals() void DifferentialPropertiesPlugin::cb_computeNormal()
{ {
QList<QListWidgetItem*> currentItems = m_computeNormalsDialog->mapList->selectedItems(); QList<QListWidgetItem*> currentItems = m_computeNormalDialog->mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
const QString& mapname = currentItems[0]->text(); const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname)); MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap(); MAP* map = mh->getMap();
std::string positionName = m_computeNormalsDialog->combo_positionAttribute->currentText().toUtf8().constData(); std::string positionName = m_computeNormalDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeNormalsDialog->attributeName->text().toUtf8().constData(); std::string normalName;
if(m_computeNormalDialog->attributeName->text().isEmpty())
normalName = m_computeNormalDialog->combo_normalAttribute->currentText().toUtf8().constData();
else
normalName = m_computeNormalDialog->attributeName->text().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName); VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName); VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid()) if(!normal.isValid())
...@@ -48,7 +62,72 @@ void DifferentialPropertiesPlugin::cb_computeNormals() ...@@ -48,7 +62,72 @@ void DifferentialPropertiesPlugin::cb_computeNormals()
Algo::Geometry::computeNormalVertices<PFP>(*map, position, normal); Algo::Geometry::computeNormalVertices<PFP>(*map, position, normal);
if(m_computeNormalsDialog->check_createVBO->checkState() == Qt::Checked) if(m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
{
if(view->isLinkedToMap(mh))
view->updateGL();
}
}
}
void DifferentialPropertiesPlugin::cb_computeCurvature()
{
QList<QListWidgetItem*> currentItems = m_computeCurvatureDialog->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_computeCurvatureDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeCurvatureDialog->combo_normalAttribute->currentText().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
std::string KmaxName;
if(m_computeCurvatureDialog->KmaxAttributeName->text().isEmpty())
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText().toUtf8().constData();
else
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> Kmax = map->getAttribute<VEC3, VERTEX>(KmaxName);
if(!Kmax.isValid())
Kmax = map->addAttribute<VEC3, VERTEX>(KmaxName);
std::string KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText().toUtf8().constData();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text().toUtf8().constData();
VertexAttribute<VEC3> Kmin = map->getAttribute<VEC3, VERTEX>(KminName);
if(!Kmin.isValid())
Kmin = map->addAttribute<VEC3, VERTEX>(KminName);
std::string kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText().toUtf8().constData();
else
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text().toUtf8().constData();
VertexAttribute<REAL> kmax = map->getAttribute<REAL, VERTEX>(kmaxName);
if(!kmax.isValid())
kmax = map->addAttribute<REAL, VERTEX>(kmaxName);
std::string kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText().toUtf8().constData();
else
kminName = m_computeCurvatureDialog->kminAttributeName->text().toUtf8().constData();
VertexAttribute<REAL> kmin = map->getAttribute<REAL, VERTEX>(kminName);
if(!kmin.isValid())
kmin = map->addAttribute<REAL, VERTEX>(kminName);
Algo::Geometry::computeCurvatureVertices_NormalCycles<PFP>(*map, position, normal);
if(m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal); mh->createVBO(normal);
QList<View*> views = m_window->getViewsList(); QList<View*> views = m_window->getViewsList();
......
...@@ -198,51 +198,6 @@ public: ...@@ -198,51 +198,6 @@ public:
}; };
//
//class SelectorDartMarked : public FunctorSelect
//{
//public:
//protected:
// const DartMarker& m_dm;
//public:
// SelectorDartMarked(const DartMarker& dm): m_dm(dm) {}
// bool operator()(Dart d) const { return m_dm.isMarked(d); }
//};
//
//
//class SelectorCellMarked : public FunctorSelect
//{
//public:
//protected:
// const CellMarker& m_cm;
//public:
// SelectorCellMarked(const CellMarker& cm): m_cm(cm) {}
// bool operator()(Dart d) const { return m_cm.isMarked(d); }
//};
//
//class SelectorDartNotMarked : public FunctorSelect
//{
//public:
//protected:
// const DartMarker& m_dm;
//public:
// SelectorDartNotMarked(const DartMarker& dm): m_dm(dm) {}
// bool operator()(Dart d) const { return !m_dm.isMarked(d); }
//};
//
//
//template <typename MAP>
//class SelectorCellNotMarked : public FunctorSelect
//{
//public:
//protected:
// const CellMarker& m_cm;
//public:
// SelectorCellNotMarked(const CellMarker& cm): m_cm(cm) {}
// bool operator()(Dart d) const { return !m_cm.isMarked(d); }
//};
// Counting Functors : increment its value every time it is applied // Counting Functors : increment its value every time it is applied
/********************************************************/ /********************************************************/
......
...@@ -40,23 +40,23 @@ std::string nameOfType(const T& v) ...@@ -40,23 +40,23 @@ std::string nameOfType(const T& v)
template <> inline std::string nameOfType(const char& v) { return "char"; } template <> inline std::string nameOfType(const char& v) { return "char"; }
template <> inline std::string nameOfType(const short int& v) { return "short int"; } template <> inline std::string nameOfType(const short& v) { return "short"; }
template <> inline std::string nameOfType(const int& v) { return "int"; } template <> inline std::string nameOfType(const int& v) { return "int"; }
template <> inline std::string nameOfType(const long int& v) { return "long int"; } template <> inline std::string nameOfType(const long& v) { return "long"; }
template <> inline std::string nameOfType(const long long& v) { return "long long"; } template <> inline std::string nameOfType(const long long& v) { return "long long"; }
template <> inline std::string nameOfType(const unsigned long long& v) { return "long long"; }
template <> inline std::string nameOfType(const unsigned char& v) { return "unsigned char"; } template <> inline std::string nameOfType(const unsigned char& v) { return "unsigned char"; }