From 9c47bfe28e5f2d29209ae9bb711d13dfb608e7d1 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 9 Jun 2005 17:22:05 +0000
Subject: [PATCH] add little menu to choose the quality measure in
 Options->Mesh->Visibility

---
 Common/Context.h        |  3 +-
 Common/DefaultOptions.h | 11 +++----
 Common/Options.cpp      | 38 +++++++++++++++++-------
 Common/Options.h        |  5 ++--
 Fltk/Callbacks.cpp      |  7 +++--
 Fltk/GUI.cpp            | 14 +++++++--
 Graphics/Mesh.cpp       | 66 +++++++++++++++++++++++++++++++++++++----
 7 files changed, 115 insertions(+), 29 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index 6f55ddeaac..5e864e9843 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -175,7 +175,8 @@ public :
     int points_per_element;
     int optimize;
     double quality;
-    double gamma_inf, gamma_sup, radius_inf, radius_sup;
+    int quality_type;
+    double quality_inf, quality_sup, radius_inf, radius_sup;
     double scaling_factor, lc_factor, rand_factor;
     int dual, interactive;
     int light, light_two_side;
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 8ddc89ba47..c8c431c69b 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -876,11 +876,12 @@ StringXNumber MeshOptions_Number[] = {
   { F|O, "Format" , opt_mesh_format , FORMAT_MSH , 
     "Mesh output format (1=msh, 2=unv, 3=gref, 19=vrml)" },
 
-  { F|O, "GammaInf" , opt_mesh_gamma_inf , 0.0 , 
-    "Only display elements whose Gamma factor is greater than GammaInf" },
-  { F|O, "GammaSup" , opt_mesh_gamma_sup , 0.0 , 
-    "Only display elements whose Gamma factor is smaller than GammaSup" },
-
+  { F|O, "QualityInf" , opt_mesh_quality_inf , 0.0 , 
+    "Only display elements whose quality measure is greater than QualityInf" },
+  { F|O, "QualitySup" , opt_mesh_quality_sup , 0.0 , 
+    "Only display elements whose quality measure is smaller than QualitySup" },
+  { F|O, "QualityType" , opt_mesh_quality_type , 0. , 
+    "Type of quality measure (0=gamma~vol/sum_face/max_edge, 1=eta~vol^(2/3)/sum_edge^2, 2=rho~min_edge/max_edge)" },
   { F|O, "Interactive" , opt_mesh_interactive , 0. ,
     "Show the construction of 2D anisotropic mesh in real time" },
 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 7b6ebbabe9..21b74512b2 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.245 2005-06-06 23:14:59 geuzaine Exp $
+// $Id: Options.cpp,v 1.246 2005-06-09 17:22:04 geuzaine Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -4028,30 +4028,46 @@ double opt_mesh_rand_factor(OPT_ARGS_NUM)
   return CTX.mesh.rand_factor;
 }
 
-double opt_mesh_gamma_inf(OPT_ARGS_NUM)
+double opt_mesh_quality_type(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET) {
-    if(CTX.mesh.gamma_inf != val) CTX.mesh.changed = 1;
-    CTX.mesh.gamma_inf = val;
+    if(CTX.mesh.quality_type != val) CTX.mesh.changed = 1;
+    CTX.mesh.quality_type = (int)val;
+    if(CTX.mesh.quality_type < 0 || CTX.mesh.quality_type > 2)
+      CTX.mesh.quality_type = 0;
+  }
+#if defined(HAVE_FLTK)
+  if(WID && (action & GMSH_GUI)){
+    WID->mesh_choice[6]->value(CTX.mesh.quality_type);
+  }
+#endif
+  return CTX.mesh.quality_type;
+}
+
+double opt_mesh_quality_inf(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET) {
+    if(CTX.mesh.quality_inf != val) CTX.mesh.changed = 1;
+    CTX.mesh.quality_inf = val;
   }
 #if defined(HAVE_FLTK)
   if(WID && (action & GMSH_GUI))
-    WID->mesh_value[4]->value(CTX.mesh.gamma_inf);
+    WID->mesh_value[4]->value(CTX.mesh.quality_inf);
 #endif
-  return CTX.mesh.gamma_inf;
+  return CTX.mesh.quality_inf;
 }
 
-double opt_mesh_gamma_sup(OPT_ARGS_NUM)
+double opt_mesh_quality_sup(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET) {
-    if(CTX.mesh.gamma_sup != val) CTX.mesh.changed = 1;
-    CTX.mesh.gamma_sup = val;
+    if(CTX.mesh.quality_sup != val) CTX.mesh.changed = 1;
+    CTX.mesh.quality_sup = val;
   }
 #if defined(HAVE_FLTK)
   if(WID && (action & GMSH_GUI))
-    WID->mesh_value[5]->value(CTX.mesh.gamma_sup);
+    WID->mesh_value[5]->value(CTX.mesh.quality_sup);
 #endif
-  return CTX.mesh.gamma_sup;
+  return CTX.mesh.quality_sup;
 }
 
 double opt_mesh_radius_inf(OPT_ARGS_NUM)
diff --git a/Common/Options.h b/Common/Options.h
index 8db0f23b86..6a4ffd4252 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -410,8 +410,9 @@ double opt_mesh_explode(OPT_ARGS_NUM);
 double opt_mesh_scaling_factor(OPT_ARGS_NUM);
 double opt_mesh_lc_factor(OPT_ARGS_NUM);
 double opt_mesh_rand_factor(OPT_ARGS_NUM);
-double opt_mesh_gamma_inf(OPT_ARGS_NUM);
-double opt_mesh_gamma_sup(OPT_ARGS_NUM);
+double opt_mesh_quality_inf(OPT_ARGS_NUM);
+double opt_mesh_quality_sup(OPT_ARGS_NUM);
+double opt_mesh_quality_type(OPT_ARGS_NUM);
 double opt_mesh_radius_inf(OPT_ARGS_NUM);
 double opt_mesh_radius_sup(OPT_ARGS_NUM);
 double opt_mesh_points(OPT_ARGS_NUM);
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 95da1e3e51..a4efc378c6 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.354 2005-06-08 19:12:04 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.355 2005-06-09 17:22:04 geuzaine Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -1040,8 +1040,8 @@ void mesh_options_ok_cb(CALLBACK_ARGS)
   opt_mesh_scaling_factor(0, GMSH_SET, WID->mesh_value[1]->value());
   opt_mesh_lc_factor(0, GMSH_SET, WID->mesh_value[2]->value());
   opt_mesh_rand_factor(0, GMSH_SET, WID->mesh_value[3]->value());
-  opt_mesh_gamma_inf(0, GMSH_SET, WID->mesh_value[4]->value());
-  opt_mesh_gamma_sup(0, GMSH_SET, WID->mesh_value[5]->value());
+  opt_mesh_quality_inf(0, GMSH_SET, WID->mesh_value[4]->value());
+  opt_mesh_quality_sup(0, GMSH_SET, WID->mesh_value[5]->value());
   opt_mesh_radius_inf(0, GMSH_SET, WID->mesh_value[6]->value());
   opt_mesh_radius_sup(0, GMSH_SET, WID->mesh_value[7]->value());
   opt_mesh_normals(0, GMSH_SET, WID->mesh_value[8]->value());
@@ -1067,6 +1067,7 @@ void mesh_options_ok_cb(CALLBACK_ARGS)
 		  (WID->mesh_choice[3]->value() == 0) ? DELAUNAY_ISO :
 		  FRONTAL_NETGEN);
   opt_mesh_color_carousel(0, GMSH_SET, WID->mesh_choice[4]->value());
+  opt_mesh_quality_type(0, GMSH_SET, WID->mesh_choice[6]->value());
 }
 
 void mesh_cut_plane_cb(CALLBACK_ARGS)
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index e357d195e0..ec825518f6 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.440 2005-05-27 21:34:53 geuzaine Exp $
+// $Id: GUI.cpp,v 1.441 2005-06-09 17:22:04 geuzaine Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -2304,12 +2304,22 @@ void GUI::create_option_window()
       mesh_value[4]->step(0.001);
       mesh_value[4]->align(FL_ALIGN_RIGHT);
 
-      mesh_value[5] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 7 * BH, IW / 2, BH, "Tetrahedra quality range");
+      mesh_value[5] = new Fl_Value_Input(L + 2 * WB + IW / 2, 2 * WB + 7 * BH, IW / 2, BH, "Element quality range");
       mesh_value[5]->minimum(0);
       mesh_value[5]->maximum(1);
       mesh_value[5]->step(0.001);
       mesh_value[5]->align(FL_ALIGN_RIGHT);
 
+      static Fl_Menu_Item menu_quality_type[] = {
+        {"Gamma", 0, 0, 0},
+        {"Eta", 0, 0, 0},
+        {"Rho", 0, 0, 0},
+        {0}
+      };
+      mesh_choice[6] = new Fl_Choice(L + width - BB - 5 * WB, 2 * WB + 7 * BH, BB, BH);
+      mesh_choice[6]->menu(menu_quality_type);
+      mesh_choice[6]->align(FL_ALIGN_LEFT);
+
       mesh_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW / 2, BH);
       mesh_value[6]->align(FL_ALIGN_RIGHT);
 
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 962c443fa8..b237791838 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.130 2005-06-03 22:42:54 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.131 2005-06-09 17:22:05 geuzaine Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -835,6 +835,16 @@ void Draw_Mesh_Triangle(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = s->RhoShapeMeasure();
+    else
+      tmp = 0.0;
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
+      return;
+  }
+
   if(CTX.mesh.radius_sup) {
     double r = s->maxEdge();
     if(r < CTX.mesh.radius_inf || r > CTX.mesh.radius_sup)
@@ -994,6 +1004,16 @@ void Draw_Mesh_Quadrangle(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = q->RhoShapeMeasure();
+    else
+      tmp = 0.0;
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
+      return;
+  }
+
   if(CTX.mesh.radius_sup) {
     double r = q->maxEdge();
     if(r < CTX.mesh.radius_inf || r > CTX.mesh.radius_sup)
@@ -1144,7 +1164,7 @@ void Draw_Mesh_Quadrangle(void *a, void *b)
 void Draw_Mesh_Tetrahedron(void *a, void *b)
 {
   char Num[100];
-  double tmp, X[4], Y[4], Z[4], X2[6], Y2[6], Z2[6];
+  double X[4], Y[4], Z[4], X2[6], Y2[6], Z2[6];
 
   SimplexBase *s = *(SimplexBase **) a;
 
@@ -1155,9 +1175,15 @@ void Draw_Mesh_Tetrahedron(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
-  if(CTX.mesh.gamma_sup) {
-    tmp = s->GammaShapeMeasure();
-    if(tmp < CTX.mesh.gamma_inf || tmp > CTX.mesh.gamma_sup)
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = s->RhoShapeMeasure();
+    else if(CTX.mesh.quality_type == 1)
+      tmp = s->EtaShapeMeasure();
+    else
+      tmp = s->GammaShapeMeasure();
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
       return;
   }
 
@@ -1328,6 +1354,16 @@ void Draw_Mesh_Hexahedron(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = h->RhoShapeMeasure();
+    else
+      tmp = 0.0;
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
+      return;
+  }
+
   if(CTX.mesh.radius_sup) {
     double r = h->maxEdge();
     if(r < CTX.mesh.radius_inf || r > CTX.mesh.radius_sup)
@@ -1509,6 +1545,16 @@ void Draw_Mesh_Prism(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = p->RhoShapeMeasure();
+    else
+      tmp = 0.0;
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
+      return;
+  }
+
   if(CTX.mesh.radius_sup) {
     double r = p->maxEdge();
     if(r < CTX.mesh.radius_inf || r > CTX.mesh.radius_sup)
@@ -1705,6 +1751,16 @@ void Draw_Mesh_Pyramid(void *a, void *b)
   if(part && !(*part)->Visible)
     return;
 
+  if(CTX.mesh.quality_sup) {
+    double tmp;
+    if(CTX.mesh.quality_type == 2)
+      tmp = p->RhoShapeMeasure();
+    else
+      tmp = 0.0;
+    if(tmp < CTX.mesh.quality_inf || tmp > CTX.mesh.quality_sup)
+      return;
+  }
+
   if(CTX.mesh.radius_sup) {
     double r = p->maxEdge();
     if(r < CTX.mesh.radius_inf || r > CTX.mesh.radius_sup)
-- 
GitLab