From f6f2f3742f6b836902c7cb98ee3846e222e0544a Mon Sep 17 00:00:00 2001
From: Amaury Johnen <amaury.johnen@uclouvain.be>
Date: Fri, 11 Aug 2017 17:21:29 +0200
Subject: [PATCH] cleanup

---
 Plugin/AnalyseCurvedMesh.cpp | 40 +++++++++++++++++++++---------------
 Plugin/AnalyseCurvedMesh.h   |  1 +
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/Plugin/AnalyseCurvedMesh.cpp b/Plugin/AnalyseCurvedMesh.cpp
index a0becda9c6..28523f8db4 100644
--- a/Plugin/AnalyseCurvedMesh.cpp
+++ b/Plugin/AnalyseCurvedMesh.cpp
@@ -113,8 +113,8 @@ PView* GMSH_AnalyseCurvedMeshPlugin::execute(PView *v)
   bool drawPView  = static_cast<int>(CurvedMeshOptions_Number[4].def);
   bool recompute  = static_cast<bool>(CurvedMeshOptions_Number[5].def);
   int askedDim    = static_cast<int>(CurvedMeshOptions_Number[6].def);
-  _numElementToScan = static_cast<int>(CurvedMeshOptions_Number[7].def);
 
+  _numElementToScan = static_cast<int>(CurvedMeshOptions_Number[7].def);
   _viewOrder = 10;
   _elementToScan = NULL;
   _hoElement = NULL;
@@ -177,21 +177,7 @@ PView* GMSH_AnalyseCurvedMeshPlugin::execute(PView *v)
   if (printStatS) _printStatIGE();
   if (printStatI) _printStatICN();
 
-  if (_hoElement) {
-    std::map<int, std::vector<double>> dataPVelement;
-    dataPVelement[_hoElement->getNum()] = _jacElementToScan;
-    std::stringstream name;
-    name << "Jacobian elem " << _numElementToScan;
-    PView *view = new PView(name.str().c_str(), "ElementNodeData",
-                            _m, dataPVelement, 0, 1);
-    const nodalBasis *fs = BasisFactory::getNodalBasis(_hoElement->getTypeForMSH());
-    const polynomialBasis *pfs = dynamic_cast<const polynomialBasis*>(fs);
-    PViewData *viewData = view->getData();
-    viewData->deleteInterpolationMatrices(_hoElement->getType());
-    viewData->setInterpolationMatrices(_hoElement->getType(),
-                                       pfs->coefficients, pfs->monomials,
-                                       pfs->coefficients, pfs->monomials);
-  }
+  _createPViewElementToScan();
 
   // Create PView
   if (drawPView)
@@ -373,7 +359,7 @@ void GMSH_AnalyseCurvedMeshPlugin::_computeMinMaxJandValidity(int dim)
       if (min < 0 && max < 0) ++cntInverted;
       progress.next();
 
-      _computeJacobianToScan(el, normals);
+      _computeJacobianToScan(el, entity, normals);
     }
     delete normals;
   }
@@ -629,4 +615,24 @@ void GMSH_AnalyseCurvedMeshPlugin::_addElementInEntity(MElement *element,
   }
 }
 
+void GMSH_AnalyseCurvedMeshPlugin::_createPViewElementToScan()
+{
+  if (!_hoElement) return;
+
+  // Jacobian determinant
+  std::map<int, std::vector<double>> dataPView;
+  dataPView[_hoElement->getNum()] = _jacElementToScan;
+  std::stringstream name;
+  name << "Jacobian elem " << _numElementToScan;
+  PView *view = new PView(name.str().c_str(), "ElementNodeData",
+                          _m, dataPView, 0, 1);
+  const nodalBasis *fs = BasisFactory::getNodalBasis(_hoElement->getTypeForMSH());
+  const polynomialBasis *pfs = dynamic_cast<const polynomialBasis*>(fs);
+  PViewData *viewData = view->getData();
+  viewData->deleteInterpolationMatrices(_hoElement->getType());
+  viewData->setInterpolationMatrices(_hoElement->getType(),
+                                     pfs->coefficients, pfs->monomials,
+                                     pfs->coefficients, pfs->monomials);
+}
+
 #endif
diff --git a/Plugin/AnalyseCurvedMesh.h b/Plugin/AnalyseCurvedMesh.h
index 51d572a114..68ab37df45 100644
--- a/Plugin/AnalyseCurvedMesh.h
+++ b/Plugin/AnalyseCurvedMesh.h
@@ -91,6 +91,7 @@ private :
   void _computeJacobianToScan(MElement*, GEntity*,
                               const fullMatrix<double> *normals);
   void _addElementInEntity(MElement*, GEntity*);
+  void _createPViewElementToScan();
 };
 
 #endif
-- 
GitLab