From f2a997c55b9f1158687ec185952e47ee341e8431 Mon Sep 17 00:00:00 2001
From: Nicolas Tardieu <nicolas.tardieu@edf.fr>
Date: Wed, 29 Jun 2005 10:02:55 +0000
Subject: [PATCH] Modification to support Tetgen algorithm. All modifications
 are commentarized because this feature is not functionnal : the transfer from
 Gmsh to Tetgen is OK, but the transfer from Tetgen to Gmsh is not : all the
 mesh (points, lines, surfaces, volumes) must be recreated in Gmsh...

---
 Common/CommandLine.cpp  |  8 +++++++-
 Common/DefaultOptions.h |  1 +
 Common/Options.cpp      |  6 +++++-
 Fltk/Callbacks.cpp      |  6 +++++-
 Fltk/GUI.cpp            |  3 ++-
 Mesh/3D_Mesh.cpp        |  6 +++++-
 Mesh/Mesh.h             |  2 ++
 configure.in            | 32 +++++++++++++++++++++++++++++++-
 8 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index bc34b9090a..000fbdd138 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,4 +1,4 @@
-// $Id: CommandLine.cpp,v 1.59 2005-06-25 17:17:15 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.60 2005-06-29 10:02:55 tardieu Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -71,6 +71,7 @@ void Print_Usage(char *name){
   Msg(DIRECT, "  -o file               Specify mesh output file name");
   Msg(DIRECT, "  -format string        Set output mesh format (msh, unv, gref, p3d)");
   Msg(DIRECT, "  -algo string          Select mesh algorithm (iso, tri, aniso, netgen)");
+//  Msg(DIRECT, "  -algo string          Select mesh algorithm (iso, tri, aniso, netgen, tetgen)");
   Msg(DIRECT, "  -smooth int           Set number of mesh smoothing steps");
   Msg(DIRECT, "  -optimize             Optimize quality of tetrahedral elements");
   Msg(DIRECT, "  -order int            Set mesh order (1, 2)");
@@ -125,6 +126,9 @@ char *Get_BuildOptions(void)
 #if defined(HAVE_NETGEN)
     strcat(opt, "NETGEN ");
 #endif
+//#if defined(HAVE_TETGEN)
+//    strcat(opt, "TETGEN ");
+//#endif
 #if defined(HAVE_LIBJPEG)
     strcat(opt, "JPEG ");
 #endif
@@ -408,6 +412,8 @@ void Get_Options(int argc, char *argv[])
             CTX.mesh.algo2d = DELAUNAY_ANISO;
           else if(!strncmp(argv[i], "netgen", 6))
             CTX.mesh.algo3d = FRONTAL_NETGEN;
+//          else if(!strncmp(argv[i], "tetgen", 6))
+//            CTX.mesh.algo3d = DELAUNAY_TETGEN;
           else {
             fprintf(stderr, ERROR_STR "Unknown mesh algorithm\n");
             exit(1);
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 31e159de34..65692c55f4 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -835,6 +835,7 @@ StringXNumber MeshOptions_Number[] = {
     "2D mesh algorithm (1=isotropic, 2=anisotropic, 3=triangle)" }, 
   { F|O, "Algorithm3D" , opt_mesh_algo3d , DELAUNAY_ISO ,
     "3D mesh algorithm (1=isotropic, 4=netgen)" }, 
+//    "3D mesh algorithm (1=isotropic, 4=netgen, 5=tetgen)" }, 
   { F,   "AllowDegeneratedExtrude" , opt_mesh_allow_degenerated_extrude , 0. , 
     "Allow the generation of degenerated hexahedra or prisms during extrusion" },
   { F|O, "AngleSmoothNormals" , opt_mesh_angle_smooth_normals , 180.0 ,
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 7a82a69d98..42673d7526 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.247 2005-06-11 02:01:38 geuzaine Exp $
+// $Id: Options.cpp,v 1.248 2005-06-29 10:02:55 tardieu Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -4432,6 +4432,7 @@ double opt_mesh_algo3d(OPT_ARGS_NUM)
   if(action & GMSH_SET){
     int algo = (int)val;
     if(algo != DELAUNAY_ISO && algo != FRONTAL_NETGEN){
+//    if(algo != DELAUNAY_ISO && algo != FRONTAL_NETGEN && algo != DELAUNAY_TETGEN){
       Msg(WARNING, "Unknown mesh algorithm: keeping existing value");
     }
     else{
@@ -4448,6 +4449,9 @@ double opt_mesh_algo3d(OPT_ARGS_NUM)
     default:
       WID->mesh_choice[3]->value(1);
       break;
+//    case DELAUNAY_TETGEN:
+//      WID->mesh_choice[3]->value(2);
+//      break;
     }
   }
 #endif
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 8f7f6b7331..b36a1f5132 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.357 2005-06-27 15:03:45 remacle Exp $
+// $Id: Callbacks.cpp,v 1.358 2005-06-29 10:02:55 tardieu Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -1081,6 +1081,10 @@ void mesh_options_ok_cb(CALLBACK_ARGS)
   opt_mesh_algo3d(0, GMSH_SET,
 		  (WID->mesh_choice[3]->value() == 0) ? DELAUNAY_ISO :
 		  FRONTAL_NETGEN);
+//  opt_mesh_algo3d(0, GMSH_SET,
+//		  (WID->mesh_choice[3]->value() == 0) ? DELAUNAY_ISO :
+//		  (WID->mesh_choice[3]->value() == 1) ? FRONTAL_NETGEN :
+//		  DELAUNAY_TETGEN);
   opt_mesh_color_carousel(0, GMSH_SET, WID->mesh_choice[4]->value());
   opt_mesh_quality_type(0, GMSH_SET, WID->mesh_choice[6]->value());
 }
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 7dd1f5e0fe..aae188936b 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.444 2005-06-27 15:03:45 remacle Exp $
+// $Id: GUI.cpp,v 1.445 2005-06-29 10:02:55 tardieu Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -2214,6 +2214,7 @@ void GUI::create_option_window()
       static Fl_Menu_Item menu_3d_algo[] = {
         {"Isotropic", 0, 0, 0},
         {"Netgen", 0, 0, 0},
+//        {"Tetgen", 0, 0, 0},
         {0}
       };
 
diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp
index 56e4c4e78c..b5595be13c 100644
--- a/Mesh/3D_Mesh.cpp
+++ b/Mesh/3D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_Mesh.cpp,v 1.65 2005-05-15 01:44:26 geuzaine Exp $
+// $Id: 3D_Mesh.cpp,v 1.66 2005-06-29 10:02:55 tardieu Exp $
 //
 // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 //
@@ -875,6 +875,10 @@ void Maillage_Volume(void *data, void *dum)
   }
   else if((v->Typ != 99999) && Mesh_Netgen(v)) {
   }
+//  else if((v->Typ != 99999) && Mesh_Tetgen(v)) {
+//  }
+//  else if((v->Typ == 99999) && (CTX.mesh.algo3d != FRONTAL_NETGEN)
+//                            && (CTX.mesh.algo3d != DELAUNAY_TETGEN)) {
   else if((v->Typ == 99999) && (CTX.mesh.algo3d != FRONTAL_NETGEN)) {
     
     Simplexes_New = List_Create(10, 10, sizeof(Simplex *));
diff --git a/Mesh/Mesh.h b/Mesh/Mesh.h
index fbd9d07638..980252367f 100644
--- a/Mesh/Mesh.h
+++ b/Mesh/Mesh.h
@@ -395,6 +395,7 @@ typedef struct{
 #define DELAUNAY_ANISO 2
 #define DELAUNAY_TRIANGLE 3
 #define FRONTAL_NETGEN 4
+//#define DELAUNAY_TETGEN 5
 
 struct _Mesh{
   char name[256];
@@ -474,6 +475,7 @@ int AlgorithmeMaillage2DAnisotropeModeJF(Surface *s);
 void Maillage_Automatique_VieuxCode(Surface *pS, Mesh *m, int ori);
 int Mesh_Triangle(Surface *s);
 int Mesh_Netgen(Volume *v);
+//int Mesh_Tetgen(Volume *v);
 void Optimize_Netgen(Volume *v);
 void Optimize_Netgen(Mesh *m);
 
diff --git a/configure.in b/configure.in
index 56936e6107..2be85c3137 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.71 2005-06-24 18:14:15 geuzaine Exp $
+dnl $Id: configure.in,v 1.72 2005-06-29 10:02:54 tardieu Exp $
 dnl
 dnl Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
 dnl
@@ -277,6 +277,36 @@ else
 fi
 
 
+#dnl Check if Tetgen is installed
+#AC_CHECK_FILE(./Tetgen/tetgen.h, TETGEN="yes", TETGEN="no")
+#if test "x${TETGEN}" = "xyes"; then
+#  if test "x$enable_tetgen" != "xno"; then
+#     GMSH_DIRS="${GMSH_DIRS} Tetgen"
+#     GMSH_LIBS="${GMSH_LIBS} -lGmshTetgen"
+#     FLAGS="-DHAVE_TETGEN ${FLAGS}"
+#     echo "********************************************************************"
+#     echo "You are building a version of Gmsh that contains Hang Si's"
+#     echo "Tetgen as an alternative 3D mesh generator. Tetgen is distributed"
+#     echo "under the GNU LGPL: see ./Tetgen/LICENSE for more info."
+#     echo "To disable Tetgen, run configure again with the --disable-tetgen"
+#     echo "option."
+#     echo "********************************************************************"
+#  fi
+#else
+#  if test "x$enable_tetgen" != "xno"; then
+#     echo "********************************************************************"
+#     echo "If you want to use Hang Si's Tetgen as an alternative "
+#     echo "3D mesh generator, please download Tetgen from the project's"
+#     echo "web site at http://www.tetgen.berlios.de, unpack the archive"
+#     echo "and move the files in the ./Tetgen subdirectory. Then"
+#     echo "run ./configure again."
+#     echo "Please note that by doing so, you agree with Tetgen's licensing"
+#     echo "requirements stated in ./Tetgen/LICENSE."
+#     echo "********************************************************************"
+#  fi
+#fi
+
+
 dnl Check for MathEval
 AC_CHECK_FILE(./MathEval/matheval.cpp, MATHEVAL="yes", MATHEVAL="no")
 if test "x${MATHEVAL}" = "xyes"; then
-- 
GitLab