Commit e6fb3a99 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

add option to compute kmean & kgaussian from compute curvature function

parent 31961900
...@@ -6,19 +6,19 @@ ...@@ -6,19 +6,19 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>570</width> <width>568</width>
<height>452</height> <height>442</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Compute Curvature</string> <string>Compute Curvature</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QGridLayout" name="gridLayout_2">
<item> <item row="0" column="0">
<widget class="QListWidget" name="mapList"/> <widget class="QListWidget" name="mapList"/>
</item> </item>
<item> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
...@@ -61,26 +61,53 @@ ...@@ -61,26 +61,53 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="2" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Computed attributes</string> <string>Computed attributes</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Kmax :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item row="0" column="2"> <item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <widget class="QComboBox" name="combo_KmaxAttribute">
<item> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>New attribute :</string> <string>New attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="4">
<widget class="QLineEdit" name="KmaxAttributeName"/> <widget class="QLineEdit" name="KmaxAttributeName"/>
</item> </item>
</layout>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="label_10">
<property name="font"> <property name="font">
...@@ -96,15 +123,13 @@ ...@@ -96,15 +123,13 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
<property name="text"> <property name="text">
<string>Existing attribute :</string> <string>Existing attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="2">
<widget class="QComboBox" name="combo_kmaxAttribute"> <widget class="QComboBox" name="combo_kmaxAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -114,22 +139,16 @@ ...@@ -114,22 +139,16 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="3">
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>New attribute :</string> <string>New attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="4">
<widget class="QLineEdit" name="kmaxAttributeName"/> <widget class="QLineEdit" name="kmaxAttributeName"/>
</item> </item>
</layout>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="font"> <property name="font">
...@@ -145,15 +164,13 @@ ...@@ -145,15 +164,13 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Existing attribute :</string> <string>Existing attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="2">
<widget class="QComboBox" name="combo_KminAttribute"> <widget class="QComboBox" name="combo_KminAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -163,22 +180,16 @@ ...@@ -163,22 +180,16 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="3">
</item>
<item row="2" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>New attribute :</string> <string>New attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="4">
<widget class="QLineEdit" name="KminAttributeName"/> <widget class="QLineEdit" name="KminAttributeName"/>
</item> </item>
</layout>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
<property name="font"> <property name="font">
...@@ -194,15 +205,13 @@ ...@@ -194,15 +205,13 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
<property name="text"> <property name="text">
<string>Existing attribute :</string> <string>Existing attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="3" column="2">
<widget class="QComboBox" name="combo_kminAttribute"> <widget class="QComboBox" name="combo_kminAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -212,22 +221,16 @@ ...@@ -212,22 +221,16 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="3" column="3">
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
<string>New attribute :</string> <string>New attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="3" column="4">
<widget class="QLineEdit" name="kminAttributeName"/> <widget class="QLineEdit" name="kminAttributeName"/>
</item> </item>
</layout>
</item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="font"> <property name="font">
...@@ -243,15 +246,13 @@ ...@@ -243,15 +246,13 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_17"> <widget class="QLabel" name="label_17">
<property name="text"> <property name="text">
<string>Existing attribute :</string> <string>Existing attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="4" column="2">
<widget class="QComboBox" name="combo_KnormalAttribute"> <widget class="QComboBox" name="combo_KnormalAttribute">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -261,62 +262,35 @@ ...@@ -261,62 +262,35 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="4" column="3">
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_16"> <widget class="QLabel" name="label_16">
<property name="text"> <property name="text">
<string>New attribute :</string> <string>New attribute :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="4" column="4">
<widget class="QLineEdit" name="KnormalAttributeName"/> <widget class="QLineEdit" name="KnormalAttributeName"/>
</item> </item>
</layout> <item row="5" column="0" colspan="2">
</item> <widget class="QCheckBox" name="check_computeKmean">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Kmax :</string> <string>compute kmean</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="5" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QCheckBox" name="check_computeKgaussian">
<item>
<widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Existing attribute :</string> <string>compute kgaussian</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_KmaxAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QPushButton" name="button_cancel"> <widget class="QPushButton" name="button_cancel">
<property name="text"> <property name="text">
......
...@@ -62,6 +62,8 @@ public slots: ...@@ -62,6 +62,8 @@ public slots:
const QString& KminAttributeName = "Kmin", const QString& KminAttributeName = "Kmin",
const QString& kminAttributeName = "kmin", const QString& kminAttributeName = "kmin",
const QString& KnormalAttributeName = "Knormal", const QString& KnormalAttributeName = "Knormal",
bool compute_kmean = true,
bool compute_kgaussian = true,
bool autoUpdate = true bool autoUpdate = true
); );
...@@ -90,10 +92,10 @@ private: ...@@ -90,10 +92,10 @@ private:
ComputeCurvatureParameters( ComputeCurvatureParameters(
const QString& p, const QString& n, const QString& p, const QString& n,
const QString& Kmax, const QString& kmax, const QString& Kmin, const QString& kmin, const QString& Knormal, const QString& Kmax, const QString& kmax, const QString& Kmin, const QString& kmin, const QString& Knormal,
bool update) : bool kmean, bool kgaussian, bool update) :
positionName(p), normalName(n), positionName(p), normalName(n),
KmaxName(Kmax), kmaxName(kmax), KminName(Kmin), kminName(kmin), KnormalName(Knormal), KmaxName(Kmax), kmaxName(kmax), KminName(Kmin), kminName(kmin), KnormalName(Knormal),
autoUpdate(update) compute_kmean(kmean), compute_kgaussian(kgaussian), autoUpdate(update)
{} {}
QString positionName; QString positionName;
QString normalName; QString normalName;
...@@ -102,6 +104,8 @@ private: ...@@ -102,6 +104,8 @@ private:
QString KminName; QString KminName;
QString kminName; QString kminName;
QString KnormalName; QString KnormalName;
bool compute_kmean;
bool compute_kgaussian;
bool autoUpdate; bool autoUpdate;
}; };
QHash<QString, ComputeCurvatureParameters> computeCurvatureLastParameters; QHash<QString, ComputeCurvatureParameters> computeCurvatureLastParameters;
......
...@@ -186,6 +186,8 @@ void DifferentialPropertiesPlugin::computeCurvature( ...@@ -186,6 +186,8 @@ void DifferentialPropertiesPlugin::computeCurvature(
const QString& KminAttributeName, const QString& KminAttributeName,
const QString& kminAttributeName, const QString& kminAttributeName,
const QString& KnormalAttributeName, const QString& KnormalAttributeName,
bool compute_kmean,
bool compute_kgaussian,
bool autoUpdate) bool autoUpdate)
{ {
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName)); MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
...@@ -232,7 +234,7 @@ void DifferentialPropertiesPlugin::computeCurvature( ...@@ -232,7 +234,7 @@ void DifferentialPropertiesPlugin::computeCurvature(
ComputeCurvatureParameters( ComputeCurvatureParameters(
positionAttributeName, normalAttributeName, positionAttributeName, normalAttributeName,
KmaxAttributeName, kmaxAttributeName, KminAttributeName, kminAttributeName, KnormalAttributeName, KmaxAttributeName, kmaxAttributeName, KminAttributeName, kminAttributeName, KnormalAttributeName,
autoUpdate); compute_kmean, compute_kgaussian, autoUpdate);
mh->createVBO(Kmax); mh->createVBO(Kmax);
mh->createVBO(kmax); mh->createVBO(kmax);
...@@ -245,6 +247,32 @@ void DifferentialPropertiesPlugin::computeCurvature( ...@@ -245,6 +247,32 @@ void DifferentialPropertiesPlugin::computeCurvature(
mh->notifyAttributeModification(Kmin); mh->notifyAttributeModification(Kmin);
mh->notifyAttributeModification(kmin); mh->notifyAttributeModification(kmin);
mh->notifyAttributeModification(Knormal); mh->notifyAttributeModification(Knormal);
if(compute_kmean)
{
VertexAttribute<PFP2::REAL> kmean = mh->getAttribute<PFP2::REAL, VERTEX>("kmean");
if(!kmean.isValid())
kmean = mh->addAttribute<PFP2::REAL, VERTEX>("kmean");
for(unsigned int i = kmin.begin(); i != kmin.end(); kmin.next(i))
kmean[i] = (kmin[i] + kmax[i]) / 2.0;
mh->createVBO(kmean);
mh->notifyAttributeModification(kmean);
}
if(compute_kgaussian)
{
VertexAttribute<PFP2::REAL> kgaussian = mh->getAttribute<PFP2::REAL, VERTEX>("kgaussian");
if(!kgaussian.isValid())
kgaussian = mh->addAttribute<PFP2::REAL, VERTEX>("kgaussian");
for(unsigned int i = kmin.begin(); i != kmin.end(); kmin.next(i))
kgaussian[i] = kmin[i] * kmax[i];
mh->createVBO(kgaussian);
mh->notifyAttributeModification(kgaussian);
}
} }
#ifndef DEBUG #ifndef DEBUG
......
...@@ -67,7 +67,12 @@ void RenderScalarPlugin::redraw(View* view) ...@@ -67,7 +67,12 @@ void RenderScalarPlugin::redraw(View* view)
m_scalarShader->setMinValue(p->scalarMin); m_scalarShader->setMinValue(p->scalarMin);
m_scalarShader->setMaxValue(p->scalarMax); m_scalarShader->setMaxValue(p->scalarMax);
m_scalarShader->setExpansion(p->expansion); m_scalarShader->setExpansion(p->expansion);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
m->draw(m_scalarShader, Algo::Render::GL2::TRIANGLES); m->draw(m_scalarShader, Algo::Render::GL2::TRIANGLES);
glDisable(GL_POLYGON_OFFSET_FILL);
} }
} }
} }
...@@ -251,8 +256,8 @@ void RenderScalarPlugin::attributeModified(unsigned int orbit, QString nameAttr) ...@@ -251,8 +256,8 @@ void RenderScalarPlugin::attributeModified(unsigned int orbit, QString nameAttr)
if(perMap->scalarVBO && nameAttr == QString::fromStdString(perMap->scalarVBO->name())) if(perMap->scalarVBO && nameAttr == QString::fromStdString(perMap->scalarVBO->name()))
{ {
const VertexAttribute<PFP2::REAL>& attr = map->getAttribute<PFP2::REAL, VERTEX>(nameAttr); const VertexAttribute<PFP2::REAL>& attr = map->getAttribute<PFP2::REAL, VERTEX>(nameAttr);
perMap->scalarMin = 1e20; perMap->scalarMin = std::numeric_limits<float>::max();
perMap->scalarMax = -1e20; perMap->scalarMax = std::numeric_limits<float>::min();
for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i)) for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i))
{ {
perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin; perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin;
......
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