From fee8aca262e94714be82392cedaf8862cfc7c223 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 10 Apr 2013 17:36:57 +0000
Subject: [PATCH] restore -q option for initial delaunau tetrahedralization +
 added an option to control the value

---
 Common/Context.h        | 1 +
 Common/DefaultOptions.h | 2 ++
 Common/Options.cpp      | 7 +++++++
 Common/Options.h        | 1 +
 Mesh/meshGRegion.cpp    | 5 +++--
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index f5c79550cc..c521b4507b 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -48,6 +48,7 @@ struct contextMeshOptions {
   std::map<int,int> curvature_control_per_face;
   int bunin;
   int ignorePartBound;
+  double delaunayQ;
 };
 
 struct contextGeometryOptions {
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index a0a4327b06..19399b623f 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -900,6 +900,8 @@ StringXNumber MeshOptions_Number[] = {
   { F,   "CpuTime" , opt_mesh_cpu_time , 0. ,
     "CPU time (in seconds) for the generation of the current mesh (read-only)" },
 
+  { F|O, "DelaunayQ" , opt_mesh_delaunay_q , 3.5 ,
+    "Quality factor for initial Delaunay tetrahedralization" },
   { F|O, "DrawSkinOnly" , opt_mesh_draw_skin_only , 0. ,
     "Draw only the skin of 3D meshes?" },
   { F|O, "Dual" , opt_mesh_dual , 0. ,
diff --git a/Common/Options.cpp b/Common/Options.cpp
index fa1671862f..d910c42fa2 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -4586,6 +4586,13 @@ double opt_mesh_rand_factor(OPT_ARGS_NUM)
   return CTX::instance()->mesh.randFactor;
 }
 
+double opt_mesh_delaunay_q(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX::instance()->mesh.delaunayQ = val;
+  return CTX::instance()->mesh.delaunayQ;
+}
+
 double opt_mesh_quality_type(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET) {
diff --git a/Common/Options.h b/Common/Options.h
index 834016f612..78cb4ecad1 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -364,6 +364,7 @@ double opt_mesh_rand_factor(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_delaunay_q(OPT_ARGS_NUM);
 double opt_mesh_radius_inf(OPT_ARGS_NUM);
 double opt_mesh_radius_sup(OPT_ARGS_NUM);
 double opt_mesh_label_type(OPT_ARGS_NUM);
diff --git a/Mesh/meshGRegion.cpp b/Mesh/meshGRegion.cpp
index 8faa8f434f..97eadb0633 100644
--- a/Mesh/meshGRegion.cpp
+++ b/Mesh/meshGRegion.cpp
@@ -564,8 +564,9 @@ void MeshDelaunayVolume(std::vector<GRegion*> &regions)
 	       (Msg::GetVerbosity() > 6) ? 'V': '\0');
     }
     else {
-      sprintf(opts, "Ype%c",  (Msg::GetVerbosity() < 3) ? 'Q':
-      	      (Msg::GetVerbosity() > 6) ? 'V': '\0');
+      sprintf(opts, "-q%gYpe%c",  CTX::instance()->mesh.delaunayQ,
+              (Msg::GetVerbosity() < 3) ? 'Q':
+              (Msg::GetVerbosity() > 6) ? 'V': '\0');
     }
     try{
       tetrahedralize(opts, &in, &out);
-- 
GitLab