From af4073973c1d0209ad4b31012a7ea1d074b92cfe Mon Sep 17 00:00:00 2001
From: Karsten Rink <karsten.rink@ufz.de>
Date: Tue, 2 Sep 2014 15:39:11 +0200
Subject: [PATCH] added new metric to gui

---
 Gui/DataView/MshQualitySelection.ui        |  7 ++++++
 Gui/DataView/MshQualitySelectionDialog.cpp | 28 ++++++++++++----------
 Gui/VtkVis/VtkVisPipeline.cpp              |  3 +++
 Gui/mainwindow.cpp                         | 10 +-------
 MeshLib/MeshEnums.cpp                      | 20 +++++++++-------
 MeshLib/MeshEnums.h                        | 11 +++++----
 6 files changed, 43 insertions(+), 36 deletions(-)

diff --git a/Gui/DataView/MshQualitySelection.ui b/Gui/DataView/MshQualitySelection.ui
index d082f66f6f3..6007c249ecd 100644
--- a/Gui/DataView/MshQualitySelection.ui
+++ b/Gui/DataView/MshQualitySelection.ui
@@ -48,6 +48,13 @@
         </property>
        </widget>
       </item>
+      <item>
+       <widget class="QRadioButton" name="choiceRadius">
+        <property name="text">
+         <string>Radius to Shortest Edge Ratio</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
diff --git a/Gui/DataView/MshQualitySelectionDialog.cpp b/Gui/DataView/MshQualitySelectionDialog.cpp
index 4885d7d85bc..f6d8e7ecdb2 100644
--- a/Gui/DataView/MshQualitySelectionDialog.cpp
+++ b/Gui/DataView/MshQualitySelectionDialog.cpp
@@ -30,20 +30,22 @@ MshQualitySelectionDialog::~MshQualitySelectionDialog()
 /// Instructions if the OK-Button has been pressed.
 void MshQualitySelectionDialog::accept()
 {
-	MeshQualityType t;
-	if (this->choiceEdges->isChecked())
-		t = MeshQualityType::EDGERATIO;
-	else if (this->choiceArea->isChecked())
-		t = MeshQualityType::AREA;
-	else if (this->choiceVolume->isChecked())
-		t = MeshQualityType::VOLUME;
-	else if (this->choiceAngles->isChecked())
-		t = MeshQualityType::EQUIANGLESKEW;
-	else
-		t = MeshQualityType::INVALID;
+    MeshQualityType t;
+    if (this->choiceEdges->isChecked())
+        t = MeshQualityType::EDGERATIO;
+    else if (this->choiceArea->isChecked())
+        t = MeshQualityType::AREA;
+    else if (this->choiceVolume->isChecked())
+        t = MeshQualityType::VOLUME;
+    else if (this->choiceAngles->isChecked())
+        t = MeshQualityType::EQUIANGLESKEW;
+    else if (this->choiceRadius->isChecked())
+        t = MeshQualityType::RADIUSEDGERATIO;
+    else
+        t = MeshQualityType::INVALID;
 
-	emit measureSelected(_msh, t);
-	this->done(QDialog::Accepted);
+    emit measureSelected(_msh, t);
+    this->done(QDialog::Accepted);
 }
 
 /// Instructions if the Cancel-Button has been pressed.
diff --git a/Gui/VtkVis/VtkVisPipeline.cpp b/Gui/VtkVis/VtkVisPipeline.cpp
index aa2ac916868..3b5a38ac72f 100644
--- a/Gui/VtkVis/VtkVisPipeline.cpp
+++ b/Gui/VtkVis/VtkVisPipeline.cpp
@@ -28,6 +28,7 @@
 #include "MeshQuality/AreaMetric.h"
 #include "MeshQuality/VolumeMetric.h"
 #include "MeshQuality/EdgeRatioMetric.h"
+#include "MeshQuality/RadiusEdgeRatioMetric.h"
 #include "MshItem.h"
 #include "MshModel.h"
 #include "StationTreeModel.h"
@@ -469,6 +470,8 @@ void VtkVisPipeline::checkMeshQuality(VtkMeshSource* source, MeshQualityType t)
 			quality_tester = new MeshLib::VolumeMetric(*mesh);
 		else if (t == MeshQualityType::EQUIANGLESKEW)
 			quality_tester = new MeshLib::AngleSkewMetric(*mesh);
+		else if (t == MeshQualityType::RADIUSEDGERATIO)
+			quality_tester = new MeshLib::RadiusEdgeRatioMetric(*mesh);
 		else
 		{
 			ERR("VtkVisPipeline::checkMeshQuality(): Unknown MeshQualityType.");
diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp
index 2a580bd5c8c..6f93923da37 100644
--- a/Gui/mainwindow.cpp
+++ b/Gui/mainwindow.cpp
@@ -13,8 +13,7 @@
  */
 
 #include "mainwindow.h"
-#include <algorithm>
-#include "MeshQuality\RadiusEdgeRatioMetric.h"
+
 // ThirdParty/logog
 #include "logog/include/logog.hpp"
 
@@ -1299,13 +1298,6 @@ void MainWindow::showDataExplorerSettingsDialog()
 
 void MainWindow::FEMTestStart()
 {
-    const MeshLib::Mesh* msh = _project.getMesh("Ammer-Homogen100m-Final");
-    MeshLib::RadiusEdgeRatioMetric metric(*msh);
-    metric.calculateQuality();
-    std::vector<double> result (metric.getElementQuality());
-    auto minmax = std::minmax_element(result.begin(), result.end());
-    std::cout << "min: " << *minmax.first << " at pos " << minmax.first-result.begin() 
-              << ", max: " << *minmax.second << " at pos " << minmax.second-result.begin() << std::endl;
 }
 
 void MainWindow::showTrackingSettingsDialog()
diff --git a/MeshLib/MeshEnums.cpp b/MeshLib/MeshEnums.cpp
index 910b4c5a05b..73f7bf6913f 100644
--- a/MeshLib/MeshEnums.cpp
+++ b/MeshLib/MeshEnums.cpp
@@ -54,14 +54,16 @@ MeshElemType String2MeshElemType(const std::string &s)
 
 const std::string MeshQualityType2String(const MeshQualityType t)
 {
-	if (t == MeshQualityType::AREA)
-		return "Area";
-	if (t == MeshQualityType::EDGERATIO)
-		return "EdgeRatio";
-	if (t == MeshQualityType::EQUIANGLESKEW)
-		return "EquiAngleSkew";
-	if (t == MeshQualityType::VOLUME)
-		return "Volume";
-	return "none";
+    if (t == MeshQualityType::AREA)
+        return "Area";
+    if (t == MeshQualityType::EDGERATIO)
+        return "EdgeRatio";
+    if (t == MeshQualityType::EQUIANGLESKEW)
+        return "EquiAngleSkew";
+    if (t == MeshQualityType::RADIUSEDGERATIO)
+        return "RadiusEdgeRatio";
+    if (t == MeshQualityType::VOLUME)
+        return "Volume";
+    return "none";
 }
 
diff --git a/MeshLib/MeshEnums.h b/MeshLib/MeshEnums.h
index 3bf5caecdd9..ac63a453835 100644
--- a/MeshLib/MeshEnums.h
+++ b/MeshLib/MeshEnums.h
@@ -61,11 +61,12 @@ enum class CellType
  */
 enum class MeshQualityType
 {
-	INVALID = 0,
-	AREA,
-	VOLUME,
-	EDGERATIO,
-	EQUIANGLESKEW
+    INVALID = 0,
+    AREA,
+    VOLUME,
+    EDGERATIO,
+    EQUIANGLESKEW,
+    RADIUSEDGERATIO
 };
 
 /// Given a MeshElemType this returns the appropriate string.
-- 
GitLab