From e6fb3a99e0b25b13576dac16359fe3c450a5d9f2 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Tue, 12 Mar 2013 17:22:30 +0100 Subject: [PATCH] add option to compute kmean & kgaussian from compute curvature function --- .../forms/computeCurvatureDialog.ui | 322 ++++++++---------- .../include/differentialProperties.h | 8 +- .../src/differentialProperties.cpp | 30 +- .../Plugins/renderScalar/src/renderScalar.cpp | 9 +- 4 files changed, 190 insertions(+), 179 deletions(-) diff --git a/SCHNApps/Plugins/differentialProperties/forms/computeCurvatureDialog.ui b/SCHNApps/Plugins/differentialProperties/forms/computeCurvatureDialog.ui index 91245f8a..bcfc9a10 100644 --- a/SCHNApps/Plugins/differentialProperties/forms/computeCurvatureDialog.ui +++ b/SCHNApps/Plugins/differentialProperties/forms/computeCurvatureDialog.ui @@ -6,19 +6,19 @@ 0 0 - 570 - 452 + 568 + 442 Compute Curvature - - + + - - + + @@ -61,25 +61,52 @@ - + Computed attributes + + + + + 75 + true + true + + + + Kmax : + + + + + + + Existing attribute : + + + - - - - - New attribute : - - - - - - - + + + + 0 + 0 + + + + + + + + New attribute : + + + + + @@ -96,39 +123,31 @@ - - - - - Existing attribute : - - - - - - - - 0 - 0 - - - - - + + + Existing attribute : + + - - - - - New attribute : - - - - - - - + + + + 0 + 0 + + + + + + + + New attribute : + + + + + @@ -145,39 +164,31 @@ - - - - - Existing attribute : - - - - - - - - 0 - 0 - - - - - + + + Existing attribute : + + - - - - - New attribute : - - - - - - - + + + + 0 + 0 + + + + + + + + New attribute : + + + + + @@ -194,39 +205,31 @@ - - - - - Existing attribute : - - - - - - - - 0 - 0 - - - - - + + + Existing attribute : + + - - - - - New attribute : - - - - - - - + + + + 0 + 0 + + + + + + + + New attribute : + + + + + @@ -243,80 +246,51 @@ - - - - - Existing attribute : - - - - - - - - 0 - 0 - - - - - + + + Existing attribute : + + - - - - - New attribute : - - - - - - - + + + + 0 + 0 + + + - - - - - 75 - true - true - + + + + New attribute : + + + + + + + - Kmax : + compute kmean - - - - - - Existing attribute : - - - - - - - - 0 - 0 - - - - - + + + + compute kgaussian + + - - + + diff --git a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h index c971956d..dbb053ec 100644 --- a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h +++ b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h @@ -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 computeCurvatureLastParameters; diff --git a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp index 39291895..f8afc02a 100644 --- a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp +++ b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp @@ -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* mh = static_cast*>(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 kmean = mh->getAttribute("kmean"); + if(!kmean.isValid()) + kmean = mh->addAttribute("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 kgaussian = mh->getAttribute("kgaussian"); + if(!kgaussian.isValid()) + kgaussian = mh->addAttribute("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 diff --git a/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp b/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp index 3b9eda04..4138b41f 100644 --- a/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp +++ b/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp @@ -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& attr = map->getAttribute(nameAttr); - perMap->scalarMin = 1e20; - perMap->scalarMax = -1e20; + perMap->scalarMin = std::numeric_limits::max(); + perMap->scalarMax = std::numeric_limits::min(); for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i)) { perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin; -- GitLab