From d6ec3072d93fd7a17113050e1143e40d48b8d111 Mon Sep 17 00:00:00 2001
From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be>
Date: Fri, 25 Oct 2013 13:32:17 +0000
Subject: [PATCH] small modif for high order optimization

---
 Fltk/highOrderToolsWindow.cpp | 12 ++++++++++--
 Mesh/meshGFaceOptimize.cpp    |  8 +++++++-
 Mesh/meshGFaceOptimize.h      |  1 +
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Fltk/highOrderToolsWindow.cpp b/Fltk/highOrderToolsWindow.cpp
index 63b4feb541..d9410ed48e 100644
--- a/Fltk/highOrderToolsWindow.cpp
+++ b/Fltk/highOrderToolsWindow.cpp
@@ -132,6 +132,12 @@ static void highordertools_runopti_cb(Fl_Widget *w, void *data)
   int nbLayers = (int) o->value[2]->value();
   double threshold_max = o->value[8]->value();
 
+  int NE = 0;
+  for (GModel::riter it = GModel::current()->firstRegion(); it != GModel::current()->lastRegion(); ++it){
+    NE += (*it)->getNumMeshElements();
+  }
+
+
 #if defined(HAVE_OPTHOM)
   switch(algo) {
   case 0: {                                                               // Optimization
@@ -140,7 +146,9 @@ static void highordertools_runopti_cb(Fl_Widget *w, void *data)
     p.BARRIER_MIN = threshold_min;
     p.BARRIER_MAX = threshold_max;
     p.onlyVisible = onlyVisible;
-    p.dim = GModel::current()->getDim();
+    // change dim if no 3D elements are there
+    p.dim = GModel::current()->getDim() == 3 ? ( NE ? 3 : 2 ) :  GModel::current()->getDim();
+    printf("%d %d\n",NE,p.dim);
     p.itMax = (int) o->value[3]->value();
     p.optPassMax = (int) o->value[4]->value();
     p.weightFixed =  o->value[5]->value();
@@ -164,7 +172,7 @@ static void highordertools_runopti_cb(Fl_Widget *w, void *data)
     p.BARRIER_MIN = threshold_min;
     p.BARRIER_MAX = threshold_max;
     p.onlyVisible = onlyVisible;
-    p.dim = GModel::current()->getDim();
+    p.dim = GModel::current()->getDim() == 3 ? ( NE ? 3 : 2 ) :  GModel::current()->getDim();
     p.distanceFactor =  o->value[7]->value();
     HighOrderMeshFastCurving(GModel::current(), p);
     break;
diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp
index 71cfe76607..1196287ede 100644
--- a/Mesh/meshGFaceOptimize.cpp
+++ b/Mesh/meshGFaceOptimize.cpp
@@ -234,7 +234,10 @@ void transferDataStructure(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris,
       if(pp < 0) t->reverse();
     }
   }
+  computeEquivalences(gf, data);
+}
 
+void computeEquivalences(GFace *gf, bidimMeshData & data){
   if (data.equivalence){
     std::vector<MTriangle*> newT;
     for (unsigned int i=0;i<gf->triangles.size();i++){
@@ -252,10 +255,13 @@ void transferDataStructure(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris,
     }
     gf->triangles = newT;
   }
+}
 
-
+int splitEquivalentTriangles(GFace *gf, bidimMeshData & data){
+  
 }
 
+
 void buildVertexToTriangle(std::vector<MTriangle*> &eles, v2t_cont &adj)
 {
   adj.clear();
diff --git a/Mesh/meshGFaceOptimize.h b/Mesh/meshGFaceOptimize.h
index 5d363c1917..a866812ec0 100644
--- a/Mesh/meshGFaceOptimize.h
+++ b/Mesh/meshGFaceOptimize.h
@@ -80,6 +80,7 @@ void buildMeshGenerationDataStructures(GFace *gf,
                                        std::set<MTri3*, compareTri3Ptr> &AllTris,
 				       bidimMeshData & data);
 void transferDataStructure(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris,bidimMeshData &DATA);
+void computeEquivalences(GFace *gf,bidimMeshData &DATA);
 void recombineIntoQuads(GFace *gf, 
                         bool topologicalOpti   = true, 
                         bool nodeRepositioning = true);
-- 
GitLab