Commit e6fb3a99 authored by Pierre Kraemer's avatar Pierre Kraemer

add option to compute kmean & kgaussian from compute curvature function

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