From 6f93c4acea2131e19194d71b6fdca0dc6c762589 Mon Sep 17 00:00:00 2001
From: Amaury Johnan <amjohnen@gmail.com>
Date: Thu, 9 Oct 2014 12:32:31 +0000
Subject: [PATCH] avoid to create PView if there are no data

---
 Plugin/AnalyseCurvedMesh.cpp | 34 ++++++++++++++++------------------
 Plugin/AnalyseCurvedMesh.h   |  5 +----
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/Plugin/AnalyseCurvedMesh.cpp b/Plugin/AnalyseCurvedMesh.cpp
index 636575f494..1c28f84027 100644
--- a/Plugin/AnalyseCurvedMesh.cpp
+++ b/Plugin/AnalyseCurvedMesh.cpp
@@ -4,23 +4,17 @@
 // bugs and problems to the public mailing list <gmsh@geuz.org>.
 
 #include "AnalyseCurvedMesh.h"
-#include "GModel.h"
 #include "OS.h"
 #include "Context.h"
-
-#include <cmath>
-#include <queue>
-#include <sstream>
-
-#include "GmshMessage.h"
-#include "PView.h"
-
 #if defined(HAVE_OPENGL)
 #include "drawContext.h"
 #endif
-#if defined(HAVE_FLTK)
-#include "FlGui.h"
-#endif
+#include "PView.h"
+#include "GModel.h"
+#include "MElement.h"
+#include "bezierBasis.h"
+#include "MetricBasis.h"
+#include <sstream>
 
 namespace {
 
@@ -181,9 +175,11 @@ PView *GMSH_AnalyseCurvedMeshPlugin::execute(PView *v)
             dataPV[el->getNum()].push_back(_data[i].minJ());
           }
         }
-        std::stringstream name;
-        name << "min J " << dim << "D";
-        new PView(name.str().c_str(), "ElementData", _m, dataPV);
+        if (dataPV.size()) {
+          std::stringstream name;
+          name << "min J " << dim << "D";
+          new PView(name.str().c_str(), "ElementData", _m, dataPV);
+        }
       }
       if (!_PViewR[dim-1] && _computeMetric) {
         _PViewR[dim-1] = true;
@@ -193,9 +189,11 @@ PView *GMSH_AnalyseCurvedMeshPlugin::execute(PView *v)
           if (el->getDim() == dim)
             dataPV[el->getNum()].push_back(_data[i].minR());
         }
-        std::stringstream name;
-        name << "min R " << dim << "D";
-        new PView(name.str().c_str(), "ElementData", _m, dataPV);
+        if (dataPV.size()) {
+          std::stringstream name;
+          name << "min R " << dim << "D";
+          new PView(name.str().c_str(), "ElementData", _m, dataPV);
+        }
       }
     }
   }
diff --git a/Plugin/AnalyseCurvedMesh.h b/Plugin/AnalyseCurvedMesh.h
index 37300d9069..ed6c1c3260 100644
--- a/Plugin/AnalyseCurvedMesh.h
+++ b/Plugin/AnalyseCurvedMesh.h
@@ -7,11 +7,8 @@
 #define _ANALYSECURVEDMESH_H_
 
 #include "Plugin.h"
-#include "JacobianBasis.h"
-#include "MetricBasis.h"
-#include "MElement.h"
-
 #include <vector>
+class MElement;
 
 extern "C"
 {
-- 
GitLab