From 7d76676464d74147af37153b2e065ed33e06a35a Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 2 Oct 2007 20:07:29 +0000
Subject: [PATCH] added option to draw skin of 3D meshes

---
 Common/Context.h        |  2 +-
 Common/DefaultOptions.h |  2 ++
 Common/Options.cpp      | 10 +++++++++-
 Common/Options.h        |  1 +
 Graphics/Mesh.cpp       |  5 +++--
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index c14a3cbf5b..115fc94b21 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -176,7 +176,7 @@ public :
     int quality_type, label_type;
     double quality_inf, quality_sup, radius_inf, radius_sup;
     double scaling_factor, lc_factor, rand_factor, lc_integration_precision;
-    int dual;
+    int dual, draw_skin_only;
     int light, light_two_side, light_lines;
     int format, nb_smoothing, algo2d, algo3d, algo_recombine;
     int order, second_order_linear, second_order_incomplete;
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 0017ed7935..98165d6213 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -917,6 +917,8 @@ StringXNumber MeshOptions_Number[] = {
   { F,   "CutPlaneD" , opt_mesh_cut_planed , 0.0 , 
     "Fourth cut plane equation coefficient (`D' in `AX+BY+CZ+D=0')" },
 
+  { F|O, "DrawSkinOnly" , opt_mesh_draw_skin_only , 0. ,
+    "Draw only the skin of 3D meshes?" },
   { F|O, "Dual" , opt_mesh_dual , 0. ,
     "Display the dual mesh obtained by barycentric subdivision" },
 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index ca50d51528..37405944c5 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.362 2007-09-24 08:14:28 geuzaine Exp $
+// $Id: Options.cpp,v 1.363 2007-10-02 20:07:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -4935,6 +4935,14 @@ double opt_mesh_dual(OPT_ARGS_NUM)
   return CTX.mesh.dual;
 }
 
+double opt_mesh_draw_skin_only(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET) {
+    CTX.mesh.draw_skin_only = (int)val;
+  }
+  return CTX.mesh.draw_skin_only;
+}
+
 double opt_mesh_use_cut_plane(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET){
diff --git a/Common/Options.h b/Common/Options.h
index 63eedc0afe..18ce4f9d1b 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -483,6 +483,7 @@ double opt_mesh_smooth_internal_edges(OPT_ARGS_NUM);
 double opt_mesh_second_order_linear(OPT_ARGS_NUM);
 double opt_mesh_second_order_incomplete(OPT_ARGS_NUM);
 double opt_mesh_dual(OPT_ARGS_NUM);
+double opt_mesh_draw_skin_only(OPT_ARGS_NUM);
 double opt_mesh_use_cut_plane(OPT_ARGS_NUM);
 double opt_mesh_cut_plane_draw_intersect(OPT_ARGS_NUM);
 double opt_mesh_cut_plane_only_volume(OPT_ARGS_NUM);
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 3c3f666ac8..f45ace2abf 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Mesh.cpp,v 1.208 2007-09-22 20:35:18 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.209 2007-10-02 20:07:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -417,6 +417,7 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements,
 
     if(faces){
       bool unique = e->dim() > 2 && !CTX.pick_elements;
+      bool skin = e->dim() > 2 && CTX.mesh.draw_skin_only;
       for(int j = 0; j < ele->getNumFacesRep(); j++){
 	double x[3], y[3], z[3];
 	SVector3 n[3];
@@ -431,7 +432,7 @@ static void addElementsInArrays(GEntity *e, std::vector<T*> &elements,
 	if(e->dim() == 2 && CTX.mesh.smooth_normals)
 	  for(int k = 0; k < 3; k++)
 	    e->model()->normals->get(x[k], y[k], z[k], n[k][0], n[k][1], n[k][2]);
-	e->va_triangles->add(x, y, z, n, col, ele, unique);
+	e->va_triangles->add(x, y, z, n, col, ele, unique, skin);
       }
     }
   }
-- 
GitLab