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(
SET( PLUGIN_SRC
${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
${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
${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 )
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ComputeNormalsDialog</class>
<widget class="QDialog" name="ComputeNormalsDialog">
<class>ComputeNormalDialog</class>
<widget class="QDialog" name="ComputeNormalDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>228</height>
<width>447</width>
<height>311</height>
</rect>
</property>
<property name="windowTitle">
<string>Compute Normals</string>
<string>Compute Normal</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="mapList"/>
</item>
......@@ -29,7 +29,7 @@
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -39,27 +39,53 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<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>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Normal attribute</string>
</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>
</item>
<item>
......@@ -94,7 +120,7 @@
<connection>
<sender>button_ok</sender>
<signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver>
<receiver>ComputeNormalDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
......@@ -110,7 +136,7 @@
<connection>
<sender>button_cancel</sender>
<signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver>
<receiver>ComputeNormalDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
......
#ifndef _COMPUTENORMALS_DIALOG_H_
#define _COMPUTENORMALS_DIALOG_H_
#ifndef _COMPUTENORMAL_DIALOG_H_
#define _COMPUTENORMAL_DIALOG_H_
#include "ui_computeNormalsDialog.h"
#include "ui_computeNormalDialog.h"
namespace CGoGN
{
......@@ -11,12 +11,12 @@ namespace SCHNApps
class Window;
class ComputeNormalsDialog : public QDialog, public Ui::ComputeNormalsDialog
class ComputeNormalDialog : public QDialog, public Ui::ComputeNormalDialog
{
Q_OBJECT
public:
ComputeNormalsDialog(Window* w);
ComputeNormalDialog(Window* w);
void init();
public slots:
......
......@@ -3,7 +3,8 @@
#include "plugin.h"
#include "computeNormalsDialog.h"
#include "computeNormalDialog.h"
#include "computeCurvatureDialog.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
......@@ -21,6 +22,7 @@ struct PFP: public PFP_STANDARD
};
typedef PFP::MAP MAP;
typedef PFP::REAL REAL;
typedef PFP::VEC3 VEC3;
......@@ -58,13 +60,17 @@ public:
virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
public slots:
void cb_openComputeNormalsDialog();
void cb_computeNormals();
void cb_openComputeNormalDialog();
void cb_openComputeCurvatureDialog();
void cb_computeNormal();
void cb_computeCurvature();
private:
ComputeNormalsDialog* m_computeNormalsDialog;
ComputeNormalDialog* m_computeNormalDialog;
ComputeCurvatureDialog* m_computeCurvatureDialog;
QAction* computeNormalsAction;
QAction* computeNormalAction;
QAction* computeCurvatureAction;
};
......
#include "computeNormalsDialog.h"
#include "computeNormalDialog.h"
#include "differentialProperties.h"
#include "window.h"
......@@ -10,28 +10,30 @@ namespace CGoGN
namespace SCHNApps
{
ComputeNormalsDialog::ComputeNormalsDialog(Window* w) : m_window(w)
ComputeNormalDialog::ComputeNormalDialog(Window* w) : m_window(w)
{
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
}
void ComputeNormalsDialog::init()
void ComputeNormalDialog::init()
{
mapList->clear();
combo_positionAttribute->clear();
combo_normalAttribute->clear();
attributeName->setText("normal");
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
}
void ComputeNormalsDialog::cb_selectedMapChanged()
void ComputeNormalDialog::cb_selectedMapChanged()
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute->clear();
combo_normalAttribute->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname);
GenericMap* map = mh->getGenericMap();
......@@ -48,8 +50,13 @@ void ComputeNormalsDialog::cb_selectedMapChanged()
if(types[i] == vec3TypeName)
{
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_normalAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "normal") // try to select a normal attribute named "normal"
combo_normalAttribute->setCurrentIndex(j);
++j;
}
}
......
......@@ -7,40 +7,54 @@
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);
addMenuAction("Surface;Differential Properties;Compute Normals", computeNormalsAction);
addMenuAction("Surface;Differential Properties;Compute Normal", computeNormalAction);
addMenuAction("Surface;Differential Properties;Compute Curvature", computeCurvatureAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(computeNormalAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalDialog()));
connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeCurvatureDialog()));
connect(m_computeNormalsDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormals()));
connect(m_computeNormalsDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeNormals()));
connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormal()));
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;
}
void DifferentialPropertiesPlugin::cb_openComputeNormalsDialog()
void DifferentialPropertiesPlugin::cb_openComputeNormalDialog()
{
m_computeNormalDialog->init();
m_computeNormalDialog->show();
}
void DifferentialPropertiesPlugin::cb_openComputeCurvatureDialog()
{
m_computeNormalsDialog->init();
m_computeNormalsDialog->show();
m_computeCurvatureDialog->init();
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())
{
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_computeNormalsDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeNormalsDialog->attributeName->text().toUtf8().constData();
std::string positionName = m_computeNormalDialog->combo_positionAttribute->currentText().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> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid())
......@@ -48,7 +62,72 @@ void DifferentialPropertiesPlugin::cb_computeNormals()
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);
QList<View*> views = m_window->getViewsList();
......
......@@ -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
/********************************************************/
......
......@@ -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 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 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 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 short int& v) { return "unsigned short int"; }
template <> inline std::string nameOfType(const unsigned short& v) { return "unsigned short"; }
template <> inline std::string nameOfType(const unsigned int& v) { return "unsigned int"; }
template <> inline std::string nameOfType(const unsigned long int& v) { return "unsigned long int"; }
template <> inline std::string nameOfType(const unsigned long& v) { return "unsigned long"; }
template <> inline std::string nameOfType(const unsigned long long& v) { return "unsigned long long"; }
template <> inline std::string nameOfType(const float& v) { return "float"; }
......
......@@ -46,15 +46,18 @@ GenericMap::GenericMap() : m_nbThreads(1)
registerAttribute<Dart>("Dart");
registerAttribute<Mark>("Mark");
registerAttribute<long>("long");
registerAttribute<int>("int");
registerAttribute<short>("short");
registerAttribute<char>("char");
registerAttribute<short>("short");
registerAttribute<int>("int");
registerAttribute<long>("long");
registerAttribute<unsigned long>("unsigned long");
registerAttribute<unsigned int>("unsigned int");
registerAttribute<unsigned short>("unsigned short");
registerAttribute<unsigned char>("unsigned char");
registerAttribute<unsigned short>("unsigned short");
registerAttribute<unsigned int>("unsigned int");
registerAttribute<unsigned long>("unsigned long");
registerAttribute<float>("float");
registerAttribute<double>("double");
registerAttribute<Geom::Vec2f>(Geom::Vec2f::CGoGNnameOfType());
registerAttribute<Geom::Vec3f>(Geom::Vec3f::CGoGNnameOfType());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment