diff --git a/Common/ColorTable.cpp b/Common/ColorTable.cpp
index 061b7953cb6238366facf75fb644b20a6305d72f..566fb89576a54427dda25f4b0a7c4b436f821f87 100644
--- a/Common/ColorTable.cpp
+++ b/Common/ColorTable.cpp
@@ -1,4 +1,4 @@
-// $Id: ColorTable.cpp,v 1.3 2001-02-12 17:38:02 geuzaine Exp $
+// $Id: ColorTable.cpp,v 1.4 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "ColorTable.h"
@@ -40,13 +40,17 @@ void ColorTable_Recompute(ColorTable *ct, int rgb_flag, int alpha_flag){
   rotate = ct->ipar[COLORTABLE_ROTATE];
 
   for (i=0 ; i<ct->size ; i++) {
-    
-    if(i+rotate<0)
-      s = (float) (i+rotate+ct->size) / (float) (ct->size-1);
-    else if(i+rotate>ct->size-1)
-      s = (float) (i+rotate-ct->size) / (float) (ct->size-1);
+
+    if(ct->size>1){
+      if(i+rotate<0)
+	s = (float) (i+rotate+ct->size) / (float) (ct->size-1);
+      else if(i+rotate>ct->size-1)
+	s = (float) (i+rotate-ct->size) / (float) (ct->size-1);
+      else
+	s = (float) (i+rotate) / (float) (ct->size-1);
+    }
     else
-      s = (float) (i+rotate) / (float) (ct->size-1);
+      s = 0.;
 
     if(ct->ipar[COLORTABLE_SWAP]) s = 1.0 - s;
     
@@ -80,16 +84,20 @@ void ColorTable_Recompute(ColorTable *ct, int rgb_flag, int alpha_flag){
         if (s-bias<=0.00) {
           r = 0 ; g = 0 ; b = 255 ; 
         }
-        else if(s-bias<=0.25+curve){ 
+        else if(s-bias<=0.25+curve){
+	  curve = (curve == -0.25)? -0.26 : curve;
           r = 0 ; g = (int)((s-bias)*(255./(0.25+curve))) ; b = 255 ; 
         }
-        else if(s-bias<=0.50) { 
+        else if(s-bias<=0.50) {
+	  curve = (curve == 0.25)? 0.26 : curve;
           r = 0 ; g = 255 ; b = (int)(255.-(255./(0.25-curve))*(s-bias-0.25-curve)); 
         }
-        else if(s-bias<=0.75-curve){ 
+        else if(s-bias<=0.75-curve){
+	  curve = (curve == 0.25)? 0.26 : curve;
           r = (int)((s-bias-0.5)*(255./(0.25-curve))); g = 255 ; b = 0 ; 
         }
-        else if(s-bias<=1.00) { 
+        else if(s-bias<=1.00) {
+	  curve = (curve == -0.25)? -0.26 : curve;
           r = 255; g = (int)(255.-(255./(0.25+curve))*(s-bias-0.75+curve)) ; b = 0 ;
         }
         else { 
@@ -127,8 +135,8 @@ void ColorTable_Recompute(ColorTable *ct, int rgb_flag, int alpha_flag){
       if(ct->fpar[COLORTABLE_BETA]){
         if(ct->fpar[COLORTABLE_BETA] > 0.0)
           gamma = 1. - ct->fpar[COLORTABLE_BETA];
-        else
-          gamma = 1./(1.001 + ct->fpar[COLORTABLE_BETA]);
+	else 
+	  gamma = 1./(1.001 + ct->fpar[COLORTABLE_BETA]);//beta is thresholded to [-1,1]
         r = (int)( 255. * pow((double)r/255.,gamma) );
         g = (int)( 255. * pow((double)g/255.,gamma) );
         b = (int)( 255. * pow((double)b/255.,gamma) );
diff --git a/Common/ColorTable.h b/Common/ColorTable.h
index ac8f2cb77af03616eb0f4b8739e887122a3f1198..e0b1b52676beb57c63ded298f844bcf0dbc4617e 100644
--- a/Common/ColorTable.h
+++ b/Common/ColorTable.h
@@ -6,7 +6,7 @@
 
 typedef struct{
   unsigned int table[COLORTABLE_NBMAX_COLOR];
-  int size;
+  int size; // must be >= 2
   int ipar[COLORTABLE_NBMAX_PARAM];
   float fpar[COLORTABLE_NBMAX_PARAM];
 }ColorTable;
diff --git a/Common/Numeric.cpp b/Common/Numeric.cpp
index 330037f1b073e7d0621fca45999e15a3573a3e4a..43a6ac8d5a6dcd7092a77a86b2fd980009096564 100644
--- a/Common/Numeric.cpp
+++ b/Common/Numeric.cpp
@@ -1,4 +1,4 @@
-// $Id: Numeric.cpp,v 1.2 2001-11-01 09:39:50 geuzaine Exp $
+// $Id: Numeric.cpp,v 1.3 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -49,7 +49,7 @@ int sys2x2 (double mat[2][2], double b[2], double res[2]){
 
   // TOLERANCE ! WARNING WARNING
   if (norm == 0.0 || fabs (det) / norm < 1.e-12){
-    Msg(DEBUG, "Assuming 2x2 matrix is singular (det/norm == %g)", fabs(det)/norm);
+    if(norm) Msg(DEBUG, "Assuming 2x2 matrix is singular (det/norm == %g)", fabs(det)/norm);
     res[0] = res[1] = 0.0 ;
     return 0;
   }
@@ -108,7 +108,7 @@ int sys3x3_with_tol (double mat[3][3], double b[3], double res[3], double *det){
 
   // TOLERANCE ! WARNING WARNING
   if (norm == 0.0 || fabs (*det) / norm < 1.e-12){
-    Msg(DEBUG, "Assuming 3x3 matrix is singular (det/norm == %g)", fabs(*det)/norm);
+    if(norm) Msg(DEBUG, "Assuming 3x3 matrix is singular (det/norm == %g)", fabs(*det)/norm);
     res[0] = res[1] = res[2] = 0.0 ;
     return 0;
   }
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 37efb30d6d2ff74f5c2cbae772ce45aacbf833a8..b680e62628a7f94b9fe0cb58e7aa887434675ba6 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.65 2001-11-19 14:24:01 geuzaine Exp $
+// $Id: Options.cpp,v 1.66 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -692,15 +692,15 @@ double opt_general_translation2(OPT_ARGS_NUM){
   return CTX.t[2];
 }
 double opt_general_scale0(OPT_ARGS_NUM){
-  if(action & GMSH_SET) CTX.s[0] = val;
+  if(action & GMSH_SET) CTX.s[0] = val?val:1.0;
   return CTX.s[0];
 }
 double opt_general_scale1(OPT_ARGS_NUM){
-  if(action & GMSH_SET) CTX.s[1] = val;
+  if(action & GMSH_SET) CTX.s[1] = val?val:1.0;
   return CTX.s[1];
 }
 double opt_general_scale2(OPT_ARGS_NUM){
-  if(action & GMSH_SET) CTX.s[2] = val;
+  if(action & GMSH_SET) CTX.s[2] = val?val:1.0;
   return CTX.s[2];
 }
 double opt_general_point_size(OPT_ARGS_NUM){
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 6fb150961e7302926bfc0bb1c438b3446f5b10da..500072cebf19edc3e91ad1b98a28eedf0a1fca40 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.96 2001-11-19 18:40:58 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.97 2001-12-03 08:41:43 geuzaine Exp $
 
 #include <sys/types.h>
 #include <signal.h>
@@ -11,7 +11,6 @@
 #include "Draw.h"
 #include "Views.h"
 #include "Timer.h"
-#include "Visibility.h"
 #include "CreateFile.h"
 #include "OpenFile.h"
 #include "GetOptions.h"
@@ -20,6 +19,7 @@
 #include "GUI.h"
 #include "Callbacks.h"
 #include "Plugin.h"
+#include "Visibility.h"
 
 using namespace std;
 
@@ -32,7 +32,7 @@ using namespace std;
 #include <errno.h>
 
 extern GUI       *WID;
-extern Mesh       M;
+extern Mesh      *THEM;
 extern Context_T  CTX;
 
 // Compatibility/local routines
@@ -391,19 +391,6 @@ void opt_general_ok_cb(CALLBACK_ARGS){
 void opt_geometry_cb(CALLBACK_ARGS) {
   WID->create_geometry_options_window();
 }
-void opt_geometry_show_by_entity_num_cb(CALLBACK_ARGS) {
-  char * c = (char*)((Fl_Input*)w)->value(); 
-  if (!strcmp(c,"all") || !strcmp(c,"*")){
-    if(SHOW_ALL_ENTITIES){ RemplirEntitesVisibles(0); SHOW_ALL_ENTITIES = 0; }
-    else { RemplirEntitesVisibles(1); SHOW_ALL_ENTITIES = 1; }
-  }
-  else{ 
-    int i = atoi(c);
-    if(EntiteEstElleVisible(i)) ToutesLesEntitesRelatives(i,EntitesVisibles,0);
-    else ToutesLesEntitesRelatives(i,EntitesVisibles,1);
-  }
-  Draw();
-}
 void opt_geometry_color_scheme_cb(CALLBACK_ARGS){
   opt_geometry_color_scheme(0,GMSH_SET, WID->geo_value[2]->value());
   Draw();
@@ -431,9 +418,6 @@ void opt_geometry_ok_cb(CALLBACK_ARGS) {
 void opt_mesh_cb(CALLBACK_ARGS) {
   WID->create_mesh_options_window();
 }
-void opt_mesh_show_by_entity_num_cb(CALLBACK_ARGS) {
-  opt_geometry_show_by_entity_num_cb(w,data);
-}
 void opt_mesh_color_scheme_cb(CALLBACK_ARGS){
   opt_mesh_color_scheme(0,GMSH_SET, WID->mesh_value[12]->value());
   Draw();
@@ -513,13 +497,13 @@ void opt_statistics_update_cb(CALLBACK_ARGS) {
 void opt_statistics_histogram_cb(CALLBACK_ARGS) {
   int i, type=(long int)data;
 
-  Print_Histogram(M.Histogram[type]);
+  Print_Histogram(THEM->Histogram[type]);
 
   double *x=(double*)Malloc(NB_HISTOGRAM*sizeof(double));
   double *y=(double*)Malloc(NB_HISTOGRAM*sizeof(double));
   for(i=0;i<NB_HISTOGRAM;i++){
     x[i]=(double)(i+1)/(double)NB_HISTOGRAM;
-    y[i]=(double)M.Histogram[type][i];
+    y[i]=(double)THEM->Histogram[type][i];
   }
   char *name;
   if(type==0) name = "Gamma";
@@ -546,6 +530,199 @@ void opt_save_cb(CALLBACK_ARGS) {
   Print_Options(0,GMSH_OPTIONSRC, CTX.optionsrc_filename); 
 }
 
+// Option Visibility Menu
+
+void select_vis_browser(int mode){
+  int i;
+  Entity *e;
+  for(i=1 ; i<=WID->vis_browser->size(); i++){
+    e = (Entity*)WID->vis_browser->data(i);
+    if((mode == VIS_GEO|VIS_MESH && e->Visible() == mode) ||
+       (mode == VIS_GEO          && e->Visible() & VIS_GEO) ||
+       (mode == VIS_MESH         && e->Visible() & VIS_MESH)) 
+      WID->vis_browser->select(i);
+  }
+}
+
+void opt_visibility_cb(CALLBACK_ARGS) {
+  int i, type, mode;
+  List_T *list;
+  Entity *e;
+
+  WID->create_visibility_window();
+  WID->vis_browser->clear();
+
+  switch(WID->vis_type->value()){
+  case 0 : type = ELEMENTARY; break;
+  default: type = PHYSICAL; break;
+  }
+  switch(WID->vis_browser_mode->value()){
+  case 0 : mode = VIS_GEO|VIS_MESH; break;
+  case 1 : mode = VIS_GEO; break;
+  default: mode = VIS_MESH; break;
+  }
+
+  list = GetVisibilityList(type);
+
+  for(i=0 ; i<List_Nbr(list); i++){
+    e = (Entity*)List_Pointer(list,i);
+    WID->vis_browser->add(e->BrowserLine(),e);
+  }
+  select_vis_browser(mode);
+}
+
+void opt_visibility_ok_cb(CALLBACK_ARGS) {
+  int i, mode;
+  Entity *e;
+
+  InitVisibilityThroughPhysical();
+
+  switch(WID->vis_type->value()){
+  case 0 : ClearVisibilityList(PHYSICAL); break;
+  default: ClearVisibilityList(ELEMENTARY); break;
+  }
+  switch(WID->vis_browser_mode->value()){
+  case 0 : mode = VIS_GEO|VIS_MESH; break;
+  case 1 : mode = VIS_GEO; break;
+  default: mode = VIS_MESH; break;
+  }
+
+  for(i=1 ; i<=WID->vis_browser->size(); i++){
+    e = (Entity*)WID->vis_browser->data(i);
+    if(WID->vis_browser->selected(i)){
+      e->Visible(e->Visible()|mode);
+    }
+    else{
+      switch(WID->vis_browser_mode->value()){
+      case 0 : 
+	e->Visible(0);
+	break;
+      case 1 :
+	if(e->Visible() & VIS_MESH) e->Visible(VIS_MESH);
+	else e->Visible(0);
+	break;
+      default :
+	if(e->Visible() & VIS_GEO) e->Visible(VIS_GEO);
+	else e->Visible(0);
+	break;
+      }
+    }
+  }
+
+  if(WID->vis_butt[0]->value()){
+    for(i=1 ; i<=WID->vis_browser->size(); i++){
+      e = (Entity*)WID->vis_browser->data(i);
+      e->RecurVisible();
+    }
+    select_vis_browser(mode);
+  }
+
+  Draw();
+}
+
+void opt_visibility_sort_cb(CALLBACK_ARGS){
+  int i, val = (long int)data, selectall;
+
+  if(!val){
+    selectall=0;
+    for(i=1 ; i<=WID->vis_browser->size(); i++)
+      if(!WID->vis_browser->selected(i)){
+	selectall=1;
+	break;
+      }
+    if(selectall)
+      for(i=1 ; i<=WID->vis_browser->size(); i++)
+	WID->vis_browser->select(i);
+    else
+      WID->vis_browser->deselect();
+  }
+  else{
+    SetVisibilitySort(val);
+    opt_visibility_cb(NULL,NULL);
+  }
+}
+
+static int vnod, velm;
+static void vis_nod(void *a, void *b){ (*(Vertex**)a)->Visible = vnod; }
+static void vis_sim(void *a, void *b){ (*(Simplex**)a)->Visible = velm; }
+static void vis_hex(void *a, void *b){ (*(Hexahedron**)a)->Visible = velm; }
+static void vis_pri(void *a, void *b){ (*(Prism**)a)->Visible = velm; }
+static void vis_pyr(void *a, void *b){ (*(Pyramid**)a)->Visible = velm; }
+
+void opt_visibility_number_cb(CALLBACK_ARGS){
+  static int allnod=1, allelm=1;
+  int i, type = WID->vis_input_mode->value(), found, num;
+  List_T *tmp;
+  Vertex vv,*v,**pv;
+  Volume *V;
+  Simplex SS, *S, **pS;
+  Hexahedron HH, *H, **pH;
+  Prism PP, *P, **pP;
+  Pyramid QQ, *Q, **pQ;
+  char *str = (char*)((Fl_Input*)w)->value(); 
+
+  if (!strcmp(str,"all") || !strcmp(str,"*")){
+    if(type==0){
+      allnod = !allnod;
+      vnod = allnod ? VIS_MESH : 0;
+      Tree_Action(THEM->Vertices, vis_nod);
+    }
+    else{
+      allelm = !allelm;
+      velm = allelm ? VIS_MESH : 0;
+      Tree_Action(THEM->Simplexes, vis_sim);
+      tmp = Tree2List(THEM->Volumes);
+      for(i=0; i<List_Nbr(tmp); i++){
+	List_Read(tmp, i, &V);
+	Tree_Action(V->Hexahedra, vis_hex);
+	Tree_Action(V->Prisms, vis_pri);
+	Tree_Action(V->Pyramids, vis_pyr);
+      }
+      List_Delete(tmp);
+    }
+  }
+  else{ 
+    num = atoi(str);
+
+    if(type==0){
+      vv.Num = num; v = &vv;
+      if((pv = (Vertex**)Tree_PQuery(THEM->Vertices, &v)))
+	(*pv)->Visible = (*pv)->Visible ? 0 : VIS_MESH;
+      else
+	Msg(WARNING, "Unknown node %d (use '*' to hide/show all nodes)", num);
+    }
+    else{
+      SS.Num = num; S = &SS;
+      HH.Num = num; H = &HH;
+      PP.Num = num; P = &PP;
+      QQ.Num = num; Q = &QQ;
+      if((pS = (Simplex**)Tree_PQuery(THEM->Simplexes, &S))){
+	(*pS)->Visible = (*pS)->Visible ? 0 : VIS_MESH;
+      }
+      else{
+	found = 0;
+	tmp = Tree2List(THEM->Volumes);
+	for(i=0; i<List_Nbr(tmp); i++){
+	  List_Read(tmp, i, &V);
+	  if((pH = (Hexahedron**)Tree_PQuery(V->Hexahedra, &H))){
+	    (*pH)->Visible = (*pH)->Visible ? 0 : VIS_MESH; found = 1; break;
+	  }
+	  if((pP = (Prism**)Tree_PQuery(V->Prisms, &P))){
+	    (*pP)->Visible = (*pP)->Visible ? 0 : VIS_MESH; found = 1; break;
+	  }
+	  if((pQ = (Pyramid**)Tree_PQuery(V->Pyramids, &Q))){
+	    (*pQ)->Visible = (*pQ)->Visible ? 0 : VIS_MESH; found = 1; break;
+	  }
+	}
+	List_Delete(tmp);
+	if(!found) 
+	  Msg(WARNING, "Unknown element %d (use '*' to hide/show all elements)", num);
+      }
+    }
+  }
+  Draw();
+}
+
 // Help Menu
 
 void help_short_cb(CALLBACK_ARGS){
@@ -708,12 +885,12 @@ static void _new_multiline(int type){
 	}
       }
       n=0;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -748,13 +925,13 @@ void geometry_elementary_add_new_line_cb(CALLBACK_ARGS){
     }
     if(ib == 0) { /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
     if(n == 2){
       add_multline(2,p,CTX.filename);
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       n=0;
     }
@@ -790,13 +967,13 @@ void geometry_elementary_add_new_circle_cb(CALLBACK_ARGS){
     }
     if(ib == 0) { /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
     if(n == 3){
       add_circ(p[0],p[1],p[2],CTX.filename); /* begin, center, end */
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       n=0;
     }
@@ -827,13 +1004,13 @@ void geometry_elementary_add_new_ellipsis_cb(CALLBACK_ARGS){
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
     if(n == 4){
       add_ell(p[0],p[1],p[2],p[3],CTX.filename);
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       n=0;
     }
@@ -874,7 +1051,7 @@ static void _new_surface_volume(int mode){
       Msg(STATUS3N,"Select boundary ('q'=quit)");
       ib = SelectEntity(type, &v,&c,&s);
       if(ib <= 0){
-	ZeroHighlight(&M);
+	ZeroHighlight(THEM);
 	Draw();
 	goto stopall;
       }       
@@ -889,7 +1066,7 @@ static void _new_surface_volume(int mode){
 	  Msg(STATUS3N,"Select holes ('q'=quit)");
 	  ib = SelectEntity(type, &v,&c,&s); 
 	  if(ib <= 0){
-	    ZeroHighlight(&M);
+	    ZeroHighlight(THEM);
 	    Draw();
 	    break;
 	  }
@@ -908,7 +1085,7 @@ static void _new_surface_volume(int mode){
 	  case 1 : add_surf(Liste2,CTX.filename,0,1); break;
 	  case 2 : add_multvol(Liste2,CTX.filename); break;
 	  }
-	  ZeroHighlight(&M);
+	  ZeroHighlight(THEM);
 	  Draw();
 	  break;
 	}
@@ -962,7 +1139,7 @@ static void _transform_point_curve_surface(int transfo, int mode, char *what){
   while(1){
     Msg(STATUS3N,"Select %s ('q'=quit)", what);
     if(!SelectEntity(type, &v,&c,&s)){
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -980,7 +1157,7 @@ static void _transform_point_curve_surface(int transfo, int mode, char *what){
     case 5: protude(num,CTX.filename,what); break;
     case 6: delet(num,CTX.filename,what); break;
     }
-    ZeroHighlight(&M);
+    ZeroHighlight(THEM);
     Draw();
   }
   Msg(STATUS3N,"Ready");
@@ -1210,12 +1387,12 @@ static void _add_physical(char *what){
       if(List_Nbr(Liste1)){
 	add_physical(Liste1,CTX.filename,type,&zone);
 	List_Reset(Liste1);
-	ZeroHighlight(&M);
+	ZeroHighlight(THEM);
 	Draw();
       }
     }
     if(ib == 0){
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -1242,29 +1419,29 @@ void geometry_physical_add_volume_cb (CALLBACK_ARGS){
 // Dynamic Mesh Menus
 
 void mesh_save_cb(CALLBACK_ARGS) {
-  Print_Mesh(&M, CTX.output_filename, CTX.mesh.format);
+  Print_Mesh(THEM, CTX.output_filename, CTX.mesh.format);
 }
 void mesh_save_all_cb(CALLBACK_ARGS) {
   int all = CTX.mesh.save_all;
   CTX.mesh.save_all = 1;
-  Print_Mesh(&M, CTX.output_filename, CTX.mesh.format);
+  Print_Mesh(THEM, CTX.output_filename, CTX.mesh.format);
   CTX.mesh.save_all = all;
 }
 void mesh_define_cb(CALLBACK_ARGS){
   WID->set_context(menu_mesh_define, 0);
 }
 void mesh_1d_cb(CALLBACK_ARGS){
-  mai3d(&M, 1); 
+  mai3d(THEM, 1); 
   Draw();
   Msg(STATUS3N,"Ready");
 }
 void mesh_2d_cb(CALLBACK_ARGS){
-  mai3d(&M, 2);
+  mai3d(THEM, 2);
   Draw();
   Msg(STATUS3N,"Ready");
 } 
 void mesh_3d_cb(CALLBACK_ARGS){
-  mai3d(&M, 3); 
+  mai3d(THEM, 3); 
   Draw();
   Msg(STATUS3N,"Ready");
 } 
@@ -1292,14 +1469,14 @@ void mesh_define_length_cb (CALLBACK_ARGS){
       if(n >= 1) {
 	add_charlength(n,p,CTX.filename); 
 	n=0;
-	ZeroHighlight(&M);
+	ZeroHighlight(THEM);
 	Draw();
 	break;
       }
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -1330,12 +1507,12 @@ void mesh_define_recombine_cb (CALLBACK_ARGS){
 	add_recosurf(n,p,CTX.filename); break;
       }
       n=0;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -1421,13 +1598,13 @@ static void _add_transfinite(int dim){
 	      break;
 	    }
 	    n=0;
-	    ZeroHighlight(&M);
+	    ZeroHighlight(THEM);
 	    Draw();
 	    break;
 	  }
 	  if(ib == 0){ /* 'q' */
 	    n=0 ;
-	    ZeroHighlight(&M);
+	    ZeroHighlight(THEM);
 	    Draw();
 	    break;
 	  }
@@ -1440,12 +1617,12 @@ static void _add_transfinite(int dim){
 	if(n >= 1) add_trsfline(n,p,CTX.filename);
       }
       n=0;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
     }
     if(ib == 0){ /* 'q' */
       n=0 ;
-      ZeroHighlight(&M);
+      ZeroHighlight(THEM);
       Draw();
       break;
     }
@@ -1776,14 +1953,10 @@ void view_options_plugin_cb(CALLBACK_ARGS){
   std::pair<int,GMSH_Plugin*> *pair =  (std::pair<int,GMSH_Plugin*>*)data;
   GMSH_Plugin *p = pair->second;
 
-  if(!p->dialogBox)p->dialogBox = WID->create_plugin_window(p);
+  if(!p->dialogBox) p->dialogBox = WID->create_plugin_window(p);
 
   p->dialogBox->run_button->callback(view_plugin_cb, (void*)pair);
-
-  if(p->dialogBox->main_window->shown())
-    p->dialogBox->main_window->redraw();
-  else
-    p->dialogBox->main_window->show();    
+  p->dialogBox->main_window->show();    
 }
 
 void view_options_custom_cb(CALLBACK_ARGS){
@@ -2033,7 +2206,7 @@ void con_geometry_define_point_cb(CALLBACK_ARGS){
   strcpy(z_text, WID->context_geometry_input[4]->value());
   strcpy(l_text, WID->context_geometry_input[5]->value());
   add_point(CTX.filename);
-  ZeroHighlight(&M);
+  ZeroHighlight(THEM);
   Replot();
 }
 
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
index e25902d56eb93252c77c3182f049f7c6fb52d278..211d409d031d99f6776914f82921dc9e0e32912b 100644
--- a/Fltk/Callbacks.h
+++ b/Fltk/Callbacks.h
@@ -52,14 +52,12 @@ void opt_general_ok_cb(CALLBACK_ARGS) ;
 // Option Geometry Menu
 
 void opt_geometry_cb(CALLBACK_ARGS) ;
-void opt_geometry_show_by_entity_num_cb(CALLBACK_ARGS) ;
 void opt_geometry_color_scheme_cb(CALLBACK_ARGS) ;
 void opt_geometry_ok_cb(CALLBACK_ARGS) ;
 
 // Option Mesh Menu
 
 void opt_mesh_cb(CALLBACK_ARGS) ;
-void opt_mesh_show_by_entity_num_cb(CALLBACK_ARGS) ;
 void opt_mesh_color_scheme_cb(CALLBACK_ARGS) ;
 void opt_mesh_ok_cb(CALLBACK_ARGS) ;
 
@@ -85,6 +83,13 @@ void opt_message_cb(CALLBACK_ARGS) ;
 void opt_message_clear_cb(CALLBACK_ARGS) ;
 void opt_message_save_cb(CALLBACK_ARGS) ;
 
+// Option Visibility Menu
+
+void opt_visibility_cb(CALLBACK_ARGS) ;
+void opt_visibility_sort_cb(CALLBACK_ARGS) ;
+void opt_visibility_number_cb(CALLBACK_ARGS);
+void opt_visibility_ok_cb(CALLBACK_ARGS) ;
+
 void opt_save_cb(CALLBACK_ARGS) ;
 
 // Help Menu
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 9addec20843f36c5fde30467bed9c77b290ea8ef..6c3cfca73b5b9bf1f9408c722e5740746d8bc9ac 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.138 2001-11-23 12:14:05 geuzaine Exp $
+// $Id: GUI.cpp,v 1.139 2001-12-03 08:41:43 geuzaine Exp $
 
 // To make the interface as visually consistent as possible, please:
 // - use the IW, BB, BH, BW and WB values
@@ -78,6 +78,7 @@ Fl_Menu_Item m_menubar_table[] = {
          {"UCB YUV (yuv)...",          0, (Fl_Callback *)file_save_as_yuv_cb, 0},
          {0},
       {0},
+    {"Visibility...",    FL_SHIFT+'v', (Fl_Callback *)opt_visibility_cb, 0},
     {"Messages...",      FL_SHIFT+'l', (Fl_Callback *)opt_message_cb, 0},
     {"Statistics...",    FL_SHIFT+'i', (Fl_Callback *)opt_statistics_cb, 0, FL_MENU_DIVIDER},
     {"Quit",             FL_CTRL+'q', (Fl_Callback *)file_quit_cb, 0},
@@ -508,6 +509,7 @@ GUI::GUI(int argc, char **argv) {
   post_window = NULL;
   stat_window = NULL;
   msg_window = NULL;
+  vis_window = NULL;
   about_window = NULL;
   view_window = NULL;
   context_geometry_window = NULL;
@@ -548,6 +550,7 @@ GUI::GUI(int argc, char **argv) {
   create_post_options_window();
   create_view_options_window(-1);
   create_message_window();
+  create_visibility_window();
   create_about_window();
   create_getdp_window();
 
@@ -1118,7 +1121,7 @@ void GUI::create_geometry_options_window(){
   }
     
   int width = 25*CTX.fontsize;
-  int height = 5*WB+9*BH ;
+  int height = 5*WB+10*BH ;
   int BW = width-4*WB;
   
   geo_window = new Fl_Window(width,height);
@@ -1127,7 +1130,7 @@ void GUI::create_geometry_options_window(){
   { 
     Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH);
     { 
-      Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Algorithm");
+      Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "General");
       o->labelsize(CTX.fontsize);
       o->hide();
       geo_butt[8] = new Fl_Check_Button(2*WB, 2*WB+1*BH, BW, BH, "Auto coherence (suppress duplicates)");
@@ -1155,18 +1158,11 @@ void GUI::create_geometry_options_window(){
 	geo_butt[i]->selection_color(TOGGLE_COLOR);
       }
       
-      geo_input = new Fl_Input(2*WB, 2*WB+5*BH, IW, BH, "Show by entity number");
-      geo_input->labelsize(CTX.fontsize);
-      geo_input->textsize(CTX.fontsize);
-      geo_input->align(FL_ALIGN_RIGHT);
-      geo_input->callback(opt_geometry_show_by_entity_num_cb);
-      geo_input->when(FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED);
-      
-      geo_value[0] = new Fl_Value_Input(2*WB, 2*WB+6*BH, IW, BH, "Normals");
+      geo_value[0] = new Fl_Value_Input(2*WB, 2*WB+5*BH, IW, BH, "Normals");
       geo_value[0]->minimum(0); 
       geo_value[0]->maximum(100);
       geo_value[0]->step(0.1);
-      geo_value[1] = new Fl_Value_Input(2*WB, 2*WB+7*BH, IW, BH, "Tangents");
+      geo_value[1] = new Fl_Value_Input(2*WB, 2*WB+6*BH, IW, BH, "Tangents");
       geo_value[1]->minimum(0);
       geo_value[1]->maximum(100);
       geo_value[1]->step(0.1);
@@ -1255,7 +1251,7 @@ void GUI::create_mesh_options_window(){
   }
     
   int width = 25*CTX.fontsize;
-  int height = 5*WB+12*BH ;
+  int height = 5*WB+10*BH ;
   int BW = width-4*WB;
   
   mesh_window = new Fl_Window(width,height);
@@ -1264,33 +1260,23 @@ void GUI::create_mesh_options_window(){
   { 
     Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH);
     { 
-      Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Algorithm");
+      Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "General");
       o->labelsize(CTX.fontsize);
       o->hide();
       
-      mesh_butt[0] = new Fl_Check_Button(2*WB, 2*WB+1*BH, BW, BH, "Isotropic");
-      mesh_butt[1] = new Fl_Check_Button(2*WB, 2*WB+2*BH, BW, BH, "Isotropic (Triangle)");
-      mesh_butt[2] = new Fl_Check_Button(2*WB, 2*WB+3*BH, BW, BH, "Anisotropic");
-      for(i=0 ; i<3 ; i++){
-	mesh_butt[i]->type(FL_RADIO_BUTTON);
-	mesh_butt[i]->down_box(RADIO_BOX);
-	mesh_butt[i]->labelsize(CTX.fontsize);
-	mesh_butt[i]->selection_color(RADIO_COLOR);
-      }
-      
-      mesh_value[0] = new Fl_Value_Input(2*WB, 2*WB+4*BH, IW, BH, "Number of smoothing steps");
+      mesh_value[0] = new Fl_Value_Input(2*WB, 2*WB+1*BH, IW, BH, "Number of smoothing steps");
       mesh_value[0]->minimum(0);
       mesh_value[0]->maximum(100); 
       mesh_value[0]->step(1);
-      mesh_value[1] = new Fl_Value_Input(2*WB, 2*WB+5*BH, IW, BH, "Mesh scaling factor");
+      mesh_value[1] = new Fl_Value_Input(2*WB, 2*WB+2*BH, IW, BH, "Mesh scaling factor");
       mesh_value[1]->minimum(0.001);
       mesh_value[1]->maximum(1000); 
       mesh_value[1]->step(0.001);
-      mesh_value[2] = new Fl_Value_Input(2*WB, 2*WB+6*BH, IW, BH, "Characteristic length factor");
+      mesh_value[2] = new Fl_Value_Input(2*WB, 2*WB+3*BH, IW, BH, "Characteristic length factor");
       mesh_value[2]->minimum(0.001);
       mesh_value[2]->maximum(1000); 
       mesh_value[2]->step(0.001);
-      mesh_value[3] = new Fl_Value_Input(2*WB, 2*WB+7*BH, IW, BH, "Random perturbation factor");
+      mesh_value[3] = new Fl_Value_Input(2*WB, 2*WB+4*BH, IW, BH, "Random perturbation factor");
       mesh_value[3]->minimum(1.e-6);
       mesh_value[3]->maximum(1.e-1); 
       mesh_value[3]->step(1.e-6);
@@ -1301,16 +1287,41 @@ void GUI::create_mesh_options_window(){
 	mesh_value[i]->align(FL_ALIGN_RIGHT);
       }
       
-      mesh_butt[3] = new Fl_Check_Button(2*WB, 2*WB+8*BH, BW, BH, "Second order elements");
+      mesh_butt[3] = new Fl_Check_Button(2*WB, 2*WB+5*BH, BW, BH, "Second order elements");
       mesh_butt[3]->deactivate();//2nd order elements do not work. Disable the graphical option.
-      mesh_butt[4] = new Fl_Check_Button(2*WB, 2*WB+9*BH, BW, BH, "Interactive");
-      mesh_butt[5] = new Fl_Check_Button(2*WB, 2*WB+10*BH, BW, BH, "Constrain background mesh");
-      for(i=3 ; i<6 ; i++){
-	mesh_butt[i]->type(FL_TOGGLE_BUTTON);
-	mesh_butt[i]->down_box(TOGGLE_BOX);
+      mesh_butt[3]->type(FL_TOGGLE_BUTTON);
+      mesh_butt[3]->down_box(TOGGLE_BOX);
+      mesh_butt[3]->labelsize(CTX.fontsize);
+      mesh_butt[3]->selection_color(TOGGLE_COLOR);
+
+      mesh_butt[5] = new Fl_Check_Button(2*WB, 2*WB+6*BH, BW, BH, "Constrain background mesh");
+      mesh_butt[5]->type(FL_TOGGLE_BUTTON);
+      mesh_butt[5]->down_box(TOGGLE_BOX);
+      mesh_butt[5]->labelsize(CTX.fontsize);
+      mesh_butt[5]->selection_color(TOGGLE_COLOR);
+
+      o->end();
+    }
+    { 
+      Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "2D");
+      o->labelsize(CTX.fontsize);
+      o->hide();
+      
+      mesh_butt[0] = new Fl_Check_Button(2*WB, 2*WB+1*BH, BW, BH, "Old isotropic algorithm");
+      mesh_butt[1] = new Fl_Check_Button(2*WB, 2*WB+2*BH, BW, BH, "New isotropic algorithm");
+      mesh_butt[2] = new Fl_Check_Button(2*WB, 2*WB+3*BH, BW, BH, "Anisotropic algorithm");
+      for(i=0 ; i<3 ; i++){
+	mesh_butt[i]->type(FL_RADIO_BUTTON);
+	mesh_butt[i]->down_box(RADIO_BOX);
 	mesh_butt[i]->labelsize(CTX.fontsize);
-	mesh_butt[i]->selection_color(TOGGLE_COLOR);
+	mesh_butt[i]->selection_color(RADIO_COLOR);
       }
+      mesh_butt[4] = new Fl_Check_Button(2*WB, 2*WB+4*BH, BW, BH, "Interactive");
+      mesh_butt[4]->type(FL_TOGGLE_BUTTON);
+      mesh_butt[4]->down_box(TOGGLE_BOX);
+      mesh_butt[4]->labelsize(CTX.fontsize);
+      mesh_butt[4]->selection_color(TOGGLE_COLOR);
+
       o->end();
     }
     { 
@@ -1330,26 +1341,19 @@ void GUI::create_mesh_options_window(){
 	mesh_butt[i]->labelsize(CTX.fontsize);
 	mesh_butt[i]->selection_color(TOGGLE_COLOR);
       }
-      mesh_input = new Fl_Input(2*WB, 2*WB+5*BH, IW, BH, "Show by entity Number");
-      mesh_input->labelsize(CTX.fontsize);
-      mesh_input->textsize(CTX.fontsize);
-      mesh_input->align(FL_ALIGN_RIGHT);
-      mesh_input->callback(opt_mesh_show_by_entity_num_cb);
-      mesh_input->when(FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED);
-      
-      mesh_value[4] = new Fl_Value_Input(2*WB, 2*WB+6*BH, IW/2, BH);
+      mesh_value[4] = new Fl_Value_Input(2*WB, 2*WB+5*BH, IW/2, BH);
       mesh_value[4]->minimum(0); 
       mesh_value[4]->maximum(1);
       mesh_value[4]->step(0.001);
-      mesh_value[5] = new Fl_Value_Input(2*WB+IW/2, 2*WB+6*BH, IW/2, BH, "Quality range");
+      mesh_value[5] = new Fl_Value_Input(2*WB+IW/2, 2*WB+5*BH, IW/2, BH, "Quality range");
       mesh_value[5]->minimum(0); 
       mesh_value[5]->maximum(1);
       mesh_value[5]->step(0.001);
       
-      mesh_value[6] = new Fl_Value_Input(2*WB, 2*WB+7*BH, IW/2, BH);
-      mesh_value[7] = new Fl_Value_Input(2*WB+IW/2, 2*WB+7*BH, IW/2, BH, "Size range");
+      mesh_value[6] = new Fl_Value_Input(2*WB, 2*WB+6*BH, IW/2, BH);
+      mesh_value[7] = new Fl_Value_Input(2*WB+IW/2, 2*WB+6*BH, IW/2, BH, "Size range");
       
-      mesh_value[8] = new Fl_Value_Input(2*WB, 2*WB+8*BH, IW, BH, "Normals");
+      mesh_value[8] = new Fl_Value_Input(2*WB, 2*WB+7*BH, IW, BH, "Normals");
       mesh_value[8]->minimum(0); 
       mesh_value[8]->maximum(100);
       mesh_value[8]->step(1);
@@ -1504,7 +1508,7 @@ void GUI::create_post_options_window(){
     return;
   }
 
-  int width = 24*CTX.fontsize;
+  int width = 25*CTX.fontsize;
   int height = 5*WB+10*BH ;
   int BW = width-4*WB;
   
@@ -1591,7 +1595,7 @@ void GUI::create_statistics_window(){
     return;
   }
 
-  int width = 24*CTX.fontsize;
+  int width = 25*CTX.fontsize;
   int height = 5*WB+17*BH ;
   
   stat_window = new Fl_Window(width,height);
@@ -1935,6 +1939,121 @@ void GUI::fatal_error(char *filename){
 	   "(all messages have been saved in the error log file '%s')", filename);
 }
 
+//********************** Create the visibility window ****************************
+
+void GUI::reset_visibility(){
+  if(vis_window){
+    vis_browser->clear();
+    if(vis_window->shown()) 
+      opt_visibility_cb(NULL,NULL);
+  }
+}
+
+void GUI::create_visibility_window(){
+
+  if(vis_window){
+    vis_window->show();
+    return;
+  }
+
+  static int cols[5] = {15,100,100,200,0};  
+  static Fl_Menu_Item type_table[] = {
+    {"Elementary",  0, (Fl_Callback *)opt_visibility_cb},
+    {"Physical",    0, (Fl_Callback *)opt_visibility_cb},
+    {0}
+  };
+  static Fl_Menu_Item browser_mode_table[] = {
+    {"Geometry+Mesh",  0, (Fl_Callback *)opt_visibility_cb},
+    {"Geometry",       0, (Fl_Callback *)opt_visibility_cb},
+    {"Mesh",           0, (Fl_Callback *)opt_visibility_cb},
+    {0}
+  };
+  static Fl_Menu_Item input_mode_table[] = {
+    {"Node",     0, 0},
+    {"Element",  0, 0},
+    {0}
+  };
+
+  int width = cols[0]+cols[1]+cols[2]+cols[3]+2*WB;
+  int height = 15*BH ;
+  
+  vis_window = new Fl_Window(width,height);
+  vis_window->box(WINDOW_BOX);
+  vis_window->label("Visibility");
+  
+  int brw = width-2*WB;
+
+  vis_type = new Fl_Choice(1*WB,1*WB+0*BH,brw/3,BH);
+  vis_type->menu(type_table);
+  vis_type->textsize(CTX.fontsize);
+  
+  vis_browser_mode = new Fl_Choice(2*WB+brw/3,1*WB+0*BH,brw/3,BH);
+  vis_browser_mode->menu(browser_mode_table);
+  vis_browser_mode->textsize(CTX.fontsize);
+  
+  vis_butt[0] = new Fl_Check_Button(3*WB+2*brw/3, 1*WB+0*BH, brw/3, BH, "Recursive");
+  vis_butt[0]->type(FL_TOGGLE_BUTTON);
+  vis_butt[0]->down_box(TOGGLE_BOX);
+  vis_butt[0]->labelsize(CTX.fontsize);
+  vis_butt[0]->selection_color(TOGGLE_COLOR);
+  vis_butt[0]->value(1);
+
+  Fl_Button* o0 = new Fl_Button(1*WB, 2*WB+1*BH, cols[0], BH, "*");
+  o0->labelsize(CTX.fontsize);
+  o0->callback(opt_visibility_sort_cb, (void*)0);
+
+  Fl_Button* o1 = new Fl_Button(1*WB+cols[0], 2*WB+1*BH, cols[1], BH, "Type");
+  //Fl_Box *a = new Fl_Box(FL_NO_BOX, 1*WB+15+cols[0]-15-20, 2*WB+1*BH, 15, BH, "@#UpArrow");
+  //a->labeltype(FL_SYMBOL_LABEL);
+  o1->labelsize(CTX.fontsize);
+  o1->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
+  o1->callback(opt_visibility_sort_cb, (void*)1);
+
+  Fl_Button* o2 = new Fl_Button(1*WB+cols[0]+cols[1], 2*WB+1*BH, cols[2], BH, "Number");
+  o2->labelsize(CTX.fontsize);
+  o2->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
+  o2->callback(opt_visibility_sort_cb, (void*)2);
+
+  Fl_Button* o3 = new Fl_Button(1*WB+cols[0]+cols[1]+cols[2], 2*WB+1*BH, cols[3], BH, "Name");
+  o3->labelsize(CTX.fontsize);
+  o3->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
+  o3->callback(opt_visibility_sort_cb, (void*)3);
+
+  vis_browser = new Fl_Browser(1*WB, 2*WB+2*BH, brw, height-5*WB-4*BH);
+  vis_browser->textfont(FL_COURIER);
+  vis_browser->textsize(CTX.fontsize);
+  vis_browser->type(FL_MULTI_BROWSER);
+  vis_browser->column_widths(cols);
+
+  vis_window->resizable(new Fl_Box(width-3*WB-2*BB-10,height-5*WB-2*BH-10, 10,10));
+
+  vis_input = new Fl_Input(1*WB, height-2*WB-2*BH, brw/3, BH);
+  vis_input->labelsize(CTX.fontsize);
+  vis_input->textsize(CTX.fontsize);
+  vis_input->callback(opt_visibility_number_cb);
+  vis_input->when(FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED);
+
+  vis_input_mode = new Fl_Choice(2*WB+brw/3, height-2*WB-2*BH, brw/3, BH);
+  vis_input_mode->menu(input_mode_table);
+  vis_input_mode->textsize(CTX.fontsize);
+  
+  { 
+    Fl_Return_Button* o = new Fl_Return_Button(width-2*BB-2*WB, height-BH-WB, BB, BH, "OK");
+    o->labelsize(CTX.fontsize);
+    o->callback(opt_visibility_ok_cb);
+  }
+  { 
+    Fl_Button* o = new Fl_Button(width-BB-WB, height-BH-WB, BB, BH, "Cancel");
+    o->labelsize(CTX.fontsize);
+    o->callback(cancel_cb, (void*)vis_window);
+  }
+
+  if(CTX.center_windows)
+    vis_window->position(m_window->x()+m_window->w()/2-width/2,
+			 m_window->y()+9*BH-height/2);
+  vis_window->end();
+}
+
 //******************************* Create the about window ******************************
 
 void GUI::create_about_window(){
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index 6b735671b2957c7aa8a8e883dc54a19f838976e8..573ae7c235bbc020b5c84f29ef55f82a8e3de929 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -143,6 +143,13 @@ public:
   Fl_Window        *msg_window ;
   Fl_Browser       *msg_browser ;
 
+  // visibility window
+  Fl_Window        *vis_window ;
+  Fl_Choice        *vis_type, *vis_browser_mode, *vis_input_mode ;
+  Fl_Browser       *vis_browser ;
+  Fl_Check_Button  *vis_butt[20] ;
+  Fl_Input         *vis_input;
+
   // about window
   Fl_Window        *about_window ;
 
@@ -184,6 +191,7 @@ public:
   void create_post_options_window();
   PluginDialogBox *create_plugin_window(GMSH_Plugin *p);
   void create_view_options_window(int numview);
+  void create_visibility_window();
   void create_statistics_window();
   void create_message_window();
   void create_about_window();
@@ -213,6 +221,7 @@ public:
   void set_title(char *str);
   void add_handler();
   int  global_shortcuts(int event);
+  void reset_visibility();
   int  selection, try_selection, quit_selection, end_selection;
 
 };
diff --git a/Fltk/Makefile b/Fltk/Makefile
index c030fd35be4a11e4be42b1efff6f9802daef77a4..905a9fac0ae04935514949e3a2df76f89fe2aefa 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.28 2001-10-30 09:52:33 geuzaine Exp $
+# $Id: Makefile,v 1.29 2001-12-03 08:41:43 geuzaine Exp $
 #
 # Makefile for "libFltk.a"
 #
@@ -95,7 +95,7 @@ Callbacks.o: Callbacks.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../Geo/Verif.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
  ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \
  ../Mesh/Matrix.h ../Graphics/Draw.h ../Common/Views.h \
- ../Common/ColorTable.h ../Common/Timer.h ../Geo/Visibility.h \
+ ../Common/ColorTable.h ../Common/Timer.h \
  ../Graphics/CreateFile.h ../Parser/OpenFile.h ../Common/GetOptions.h \
  ../Common/Context.h ../Common/Options.h GUI.h Opengl_Window.h \
  Colorbar_Window.h Callbacks.h ../Plugin/Plugin.h Solvers.h
diff --git a/Geo/CAD.cpp b/Geo/CAD.cpp
index 002128192cbe3686658975f865b17b03e1f52381..6885c09c6d57f3f72d3c455b18ff6771fcfaaae6 100644
--- a/Geo/CAD.cpp
+++ b/Geo/CAD.cpp
@@ -1,4 +1,4 @@
-// $Id: CAD.cpp,v 1.44 2001-11-28 17:35:51 geuzaine Exp $
+// $Id: CAD.cpp,v 1.45 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -259,7 +259,6 @@ Curve *DuplicateCurve (Curve *c){
 void CopySurface (Surface *s, Surface *ss){
   int i,j;
   ss->Typ = s->Typ;
-  ss->Mat = s->Mat;
   //We should not copy the meshing method: if the meshes are to
   //be copied, the meshing algorithm will take care of it
   //(e.g. ExtrudeMesh()).
@@ -288,7 +287,7 @@ Surface *DuplicateSurface (Surface *s){
   Vertex *v,*newv;
   int i;
 
-  ps = Create_Surface(NEWSURFACE(),0,0);
+  ps = Create_Surface(NEWSURFACE(),0);
   CopySurface(s,ps);
   for(i=0;i<List_Nbr(ps->Generatrices);i++){
     List_Read(ps->Generatrices,i,&c);
@@ -952,6 +951,7 @@ void Extrude_ProtudePoint(int type, int ip,
 
   case TRANSLATE_ROTATE :
     d = CTX.geom.extrude_spline_points;
+    d = d?d:1;
     c = Create_Curve(NEWLINE(),MSH_SEGM_SPLN,1,NULL,NULL,-1,-1,0.,1.);
     c->Control_Points = List_Create(CTX.geom.extrude_spline_points,1,sizeof(Vertex*));
     c->Extrude = new ExtrudeParams;
@@ -1085,9 +1085,9 @@ Surface *Extrude_ProtudeCurve(int type, int ic,
   if(!CurveBeg && !CurveEnd) return NULL;
 
   if(!CurveBeg || !CurveEnd)
-    s = Create_Surface(NEWSURFACE(),MSH_SURF_TRIC,0);
+    s = Create_Surface(NEWSURFACE(),MSH_SURF_TRIC);
   else
-    s = Create_Surface(NEWSURFACE(),MSH_SURF_REGL,0);
+    s = Create_Surface(NEWSURFACE(),MSH_SURF_REGL);
 
   s->Generatrices = List_Create(4,1,sizeof(Curve*));
   s->Extrude = new ExtrudeParams;
@@ -1164,7 +1164,7 @@ void Extrude_ProtudeSurface(int type, int is,
   }
   
   if(NewVolume){
-    pv = Create_Volume(NewVolume,0,0);
+    pv = Create_Volume(NewVolume,0);
     pv->Extrude = new ExtrudeParams;
     pv->Extrude->fill(type,T0,T1,T2,A0,A1,A2,X0,X1,X2,alpha);
     pv->Extrude->geo.Source = is;
@@ -1303,7 +1303,7 @@ void ReplaceDuplicatePoints(Mesh *m){
 
   List_T *points2delete = List_Create(100,100,sizeof(Vertex*));
 
-  /* Create unique points */
+  // Create unique points
 
   start = Tree_Nbr(m->Points);
 
@@ -1338,7 +1338,7 @@ void ReplaceDuplicatePoints(Mesh *m){
     Tree_Action(m->Vertices,MaxNumPoint);
   }
 
-  /* Replace old points in curves */
+  // Replace old points in curves
 
   All = Tree2List(m->Curves);
   for(i=0;i<List_Nbr(All);i++){
@@ -1357,7 +1357,7 @@ void ReplaceDuplicatePoints(Mesh *m){
   }
   List_Delete(All);
 
-  /* Replace old points in surfaces */
+  // Replace old points in surfaces
 
   All = Tree2List(m->Surfaces);
   for(i=0;i<List_Nbr(All);i++){
@@ -1389,7 +1389,7 @@ void ReplaceDuplicateCurves(Mesh *m){
   Surface *s;
   int i,j,start,end;
 
-  /* Create unique curves */
+  // Create unique curves
 
   start = Tree_Nbr(m->Curves);
 
@@ -1434,7 +1434,7 @@ void ReplaceDuplicateCurves(Mesh *m){
     Tree_Action(m->Curves,MaxNumCurve);
   }
 
-  /* Replace old curves in surfaces */
+  // Replace old curves in surfaces
 
   All = Tree2List(m->Surfaces);
   for(i=0;i<List_Nbr(All);i++){
@@ -1462,7 +1462,7 @@ void ReplaceDuplicateSurfaces(Mesh *m){
   Volume *vol;
   int i,j,start,end;
 
-  /* Create unique surfaces */
+  // Create unique surfaces
 
   start = Tree_Nbr(m->Surfaces);
 
@@ -1495,7 +1495,7 @@ void ReplaceDuplicateSurfaces(Mesh *m){
     Tree_Action(m->Surfaces,MaxNumSurface);
   }
 
-  /* Replace old surfaces in volumes */
+  // Replace old surfaces in volumes
 
   All = Tree2List(m->Volumes);
   for(i=0;i<List_Nbr(All);i++){
diff --git a/Geo/DataBase.cpp b/Geo/DataBase.cpp
index dbce637eb56518edfd41d3f954a5667fb30227bd..ab8740837285b80a73236083d5bfd1f0ead07620 100644
--- a/Geo/DataBase.cpp
+++ b/Geo/DataBase.cpp
@@ -1,4 +1,4 @@
-// $Id: DataBase.cpp,v 1.17 2001-10-29 08:52:19 geuzaine Exp $
+// $Id: DataBase.cpp,v 1.18 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -105,7 +105,7 @@ void AddQuadricSurfaceInDataBase (int Typ, int NumQuadric, double zaxis[3],
   Curve *c;
   EdgeLoop *el;
   
-  s = Create_Surface(NumQuadric,Typ,0);
+  s = Create_Surface(NumQuadric,Typ);
   s->Method = LIBRE;
   for(i=0;i<3;i++)s->Cyl.xaxis[i] = xaxis[i];
   for(i=0;i<3;i++)s->Cyl.zaxis[i] = zaxis[i];
@@ -153,7 +153,7 @@ void CreateSurfaceFromOldCrappyDatabase (int izon, int typzon, int o1, int o2,
   Vertex V,*v;
   EdgeLoop *el;
 
-  s = Create_Surface(izon,typzon,0);
+  s = Create_Surface(izon,typzon);
   s->Method = LIBRE;
   
   NbLoop = List_Nbr(loops);
@@ -212,7 +212,7 @@ void CreateVolumeFromOldCrappyDatabase (int izon, List_T *loops, Mesh *M){
   Surface *s;
   Volume *v;
   
-  v = Create_Volume(izon,MSH_VOLUME,0);
+  v = Create_Volume(izon,MSH_VOLUME);
   v->Surfaces = List_Create(4, 1, sizeof(Surface*));
   for(i=0;i<List_Nbr(loops);i++){
     List_Read(loops,i,&iLoop);
diff --git a/Geo/Makefile b/Geo/Makefile
index 55c893a837b31f68276835cec75be47b97cdd5d2..6a66fa8e614a246af1d1bfbec41d2f1da923f59b 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.27 2001-10-30 09:52:34 geuzaine Exp $
+# $Id: Makefile,v 1.28 2001-12-03 08:41:43 geuzaine Exp $
 #
 # Makefile for "libGeo.a"
 #
@@ -28,7 +28,6 @@ SRC =  	CAD.cpp \
         Geo.cpp \
         StepGeomDatabase.cpp \
 	Verif.cpp \
-	Visibility.cpp \
         Print_Geo.cpp
 
 OBJ = $(SRC:.cpp=.o)
@@ -95,11 +94,6 @@ Verif.o: Verif.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../DataStr/avl.h ../DataStr/Tools.h Geo.h CAD.h ../Mesh/Mesh.h \
  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Matrix.h DataBase.h
-Visibility.o: Visibility.cpp ../Common/Gmsh.h ../Common/Message.h \
- ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
- ../DataStr/avl.h ../DataStr/Tools.h Geo.h CAD.h ../Mesh/Mesh.h \
- ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
- ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Matrix.h DataBase.h
 Print_Geo.o: Print_Geo.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
  ../DataStr/avl.h ../DataStr/Tools.h Geo.h ../Mesh/Mesh.h \
diff --git a/Geo/Visibility.cpp b/Geo/Visibility.cpp
deleted file mode 100644
index 0f4f86b37935f8fcb4014f29f3a799d1c1896de2..0000000000000000000000000000000000000000
--- a/Geo/Visibility.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-
-#include "Gmsh.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "DataBase.h"
-
-extern Mesh *THEM;
-
-/* Gestion des entites visibles */
-
-Tree_T  *EntitesVisibles=NULL;
-int      SHOW_ALL_ENTITIES;
-
-typedef struct{
- int Entite;
- int Visible;
-}EntiteVisible;
-
-int compareEntiteVisible(const void *a, const void *b){
-  EntiteVisible *q,*w;
-  q = (EntiteVisible*)a;
-  w = (EntiteVisible*)b;
-  return(q->Entite-w->Entite);
-}
-
-int EntiteEstElleVisible(int iEnt){
-  EntiteVisible e;
-  e.Entite = iEnt;
-  if(Tree_Query(EntitesVisibles,&e))
-    return e.Visible;
-  return 1;
-}
-
-void ToutesLesEntitesRelatives(int iEnt, Tree_T *Tree, int add_rem){
-  int i;
-  EntiteVisible e;
-
-  Surface *s;
-  Volume *v;
-  Curve *c;
-
-  if((c = FindCurve(iEnt,THEM))){
-  }
-  else if((s = FindSurface(iEnt,THEM))){
-    for(i=0;i<List_Nbr(s->Generatrices);i++){
-      List_Read(s->Generatrices,i,&c);
-      e.Entite = abs(c->Num);
-      e.Visible = add_rem;
-      Tree_Replace(Tree,&e);
-    }
-  }
-  else if((v = FindVolume(iEnt,THEM))){
-    for(i=0;i<List_Nbr(v->Surfaces);i++){
-      List_Read(v->Surfaces,i,&s);
-      e.Entite = abs(s->Num);
-      e.Visible = add_rem;
-      Tree_Replace(Tree,&e);
-    }
-  }
-
-  e.Entite = abs(iEnt);
-  e.Visible = add_rem;
-  Tree_Replace(Tree,&e);
-}
-
-void RemplirEntitesVisibles (int add_rem){
-  int i;
-  Volume *v;
-  Surface *s;
-  Curve *c;
-
-  List_T *ListVolumes = Tree2List (THEM->Volumes);
-  List_T *ListSurfaces = Tree2List (THEM->Surfaces);
-  List_T *ListCurves = Tree2List (THEM->Curves);
-  EntitesVisibles = Tree_Create(sizeof(EntiteVisible),compareEntiteVisible);
-  for(i=0;i<List_Nbr(ListVolumes);i++){
-    List_Read(ListVolumes,i,&v);
-    ToutesLesEntitesRelatives(v->Num,EntitesVisibles,add_rem);
-  }
-  for(i=0;i<List_Nbr(ListSurfaces);i++){
-    List_Read(ListSurfaces,i,&s);
-    ToutesLesEntitesRelatives(s->Num,EntitesVisibles,add_rem);
-  }
-  for(i=0;i<List_Nbr(ListCurves);i++){
-    List_Read(ListCurves,i,&c);
-    ToutesLesEntitesRelatives(c->Num,EntitesVisibles,add_rem);
-  }
-  List_Delete(ListVolumes);
-  List_Delete(ListSurfaces);
-  List_Delete(ListCurves);
-}
diff --git a/Geo/Visibility.h b/Geo/Visibility.h
deleted file mode 100644
index 9be0d6db62292403e658227c11c6027f695c9aa5..0000000000000000000000000000000000000000
--- a/Geo/Visibility.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _VISIBILITY_H_
-#define _VISIBILITY_H_
-
-int EntiteEstElleVisible(int iEnt);
-void ToutesLesEntitesRelatives(int iEnt, Tree_T *Tree, int add_rem);
-void RemplirEntitesVisibles (int add_rem);
-
-extern Tree_T *EntitesVisibles;
-extern int     SHOW_ALL_ENTITIES;
-
-#endif
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index ded8b5725d34f7fc57aa0f8f1135f11d1eee8c93..56d1c8e10ebede9a683f41ee8ef105f276c2e04f 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.31 2001-11-05 08:37:43 geuzaine Exp $
+// $Id: Geom.cpp,v 1.32 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -10,7 +10,6 @@
 #include "Context.h"
 #include "Verif.h"
 #include "Interpolation.h"
-#include "Visibility.h"
 #include "STL.h"
 #include "gl2ps.h"
 
@@ -24,17 +23,19 @@ extern Mesh      *THEM;
 static int   Highlighted = 0; 
 
 void Draw_GeoPoint (void *a, void *b){
-  Vertex **v;
+  Vertex *v;
   char Num[100];
 
-  v = (Vertex**)a;
+  v = *(Vertex**)a;
+
+  if(!(v->Visible & VIS_GEO)) return;
 
   if(CTX.render_mode == GMSH_SELECT){
     glLoadName(0);
-    glPushName((*v)->Num);
+    glPushName(v->Num);
   }
 
-  if((*v)->Frozen){
+  if(v->Frozen){
     glPointSize(CTX.geom.point_sel_size); 
     gl2psPointSize(CTX.geom.point_sel_size * CTX.print.eps_point_size_factor);
     glColor4ubv((GLubyte*)&CTX.color.geom.point_sel);
@@ -52,15 +53,15 @@ void Draw_GeoPoint (void *a, void *b){
 
   if(CTX.geom.points){
     glBegin(GL_POINTS);
-    glVertex3d((*v)->Pos.X, (*v)->Pos.Y, (*v)->Pos.Z);
+    glVertex3d(v->Pos.X, v->Pos.Y, v->Pos.Z);
     glEnd();
   }
 
   if(CTX.geom.points_num){
-    sprintf(Num,"%d",(*v)->Num);
-    glRasterPos3d((*v)->Pos.X+3*CTX.pixel_equiv_x/CTX.s[0],
-                  (*v)->Pos.Y+3*CTX.pixel_equiv_x/CTX.s[1], 
-                  (*v)->Pos.Z+3*CTX.pixel_equiv_x/CTX.s[2]);
+    sprintf(Num,"%d",v->Num);
+    glRasterPos3d(v->Pos.X+3*CTX.pixel_equiv_x/CTX.s[0],
+                  v->Pos.Y+3*CTX.pixel_equiv_x/CTX.s[1], 
+                  v->Pos.Z+3*CTX.pixel_equiv_x/CTX.s[2]);
     Draw_String(Num);
   }
 
@@ -84,7 +85,7 @@ void Draw_Curve (void *a, void *b){
 
   c = *(Curve**)a;
 
-  if(c->Dirty || c->Num<0 || !EntiteEstElleVisible(c->Num)) return;
+  if(c->Num<0 || !(c->Visible & VIS_GEO) || c->Dirty) return;
 
   if(CTX.render_mode == GMSH_SELECT){
     glLoadName(1);
@@ -493,7 +494,7 @@ void Draw_Surface (void *a, void *b){
 
   s = *(Surface**)a;
 
-  if(s->Dirty || !s || !s->Support || !EntiteEstElleVisible(s->Num)) return;
+  if(!s || !s->Support || !(s->Visible & VIS_GEO) || s->Dirty) return;
 
   if(CTX.render_mode == GMSH_SELECT){
     glLoadName(2);
@@ -501,7 +502,7 @@ void Draw_Surface (void *a, void *b){
   }
 
   if(!CTX.geom.shade){
-    if(s->Mat){
+    if(s->ipar[4]){
       glLineWidth(CTX.geom.line_sel_width); 
       gl2psLineWidth(CTX.geom.line_sel_width * CTX.print.eps_line_width_factor);
       glColor4ubv((GLubyte*)&CTX.color.geom.surface_sel);
@@ -635,7 +636,7 @@ void ZeroPoint(void *a,void *b){
 void ZeroSurface(void *a,void *b){
   Surface *s;
   s = *(Surface**)a;
-  s->Mat = 0;
+  s->ipar[4] = 0;
 }
 
 void ZeroHighlight(Mesh *m){
@@ -690,8 +691,8 @@ void HighlightEntity(Vertex *v,Curve *c, Surface *s, int permanent){
     Msg(STATUS1N,"Curve %d  {%d->%d}",c->Num,c->beg->Num,c->end->Num);
   }
   else if(s){
-    if(permanent && s->Mat == 1) return;
-    if(permanent) s->Mat = 1;
+    if(permanent && s->ipar[4] == 1) return;
+    if(permanent) s->ipar[4] = 1;
     if(CTX.geom.highlight) Draw_Surface(&s,NULL);
     sprintf(Message,"Surface %d {",s->Num);
 
diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index dc3f612738652c2ee2a5db0f05a2583ba22bd846..555dc2e4ee7adfe95a34f5a9f33de32d799fc96b 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,4 +1,4 @@
-// $Id: Graph2D.cpp,v 1.15 2001-11-22 11:23:52 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.16 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -125,7 +125,7 @@ static void Draw_Graph2D(Post_View *v,
   
   // y tics + labels
 
-  nb = v->NbIso;
+  nb = v->NbIso?v->NbIso:1;
   if(v->ShowScale && (v->NbIso * font_h > height)) nb = (int)floor(height/font_h);
 
   dy = height/(double)nb;
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 5825149057eb6f6794dfd6c38fc7c63d537b7453..dcc60ee753fd8c82618e5db5f3dc379a7970e4b9 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.33 2001-10-30 09:52:36 geuzaine Exp $
+# $Id: Makefile,v 1.34 2001-12-03 08:41:43 geuzaine Exp $
 #
 # Makefile for "libGraphics.a"
 #
@@ -32,6 +32,7 @@ SRC = Draw.cpp \
       PostSimplex.cpp \
       IsoSimplex.cpp \
       Entity.cpp \
+      Visibility.cpp \
       Scale.cpp \
       Graph2D.cpp \
       Axes.cpp \
@@ -82,8 +83,7 @@ Mesh.o: Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Matrix.h Draw.h \
  ../Common/Views.h ../Common/ColorTable.h ../Common/Context.h \
- ../Geo/MinMax.h gl2ps.h ../Geo/Verif.h ../Common/Numeric.h \
- ../Geo/Visibility.h
+ ../Geo/MinMax.h gl2ps.h ../Geo/Verif.h ../Common/Numeric.h
 Geom.o: Geom.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
  ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
@@ -91,8 +91,7 @@ Geom.o: Geom.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
  ../Mesh/Metric.h ../Mesh/Matrix.h ../Mesh/Utils.h Draw.h \
  ../Common/Views.h ../Common/ColorTable.h ../Common/Context.h \
- ../Geo/Verif.h ../Mesh/Interpolation.h ../Geo/Visibility.h \
- ../Mesh/STL.h gl2ps.h
+ ../Geo/Verif.h ../Mesh/Interpolation.h ../Mesh/STL.h gl2ps.h
 Post.o: Post.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
  ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp
index 6008817b9607b3cdc18f930e1d3bc7e039b5c356..e0ee337b09efb4ad615b9604a431c8d8dd71c44b 100644
--- a/Graphics/Mesh.cpp
+++ b/Graphics/Mesh.cpp
@@ -1,8 +1,9 @@
-// $Id: Mesh.cpp,v 1.44 2001-11-13 08:07:50 geuzaine Exp $
+// $Id: Mesh.cpp,v 1.45 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
 #include "Geo.h"
+#include "CAD.h"
 #include "Mesh.h"
 #include "Draw.h"
 #include "Context.h"
@@ -10,7 +11,6 @@
 #include "gl2ps.h"
 #include "Verif.h"
 #include "Numeric.h"
-#include "Visibility.h"
 
 extern Mesh      *THEM;
 extern Context_T  CTX;
@@ -152,49 +152,57 @@ void Draw_Mesh (Mesh *M) {
 }
 
 void Draw_Mesh_Volumes(void *a, void *b){
-  Volume **v;
-  v = (Volume**)a;
+  Volume *v;
+  v = *(Volume**)a;
   iColor++;
-  Tree_Action((*v)->Simplexes, Draw_Simplex_Volume);
-  Tree_Action((*v)->Hexahedra, Draw_Hexahedron_Volume);
-  Tree_Action((*v)->Prisms, Draw_Prism_Volume);
-  Tree_Action((*v)->Pyramids, Draw_Pyramid_Volume);
+  // Ceci est la bonne methode, mais ne marchera que qd on aura une
+  // structure coherente poue les volumes
+  // if(!(v->Visible & VIS_MESH)) return;
+  Tree_Action(v->Simplexes, Draw_Simplex_Volume);
+  Tree_Action(v->Hexahedra, Draw_Hexahedron_Volume);
+  Tree_Action(v->Prisms, Draw_Prism_Volume);
+  Tree_Action(v->Pyramids, Draw_Pyramid_Volume);
 }
 
 void Draw_Mesh_Surfaces (void *a,void *b){
-  Surface **s;
-  s = (Surface**)a;
+  Surface *s;
+  s = *(Surface**)a;
   iColor++;
-  Tree_Action((*s)->Simplexes, Draw_Simplex_Surfaces);
+  if(!(s->Visible & VIS_MESH)) return;
+  Tree_Action(s->Simplexes, Draw_Simplex_Surfaces);
 }
 
 void Draw_Mesh_Extruded_Surfaces(void *a, void *b){
-  Volume **v;
-  v = (Volume**)a;
-  Tree_Action((*v)->Simp_Surf, Draw_Simplex_Surfaces);
+  Volume *v;
+  v = *(Volume**)a;
+  if(!(v->Visible & VIS_MESH)) return;
+  Tree_Action(v->Simp_Surf, Draw_Simplex_Surfaces);
 }
 
 void Draw_Mesh_Curves (void *a, void *b){
-  Curve **c;
-  c = (Curve**)a;
-  if((*c)->Num < 0)return;
+  Curve *c;
+  c = *(Curve**)a;
+  if(c->Num < 0) return;
   iColor++;
-  Tree_Action((*c)->Simplexes,Draw_Simplex_Curves);
+  if(!(c->Visible & VIS_MESH)) return;
+  Tree_Action(c->Simplexes,Draw_Simplex_Curves);
 }
 
 void Draw_Mesh_Points (void *a, void *b){
-  Vertex **v;
+  Vertex *v;
   char Num[100];
 
-  v = (Vertex**)a;
+  v = *(Vertex**)a;
+
+  if(!(v->Visible & VIS_MESH)) return;
 
   if(CTX.mesh.use_cut_plane){
-    if(CTX.mesh.evalCutPlane((*v)->Pos.X, (*v)->Pos.Y, (*v)->Pos.Z) < 0)return;
+    if(CTX.mesh.evalCutPlane(v->Pos.X, v->Pos.Y, v->Pos.Z) < 0) return;
   }
   
   if(CTX.render_mode == GMSH_SELECT){
     glLoadName(0);
-    glPushName((*v)->Num);
+    glPushName(v->Num);
   }
 
   if(DrawVertexSupp) 
@@ -204,15 +212,15 @@ void Draw_Mesh_Points (void *a, void *b){
 
   if(CTX.mesh.points){
     glBegin(GL_POINTS);
-    glVertex3d((*v)->Pos.X, (*v)->Pos.Y, (*v)->Pos.Z);
+    glVertex3d(v->Pos.X, v->Pos.Y, v->Pos.Z);
     glEnd();
   }
   
   if(CTX.mesh.points_num){
-    sprintf(Num,"%d",(*v)->Num);
-    glRasterPos3d((*v)->Pos.X+3*CTX.pixel_equiv_x/CTX.s[0],
-                  (*v)->Pos.Y+3*CTX.pixel_equiv_x/CTX.s[1], 
-                  (*v)->Pos.Z+3*CTX.pixel_equiv_x/CTX.s[2]);
+    sprintf(Num,"%d",v->Num);
+    glRasterPos3d(v->Pos.X+3*CTX.pixel_equiv_x/CTX.s[0],
+                  v->Pos.Y+3*CTX.pixel_equiv_x/CTX.s[1], 
+                  v->Pos.Z+3*CTX.pixel_equiv_x/CTX.s[2]);
     Draw_String(Num);
   }
   
@@ -226,35 +234,36 @@ void Draw_Mesh_Points (void *a, void *b){
 /* ------------------------------------------------------------------------ */
 
 void Draw_Simplex_Volume (void *a, void *b){
-  Simplex **s;
+  Simplex *s;
   char Num[100];
   int fulldraw = 0;
   double tmp, X[4],Y[4],Z[4];
 
-  s = (Simplex**)a;
+  s = *(Simplex**)a;
 
-  if(!(*s)->V[3]) return;
+  if(!s->V[3] || !(s->Visible & VIS_MESH)) return;
 
-  if(!EntiteEstElleVisible((*s)->iEnt)) return;
+  // a enlever des qu'on a une structure correcte pour les volumes
+  Volume *V; if((V = FindVolume(s->iEnt,THEM)) && !(V->Visible & VIS_MESH)) return;
 
   if(CTX.mesh.gamma_sup){
-    tmp = (*s)->GammaShapeMeasure();
+    tmp = s->GammaShapeMeasure();
     if(tmp < CTX.mesh.gamma_inf || tmp > CTX.mesh.gamma_sup) return;
     fulldraw = 1;
   }
 
   if(CTX.mesh.radius_sup){
-    if((*s)->Radius < CTX.mesh.radius_inf || (*s)->Radius > CTX.mesh.radius_sup) return;
+    if(s->Radius < CTX.mesh.radius_inf || s->Radius > CTX.mesh.radius_sup) return;
     fulldraw = 1;
   }
 
 
-  double Xc = .25 * ((*s)->V[0]->Pos.X + (*s)->V[1]->Pos.X + 
-                     (*s)->V[2]->Pos.X + (*s)->V[3]->Pos.X);
-  double Yc = .25 * ((*s)->V[0]->Pos.Y + (*s)->V[1]->Pos.Y + 
-                     (*s)->V[2]->Pos.Y + (*s)->V[3]->Pos.Y);
-  double Zc = .25 * ((*s)->V[0]->Pos.Z + (*s)->V[1]->Pos.Z + 
-                     (*s)->V[2]->Pos.Z + (*s)->V[3]->Pos.Z);
+  double Xc = .25 * (s->V[0]->Pos.X + s->V[1]->Pos.X + 
+                     s->V[2]->Pos.X + s->V[3]->Pos.X);
+  double Yc = .25 * (s->V[0]->Pos.Y + s->V[1]->Pos.Y + 
+                     s->V[2]->Pos.Y + s->V[3]->Pos.Y);
+  double Zc = .25 * (s->V[0]->Pos.Z + s->V[1]->Pos.Z + 
+                     s->V[2]->Pos.Z + s->V[3]->Pos.Z);
 
   if(CTX.mesh.use_cut_plane){
     if(CTX.mesh.evalCutPlane(Xc,Yc,Zc) < 0) return;
@@ -262,16 +271,16 @@ void Draw_Simplex_Volume (void *a, void *b){
   }
 
   if(CTX.mesh.color_carousel && !fulldraw)
-    ColorSwitch((*s)->iEnt);
+    ColorSwitch(s->iEnt);
   else if(fulldraw)
     glColor4ubv((GLubyte*)&CTX.color.mesh.line);
   else
     glColor4ubv((GLubyte*)&CTX.color.mesh.tetrahedron);
 
   for (int i=0 ; i<4 ; i++) {
-     X[i] = Xc + CTX.mesh.explode * ((*s)->V[i]->Pos.X - Xc);
-     Y[i] = Yc + CTX.mesh.explode * ((*s)->V[i]->Pos.Y - Yc);
-     Z[i] = Zc + CTX.mesh.explode * ((*s)->V[i]->Pos.Z - Zc);
+     X[i] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc);
+     Y[i] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc);
+     Z[i] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc);
   }
 
   if(CTX.mesh.volumes && !(fulldraw && CTX.mesh.shade)){
@@ -300,7 +309,7 @@ void Draw_Simplex_Volume (void *a, void *b){
   }
 
   if(CTX.mesh.volumes_num){
-    sprintf(Num,"%d",(*s)->Num);
+    sprintf(Num,"%d",s->Num);
     glRasterPos3d(Xc,Yc,Zc);
     Draw_String(Num);
   }
@@ -330,7 +339,7 @@ void Draw_Simplex_Volume (void *a, void *b){
   double n[4], x1x0, y1y0, z1z0, x2x0, y2y0, z2z0;
 
   if(CTX.mesh.color_carousel)
-    ColorSwitch((*s)->iEnt);
+    ColorSwitch(s->iEnt);
   else
     glColor4ubv((GLubyte*)&CTX.color.mesh.tetrahedron);    
 
@@ -406,36 +415,33 @@ void Draw_Simplex_Volume (void *a, void *b){
 
 
 void Draw_Simplex_Surfaces (void *a, void *b){
-
-  Simplex **s;
+  Simplex *s;
   double X[4],Y[4],Z[4],Xc,Yc,Zc,pX[8],pY[8],pZ[8];
   double x1x0, y1y0, z1z0, x2x0, y2y0, z2z0, n[3], m[3], mm;
   int i,j,K,L,k;
   char Num[256];
   
-  s = (Simplex**)a;
-
-  if(!(*s)->V[2]) return ;
+  s = *(Simplex**)a;
 
-  if(!EntiteEstElleVisible ((*s)->iEnt)) return;
+  if(!s->V[2] || !(s->Visible & VIS_MESH)) return ;
 
-  if((*s)->VSUP) L=1;
+  if(s->VSUP) L=1;
   else L=0;
 
-  if ((*s)->V[3]) {
+  if (s->V[3]) {
     K = 4;
-    Xc = .25 * ((*s)->V[0]->Pos.X + (*s)->V[1]->Pos.X + 
-                (*s)->V[2]->Pos.X + (*s)->V[3]->Pos.X);
-    Yc = .25 * ((*s)->V[0]->Pos.Y + (*s)->V[1]->Pos.Y + 
-                (*s)->V[2]->Pos.Y + (*s)->V[3]->Pos.Y);
-    Zc = .25 * ((*s)->V[0]->Pos.Z + (*s)->V[1]->Pos.Z + 
-                (*s)->V[2]->Pos.Z + (*s)->V[3]->Pos.Z);
+    Xc = .25 * (s->V[0]->Pos.X + s->V[1]->Pos.X + 
+                s->V[2]->Pos.X + s->V[3]->Pos.X);
+    Yc = .25 * (s->V[0]->Pos.Y + s->V[1]->Pos.Y + 
+                s->V[2]->Pos.Y + s->V[3]->Pos.Y);
+    Zc = .25 * (s->V[0]->Pos.Z + s->V[1]->Pos.Z + 
+                s->V[2]->Pos.Z + s->V[3]->Pos.Z);
   }
   else {
     K = 3;
-    Xc = ((*s)->V[0]->Pos.X + (*s)->V[1]->Pos.X + (*s)->V[2]->Pos.X) / 3. ;
-    Yc = ((*s)->V[0]->Pos.Y + (*s)->V[1]->Pos.Y + (*s)->V[2]->Pos.Y) / 3. ;
-    Zc = ((*s)->V[0]->Pos.Z + (*s)->V[1]->Pos.Z + (*s)->V[2]->Pos.Z) / 3. ;
+    Xc = (s->V[0]->Pos.X + s->V[1]->Pos.X + s->V[2]->Pos.X) / 3. ;
+    Yc = (s->V[0]->Pos.Y + s->V[1]->Pos.Y + s->V[2]->Pos.Y) / 3. ;
+    Zc = (s->V[0]->Pos.Z + s->V[1]->Pos.Z + s->V[2]->Pos.Z) / 3. ;
   }
 
   if(CTX.mesh.use_cut_plane){
@@ -444,18 +450,18 @@ void Draw_Simplex_Surfaces (void *a, void *b){
 
   k=0;
   for (i=0 ; i<K ; i++) {
-    pX[k] = Xc + CTX.mesh.explode * ((*s)->V[i]->Pos.X - Xc);
-    pY[k] = Yc + CTX.mesh.explode * ((*s)->V[i]->Pos.Y - Yc);
-    pZ[k] = Zc + CTX.mesh.explode * ((*s)->V[i]->Pos.Z - Zc);
+    pX[k] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc);
+    pY[k] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc);
+    pZ[k] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc);
     k+=(L+1);
   }
   
   if(L){
     k=1;
     for (i=0 ; i<K ; i++) {
-      pX[k] = Xc + CTX.mesh.explode * ((*s)->VSUP[i]->Pos.X - Xc);
-      pY[k] = Yc + CTX.mesh.explode * ((*s)->VSUP[i]->Pos.Y - Yc);
-      pZ[k] = Zc + CTX.mesh.explode * ((*s)->VSUP[i]->Pos.Z - Zc);      
+      pX[k] = Xc + CTX.mesh.explode * (s->VSUP[i]->Pos.X - Xc);
+      pY[k] = Yc + CTX.mesh.explode * (s->VSUP[i]->Pos.Y - Yc);
+      pZ[k] = Zc + CTX.mesh.explode * (s->VSUP[i]->Pos.Z - Zc);      
       k+=(L+1);
     }
   }
@@ -478,9 +484,9 @@ void Draw_Simplex_Surfaces (void *a, void *b){
 
   if (CTX.mesh.normals || CTX.mesh.shade){
     for (i=0 ; i<K ; i++) {
-     X[i] = Xc + CTX.mesh.explode * ((*s)->V[i]->Pos.X - Xc);
-     Y[i] = Yc + CTX.mesh.explode * ((*s)->V[i]->Pos.Y - Yc);
-     Z[i] = Zc + CTX.mesh.explode * ((*s)->V[i]->Pos.Z - Zc);
+     X[i] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc);
+     Y[i] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc);
+     Z[i] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc);
     }
     x1x0 = X[1]-X[0]; y1y0 = Y[1]-Y[0];
     z1z0 = Z[1]-Z[0]; x2x0 = X[2]-X[0];
@@ -504,7 +510,7 @@ void Draw_Simplex_Surfaces (void *a, void *b){
   }
 
   if(CTX.mesh.surfaces_num){
-    sprintf(Num,"%d",(*s)->Num);
+    sprintf(Num,"%d",s->Num);
     glRasterPos3d(Xc,Yc,Zc);
     Draw_String(Num);
   }
@@ -553,7 +559,7 @@ void Draw_Simplex_Curves(void *a,void *b){
 
   s = *(Simplex**)a;
 
-  if(!EntiteEstElleVisible (s->iEnt)) return;
+  if(!(s->Visible & VIS_MESH)) return ;
 
   Xc = 0.5 * (s->V[0]->Pos.X + s->V[1]->Pos.X);
   Yc = 0.5 * (s->V[0]->Pos.Y + s->V[1]->Pos.Y);
@@ -611,19 +617,22 @@ void Draw_Simplex_Curves(void *a,void *b){
 /* ------------------------------------------------------------------------ */
 
 void Draw_Hexahedron_Volume (void *a, void *b){
-  Hexahedron **h;
+  Hexahedron *h;
   int i ;
   double Xc = 0.0 , Yc = 0.0, Zc = 0.0 , X[8],Y[8],Z[8];
   char Num[100];
 
-  h = (Hexahedron**)a;
+  h = *(Hexahedron**)a;
 
-  if(!EntiteEstElleVisible((*h)->iEnt)) return;
+  if(!(h->Visible & VIS_MESH)) return ;
+
+  // a enlever des qu'on a une structure correcte pour les volumes
+  Volume *V; if((V = FindVolume(h->iEnt,THEM)) && !(V->Visible & VIS_MESH)) return;
 
   for(i=0 ; i<8 ; i++){
-    Xc += (*h)->V[i]->Pos.X;
-    Yc += (*h)->V[i]->Pos.Y;
-    Zc += (*h)->V[i]->Pos.Z;
+    Xc += h->V[i]->Pos.X;
+    Yc += h->V[i]->Pos.Y;
+    Zc += h->V[i]->Pos.Z;
   }
   Xc *= .125 ; 
   Zc *= .125 ; 
@@ -634,14 +643,14 @@ void Draw_Hexahedron_Volume (void *a, void *b){
   }
 
   if(CTX.mesh.color_carousel)
-    ColorSwitch((*h)->iEnt);  
+    ColorSwitch(h->iEnt);  
   else
     glColor4ubv((GLubyte*)&CTX.color.mesh.hexahedron);
 
   for (i=0 ; i<8 ; i++) {
-    X[i] = Xc + CTX.mesh.explode * ((*h)->V[i]->Pos.X - Xc);
-    Y[i] = Yc + CTX.mesh.explode * ((*h)->V[i]->Pos.Y - Yc);
-    Z[i] = Zc + CTX.mesh.explode * ((*h)->V[i]->Pos.Z - Zc);
+    X[i] = Xc + CTX.mesh.explode * (h->V[i]->Pos.X - Xc);
+    Y[i] = Yc + CTX.mesh.explode * (h->V[i]->Pos.Y - Yc);
+    Z[i] = Zc + CTX.mesh.explode * (h->V[i]->Pos.Z - Zc);
   }
 
   glBegin(GL_LINE_LOOP);
@@ -670,7 +679,7 @@ void Draw_Hexahedron_Volume (void *a, void *b){
   glEnd();    
 
   if(CTX.mesh.volumes_num){
-    sprintf(Num,"%d",(*h)->Num);
+    sprintf(Num,"%d",h->Num);
     glRasterPos3d(Xc,Yc,Zc);
     Draw_String(Num);
   }
@@ -684,34 +693,34 @@ void Draw_Hexahedron_Volume (void *a, void *b){
     glBegin(GL_LINES);
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[0]->Pos.X+(*h)->V[1]->Pos.X+(*h)->V[5]->Pos.X+(*h)->V[4]->Pos.X)/4.,
-        ((*h)->V[0]->Pos.Y+(*h)->V[1]->Pos.Y+(*h)->V[5]->Pos.Y+(*h)->V[4]->Pos.Y)/4.,
-        ((*h)->V[0]->Pos.Z+(*h)->V[1]->Pos.Z+(*h)->V[5]->Pos.Z+(*h)->V[4]->Pos.Z)/4. );
+      ( (h->V[0]->Pos.X+h->V[1]->Pos.X+h->V[5]->Pos.X+h->V[4]->Pos.X)/4.,
+        (h->V[0]->Pos.Y+h->V[1]->Pos.Y+h->V[5]->Pos.Y+h->V[4]->Pos.Y)/4.,
+        (h->V[0]->Pos.Z+h->V[1]->Pos.Z+h->V[5]->Pos.Z+h->V[4]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[0]->Pos.X+(*h)->V[3]->Pos.X+(*h)->V[2]->Pos.X+(*h)->V[1]->Pos.X)/4.,
-        ((*h)->V[0]->Pos.Y+(*h)->V[3]->Pos.Y+(*h)->V[2]->Pos.Y+(*h)->V[1]->Pos.Y)/4.,
-        ((*h)->V[0]->Pos.Z+(*h)->V[3]->Pos.Z+(*h)->V[2]->Pos.Z+(*h)->V[1]->Pos.Z)/4. );
+      ( (h->V[0]->Pos.X+h->V[3]->Pos.X+h->V[2]->Pos.X+h->V[1]->Pos.X)/4.,
+        (h->V[0]->Pos.Y+h->V[3]->Pos.Y+h->V[2]->Pos.Y+h->V[1]->Pos.Y)/4.,
+        (h->V[0]->Pos.Z+h->V[3]->Pos.Z+h->V[2]->Pos.Z+h->V[1]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[0]->Pos.X+(*h)->V[4]->Pos.X+(*h)->V[7]->Pos.X+(*h)->V[3]->Pos.X)/4.,
-        ((*h)->V[0]->Pos.Y+(*h)->V[4]->Pos.Y+(*h)->V[7]->Pos.Y+(*h)->V[3]->Pos.Y)/4.,
-        ((*h)->V[0]->Pos.Z+(*h)->V[4]->Pos.Z+(*h)->V[7]->Pos.Z+(*h)->V[3]->Pos.Z)/4. );
+      ( (h->V[0]->Pos.X+h->V[4]->Pos.X+h->V[7]->Pos.X+h->V[3]->Pos.X)/4.,
+        (h->V[0]->Pos.Y+h->V[4]->Pos.Y+h->V[7]->Pos.Y+h->V[3]->Pos.Y)/4.,
+        (h->V[0]->Pos.Z+h->V[4]->Pos.Z+h->V[7]->Pos.Z+h->V[3]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[1]->Pos.X+(*h)->V[2]->Pos.X+(*h)->V[6]->Pos.X+(*h)->V[5]->Pos.X)/4.,
-        ((*h)->V[1]->Pos.Y+(*h)->V[2]->Pos.Y+(*h)->V[6]->Pos.Y+(*h)->V[5]->Pos.Y)/4.,
-        ((*h)->V[1]->Pos.Z+(*h)->V[2]->Pos.Z+(*h)->V[6]->Pos.Z+(*h)->V[5]->Pos.Z)/4. );
+      ( (h->V[1]->Pos.X+h->V[2]->Pos.X+h->V[6]->Pos.X+h->V[5]->Pos.X)/4.,
+        (h->V[1]->Pos.Y+h->V[2]->Pos.Y+h->V[6]->Pos.Y+h->V[5]->Pos.Y)/4.,
+        (h->V[1]->Pos.Z+h->V[2]->Pos.Z+h->V[6]->Pos.Z+h->V[5]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[2]->Pos.X+(*h)->V[3]->Pos.X+(*h)->V[7]->Pos.X+(*h)->V[6]->Pos.X)/4.,
-        ((*h)->V[2]->Pos.Y+(*h)->V[3]->Pos.Y+(*h)->V[7]->Pos.Y+(*h)->V[6]->Pos.Y)/4.,
-        ((*h)->V[2]->Pos.Z+(*h)->V[3]->Pos.Z+(*h)->V[7]->Pos.Z+(*h)->V[6]->Pos.Z)/4. );
+      ( (h->V[2]->Pos.X+h->V[3]->Pos.X+h->V[7]->Pos.X+h->V[6]->Pos.X)/4.,
+        (h->V[2]->Pos.Y+h->V[3]->Pos.Y+h->V[7]->Pos.Y+h->V[6]->Pos.Y)/4.,
+        (h->V[2]->Pos.Z+h->V[3]->Pos.Z+h->V[7]->Pos.Z+h->V[6]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*h)->V[4]->Pos.X+(*h)->V[5]->Pos.X+(*h)->V[6]->Pos.X+(*h)->V[7]->Pos.X)/4.,
-        ((*h)->V[4]->Pos.Y+(*h)->V[5]->Pos.Y+(*h)->V[6]->Pos.Y+(*h)->V[7]->Pos.Y)/4.,
-        ((*h)->V[4]->Pos.Z+(*h)->V[5]->Pos.Z+(*h)->V[6]->Pos.Z+(*h)->V[7]->Pos.Z)/4. );
+      ( (h->V[4]->Pos.X+h->V[5]->Pos.X+h->V[6]->Pos.X+h->V[7]->Pos.X)/4.,
+        (h->V[4]->Pos.Y+h->V[5]->Pos.Y+h->V[6]->Pos.Y+h->V[7]->Pos.Y)/4.,
+        (h->V[4]->Pos.Z+h->V[5]->Pos.Z+h->V[6]->Pos.Z+h->V[7]->Pos.Z)/4. );
     glEnd();
     glDisable(GL_LINE_STIPPLE);
     gl2psDisable(GL2PS_LINE_STIPPLE);
@@ -724,19 +733,22 @@ void Draw_Hexahedron_Volume (void *a, void *b){
 /* ------------------------------------------------------------------------ */
 
 void Draw_Prism_Volume (void *a, void *b){
-  Prism **p;
+  Prism *p;
   int i ;
   double Xc = 0.0 , Yc = 0.0, Zc = 0.0, X[6],Y[6],Z[6] ;
   char Num[100];
 
-  p = (Prism**)a;
+  p = *(Prism**)a;
+
+  if(!(p->Visible & VIS_MESH)) return ;
 
-  if(!EntiteEstElleVisible((*p)->iEnt)) return;
+  // a enlever des qu'on a une structure correcte pour les volumes
+  Volume *V; if((V = FindVolume(p->iEnt,THEM)) && !(V->Visible & VIS_MESH)) return;
 
   for(i=0 ; i<6 ; i++){
-    Xc += (*p)->V[i]->Pos.X;
-    Yc += (*p)->V[i]->Pos.Y;
-    Zc += (*p)->V[i]->Pos.Z;
+    Xc += p->V[i]->Pos.X;
+    Yc += p->V[i]->Pos.Y;
+    Zc += p->V[i]->Pos.Z;
   }
   Xc /= 6. ; 
   Zc /= 6. ; 
@@ -747,14 +759,14 @@ void Draw_Prism_Volume (void *a, void *b){
   }
 
   if(CTX.mesh.color_carousel)
-    ColorSwitch((*p)->iEnt);
+    ColorSwitch(p->iEnt);
   else
     glColor4ubv((GLubyte*)&CTX.color.mesh.prism);
 
   for (i=0 ; i<6 ; i++) {
-    X[i] = Xc + CTX.mesh.explode * ((*p)->V[i]->Pos.X - Xc);
-    Y[i] = Yc + CTX.mesh.explode * ((*p)->V[i]->Pos.Y - Yc);
-    Z[i] = Zc + CTX.mesh.explode * ((*p)->V[i]->Pos.Z - Zc);
+    X[i] = Xc + CTX.mesh.explode * (p->V[i]->Pos.X - Xc);
+    Y[i] = Yc + CTX.mesh.explode * (p->V[i]->Pos.Y - Yc);
+    Z[i] = Zc + CTX.mesh.explode * (p->V[i]->Pos.Z - Zc);
   }
   
   glBegin(GL_LINE_LOOP);
@@ -779,7 +791,7 @@ void Draw_Prism_Volume (void *a, void *b){
   glEnd();    
 
   if(CTX.mesh.volumes_num){
-    sprintf(Num,"%d",(*p)->Num);
+    sprintf(Num,"%d",p->Num);
     glRasterPos3d(Xc,Yc,Zc);
     Draw_String(Num);
   }
@@ -792,29 +804,29 @@ void Draw_Prism_Volume (void *a, void *b){
     glBegin(GL_LINES);
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*p)->V[0]->Pos.X+(*p)->V[2]->Pos.X+(*p)->V[1]->Pos.X)/3.,
-	((*p)->V[0]->Pos.Y+(*p)->V[2]->Pos.Y+(*p)->V[1]->Pos.Y)/3.,
-	((*p)->V[0]->Pos.Z+(*p)->V[2]->Pos.Z+(*p)->V[1]->Pos.Z)/3. );
+      ( (p->V[0]->Pos.X+p->V[2]->Pos.X+p->V[1]->Pos.X)/3.,
+	(p->V[0]->Pos.Y+p->V[2]->Pos.Y+p->V[1]->Pos.Y)/3.,
+	(p->V[0]->Pos.Z+p->V[2]->Pos.Z+p->V[1]->Pos.Z)/3. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*p)->V[3]->Pos.X+(*p)->V[4]->Pos.X+(*p)->V[5]->Pos.X)/3.,
-	((*p)->V[3]->Pos.Y+(*p)->V[4]->Pos.Y+(*p)->V[5]->Pos.Y)/3.,
-	((*p)->V[3]->Pos.Z+(*p)->V[4]->Pos.Z+(*p)->V[5]->Pos.Z)/3. );
+      ( (p->V[3]->Pos.X+p->V[4]->Pos.X+p->V[5]->Pos.X)/3.,
+	(p->V[3]->Pos.Y+p->V[4]->Pos.Y+p->V[5]->Pos.Y)/3.,
+	(p->V[3]->Pos.Z+p->V[4]->Pos.Z+p->V[5]->Pos.Z)/3. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*p)->V[0]->Pos.X+(*p)->V[1]->Pos.X+(*p)->V[4]->Pos.X+(*p)->V[3]->Pos.X)/4.,
-	((*p)->V[0]->Pos.Y+(*p)->V[1]->Pos.Y+(*p)->V[4]->Pos.Y+(*p)->V[3]->Pos.Y)/4.,
-	((*p)->V[0]->Pos.Z+(*p)->V[1]->Pos.Z+(*p)->V[4]->Pos.Z+(*p)->V[3]->Pos.Z)/4. );
+      ( (p->V[0]->Pos.X+p->V[1]->Pos.X+p->V[4]->Pos.X+p->V[3]->Pos.X)/4.,
+	(p->V[0]->Pos.Y+p->V[1]->Pos.Y+p->V[4]->Pos.Y+p->V[3]->Pos.Y)/4.,
+	(p->V[0]->Pos.Z+p->V[1]->Pos.Z+p->V[4]->Pos.Z+p->V[3]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*p)->V[0]->Pos.X+(*p)->V[3]->Pos.X+(*p)->V[5]->Pos.X+(*p)->V[2]->Pos.X)/4.,
-	((*p)->V[0]->Pos.Y+(*p)->V[3]->Pos.Y+(*p)->V[5]->Pos.Y+(*p)->V[2]->Pos.Y)/4.,
-	((*p)->V[0]->Pos.Z+(*p)->V[3]->Pos.Z+(*p)->V[5]->Pos.Z+(*p)->V[2]->Pos.Z)/4. );
+      ( (p->V[0]->Pos.X+p->V[3]->Pos.X+p->V[5]->Pos.X+p->V[2]->Pos.X)/4.,
+	(p->V[0]->Pos.Y+p->V[3]->Pos.Y+p->V[5]->Pos.Y+p->V[2]->Pos.Y)/4.,
+	(p->V[0]->Pos.Z+p->V[3]->Pos.Z+p->V[5]->Pos.Z+p->V[2]->Pos.Z)/4. );
     glVertex3d(Xc,   Yc,    Zc);  
     glVertex3d
-      ( ((*p)->V[1]->Pos.X+(*p)->V[2]->Pos.X+(*p)->V[5]->Pos.X+(*p)->V[4]->Pos.X)/4.,
-	((*p)->V[1]->Pos.Y+(*p)->V[2]->Pos.Y+(*p)->V[5]->Pos.Y+(*p)->V[4]->Pos.Y)/4.,
-	((*p)->V[1]->Pos.Z+(*p)->V[2]->Pos.Z+(*p)->V[5]->Pos.Z+(*p)->V[4]->Pos.Z)/4. );
+      ( (p->V[1]->Pos.X+p->V[2]->Pos.X+p->V[5]->Pos.X+p->V[4]->Pos.X)/4.,
+	(p->V[1]->Pos.Y+p->V[2]->Pos.Y+p->V[5]->Pos.Y+p->V[4]->Pos.Y)/4.,
+	(p->V[1]->Pos.Z+p->V[2]->Pos.Z+p->V[5]->Pos.Z+p->V[4]->Pos.Z)/4. );
     glEnd();
     glDisable(GL_LINE_STIPPLE);
     gl2psDisable(GL2PS_LINE_STIPPLE);
@@ -827,19 +839,22 @@ void Draw_Prism_Volume (void *a, void *b){
 /* ------------------------------------------------------------------------ */
 
 void Draw_Pyramid_Volume (void *a, void *b){
-  Pyramid **p;
+  Pyramid *p;
   int i ;
   double Xc = 0.0 , Yc = 0.0, Zc = 0.0, X[5],Y[5],Z[5] ;
   char Num[100];
 
-  p = (Pyramid**)a;
+  p = *(Pyramid**)a;
+
+  if(!(p->Visible & VIS_MESH)) return ;
 
-  if(!EntiteEstElleVisible((*p)->iEnt)) return;
+  // a enlever des qu'on a une structure correcte pour les volumes
+  Volume *V; if((V = FindVolume(p->iEnt,THEM)) && !(V->Visible & VIS_MESH)) return;
 
   for(i=0 ; i<5 ; i++){
-    Xc += (*p)->V[i]->Pos.X;
-    Yc += (*p)->V[i]->Pos.Y;
-    Zc += (*p)->V[i]->Pos.Z;
+    Xc += p->V[i]->Pos.X;
+    Yc += p->V[i]->Pos.Y;
+    Zc += p->V[i]->Pos.Z;
   }
   Xc /= 5. ; 
   Zc /= 5. ; 
@@ -850,14 +865,14 @@ void Draw_Pyramid_Volume (void *a, void *b){
   }
 
   if(CTX.mesh.color_carousel)
-    ColorSwitch((*p)->iEnt);
+    ColorSwitch(p->iEnt);
   else
     glColor4ubv((GLubyte*)&CTX.color.mesh.pyramid);
 
   for (i=0 ; i<5 ; i++) {
-    X[i] = Xc + CTX.mesh.explode * ((*p)->V[i]->Pos.X - Xc);
-    Y[i] = Yc + CTX.mesh.explode * ((*p)->V[i]->Pos.Y - Yc);
-    Z[i] = Zc + CTX.mesh.explode * ((*p)->V[i]->Pos.Z - Zc);
+    X[i] = Xc + CTX.mesh.explode * (p->V[i]->Pos.X - Xc);
+    Y[i] = Yc + CTX.mesh.explode * (p->V[i]->Pos.Y - Yc);
+    Z[i] = Zc + CTX.mesh.explode * (p->V[i]->Pos.Z - Zc);
   }
   
   glBegin(GL_LINE_LOOP);
@@ -879,7 +894,7 @@ void Draw_Pyramid_Volume (void *a, void *b){
   glEnd();    
 
   if(CTX.mesh.volumes_num){
-    sprintf(Num,"%d",(*p)->Num);
+    sprintf(Num,"%d",p->Num);
     glRasterPos3d(Xc,Yc,Zc);
     Draw_String(Num);
   }
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index 5e51d23cb5c8fb009566e94bb017f1c7a23e17bf..4df574332c73d81c18f995733efa10e378f2f4b2 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.30 2001-11-16 10:57:31 geuzaine Exp $
+// $Id: Post.cpp,v 1.31 2001-12-03 08:41:43 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -34,8 +34,8 @@ double GiveValueFromIndex_DoubleLog(double ValMin, double ValMax, int NbIso, int
   if(NbIso==1) return (ValMax+ValMin)/2.;
   if(ValMin <= 0.) return 0. ;
 
-  double Iso2 = Iso/2;
-  double NbIso2 = NbIso/2;
+  double Iso2 = Iso/2.;
+  double NbIso2 = NbIso/2.;
 
   return pow(10.,log10(ValMin)+Iso2*(log10(ValMax)-log10(ValMin))/(NbIso2-1.)) ;
 
diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp
index caf6cf9091bd6040cdd281cc9e57bb87b0ad8df8..cf545686c0ea7c5845e1cb6692faf6043776421d 100644
--- a/Graphics/Scale.cpp
+++ b/Graphics/Scale.cpp
@@ -1,4 +1,4 @@
-// $Id: Scale.cpp,v 1.26 2001-11-05 08:37:43 geuzaine Exp $
+// $Id: Scale.cpp,v 1.27 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -36,7 +36,7 @@ void draw_scale(Post_View *v,
   gl_font(FL_HELVETICA,CTX.gl_fontsize);
   font_h  = gl_height() ;              // hauteur totale de la fonte
   font_a  = gl_height()-gl_descent() ; // hauteur de la fonte au dessus de pt de ref
-  cs_bh   = height/v->NbIso ; // colorscale box height
+  cs_bh   = height/(v->NbIso?v->NbIso:1) ; // colorscale box height
   cv_xmin = xmin+width+tic ;  // valuescale xmin
 
   glPointSize(v->PointSize); 
@@ -95,10 +95,10 @@ void draw_scale(Post_View *v,
     }
     else if (v->IntervalsType==DRAW_POST_CONTINUOUS){
       glBegin(GL_QUADS);
-      Palette2(v,ValMin,ValMax,ValMin+i*(ValMax-ValMin)/v->NbIso);
+      Palette2(v,ValMin,ValMax,ValMin+i*(ValMax-ValMin)/(v->NbIso?v->NbIso:1));
       glVertex2d(xmin,       ymin+i*cs_bh);
       glVertex2d(xmin+width, ymin+i*cs_bh);
-      Palette2(v,ValMin,ValMax,ValMin+(i+1)*(ValMax-ValMin)/v->NbIso);
+      Palette2(v,ValMin,ValMax,ValMin+(i+1)*(ValMax-ValMin)/(v->NbIso?v->NbIso:1));
       glVertex2d(xmin+width, ymin+(i+1)*cs_bh);
       glVertex2d(xmin,       ymin+(i+1)*cs_bh);
       glEnd();  
diff --git a/Makefile b/Makefile
index d2b9ec4594a220d72368ea7a49ad0b9f0b5d698a..a41c966576a43de390e37112f9606f38c96e015f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
-# $Id: Makefile,v 1.168 2001-11-30 14:15:10 geuzaine Exp $
+# $Id: Makefile,v 1.169 2001-12-03 08:41:43 geuzaine Exp $
 
 GMSH_MAJOR_VERSION = 1
-GMSH_MINOR_VERSION = 31
-GMSH_PATCH_VERSION = 1
+GMSH_MINOR_VERSION = 32
+GMSH_PATCH_VERSION = 0
 
 MAKE = make
 CXX = c++
diff --git a/Mesh/1D_Mesh.cpp b/Mesh/1D_Mesh.cpp
index 83b0b4cd45842ea3941104132fd74064b590365a..954bf5799f29aee22179665d77e72c1793b1fc8d 100644
--- a/Mesh/1D_Mesh.cpp
+++ b/Mesh/1D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 1D_Mesh.cpp,v 1.23 2001-10-29 08:52:20 geuzaine Exp $
+// $Id: 1D_Mesh.cpp,v 1.24 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -125,6 +125,11 @@ void Maillage_Curve (void *data, void *dummy){
   c->l = Integration (c->ubeg, c->uend, F_One, Points, 1.e-4);
   List_Delete (Points);
 
+  if(!c->l){
+    Msg(GERROR, "Zero length Curve %d", c->Num);
+    return;
+  }
+
   if (c->Method == TRANSFINI || !Extrude_Mesh (c)){
     if (c->Method == TRANSFINI){
       Points = List_Create (10, 10, sizeof (IntPoint));
diff --git a/Mesh/2D_Mesh_Aniso.cpp b/Mesh/2D_Mesh_Aniso.cpp
index 96274405dad724bbf84ff243ad46483eae54e645..8e1e07a391fb050017ab50f28aabe4c07dc52c1e 100644
--- a/Mesh/2D_Mesh_Aniso.cpp
+++ b/Mesh/2D_Mesh_Aniso.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh_Aniso.cpp,v 1.22 2001-10-29 08:52:20 geuzaine Exp $
+// $Id: 2D_Mesh_Aniso.cpp,v 1.23 2001-12-03 08:41:44 geuzaine Exp $
 
 /*
    Jean-Francois Remacle
@@ -236,7 +236,7 @@ void Box_2_Triangles (List_T * P, Surface * s){
         ps->S[j] = &MyNewBoundary;
     Tree_Replace (s->Simplexes, &ps);
   }
-  // MEMORY LEAK (JF)
+
   List_Delete(smp);
 
 }
diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp
index 38cbfb536aa75359b7757c212890867f422ad0cc..82235be0fa6f6cb6749a4f5cf183460c1496ca01 100644
--- a/Mesh/Create.cpp
+++ b/Mesh/Create.cpp
@@ -1,4 +1,4 @@
-// $Id: Create.cpp,v 1.30 2001-11-30 14:15:10 geuzaine Exp $
+// $Id: Create.cpp,v 1.31 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -12,8 +12,6 @@
 extern Mesh      *THEM;
 extern Context_T  CTX;
 
-//static double CIRC_GRAN = 2.2;
-
 int compareNXE (const void *a, const void *b){
   NXE *q, *w;
 
@@ -154,18 +152,19 @@ void Add_SurfaceLoop (int Num, List_T * intlist, Mesh * M){
 }
 
 void Add_PhysicalGroup (int Num, int typ, List_T * intlist, Mesh * M){
-  PhysicalGroup *pSL;
+  PhysicalGroup *p;
   int i, j;
-  pSL = (PhysicalGroup *) Malloc (sizeof (PhysicalGroup));
-  pSL->Entities = List_Create (List_Nbr (intlist), 1, sizeof (int));
-  pSL->Num = Num;
+  p = (PhysicalGroup *) Malloc (sizeof (PhysicalGroup));
+  p->Entities = List_Create (List_Nbr (intlist), 1, sizeof (int));
+  p->Num = Num;
   THEM->MaxPhysicalNum = IMAX(THEM->MaxPhysicalNum,Num);
-  pSL->Typ = typ;
+  p->Typ = typ;
+  p->Visible = VIS_GEO|VIS_MESH;
   for (i = 0; i < List_Nbr (intlist); i++){
     List_Read (intlist, i, &j);
-    List_Add (pSL->Entities, &j);
+    List_Add (p->Entities, &j);
   }
-  List_Add (M->PhysicalGroups, &pSL);
+  List_Add (M->PhysicalGroups, &p);
 }
 
 void Add_EdgeLoop (int Num, List_T * intlist, Mesh * M){
@@ -291,12 +290,9 @@ void End_Curve (Curve * c){
     R  = sqrt(v0.Pos.X * v0.Pos.X + v0.Pos.Y * v0.Pos.Y);
     R2 = sqrt(v2.Pos.X * v2.Pos.X + v2.Pos.Y * v2.Pos.Y);
 
-    // check radius
-    if(!R || !R2)
+    if(!R || !R2) // check radius
       Msg(GERROR, "Zero radius in Circle/Ellipsis %d", c->Num);
-
-    // check if circle is coherent (allow 10% error)
-    if(!v[3] && fabs((R-R2)/(R+R2))>0.1)
+    else if(!v[3] && fabs((R-R2)/(R+R2))>0.1) // check cocircular pts (allow 10% error)
       Msg(GERROR, "Control points of Circle %d are not cocircular %g %g", c->Num, R,R2);
 
     // A1 = angle first pt
@@ -317,18 +313,23 @@ void End_Curve (Curve * c){
       rhs[0] = 1;
       rhs[1] = 1;
       sys2x2 (sys, rhs, sol);
-      if(sol[0] <= 0 || sol[1] <= 0) 
+      if(sol[0] <= 0 || sol[1] <= 0){
 	Msg(GERROR, "Ellipsis %d is wrong", Curve->Num);	
-      f1 = sqrt(1./sol[0]);
-      f2 = sqrt(1./sol[1]);
-      if(x1 < 0) 
-	A1 = -asin(y1/f2) + A4 + Pi; 
-      else
-	A1 = asin(y1/f2) + A4; 
-      if(x3 < 0) 
-	A3 = -asin(y3/f2) + A4 + Pi; 
-      else
-	A3 = asin(y3/f2) + A4; 
+	A1 = A3 = 0.;
+	f1 = f2 = R ;
+      }
+      else{
+	f1 = sqrt(1./sol[0]);
+	f2 = sqrt(1./sol[1]);
+	if(x1 < 0) 
+	  A1 = -asin(y1/f2) + A4 + Pi; 
+	else
+	  A1 = asin(y1/f2) + A4; 
+	if(x3 < 0) 
+	  A3 = -asin(y3/f2) + A4 + Pi; 
+	else
+	  A3 = asin(y3/f2) + A4; 
+      }
     }
     else{
       A1 = myatan2(v0.Pos.Y, v0.Pos.X);
@@ -407,6 +408,7 @@ Curve *Create_Curve (int Num, int Typ, int Order, List_T * Liste,
 
   pC = (Curve *) Malloc (sizeof (Curve));
   pC->Dirty = 0;
+  pC->Visible = VIS_GEO|VIS_MESH;
   pC->cp = NULL;
   pC->Vertices = NULL;
   pC->Extrude = NULL;
@@ -506,22 +508,21 @@ void Free_Curve(void *a, void *b){
     List_Delete(pC->TrsfSimplexes);
     Free(pC->k);
     List_Delete(pC->Control_Points);
-    // MEMORY_LEAK (JF)
     Free(pC->cp);
     Free(pC);
     pC = NULL;
   }
 }
 
-Surface * Create_Surface (int Num, int Typ, int Mat){
+Surface * Create_Surface (int Num, int Typ){
   Surface *pS;
 
   pS = (Surface *) Malloc (sizeof (Surface));
   pS->Dirty = 0;
+  pS->Visible = VIS_GEO|VIS_MESH;
   pS->Num = Num;
   THEM->MaxSurfaceNum = IMAX(THEM->MaxSurfaceNum,Num);
   pS->Typ = Typ;
-  pS->Mat = Mat;
   pS->Method = LIBRE;
   pS->Recombine = 0;
   pS->RecombineAngle = 30;
@@ -551,26 +552,24 @@ void Free_Surface(void *a, void *b){
     List_Delete(pS->Contours);
     List_Delete(pS->Control_Points);
     List_Delete(pS->Generatrices);
-    // MEMORY LEAK (JF)
-    if(pS->Edges)
-      {
-	Tree_Action(pS->Edges,Free_Edge);
-	Tree_Delete(pS->Edges);
-      }
+    if(pS->Edges){
+      Tree_Action(pS->Edges,Free_Edge);
+      Tree_Delete(pS->Edges);
+    }
     Free(pS);
     pS = NULL;
   }
 }
 
-Volume * Create_Volume (int Num, int Typ, int Mat){
+Volume * Create_Volume (int Num, int Typ){
   Volume *pV;
 
   pV = (Volume *) Malloc (sizeof (Volume));
   pV->Dirty = 0;
+  pV->Visible = VIS_GEO|VIS_MESH;
   pV->Num = Num;
   THEM->MaxVolumeNum = IMAX(THEM->MaxVolumeNum,Num);
   pV->Typ = Typ;
-  pV->Mat = Mat;
   pV->Method = LIBRE;
   pV->Surfaces = List_Create (1, 2, sizeof (Surface *));
   pV->Simplexes = Tree_Create (sizeof (Simplex *), compareQuality);
@@ -615,6 +614,7 @@ Hexahedron * Create_Hexahedron (Vertex * v1, Vertex * v2, Vertex * v3, Vertex *
   h = (Hexahedron *) Malloc (sizeof (Hexahedron));
   h->iEnt = -1;
   h->Num = ++THEM->MaxSimplexNum;
+  h->Visible = VIS_MESH;
   h->V[0] = v1;
   h->V[1] = v2;
   h->V[2] = v3;
@@ -643,6 +643,7 @@ Prism * Create_Prism (Vertex * v1, Vertex * v2, Vertex * v3,
   p = (Prism *) Malloc (sizeof (Prism));
   p->iEnt = -1;
   p->Num = ++THEM->MaxSimplexNum;
+  p->Visible = VIS_MESH;
   p->V[0] = v1;
   p->V[1] = v2;
   p->V[2] = v3;
@@ -669,6 +670,7 @@ Pyramid * Create_Pyramid (Vertex * v1, Vertex * v2, Vertex * v3,
   p = (Pyramid *) Malloc (sizeof (Pyramid));
   p->iEnt = -1;
   p->Num = ++THEM->MaxSimplexNum;
+  p->Visible = VIS_MESH;
   p->V[0] = v1;
   p->V[1] = v2;
   p->V[2] = v3;
diff --git a/Mesh/Create.h b/Mesh/Create.h
index 5c8f44f6a7969caaeb33297f28e3b479e067bce2..316dfec7aa0b0bdb205dd20b49c8ce20775af055 100644
--- a/Mesh/Create.h
+++ b/Mesh/Create.h
@@ -28,10 +28,10 @@ Curve *Create_Curve (int Num, int Typ, int Order, List_T * Liste,
                      List_T * Knots, int p1, int p2, double u1, double u2);
 void Free_Curve(void *a, void *b);
 
-Surface * Create_Surface (int Num, int Typ, int Mat);
+Surface * Create_Surface (int Num, int Typ);
 void Free_Surface(void *a, void *b);
 
-Volume * Create_Volume (int Num, int Typ, int Mat);
+Volume * Create_Volume (int Num, int Typ);
 void Free_Volume(void *a, void *b);
 
 Hexahedron * Create_Hexahedron (Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4,
diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp
index 750f5617a69d521e2bc7f55a895366376796fc0c..90667a6791ee285829f2c59aa60187ee886b5946 100644
--- a/Mesh/Generator.cpp
+++ b/Mesh/Generator.cpp
@@ -1,4 +1,4 @@
-// $Id: Generator.cpp,v 1.30 2001-11-07 09:33:51 geuzaine Exp $
+// $Id: Generator.cpp,v 1.31 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -104,7 +104,7 @@ void Maillage_Dimension_3 (Mesh * M){
 
   t1 = Cpu();
 
-  v = Create_Volume (99999, 99999, 99999);
+  v = Create_Volume (99999, 99999);
 
   List_T *list = Tree2List (M->Volumes);
   for (int i = 0; i < List_Nbr (list); i++){
diff --git a/Mesh/Mesh.h b/Mesh/Mesh.h
index f21f2ee4e679c100088d32eb80d0e6b30d51db4c..bfd43ce946f3677087e2b069cf5965c8124c1fb5 100644
--- a/Mesh/Mesh.h
+++ b/Mesh/Mesh.h
@@ -26,6 +26,9 @@
 
 #define CONV_VALUE    0.8
 
+#define VIS_GEO   (1<<0)
+#define VIS_MESH  (1<<1)
+
 #define NOTTOLINK 1
 #define TOLINK    2
 
@@ -168,6 +171,7 @@ class NXE{
 typedef struct{
   int Num;              /* Numero                                       */
   int iEnt;             /* Entite geometrique                           */
+  char Visible;         /* Visualization flag                           */
   Vertex *V[8];         /* 8 noeuds                                     */
   Vertex **VSUP;        /* noeuds supplem pour les elts de degre eleves */
 }Hexahedron;
@@ -175,6 +179,7 @@ typedef struct{
 typedef struct{
   int Num;              /* Numero                                       */
   int iEnt;             /* Entite geometrique                           */
+  char Visible;         /* Visualization flag                           */
   Vertex *V[6];         /* 6 noeuds                                     */
   Vertex **VSUP;        /* noeuds supplem pour les elts de degre eleves */
 }Prism;
@@ -182,6 +187,7 @@ typedef struct{
 typedef struct{
   int Num;              /* Numero                                       */
   int iEnt;             /* Entite geometrique                           */
+  char Visible;         /* Visualization flag                           */
   Vertex *V[5];         /* 5 noeuds                                     */
   Vertex **VSUP;        /* noeuds supplem pour les elts de degre eleves */
 }Pyramid;
@@ -210,14 +216,14 @@ typedef struct{
 struct _Surf{
   int Num;
   int Typ;
-  int Mat;
+  char Visible;
   int Method;
   int Recombine;
   double RecombineAngle;
-  int ipar[4];
+  int ipar[5];
   int Nu, Nv;
-  List_T *Generatrices;       /* Surface reglee    */
-  List_T *Control_Points;       /* Patchs bicubiques */
+  List_T *Generatrices; /* Surface reglee    */
+  List_T *Control_Points; /* Patchs bicubiques */
   double plan[3][3];
   double invplan[3][3];
   double a, b, c, d;
@@ -252,6 +258,7 @@ typedef struct{
 typedef struct{
   int Num;
   int Typ;
+  char Visible;
   List_T *Entities;
 }PhysicalGroup;
 
@@ -264,8 +271,8 @@ typedef struct{
 
 typedef struct {
   int Num;
-  int Mat;
   int Typ;
+  char Visible;
   int Method;
   int ipar[8];
   ExtrudeParams *Extrude;
@@ -324,6 +331,7 @@ typedef struct{
 typedef struct{
   int Num;
   int Typ;
+  char Visible;
   int Method;
   int ipar[4];
   double dpar[4];
diff --git a/Mesh/Read_Mesh.cpp b/Mesh/Read_Mesh.cpp
index a9ea073023bf02d8e43b8a8cb952e71ec8bfb8e4..ce62db1b31e3438d50d640e09a93ed7dce97b5fe 100644
--- a/Mesh/Read_Mesh.cpp
+++ b/Mesh/Read_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: Read_Mesh.cpp,v 1.31 2001-10-30 08:18:50 geuzaine Exp $
+// $Id: Read_Mesh.cpp,v 1.32 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Geo.h"
@@ -144,7 +144,7 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
 	  case TRI1: case QUA1: case TRI2: case QUA2:
 	    s = &S; s->Num = Elementary;
 	    if(!(ss = (Surface**)Tree_PQuery(M->Surfaces, &s))){
-	      s = Create_Surface(Elementary, MSH_SURF_PLAN, Elementary);
+	      s = Create_Surface(Elementary, MSH_SURF_PLAN);
 	      s->Dirty=1;
 	      Tree_Add(M->Surfaces, &s);
 	    }
@@ -155,7 +155,7 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
 	  case TET2: case HEX2: case PRI2: case PYR2:
 	    v = &V; v->Num = Elementary;
 	    if(!(vv = (Volume**)Tree_PQuery(M->Volumes, &v))){
-	      v = Create_Volume(Elementary, MSH_VOLUME, Elementary);
+	      v = Create_Volume(Elementary, MSH_VOLUME);
 	      v->Dirty=1;
 	      Tree_Add(M->Volumes, &v);
 	    }
diff --git a/Mesh/SMS.cpp b/Mesh/SMS.cpp
index e2491d215a057b103488722e7025e3cde140624b..c6019af62dc91d4b51b2566a72e71cf2c6becc0d 100644
--- a/Mesh/SMS.cpp
+++ b/Mesh/SMS.cpp
@@ -50,7 +50,7 @@ void Read_VTK_File (char *file, Mesh *m)
   fgets(line,255,in);
   sscanf(line,"%s %d %s",dumline1,&NbVertices,dumline2);
 
-  Surface *surf = Create_Surface(1,MSH_SURF_DISCRETE,1);
+  Surface *surf = Create_Surface(1,MSH_SURF_DISCRETE);
   surf->Generatrices = List_Create(1,1,sizeof(Curve*));
   Tree_Add(m->Surfaces,&surf);
   
@@ -91,7 +91,7 @@ void Read_VTK_File (char *file, Mesh *m)
 	}
       else
 	{
-	  surf = Create_Surface(1,MSH_SURF_DISCRETE,1);
+	  surf = Create_Surface(1,MSH_SURF_DISCRETE);
 	  surf->Generatrices = List_Create(1,1,sizeof(Curve*));
 	  Tree_Add(m->Surfaces,&surf);
 	}
@@ -101,7 +101,7 @@ void Read_VTK_File (char *file, Mesh *m)
   Tree_Action (surf->Simplexes, TRIE_MON_GARS2);
   if(NbFaces)m->status = 2;
 
-  Volume *vol = Create_Volume(1,MSH_VOLUME,1);
+  Volume *vol = Create_Volume(1,MSH_VOLUME);
   vol->Surfaces = List_Create(1,1,sizeof(Surface*));
   List_Add(vol->Surfaces,&surf);
   Tree_Add(m->Volumes,&vol);
@@ -212,7 +212,7 @@ void Read_Mesh_SMS (Mesh *m, FILE *in)
   
   AllFaces = List_Create(NbFaces,1,sizeof(Simplex*));
 
-  Volume *vol = Create_Volume(1,MSH_VOLUME,1);
+  Volume *vol = Create_Volume(1,MSH_VOLUME);
   vol->Surfaces = List_Create(1,1,sizeof(Surface*));
   Tree_Add(m->Volumes,&vol);
   FACE_DIMENSION = 2;
@@ -300,7 +300,7 @@ void Read_Mesh_SMS (Mesh *m, FILE *in)
 		}
 	      else
 		{
-		  surf = Create_Surface(GEntityId+10000,MSH_SURF_DISCRETE,1);
+		  surf = Create_Surface(GEntityId+10000,MSH_SURF_DISCRETE);
 		  if(!NbRegions)List_Add(vol->Surfaces,&surf);
 		  surf->Generatrices = List_Create(1,1,sizeof(Curve*));
 		  Tree_Add(m->Surfaces,&surf);
@@ -350,7 +350,7 @@ void Read_Mesh_SMS (Mesh *m, FILE *in)
 	    }
 	  else
 	    {
-	      vol = Create_Volume(GEntityId,MSH_VOLUME,GEntityId);
+	      vol = Create_Volume(GEntityId,MSH_VOLUME);
 	      Tree_Add(m->Volumes,&vol);
 	    }
 	  s->iEnt = GEntityId;
diff --git a/Mesh/Simplex.cpp b/Mesh/Simplex.cpp
index 76c488358c24b6225858e9cbc76bc812a3de3eb5..91b789e8fa9f0044402904c8d14ebb2c31486b42 100644
--- a/Mesh/Simplex.cpp
+++ b/Mesh/Simplex.cpp
@@ -1,4 +1,4 @@
-// $Id: Simplex.cpp,v 1.19 2001-10-29 08:52:20 geuzaine Exp $
+// $Id: Simplex.cpp,v 1.20 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -26,6 +26,7 @@ Simplex::Simplex (){
   iEnt = -1;
   Quality = 0. ;
   Num = TotalNumber;
+  Visible = VIS_MESH;
 }
 
 Simplex::Simplex (Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4){
@@ -38,6 +39,7 @@ Simplex::Simplex (Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4){
   Num = TotalNumber;
   THEM->MaxSimplexNum = IMAX(THEM->MaxSimplexNum,Num);
   iEnt = -1;
+  Visible = VIS_MESH;
 }
 
 Simplex::~Simplex (){
diff --git a/Mesh/Simplex.h b/Mesh/Simplex.h
index f3a5a39c868a09a14825642bef1dab4c54a57784..b34cbdc23bce81e157e11a23b27ba60425b44bf7 100644
--- a/Mesh/Simplex.h
+++ b/Mesh/Simplex.h
@@ -12,6 +12,7 @@ class Simplex{
 public:
   int     Num;           /* Numero                                       */
   int     iEnt;          /* Entite geometrique                           */
+  char    Visible;       /* Visualization flag                           */
   Face    F[4];          /* 4 faces                                      */
   Vertex  **VSUP;        /* noeuds supplem pour les elts de degre eleves */
   Vertex  *V[4];         /* 4 noeuds                                     */
diff --git a/Mesh/Vertex.cpp b/Mesh/Vertex.cpp
index 5a0c04406d29a40689ffc79d7ce811c55fff7903..3bbec9469cda1c3eb05a7dbcae90535468adeed6 100644
--- a/Mesh/Vertex.cpp
+++ b/Mesh/Vertex.cpp
@@ -1,4 +1,4 @@
-// $Id: Vertex.cpp,v 1.13 2001-11-28 16:39:42 geuzaine Exp $
+// $Id: Vertex.cpp,v 1.14 2001-12-03 08:41:44 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -11,6 +11,7 @@ extern Mesh *THEM ;
 
 Vertex::Vertex (){
   Frozen = 0;
+  Visible = VIS_GEO|VIS_MESH;
   Pos.X = 0.0;
   Pos.Y = 0.0;
   Pos.Z = 0.0;
@@ -23,6 +24,7 @@ Vertex::Vertex (){
 
 Vertex::Vertex (double X, double Y, double Z, double l, double W){
   Frozen = 0;
+  Visible = VIS_GEO|VIS_MESH;
   Pos.X = X;
   Pos.Y = Y;
   Pos.Z = Z;
@@ -82,24 +84,21 @@ Vertex *Create_Vertex (int Num, double X, double Y, double Z, double lc, double
   return pV;
 }
 
-void Delete_Vertex ( Vertex *pV )
-{
-  if(pV)
-    {
-      List_Delete(pV->ListSurf);
-      List_Delete(pV->ListCurves);
-      if(CTX.mesh.oldxtrude){//old automatic extrusion algorithm
-	List_Delete(pV->Extruded_Points);
-      }
-      else{
-	Free_ExtrudedPoints(pV->Extruded_Points);
-      }
-      delete pV;
+void Delete_Vertex ( Vertex *pV ){
+  if(pV){
+    List_Delete(pV->ListSurf);
+    List_Delete(pV->ListCurves);
+    if(CTX.mesh.oldxtrude){//old automatic extrusion algorithm
+      List_Delete(pV->Extruded_Points);
     }
+    else{
+      Free_ExtrudedPoints(pV->Extruded_Points);
+    }
+    delete pV;
+  }
 }
 
-void Free_Vertex (void *a, void *b)
-{
+void Free_Vertex (void *a, void *b){
   Delete_Vertex ( *(Vertex**)a );
 }
 
@@ -139,13 +138,13 @@ int comparePosition (const void *a, const void *b){
     return (-1);
 
   if (i != j){
-      /*
-         *w = *q;
-         printf("Les points %d et %d sont a la meme position\n",i,j);
-         printf("%12.5E %12.5E %12.5E\n",(*w)->Pos.X,(*w)->Pos.Y,(*w)->Pos.Z);
-         printf("%12.5E %12.5E %12.5E\n",(*q)->Pos.X,(*q)->Pos.Y,(*q)->Pos.Z);
-       */
-    }
+    /*
+       *w = *q;
+       printf("Les points %d et %d sont a la meme position\n",i,j);
+       printf("%12.5E %12.5E %12.5E\n",(*w)->Pos.X,(*w)->Pos.Y,(*w)->Pos.Z);
+       printf("%12.5E %12.5E %12.5E\n",(*q)->Pos.X,(*q)->Pos.Y,(*q)->Pos.Z);
+    */
+  }
   return 0;
 
 }
diff --git a/Mesh/Vertex.h b/Mesh/Vertex.h
index 444baaf117e7595398d6f396ffdd3321569ce7c5..3aaac5d82c45c253eb4406b7829d099a72c0dfcf 100644
--- a/Mesh/Vertex.h
+++ b/Mesh/Vertex.h
@@ -10,6 +10,7 @@ typedef struct {
 class Vertex {
   public :
   int     Num;
+  char    Visible;
   int     Frozen;
   double  lc,u,us[3],w;
   Coord   Pos;
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index 6fb2a58d639395e118ed953a9d69e7fdff20b614..36f23f27d0a452f9f4cb56f4f356a8847e26f3e2 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -177,7 +177,7 @@
 #line 1 "Gmsh.y"
  
 
-// $Id: Gmsh.tab.cpp,v 1.130 2001-11-14 15:31:00 geuzaine Exp $
+// $Id: Gmsh.tab.cpp,v 1.131 2001-12-03 08:41:44 geuzaine Exp $
 
 #include <stdarg.h>
 #ifndef _NOPLUGIN
@@ -632,29 +632,29 @@ static const short yyrline[] = { 0,
    707,   711,   724,   730,   736,   743,   751,   757,   763,   770,
    778,   789,   791,   792,   793,   794,   796,   798,   800,   831,
    865,   912,   927,   936,   951,   963,   977,  1000,  1024,  1036,
-  1050,  1062,  1076,  1092,  1108,  1121,  1141,  1152,  1158,  1177,
-  1191,  1197,  1203,  1222,  1228,  1234,  1250,  1257,  1263,  1269,
-  1280,  1291,  1316,  1322,  1341,  1362,  1370,  1376,  1382,  1391,
-  1397,  1403,  1415,  1421,  1426,  1431,  1438,  1440,  1441,  1444,
-  1449,  1454,  1469,  1484,  1505,  1523,  1531,  1536,  1547,  1615,
-  1635,  1642,  1646,  1666,  1679,  1690,  1712,  1734,  1755,  1761,
-  1766,  1771,  1775,  1785,  1794,  1801,  1810,  1815,  1820,  1825,
-  1830,  1835,  1840,  1845,  1850,  1858,  1863,  1868,  1873,  1878,
-  1884,  1890,  1896,  1902,  1910,  1914,  1919,  1946,  1970,  1980,
-  1999,  2017,  2035,  2057,  2078,  2099,  2113,  2134,  2139,  2150,
-  2152,  2153,  2154,  2155,  2158,  2160,  2161,  2162,  2163,  2164,
-  2165,  2166,  2167,  2174,  2175,  2176,  2177,  2178,  2179,  2180,
-  2181,  2182,  2183,  2184,  2185,  2186,  2187,  2188,  2189,  2190,
-  2191,  2192,  2193,  2194,  2195,  2196,  2197,  2198,  2199,  2200,
-  2201,  2202,  2203,  2204,  2205,  2207,  2208,  2209,  2210,  2211,
-  2212,  2213,  2214,  2215,  2216,  2217,  2218,  2219,  2220,  2221,
-  2222,  2223,  2224,  2225,  2226,  2227,  2232,  2237,  2238,  2239,
-  2243,  2254,  2271,  2282,  2301,  2317,  2333,  2349,  2366,  2371,
-  2375,  2379,  2383,  2388,  2393,  2397,  2401,  2407,  2411,  2416,
-  2420,  2425,  2429,  2433,  2439,  2445,  2452,  2458,  2462,  2466,
-  2476,  2483,  2494,  2508,  2524,  2544,  2568,  2574,  2578,  2582,
-  2593,  2598,  2609,  2614,  2632,  2637,  2650,  2656,  2662,  2667,
-  2675,  2688,  2692,  2710,  2724
+  1050,  1062,  1076,  1096,  1118,  1130,  1148,  1159,  1165,  1184,
+  1198,  1204,  1210,  1229,  1235,  1241,  1257,  1264,  1270,  1276,
+  1287,  1298,  1323,  1329,  1348,  1369,  1377,  1383,  1389,  1398,
+  1404,  1410,  1422,  1428,  1433,  1438,  1445,  1447,  1448,  1451,
+  1456,  1461,  1476,  1491,  1512,  1530,  1538,  1543,  1554,  1622,
+  1642,  1649,  1653,  1673,  1685,  1695,  1716,  1737,  1758,  1764,
+  1769,  1774,  1778,  1788,  1797,  1804,  1813,  1818,  1823,  1828,
+  1833,  1838,  1843,  1848,  1853,  1861,  1866,  1871,  1876,  1881,
+  1887,  1893,  1899,  1905,  1913,  1917,  1922,  1949,  1973,  1983,
+  2002,  2020,  2038,  2060,  2081,  2102,  2116,  2137,  2142,  2153,
+  2155,  2156,  2157,  2158,  2161,  2163,  2164,  2165,  2166,  2167,
+  2168,  2169,  2170,  2177,  2178,  2179,  2180,  2181,  2182,  2183,
+  2184,  2185,  2186,  2187,  2188,  2189,  2190,  2191,  2192,  2193,
+  2194,  2195,  2196,  2197,  2198,  2199,  2200,  2201,  2202,  2203,
+  2204,  2205,  2206,  2207,  2208,  2210,  2211,  2212,  2213,  2214,
+  2215,  2216,  2217,  2218,  2219,  2220,  2221,  2222,  2223,  2224,
+  2225,  2226,  2227,  2228,  2229,  2230,  2235,  2240,  2241,  2242,
+  2246,  2257,  2274,  2285,  2304,  2320,  2336,  2352,  2369,  2374,
+  2378,  2382,  2386,  2391,  2396,  2400,  2404,  2410,  2414,  2419,
+  2423,  2428,  2432,  2436,  2442,  2448,  2455,  2461,  2465,  2469,
+  2479,  2486,  2497,  2511,  2527,  2547,  2571,  2577,  2581,  2585,
+  2596,  2601,  2612,  2617,  2635,  2640,  2653,  2659,  2665,  2670,
+  2678,  2691,  2695,  2713,  2727
 };
 #endif
 
@@ -3243,7 +3243,7 @@ case 7:
 #line 172 "Gmsh.y"
 {
       Msg(PARSER_INFO,"STL file format");
-      STL_Surf = Create_Surface(1,MSH_SURF_STL,1);
+      STL_Surf = Create_Surface(1,MSH_SURF_STL);
       STL_Surf->STL = new STL_Data;
       return 1;
     ;
@@ -4232,12 +4232,16 @@ case 163:
 		   ct->size, COLORTABLE_NBMAX_COLOR, 0);
 	else
 	  for(i=0 ; i<ct->size ; i++) List_Read(yyvsp[-1].l, i, &ct->table[i]);
+	if(ct->size == 1){
+	  ct->size = 2;
+	  ct->table[1] = ct->table[0];
+	}
       }
       List_Delete(yyvsp[-1].l);
     ;
     break;}
 case 164:
-#line 1093 "Gmsh.y"
+#line 1097 "Gmsh.y"
 {
       ColorTable *ct = Get_ColorTable((int)yyvsp[-6].d);
       if(!ct)
@@ -4249,42 +4253,42 @@ case 164:
 		   ct->size, COLORTABLE_NBMAX_COLOR, (int)yyvsp[-6].d);
 	else
 	  for(i=0 ; i<ct->size ; i++) List_Read(yyvsp[-1].l, i, &ct->table[i]);
+	if(ct->size == 1){
+	  ct->size = 2;
+	  ct->table[1] = ct->table[0];
+	}
       }
       List_Delete(yyvsp[-1].l);
     ;
     break;}
 case 165:
-#line 1109 "Gmsh.y"
+#line 1119 "Gmsh.y"
 {
-#ifndef _NOPLUGIN
-    if(CTX.default_plugins){
-      try {
-	GMSH_PluginManager::Instance()->SetPluginOption(yyvsp[-6].c,yyvsp[-3].c,yyvsp[-1].d); 
-      }
-      catch (...) {
-	Msg(WARNING,"Unknown option '%s' or plugin '%s'",yyvsp[-3].c,yyvsp[-6].c);
+      if(CTX.default_plugins){
+	try {
+	  GMSH_PluginManager::Instance()->SetPluginOption(yyvsp[-6].c,yyvsp[-3].c,yyvsp[-1].d); 
+	}
+	catch (...) {
+	  Msg(WARNING,"Unknown option '%s' or plugin '%s'",yyvsp[-3].c,yyvsp[-6].c);
+	}
       }
-    }
-#endif
-  ;
+    ;
     break;}
 case 166:
-#line 1122 "Gmsh.y"
+#line 1131 "Gmsh.y"
 {
-#ifndef _NOPLUGIN
-    if(CTX.default_plugins){
-      try {
-	GMSH_PluginManager::Instance()->SetPluginOption(yyvsp[-6].c,yyvsp[-3].c,yyvsp[-1].c); 
-      }
-      catch (...) {
-	Msg(WARNING,"Unknown option '%s' or plugin '%s'",yyvsp[-3].c,yyvsp[-6].c);
+      if(CTX.default_plugins){
+	try {
+	  GMSH_PluginManager::Instance()->SetPluginOption(yyvsp[-6].c,yyvsp[-3].c,yyvsp[-1].c); 
+	}
+	catch (...) {
+	  Msg(WARNING,"Unknown option '%s' or plugin '%s'",yyvsp[-3].c,yyvsp[-6].c);
+	}
       }
-    }
-#endif
-  ;
+    ;
     break;}
 case 167:
-#line 1146 "Gmsh.y"
+#line 1153 "Gmsh.y"
 {
       Cdbpts101((int)yyvsp[-4].d,yyvsp[-1].v[0],yyvsp[-1].v[1],yyvsp[-1].v[2],yyvsp[-1].v[3],yyvsp[-1].v[4]);
       yyval.s.Type = MSH_POINT;
@@ -4292,7 +4296,7 @@ case 167:
     ;
     break;}
 case 168:
-#line 1153 "Gmsh.y"
+#line 1160 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_PHYSICAL_POINT,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_PHYSICAL_POINT;
@@ -4300,7 +4304,7 @@ case 168:
     ;
     break;}
 case 169:
-#line 1159 "Gmsh.y"
+#line 1166 "Gmsh.y"
 {
       Vertex *v;
       Attractor *a;
@@ -4321,7 +4325,7 @@ case 169:
     ;
     break;}
 case 170:
-#line 1178 "Gmsh.y"
+#line 1185 "Gmsh.y"
 {
       for(i=0;i<List_Nbr(yyvsp[-3].l);i++){
 	List_Read(yyvsp[-3].l,i,&d);
@@ -4334,7 +4338,7 @@ case 170:
     ;
     break;}
 case 171:
-#line 1192 "Gmsh.y"
+#line 1199 "Gmsh.y"
 {
       Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_LINE,1,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
       yyval.s.Type = MSH_SEGM_LINE;
@@ -4342,7 +4346,7 @@ case 171:
     ;
     break;}
 case 172:
-#line 1198 "Gmsh.y"
+#line 1205 "Gmsh.y"
 {
       Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_SPLN,3,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
       yyval.s.Type = MSH_SEGM_SPLN;
@@ -4350,7 +4354,7 @@ case 172:
     ;
     break;}
 case 173:
-#line 1204 "Gmsh.y"
+#line 1211 "Gmsh.y"
 {
       Curve *c;
       Attractor *a;
@@ -4371,7 +4375,7 @@ case 173:
     ;
     break;}
 case 174:
-#line 1223 "Gmsh.y"
+#line 1230 "Gmsh.y"
 {
       Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_CIRC,2,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
       yyval.s.Type = MSH_SEGM_CIRC ;
@@ -4379,7 +4383,7 @@ case 174:
     ;
     break;}
 case 175:
-#line 1229 "Gmsh.y"
+#line 1236 "Gmsh.y"
 {
       Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_ELLI,2,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
       yyval.s.Type = MSH_SEGM_ELLI ;
@@ -4387,7 +4391,7 @@ case 175:
     ;
     break;}
 case 176:
-#line 1235 "Gmsh.y"
+#line 1242 "Gmsh.y"
 {
       List_T *temp;
       int i,j;
@@ -4405,7 +4409,7 @@ case 176:
     ;
     break;}
 case 177:
-#line 1252 "Gmsh.y"
+#line 1259 "Gmsh.y"
 {
       Cdbseg101((int)yyvsp[-14].d,MSH_SEGM_PARAMETRIC,2,NULL,NULL,-1,-1,yyvsp[-10].d,yyvsp[-8].d,yyvsp[-6].c,yyvsp[-4].c,yyvsp[-2].c);
       yyval.s.Type = MSH_SEGM_PARAMETRIC ;
@@ -4413,7 +4417,7 @@ case 177:
     ;
     break;}
 case 178:
-#line 1258 "Gmsh.y"
+#line 1265 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_PHYSICAL_LINE,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_PHYSICAL_LINE;
@@ -4421,7 +4425,7 @@ case 178:
     ;
     break;}
 case 179:
-#line 1264 "Gmsh.y"
+#line 1271 "Gmsh.y"
 {
       yyval.s.Type = MSH_SEGM_LOOP;
       Cdbz101((int)yyvsp[-4].d,yyval.s.Type,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
@@ -4429,7 +4433,7 @@ case 179:
     ;
     break;}
 case 180:
-#line 1270 "Gmsh.y"
+#line 1277 "Gmsh.y"
 {
       if(List_Nbr(yyvsp[-1].l) > 3){
 	Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_BSPLN,2,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
@@ -4442,7 +4446,7 @@ case 180:
     ;
     break;}
 case 181:
-#line 1281 "Gmsh.y"
+#line 1288 "Gmsh.y"
 {
       if(List_Nbr(yyvsp[-1].l) > 3){
 	Cdbseg101((int)yyvsp[-4].d,MSH_SEGM_BEZIER,2,yyvsp[-1].l,NULL,-1,-1,0.,1.,NULL,NULL,NULL);
@@ -4455,7 +4459,7 @@ case 181:
     ;
     break;}
 case 182:
-#line 1292 "Gmsh.y"
+#line 1299 "Gmsh.y"
 {
       List_T *Temp;
       int i;
@@ -4479,7 +4483,7 @@ case 182:
     ;
     break;}
 case 183:
-#line 1317 "Gmsh.y"
+#line 1324 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_SURF_PLAN,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_SURF_PLAN;
@@ -4487,7 +4491,7 @@ case 183:
     ;
     break;}
 case 184:
-#line 1323 "Gmsh.y"
+#line 1330 "Gmsh.y"
 {
       Surface *s,*support;
       support = FindSurface((int)yyvsp[-4].d,THEM);
@@ -4508,7 +4512,7 @@ case 184:
     ;
     break;}
 case 185:
-#line 1342 "Gmsh.y"
+#line 1349 "Gmsh.y"
 {
       List_Read(yyvsp[-1].l,0,&d);
       i = (int)d;
@@ -4531,7 +4535,7 @@ case 185:
     ;
     break;}
 case 186:
-#line 1365 "Gmsh.y"
+#line 1372 "Gmsh.y"
 {
       CreateNurbsSurface ( (int) yyvsp[-16].d , (int)yyvsp[-4].d , (int)yyvsp[-2].d  , yyvsp[-13].l, yyvsp[-10].l, yyvsp[-8].l);
       yyval.s.Type  = MSH_SURF_NURBS;
@@ -4539,13 +4543,13 @@ case 186:
     ;
     break;}
 case 187:
-#line 1373 "Gmsh.y"
+#line 1380 "Gmsh.y"
 {
       CreateNurbsSurfaceSupport ((int)yyvsp[-16].d, (int) yyvsp[-4].d , (int) yyvsp[-2].d , yyvsp[-13].l, yyvsp[-10].l, yyvsp[-8].l);
     ;
     break;}
 case 188:
-#line 1377 "Gmsh.y"
+#line 1384 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_PHYSICAL_SURFACE,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_PHYSICAL_SURFACE;
@@ -4553,7 +4557,7 @@ case 188:
     ;
     break;}
 case 189:
-#line 1383 "Gmsh.y"
+#line 1390 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_SURF_LOOP,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_SURF_LOOP;
@@ -4561,7 +4565,7 @@ case 189:
     ;
     break;}
 case 190:
-#line 1392 "Gmsh.y"
+#line 1399 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_VOLUME,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_VOLUME;
@@ -4569,7 +4573,7 @@ case 190:
     ;
     break;}
 case 191:
-#line 1398 "Gmsh.y"
+#line 1405 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_VOLUME,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_VOLUME;
@@ -4577,7 +4581,7 @@ case 191:
     ;
     break;}
 case 192:
-#line 1404 "Gmsh.y"
+#line 1411 "Gmsh.y"
 {
       Cdbz101((int)yyvsp[-4].d,MSH_PHYSICAL_VOLUME,0,0,0,0,0,NULL,yyvsp[-1].l,NULL);
       yyval.s.Type = MSH_PHYSICAL_VOLUME;
@@ -4585,60 +4589,60 @@ case 192:
     ;
     break;}
 case 193:
-#line 1417 "Gmsh.y"
+#line 1424 "Gmsh.y"
 {
       TranslateShapes (yyvsp[-3].v[0],yyvsp[-3].v[1],yyvsp[-3].v[2],yyvsp[-1].l,1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 194:
-#line 1422 "Gmsh.y"
+#line 1429 "Gmsh.y"
 {
       RotateShapes(yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].d,yyvsp[-1].l);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 195:
-#line 1427 "Gmsh.y"
+#line 1434 "Gmsh.y"
 {
       SymmetryShapes(yyvsp[-3].v[0],yyvsp[-3].v[1],yyvsp[-3].v[2],yyvsp[-3].v[3],yyvsp[-1].l,1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 196:
-#line 1432 "Gmsh.y"
+#line 1439 "Gmsh.y"
 {
       DilatShapes(yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].d,yyvsp[-1].l,1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 197:
-#line 1439 "Gmsh.y"
+#line 1446 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 198:
-#line 1440 "Gmsh.y"
+#line 1447 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 199:
-#line 1441 "Gmsh.y"
+#line 1448 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 200:
-#line 1446 "Gmsh.y"
+#line 1453 "Gmsh.y"
 {
       yyval.l = List_Create(3,3,sizeof(Shape));
     ;
     break;}
 case 201:
-#line 1450 "Gmsh.y"
+#line 1457 "Gmsh.y"
 {
       List_Add(yyval.l,&yyvsp[0].s);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 202:
-#line 1455 "Gmsh.y"
+#line 1462 "Gmsh.y"
 {
       for(i=0;i<List_Nbr(yyvsp[-2].l);i++){
 	List_Read(yyvsp[-2].l, i, &d);
@@ -4655,7 +4659,7 @@ case 202:
     ;
     break;}
 case 203:
-#line 1470 "Gmsh.y"
+#line 1477 "Gmsh.y"
 {
       for(i=0;i<List_Nbr(yyvsp[-2].l);i++){
 	List_Read(yyvsp[-2].l, i, &d);
@@ -4672,7 +4676,7 @@ case 203:
     ;
     break;}
 case 204:
-#line 1485 "Gmsh.y"
+#line 1492 "Gmsh.y"
 {
       for(i=0;i<List_Nbr(yyvsp[-2].l);i++){
 	List_Read(yyvsp[-2].l, i, &d);
@@ -4689,7 +4693,7 @@ case 204:
     ;
     break;}
 case 205:
-#line 1507 "Gmsh.y"
+#line 1514 "Gmsh.y"
 {
       yyval.l = List_Create(3,3,sizeof(Shape));
       for(i=0;i<List_Nbr(yyvsp[-1].l);i++){
@@ -4701,7 +4705,7 @@ case 205:
     ;
     break;}
 case 206:
-#line 1525 "Gmsh.y"
+#line 1532 "Gmsh.y"
 {
       for(i=0;i<List_Nbr(yyvsp[-1].l);i++){
 	List_Read (yyvsp[-1].l,i,&TheShape);
@@ -4710,20 +4714,20 @@ case 206:
     ;
     break;}
 case 207:
-#line 1532 "Gmsh.y"
+#line 1539 "Gmsh.y"
 {
 	if(!strcmp(yyvsp[-4].c, "View"))
 	  FreeView((int)yyvsp[-2].d);
       ;
     break;}
 case 208:
-#line 1537 "Gmsh.y"
+#line 1544 "Gmsh.y"
 {
       Init_Mesh(THEM, 1);
     ;
     break;}
 case 209:
-#line 1549 "Gmsh.y"
+#line 1556 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-2].c, "Include")){
 
@@ -4792,7 +4796,7 @@ case 209:
     ;
     break;}
 case 210:
-#line 1616 "Gmsh.y"
+#line 1623 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-2].c, "Sleep")){
 
@@ -4814,7 +4818,7 @@ case 210:
     ;
     break;}
 case 211:
-#line 1636 "Gmsh.y"
+#line 1643 "Gmsh.y"
 {
 #ifndef _NOPLUGIN
     if(CTX.default_plugins)
@@ -4823,13 +4827,13 @@ case 211:
    ;
     break;}
 case 212:
-#line 1643 "Gmsh.y"
+#line 1650 "Gmsh.y"
 {
       exit(0);
     ;
     break;}
 case 213:
-#line 1647 "Gmsh.y"
+#line 1654 "Gmsh.y"
 {
       if(!CTX.batch){ // we're in interactive mode
 	if(Tree_Nbr(THEM->Points) != Last_NumberOfPoints){
@@ -4845,9 +4849,8 @@ case 213:
     ;
     break;}
 case 214:
-#line 1669 "Gmsh.y"
+#line 1676 "Gmsh.y"
 {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-3].d ;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-1].d ;
       LoopControlVariablesTab[ImbricatedLoop][2] = 1.0 ;
@@ -4858,9 +4861,8 @@ case 214:
     ;
     break;}
 case 215:
-#line 1680 "Gmsh.y"
+#line 1686 "Gmsh.y"
 {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-5].d ;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-3].d ;
       LoopControlVariablesTab[ImbricatedLoop][2] = yyvsp[-1].d ;
@@ -4871,9 +4873,8 @@ case 215:
     ;
     break;}
 case 216:
-#line 1691 "Gmsh.y"
+#line 1696 "Gmsh.y"
 {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-3].d ;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-1].d ;
       LoopControlVariablesTab[ImbricatedLoop][2] = 1.0 ;
@@ -4895,9 +4896,8 @@ case 216:
     ;
     break;}
 case 217:
-#line 1713 "Gmsh.y"
+#line 1717 "Gmsh.y"
 {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-5].d ;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-3].d ;
       LoopControlVariablesTab[ImbricatedLoop][2] = yyvsp[-1].d ;
@@ -4919,7 +4919,7 @@ case 217:
     ;
     break;}
 case 218:
-#line 1735 "Gmsh.y"
+#line 1738 "Gmsh.y"
 {
       if(LoopControlVariablesTab[ImbricatedLoop-1][1] >  
 	 LoopControlVariablesTab[ImbricatedLoop-1][0]){
@@ -4942,7 +4942,7 @@ case 218:
     ;
     break;}
 case 219:
-#line 1756 "Gmsh.y"
+#line 1759 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->createFunction(yyvsp[0].c,yyin,yyname,yylineno))
 	vyyerror("Redefinition of function %s",yyvsp[0].c);
@@ -4950,32 +4950,32 @@ case 219:
     ;
     break;}
 case 220:
-#line 1762 "Gmsh.y"
+#line 1765 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->leaveFunction(&yyin,yyname,yylineno))
 	vyyerror("Error while exiting function");
     ;
     break;}
 case 221:
-#line 1767 "Gmsh.y"
+#line 1770 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->enterFunction(yyvsp[-1].c,&yyin,yyname,yylineno))
 	vyyerror("Unknown function %s",yyvsp[-1].c);
     ;
     break;}
 case 222:
-#line 1772 "Gmsh.y"
+#line 1775 "Gmsh.y"
 {
       if(!yyvsp[-1].d) skip_until("If", "EndIf");
     ;
     break;}
 case 223:
-#line 1776 "Gmsh.y"
+#line 1779 "Gmsh.y"
 {
     ;
     break;}
 case 224:
-#line 1788 "Gmsh.y"
+#line 1791 "Gmsh.y"
 {
       Curve *pc, *prc;
       Extrude_ProtudePoint(TRANSLATE,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],
@@ -4984,7 +4984,7 @@ case 224:
     ;
     break;}
 case 225:
-#line 1795 "Gmsh.y"
+#line 1798 "Gmsh.y"
 {
       Curve *pc, *prc;
       Extrude_ProtudePoint(ROTATE,(int)yyvsp[-8].d,0.,0.,0.,
@@ -4993,7 +4993,7 @@ case 225:
     ;
     break;}
 case 226:
-#line 1802 "Gmsh.y"
+#line 1805 "Gmsh.y"
 {
       Curve *pc, *prc;
       Extrude_ProtudePoint(TRANSLATE_ROTATE,(int)yyvsp[-10].d,yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],
@@ -5002,98 +5002,98 @@ case 226:
     ;
     break;}
 case 227:
-#line 1811 "Gmsh.y"
+#line 1814 "Gmsh.y"
 {
       Extrude_ProtudeCurve(TRANSLATE,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],
 			   0.,0.,0.,0.,0.,0.,0.,1,NULL);
     ;
     break;}
 case 228:
-#line 1816 "Gmsh.y"
+#line 1819 "Gmsh.y"
 {
       Extrude_ProtudeCurve(ROTATE,(int)yyvsp[-8].d,0.,0.,0.,
 			   yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,1,NULL);
     ;
     break;}
 case 229:
-#line 1821 "Gmsh.y"
+#line 1824 "Gmsh.y"
 {
       Extrude_ProtudeCurve(TRANSLATE_ROTATE,(int)yyvsp[-10].d,yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],
 			   yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,1,NULL);
     ;
     break;}
 case 230:
-#line 1826 "Gmsh.y"
+#line 1829 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 231:
-#line 1831 "Gmsh.y"
+#line 1834 "Gmsh.y"
 {
       Extrude_ProtudeCurve(TRANSLATE,(int)yyvsp[-8].d,yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],
 			   0.,0.,0.,0.,0.,0.,0.,1,&extr);
     ;
     break;}
 case 232:
-#line 1836 "Gmsh.y"
+#line 1839 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 233:
-#line 1841 "Gmsh.y"
+#line 1844 "Gmsh.y"
 {
       Extrude_ProtudeCurve(ROTATE,(int)yyvsp[-12].d,0.,0.,0.,
 			   yyvsp[-10].v[0],yyvsp[-10].v[1],yyvsp[-10].v[2],yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],yyvsp[-6].d,1,&extr);
     ;
     break;}
 case 234:
-#line 1846 "Gmsh.y"
+#line 1849 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 235:
-#line 1851 "Gmsh.y"
+#line 1854 "Gmsh.y"
 {
       Extrude_ProtudeCurve(TRANSLATE_ROTATE,(int)yyvsp[-14].d,yyvsp[-12].v[0],yyvsp[-12].v[1],yyvsp[-12].v[2],
 			   yyvsp[-10].v[0],yyvsp[-10].v[1],yyvsp[-10].v[2],yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],yyvsp[-6].d,1,&extr);
     ;
     break;}
 case 236:
-#line 1859 "Gmsh.y"
+#line 1862 "Gmsh.y"
 {
       Extrude_ProtudeSurface(TRANSLATE,(int)yyvsp[-4].d,yyvsp[-2].v[0],yyvsp[-2].v[1],yyvsp[-2].v[2],
 			     0.,0.,0.,0.,0.,0.,0.,0,NULL);
     ;
     break;}
 case 237:
-#line 1864 "Gmsh.y"
+#line 1867 "Gmsh.y"
 {
       Extrude_ProtudeSurface(ROTATE,(int)yyvsp[-8].d,0.,0.,0.,
 			     yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,0,NULL);
     ;
     break;}
 case 238:
-#line 1869 "Gmsh.y"
+#line 1872 "Gmsh.y"
 {
       Extrude_ProtudeSurface(TRANSLATE_ROTATE,(int)yyvsp[-10].d,yyvsp[-8].v[0],yyvsp[-8].v[1],yyvsp[-8].v[2],
 			     yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],yyvsp[-4].v[0],yyvsp[-4].v[1],yyvsp[-4].v[2],yyvsp[-2].d,0,NULL);
     ;
     break;}
 case 239:
-#line 1874 "Gmsh.y"
+#line 1877 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 240:
-#line 1879 "Gmsh.y"
+#line 1882 "Gmsh.y"
 {
       int vol = NEWREG();
       Extrude_ProtudeSurface(TRANSLATE,(int)yyvsp[-8].d,yyvsp[-6].v[0],yyvsp[-6].v[1],yyvsp[-6].v[2],
@@ -5101,14 +5101,14 @@ case 240:
     ;
     break;}
 case 241:
-#line 1885 "Gmsh.y"
+#line 1888 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 242:
-#line 1891 "Gmsh.y"
+#line 1894 "Gmsh.y"
 {
       int vol = NEWREG();
       Extrude_ProtudeSurface(ROTATE,(int)yyvsp[-12].d,0.,0.,0.,
@@ -5116,14 +5116,14 @@ case 242:
     ;
     break;}
 case 243:
-#line 1897 "Gmsh.y"
+#line 1900 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 244:
-#line 1903 "Gmsh.y"
+#line 1906 "Gmsh.y"
 {
       int vol = NEWREG();
       Extrude_ProtudeSurface(TRANSLATE_ROTATE,(int)yyvsp[-14].d,yyvsp[-12].v[0],yyvsp[-12].v[1],yyvsp[-12].v[2],
@@ -5131,17 +5131,17 @@ case 244:
     ;
     break;}
 case 245:
-#line 1912 "Gmsh.y"
+#line 1915 "Gmsh.y"
 {
     ;
     break;}
 case 246:
-#line 1915 "Gmsh.y"
+#line 1918 "Gmsh.y"
 {
     ;
     break;}
 case 247:
-#line 1921 "Gmsh.y"
+#line 1924 "Gmsh.y"
 {
       double d;
       extr.mesh.ExtrudeMesh = true;
@@ -5152,7 +5152,7 @@ case 247:
 	extr.mesh.hLayer = (double*)Malloc(extr.mesh.NbLayer*sizeof(double));
 	for(int i=0;i<List_Nbr(yyvsp[-6].l);i++){
 	  List_Read(yyvsp[-6].l,i,&d);
-	  extr.mesh.NbElmLayer[i] = (int)d;
+	  extr.mesh.NbElmLayer[i] = (d>0)?(int)d:1;
 	  List_Read(yyvsp[-4].l,i,&d);
 	  extr.mesh.ZonLayer[i] = (int)d;
 	  List_Read(yyvsp[-2].l,i,&d);
@@ -5169,7 +5169,7 @@ case 247:
     ;
     break;}
 case 248:
-#line 1947 "Gmsh.y"
+#line 1950 "Gmsh.y"
 {
       double d;
       extr.mesh.ExtrudeMesh = true;
@@ -5180,7 +5180,7 @@ case 248:
 	extr.mesh.hLayer = (double*)Malloc(extr.mesh.NbLayer*sizeof(double));
 	for(int i=0;i<List_Nbr(yyvsp[-4].l);i++){
 	  List_Read(yyvsp[-4].l,i,&d);
-	  extr.mesh.NbElmLayer[i] = (int)d;
+	  extr.mesh.NbElmLayer[i] = (d>0)?(int)d:1;
 	  extr.mesh.ZonLayer[i] = 0;
 	  List_Read(yyvsp[-2].l,i,&d);
 	  extr.mesh.hLayer[i] = d;
@@ -5195,13 +5195,13 @@ case 248:
     ;
     break;}
 case 249:
-#line 1971 "Gmsh.y"
+#line 1974 "Gmsh.y"
 {
       extr.mesh.Recombine = true;
     ;
     break;}
 case 250:
-#line 1982 "Gmsh.y"
+#line 1985 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-3].l);i++){
@@ -5221,7 +5221,7 @@ case 250:
     ;
     break;}
 case 251:
-#line 2000 "Gmsh.y"
+#line 2003 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-6].l);i++){
@@ -5241,7 +5241,7 @@ case 251:
     ;
     break;}
 case 252:
-#line 2018 "Gmsh.y"
+#line 2021 "Gmsh.y"
 {
       Curve *c;
       for(i=0;i<List_Nbr(yyvsp[-6].l);i++){
@@ -5261,7 +5261,7 @@ case 252:
     ;
     break;}
 case 253:
-#line 2036 "Gmsh.y"
+#line 2039 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d,THEM);
       if(!s)
@@ -5285,7 +5285,7 @@ case 253:
     ;
     break;}
 case 254:
-#line 2058 "Gmsh.y"
+#line 2061 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d,THEM);
       if(!s)
@@ -5308,7 +5308,7 @@ case 254:
     ;
     break;}
 case 255:
-#line 2079 "Gmsh.y"
+#line 2082 "Gmsh.y"
 {
       Volume *v = FindVolume((int)yyvsp[-4].d,THEM);
       if(!v)
@@ -5331,7 +5331,7 @@ case 255:
     ;
     break;}
 case 256:
-#line 2100 "Gmsh.y"
+#line 2103 "Gmsh.y"
 {
       Surface *s;
       for(i=0;i<List_Nbr(yyvsp[-3].l);i++){
@@ -5347,7 +5347,7 @@ case 256:
     ;
     break;}
 case 257:
-#line 2114 "Gmsh.y"
+#line 2117 "Gmsh.y"
 {
       Surface *s;
       for(i=0;i<List_Nbr(yyvsp[-1].l);i++){
@@ -5363,71 +5363,71 @@ case 257:
     ;
     break;}
 case 258:
-#line 2136 "Gmsh.y"
+#line 2139 "Gmsh.y"
 { 
       ReplaceAllDuplicates(THEM);
     ;
     break;}
 case 259:
-#line 2140 "Gmsh.y"
+#line 2143 "Gmsh.y"
 { 
       IntersectAllSegmentsTogether();
     ;
     break;}
 case 260:
-#line 2151 "Gmsh.y"
+#line 2154 "Gmsh.y"
 {yyval.i = 1;;
     break;}
 case 261:
-#line 2152 "Gmsh.y"
+#line 2155 "Gmsh.y"
 {yyval.i = 0;;
     break;}
 case 262:
-#line 2153 "Gmsh.y"
+#line 2156 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 263:
-#line 2154 "Gmsh.y"
+#line 2157 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 264:
-#line 2155 "Gmsh.y"
+#line 2158 "Gmsh.y"
 {yyval.i = -1;;
     break;}
 case 265:
-#line 2159 "Gmsh.y"
+#line 2162 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 266:
-#line 2160 "Gmsh.y"
+#line 2163 "Gmsh.y"
 { yyval.d = yyvsp[-1].d ;          ;
     break;}
 case 267:
-#line 2161 "Gmsh.y"
+#line 2164 "Gmsh.y"
 { yyval.d = -yyvsp[0].d ;         ;
     break;}
 case 268:
-#line 2162 "Gmsh.y"
+#line 2165 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 269:
-#line 2163 "Gmsh.y"
+#line 2166 "Gmsh.y"
 { yyval.d = !yyvsp[0].d ;         ;
     break;}
 case 270:
-#line 2164 "Gmsh.y"
+#line 2167 "Gmsh.y"
 { yyval.d = yyvsp[-2].d - yyvsp[0].d ;     ;
     break;}
 case 271:
-#line 2165 "Gmsh.y"
+#line 2168 "Gmsh.y"
 { yyval.d = yyvsp[-2].d + yyvsp[0].d ;     ;
     break;}
 case 272:
-#line 2166 "Gmsh.y"
+#line 2169 "Gmsh.y"
 { yyval.d = yyvsp[-2].d * yyvsp[0].d ;     ;
     break;}
 case 273:
-#line 2168 "Gmsh.y"
+#line 2171 "Gmsh.y"
 { 
       if(!yyvsp[0].d)
 	vyyerror("Division by zero in '%g / %g'", yyvsp[-2].d, yyvsp[0].d);
@@ -5436,235 +5436,235 @@ case 273:
     ;
     break;}
 case 274:
-#line 2174 "Gmsh.y"
+#line 2177 "Gmsh.y"
 { yyval.d = (int)yyvsp[-2].d % (int)yyvsp[0].d ;  ;
     break;}
 case 275:
-#line 2175 "Gmsh.y"
+#line 2178 "Gmsh.y"
 { yyval.d = pow(yyvsp[-2].d,yyvsp[0].d) ;  ;
     break;}
 case 276:
-#line 2176 "Gmsh.y"
+#line 2179 "Gmsh.y"
 { yyval.d = yyvsp[-2].d < yyvsp[0].d ;     ;
     break;}
 case 277:
-#line 2177 "Gmsh.y"
+#line 2180 "Gmsh.y"
 { yyval.d = yyvsp[-2].d > yyvsp[0].d ;     ;
     break;}
 case 278:
-#line 2178 "Gmsh.y"
+#line 2181 "Gmsh.y"
 { yyval.d = yyvsp[-2].d <= yyvsp[0].d ;    ;
     break;}
 case 279:
-#line 2179 "Gmsh.y"
+#line 2182 "Gmsh.y"
 { yyval.d = yyvsp[-2].d >= yyvsp[0].d ;    ;
     break;}
 case 280:
-#line 2180 "Gmsh.y"
+#line 2183 "Gmsh.y"
 { yyval.d = yyvsp[-2].d == yyvsp[0].d ;    ;
     break;}
 case 281:
-#line 2181 "Gmsh.y"
+#line 2184 "Gmsh.y"
 { yyval.d = yyvsp[-2].d != yyvsp[0].d ;    ;
     break;}
 case 282:
-#line 2182 "Gmsh.y"
+#line 2185 "Gmsh.y"
 { yyval.d = yyvsp[-2].d && yyvsp[0].d ;    ;
     break;}
 case 283:
-#line 2183 "Gmsh.y"
+#line 2186 "Gmsh.y"
 { yyval.d = yyvsp[-2].d || yyvsp[0].d ;    ;
     break;}
 case 284:
-#line 2184 "Gmsh.y"
+#line 2187 "Gmsh.y"
 { yyval.d = yyvsp[-4].d? yyvsp[-2].d : yyvsp[0].d ; ;
     break;}
 case 285:
-#line 2185 "Gmsh.y"
+#line 2188 "Gmsh.y"
 { yyval.d = exp(yyvsp[-1].d);      ;
     break;}
 case 286:
-#line 2186 "Gmsh.y"
+#line 2189 "Gmsh.y"
 { yyval.d = log(yyvsp[-1].d);      ;
     break;}
 case 287:
-#line 2187 "Gmsh.y"
+#line 2190 "Gmsh.y"
 { yyval.d = log10(yyvsp[-1].d);    ;
     break;}
 case 288:
-#line 2188 "Gmsh.y"
+#line 2191 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-1].d);     ;
     break;}
 case 289:
-#line 2189 "Gmsh.y"
+#line 2192 "Gmsh.y"
 { yyval.d = sin(yyvsp[-1].d);      ;
     break;}
 case 290:
-#line 2190 "Gmsh.y"
+#line 2193 "Gmsh.y"
 { yyval.d = asin(yyvsp[-1].d);     ;
     break;}
 case 291:
-#line 2191 "Gmsh.y"
+#line 2194 "Gmsh.y"
 { yyval.d = cos(yyvsp[-1].d);      ;
     break;}
 case 292:
-#line 2192 "Gmsh.y"
+#line 2195 "Gmsh.y"
 { yyval.d = acos(yyvsp[-1].d);     ;
     break;}
 case 293:
-#line 2193 "Gmsh.y"
+#line 2196 "Gmsh.y"
 { yyval.d = tan(yyvsp[-1].d);      ;
     break;}
 case 294:
-#line 2194 "Gmsh.y"
+#line 2197 "Gmsh.y"
 { yyval.d = atan(yyvsp[-1].d);     ;
     break;}
 case 295:
-#line 2195 "Gmsh.y"
+#line 2198 "Gmsh.y"
 { yyval.d = atan2(yyvsp[-3].d,yyvsp[-1].d); ;
     break;}
 case 296:
-#line 2196 "Gmsh.y"
+#line 2199 "Gmsh.y"
 { yyval.d = sinh(yyvsp[-1].d);     ;
     break;}
 case 297:
-#line 2197 "Gmsh.y"
+#line 2200 "Gmsh.y"
 { yyval.d = cosh(yyvsp[-1].d);     ;
     break;}
 case 298:
-#line 2198 "Gmsh.y"
+#line 2201 "Gmsh.y"
 { yyval.d = tanh(yyvsp[-1].d);     ;
     break;}
 case 299:
-#line 2199 "Gmsh.y"
+#line 2202 "Gmsh.y"
 { yyval.d = fabs(yyvsp[-1].d);     ;
     break;}
 case 300:
-#line 2200 "Gmsh.y"
+#line 2203 "Gmsh.y"
 { yyval.d = floor(yyvsp[-1].d);    ;
     break;}
 case 301:
-#line 2201 "Gmsh.y"
+#line 2204 "Gmsh.y"
 { yyval.d = ceil(yyvsp[-1].d);     ;
     break;}
 case 302:
-#line 2202 "Gmsh.y"
+#line 2205 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 303:
-#line 2203 "Gmsh.y"
+#line 2206 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 304:
-#line 2204 "Gmsh.y"
+#line 2207 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-3].d*yyvsp[-3].d+yyvsp[-1].d*yyvsp[-1].d); ;
     break;}
 case 305:
-#line 2205 "Gmsh.y"
+#line 2208 "Gmsh.y"
 { yyval.d = yyvsp[-1].d*(double)rand()/(double)RAND_MAX; ;
     break;}
 case 306:
-#line 2207 "Gmsh.y"
+#line 2210 "Gmsh.y"
 { yyval.d = exp(yyvsp[-1].d);      ;
     break;}
 case 307:
-#line 2208 "Gmsh.y"
+#line 2211 "Gmsh.y"
 { yyval.d = log(yyvsp[-1].d);      ;
     break;}
 case 308:
-#line 2209 "Gmsh.y"
+#line 2212 "Gmsh.y"
 { yyval.d = log10(yyvsp[-1].d);    ;
     break;}
 case 309:
-#line 2210 "Gmsh.y"
+#line 2213 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-1].d);     ;
     break;}
 case 310:
-#line 2211 "Gmsh.y"
+#line 2214 "Gmsh.y"
 { yyval.d = sin(yyvsp[-1].d);      ;
     break;}
 case 311:
-#line 2212 "Gmsh.y"
+#line 2215 "Gmsh.y"
 { yyval.d = asin(yyvsp[-1].d);     ;
     break;}
 case 312:
-#line 2213 "Gmsh.y"
+#line 2216 "Gmsh.y"
 { yyval.d = cos(yyvsp[-1].d);      ;
     break;}
 case 313:
-#line 2214 "Gmsh.y"
+#line 2217 "Gmsh.y"
 { yyval.d = acos(yyvsp[-1].d);     ;
     break;}
 case 314:
-#line 2215 "Gmsh.y"
+#line 2218 "Gmsh.y"
 { yyval.d = tan(yyvsp[-1].d);      ;
     break;}
 case 315:
-#line 2216 "Gmsh.y"
+#line 2219 "Gmsh.y"
 { yyval.d = atan(yyvsp[-1].d);     ;
     break;}
 case 316:
-#line 2217 "Gmsh.y"
+#line 2220 "Gmsh.y"
 { yyval.d = atan2(yyvsp[-3].d,yyvsp[-1].d); ;
     break;}
 case 317:
-#line 2218 "Gmsh.y"
+#line 2221 "Gmsh.y"
 { yyval.d = sinh(yyvsp[-1].d);     ;
     break;}
 case 318:
-#line 2219 "Gmsh.y"
+#line 2222 "Gmsh.y"
 { yyval.d = cosh(yyvsp[-1].d);     ;
     break;}
 case 319:
-#line 2220 "Gmsh.y"
+#line 2223 "Gmsh.y"
 { yyval.d = tanh(yyvsp[-1].d);     ;
     break;}
 case 320:
-#line 2221 "Gmsh.y"
+#line 2224 "Gmsh.y"
 { yyval.d = fabs(yyvsp[-1].d);     ;
     break;}
 case 321:
-#line 2222 "Gmsh.y"
+#line 2225 "Gmsh.y"
 { yyval.d = floor(yyvsp[-1].d);    ;
     break;}
 case 322:
-#line 2223 "Gmsh.y"
+#line 2226 "Gmsh.y"
 { yyval.d = ceil(yyvsp[-1].d);     ;
     break;}
 case 323:
-#line 2224 "Gmsh.y"
+#line 2227 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 324:
-#line 2225 "Gmsh.y"
+#line 2228 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d,yyvsp[-1].d);  ;
     break;}
 case 325:
-#line 2226 "Gmsh.y"
+#line 2229 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-3].d*yyvsp[-3].d+yyvsp[-1].d*yyvsp[-1].d); ;
     break;}
 case 326:
-#line 2227 "Gmsh.y"
+#line 2230 "Gmsh.y"
 { yyval.d = yyvsp[-1].d*(double)rand()/(double)RAND_MAX; ;
     break;}
 case 327:
-#line 2236 "Gmsh.y"
+#line 2239 "Gmsh.y"
 { yyval.d = yyvsp[0].d; ;
     break;}
 case 328:
-#line 2237 "Gmsh.y"
+#line 2240 "Gmsh.y"
 { yyval.d = 3.141592653589793; ;
     break;}
 case 329:
-#line 2238 "Gmsh.y"
+#line 2241 "Gmsh.y"
 { yyval.d = ParUtil::Instance()->rank(); ;
     break;}
 case 330:
-#line 2239 "Gmsh.y"
+#line 2242 "Gmsh.y"
 { yyval.d = ParUtil::Instance()->size(); ;
     break;}
 case 331:
-#line 2244 "Gmsh.y"
+#line 2247 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[0].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5676,7 +5676,7 @@ case 331:
     ;
     break;}
 case 332:
-#line 2255 "Gmsh.y"
+#line 2258 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-3].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5694,7 +5694,7 @@ case 332:
     ;
     break;}
 case 333:
-#line 2272 "Gmsh.y"
+#line 2275 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-1].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5706,7 +5706,7 @@ case 333:
     ;
     break;}
 case 334:
-#line 2283 "Gmsh.y"
+#line 2286 "Gmsh.y"
 {
       TheSymbol.Name = yyvsp[-4].c ;
       if (!(pSymbol = (Symbol*)List_PQuery(Symbol_L, &TheSymbol, CompareSymbols))) {
@@ -5724,7 +5724,7 @@ case 334:
     ;
     break;}
 case 335:
-#line 2302 "Gmsh.y"
+#line 2305 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-2].c))){
 	vyyerror("Unknown numeric option class '%s'", yyvsp[-2].c);
@@ -5741,7 +5741,7 @@ case 335:
     ;
     break;}
 case 336:
-#line 2318 "Gmsh.y"
+#line 2321 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-5].c))){
 	vyyerror("Unknown numeric option class '%s'", yyvsp[-5].c);
@@ -5758,7 +5758,7 @@ case 336:
     ;
     break;}
 case 337:
-#line 2334 "Gmsh.y"
+#line 2337 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-3].c))){
 	vyyerror("Unknown numeric option class '%s'", yyvsp[-3].c);
@@ -5775,7 +5775,7 @@ case 337:
     ;
     break;}
 case 338:
-#line 2350 "Gmsh.y"
+#line 2353 "Gmsh.y"
 {
       if(!(pNumCat = Get_NumberOptionCategory(yyvsp[-6].c))){
 	vyyerror("Unknown numeric option class '%s'", yyvsp[-6].c);
@@ -5792,130 +5792,130 @@ case 338:
     ;
     break;}
 case 339:
-#line 2368 "Gmsh.y"
+#line 2371 "Gmsh.y"
 {
       memcpy(yyval.v, yyvsp[0].v, 5*sizeof(double)) ;
     ;
     break;}
 case 340:
-#line 2372 "Gmsh.y"
+#line 2375 "Gmsh.y"
 {
       for(i=0 ; i<5 ; i++) yyval.v[i] = -yyvsp[0].v[i] ;
     ;
     break;}
 case 341:
-#line 2376 "Gmsh.y"
+#line 2379 "Gmsh.y"
 { 
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[0].v[i];
     ;
     break;}
 case 342:
-#line 2380 "Gmsh.y"
+#line 2383 "Gmsh.y"
 { 
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[-2].v[i] - yyvsp[0].v[i] ;
     ;
     break;}
 case 343:
-#line 2384 "Gmsh.y"
+#line 2387 "Gmsh.y"
 {
       for(i=0 ; i<5 ; i++) yyval.v[i] = yyvsp[-2].v[i] + yyvsp[0].v[i] ;
     ;
     break;}
 case 344:
-#line 2390 "Gmsh.y"
+#line 2393 "Gmsh.y"
 { 
       yyval.v[0]=yyvsp[-9].d;  yyval.v[1]=yyvsp[-7].d;  yyval.v[2]=yyvsp[-5].d;  yyval.v[3]=yyvsp[-3].d; yyval.v[4]=yyvsp[-1].d;
     ;
     break;}
 case 345:
-#line 2394 "Gmsh.y"
+#line 2397 "Gmsh.y"
 { 
       yyval.v[0]=yyvsp[-7].d;  yyval.v[1]=yyvsp[-5].d;  yyval.v[2]=yyvsp[-3].d;  yyval.v[3]=yyvsp[-1].d; yyval.v[4]=1.0;
     ;
     break;}
 case 346:
-#line 2398 "Gmsh.y"
+#line 2401 "Gmsh.y"
 {
       yyval.v[0]=yyvsp[-5].d;  yyval.v[1]=yyvsp[-3].d;  yyval.v[2]=yyvsp[-1].d;  yyval.v[3]=0.0; yyval.v[4]=1.0;
     ;
     break;}
 case 347:
-#line 2402 "Gmsh.y"
+#line 2405 "Gmsh.y"
 {
       yyval.v[0]=yyvsp[-5].d;  yyval.v[1]=yyvsp[-3].d;  yyval.v[2]=yyvsp[-1].d;  yyval.v[3]=0.0; yyval.v[4]=1.0;
     ;
     break;}
 case 348:
-#line 2409 "Gmsh.y"
+#line 2412 "Gmsh.y"
 {
     ;
     break;}
 case 349:
-#line 2412 "Gmsh.y"
+#line 2415 "Gmsh.y"
 {
     ;
     break;}
 case 350:
-#line 2418 "Gmsh.y"
+#line 2421 "Gmsh.y"
 {
     ;
     break;}
 case 351:
-#line 2421 "Gmsh.y"
+#line 2424 "Gmsh.y"
 {
     ;
     break;}
 case 352:
-#line 2427 "Gmsh.y"
+#line 2430 "Gmsh.y"
 {
     ;
     break;}
 case 353:
-#line 2430 "Gmsh.y"
+#line 2433 "Gmsh.y"
 {
        yyval.l=yyvsp[-1].l;
     ;
     break;}
 case 354:
-#line 2434 "Gmsh.y"
+#line 2437 "Gmsh.y"
 {
        yyval.l=yyvsp[-1].l;
     ;
     break;}
 case 355:
-#line 2441 "Gmsh.y"
+#line 2444 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(List_T*)) ;
       List_Add(yyval.l, &(yyvsp[0].l)) ;
     ;
     break;}
 case 356:
-#line 2446 "Gmsh.y"
+#line 2449 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].l)) ;
     ;
     break;}
 case 357:
-#line 2454 "Gmsh.y"
+#line 2457 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       List_Add(yyval.l, &(yyvsp[0].d)) ;
     ;
     break;}
 case 358:
-#line 2459 "Gmsh.y"
+#line 2462 "Gmsh.y"
 {
       yyval.l = yyvsp[0].l ;
     ;
     break;}
 case 359:
-#line 2463 "Gmsh.y"
+#line 2466 "Gmsh.y"
 {
       yyval.l=yyvsp[-1].l;
     ;
     break;}
 case 360:
-#line 2467 "Gmsh.y"
+#line 2470 "Gmsh.y"
 {
       yyval.l=yyvsp[-1].l;
       for(i=0 ; i<List_Nbr(yyval.l) ; i++){
@@ -5925,7 +5925,7 @@ case 360:
     ;
     break;}
 case 361:
-#line 2478 "Gmsh.y"
+#line 2481 "Gmsh.y"
 { 
       yyval.l = List_Create(2,1,sizeof(double)) ; 
       for(d=yyvsp[-2].d ; (yyvsp[-2].d<yyvsp[0].d)?(d<=yyvsp[0].d):(d>=yyvsp[0].d) ; (yyvsp[-2].d<yyvsp[0].d)?(d+=1.):(d-=1.)) 
@@ -5933,7 +5933,7 @@ case 361:
     ;
     break;}
 case 362:
-#line 2484 "Gmsh.y"
+#line 2487 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ; 
       if(!yyvsp[0].d || (yyvsp[-4].d<yyvsp[-2].d && yyvsp[0].d<0) || (yyvsp[-4].d>yyvsp[-2].d && yyvsp[0].d>0)){
@@ -5946,7 +5946,7 @@ case 362:
    ;
     break;}
 case 363:
-#line 2495 "Gmsh.y"
+#line 2498 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-2].c ;
@@ -5962,7 +5962,7 @@ case 363:
     ;
     break;}
 case 364:
-#line 2509 "Gmsh.y"
+#line 2512 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-2].c ;
@@ -5980,7 +5980,7 @@ case 364:
     ;
     break;}
 case 365:
-#line 2525 "Gmsh.y"
+#line 2528 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-5].c ;
@@ -6002,7 +6002,7 @@ case 365:
     ;
     break;}
 case 366:
-#line 2545 "Gmsh.y"
+#line 2548 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       TheSymbol.Name = yyvsp[-5].c ;
@@ -6026,26 +6026,26 @@ case 366:
     ;
     break;}
 case 367:
-#line 2570 "Gmsh.y"
+#line 2573 "Gmsh.y"
 {
       yyval.l = List_Create(2,1,sizeof(double)) ;
       List_Add(yyval.l, &(yyvsp[0].d)) ;
     ;
     break;}
 case 368:
-#line 2575 "Gmsh.y"
+#line 2578 "Gmsh.y"
 {
       yyval.l = yyvsp[0].l ;
     ;
     break;}
 case 369:
-#line 2579 "Gmsh.y"
+#line 2582 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].d)) ;
     ;
     break;}
 case 370:
-#line 2583 "Gmsh.y"
+#line 2586 "Gmsh.y"
 {
       for(i=0 ; i<List_Nbr(yyvsp[0].l) ; i++){
 	List_Read(yyvsp[0].l, i, &d) ;
@@ -6055,26 +6055,26 @@ case 370:
     ;
     break;}
 case 371:
-#line 2595 "Gmsh.y"
+#line 2598 "Gmsh.y"
 {
       yyval.u = PACK_COLOR((int)yyvsp[-7].d, (int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d);
     ;
     break;}
 case 372:
-#line 2599 "Gmsh.y"
+#line 2602 "Gmsh.y"
 {
       yyval.u = PACK_COLOR((int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d, 255);
     ;
     break;}
 case 373:
-#line 2610 "Gmsh.y"
+#line 2613 "Gmsh.y"
 {
       yyval.u = Get_ColorForString(ColorString, -1, yyvsp[0].c, &flag);
       if(flag) vyyerror("Unknown color '%s'", yyvsp[0].c);
     ;
     break;}
 case 374:
-#line 2615 "Gmsh.y"
+#line 2618 "Gmsh.y"
 {
       if(!(pColCat = Get_ColorOptionCategory(yyvsp[-4].c))){
 	vyyerror("Unknown color option class '%s'", yyvsp[-4].c);
@@ -6092,13 +6092,13 @@ case 374:
     ;
     break;}
 case 375:
-#line 2634 "Gmsh.y"
+#line 2637 "Gmsh.y"
 {
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 376:
-#line 2638 "Gmsh.y"
+#line 2641 "Gmsh.y"
 {
       yyval.l = List_Create(256,10,sizeof(unsigned int)) ;
       ColorTable *ct = Get_ColorTable((int)yyvsp[-3].d);
@@ -6111,26 +6111,26 @@ case 376:
     ;
     break;}
 case 377:
-#line 2652 "Gmsh.y"
+#line 2655 "Gmsh.y"
 {
       yyval.l = List_Create(256,10,sizeof(unsigned int)) ;
       List_Add(yyval.l, &(yyvsp[0].u)) ;
     ;
     break;}
 case 378:
-#line 2657 "Gmsh.y"
+#line 2660 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].u)) ;
     ;
     break;}
 case 379:
-#line 2664 "Gmsh.y"
+#line 2667 "Gmsh.y"
 {
       yyval.c = yyvsp[0].c;
     ;
     break;}
 case 380:
-#line 2668 "Gmsh.y"
+#line 2671 "Gmsh.y"
 {
       yyval.c = (char *)Malloc((strlen(yyvsp[-3].c)+strlen(yyvsp[-1].c)+1)*sizeof(char)) ;
       strcpy(yyval.c, yyvsp[-3].c) ;  
@@ -6140,7 +6140,7 @@ case 380:
     ;
     break;}
 case 381:
-#line 2676 "Gmsh.y"
+#line 2679 "Gmsh.y"
 {
       yyval.c = (char *)Malloc((strlen(yyvsp[-1].c)+1)*sizeof(char)) ;
       for(i=strlen(yyvsp[-1].c)-1; i>=0; i--){
@@ -6155,13 +6155,13 @@ case 381:
     ;
     break;}
 case 382:
-#line 2689 "Gmsh.y"
+#line 2692 "Gmsh.y"
 {
       yyval.c = yyvsp[-1].c;
     ;
     break;}
 case 383:
-#line 2693 "Gmsh.y"
+#line 2696 "Gmsh.y"
 {
       i = PrintListOfDouble(yyvsp[-3].c,yyvsp[-1].l,tmpstring);
       if(i<0){
@@ -6181,7 +6181,7 @@ case 383:
     ;
     break;}
 case 384:
-#line 2711 "Gmsh.y"
+#line 2714 "Gmsh.y"
 { 
       if(!(pStrCat = Get_StringOptionCategory(yyvsp[-3].c)))
 	vyyerror("Unknown string option class '%s'", yyvsp[-3].c);
@@ -6197,7 +6197,7 @@ case 384:
     ;
     break;}
 case 385:
-#line 2725 "Gmsh.y"
+#line 2728 "Gmsh.y"
 { 
       if(!(pStrCat = Get_StringOptionCategory(yyvsp[-6].c)))
 	vyyerror("Unknown string option class '%s'", yyvsp[-6].c);
@@ -6434,7 +6434,7 @@ yyerrhandle:
     }
   return 1;
 }
-#line 2740 "Gmsh.y"
+#line 2743 "Gmsh.y"
 
 
 void InitSymbols(void){
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 43608392cadf335d63d522af47cdb2b31d4ad35b..0b86c3eb9438ffce1a2f5aaf2bacf460e770f13d 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,6 +1,6 @@
 %{ 
 
-// $Id: Gmsh.y,v 1.114 2001-11-14 15:31:00 geuzaine Exp $
+// $Id: Gmsh.y,v 1.115 2001-12-03 08:41:44 geuzaine Exp $
 
 #include <stdarg.h>
 #ifndef _NOPLUGIN
@@ -171,7 +171,7 @@ STLFormatItem :
     tSolid
     {
       Msg(PARSER_INFO,"STL file format");
-      STL_Surf = Create_Surface(1,MSH_SURF_STL,1);
+      STL_Surf = Create_Surface(1,MSH_SURF_STL);
       STL_Surf->STL = new STL_Data;
       return 1;
     }
@@ -1085,6 +1085,10 @@ Affectation :
 		   ct->size, COLORTABLE_NBMAX_COLOR, 0);
 	else
 	  for(i=0 ; i<ct->size ; i++) List_Read($5, i, &ct->table[i]);
+	if(ct->size == 1){
+	  ct->size = 2;
+	  ct->table[1] = ct->table[0];
+	}
       }
       List_Delete($5);
     }
@@ -1101,36 +1105,39 @@ Affectation :
 		   ct->size, COLORTABLE_NBMAX_COLOR, (int)$3);
 	else
 	  for(i=0 ; i<ct->size ; i++) List_Read($8, i, &ct->table[i]);
+	if(ct->size == 1){
+	  ct->size = 2;
+	  ct->table[1] = ct->table[0];
+	}
       }
       List_Delete($8);
     }
-    // P l u g i n s ...
+
+  /* -------- Plugins -------- */ 
+
   | tPlugin '(' tSTRING ')' '.' tSTRING tAFFECT FExpr tEND 
-  {
-#ifndef _NOPLUGIN
-    if(CTX.default_plugins){
-      try {
-	GMSH_PluginManager::Instance()->SetPluginOption($3,$6,$8); 
-      }
-      catch (...) {
-	Msg(WARNING,"Unknown option '%s' or plugin '%s'",$6,$3);
+    {
+      if(CTX.default_plugins){
+	try {
+	  GMSH_PluginManager::Instance()->SetPluginOption($3,$6,$8); 
+	}
+	catch (...) {
+	  Msg(WARNING,"Unknown option '%s' or plugin '%s'",$6,$3);
+	}
       }
     }
-#endif
-  }
+
   | tPlugin '(' tSTRING ')' '.' tSTRING tAFFECT StringExpr tEND 
-  {
-#ifndef _NOPLUGIN
-    if(CTX.default_plugins){
-      try {
-	GMSH_PluginManager::Instance()->SetPluginOption($3,$6,$8); 
-      }
-      catch (...) {
-	Msg(WARNING,"Unknown option '%s' or plugin '%s'",$6,$3);
+    {
+      if(CTX.default_plugins){
+	try {
+	  GMSH_PluginManager::Instance()->SetPluginOption($3,$6,$8); 
+	}
+	catch (...) {
+	  Msg(WARNING,"Unknown option '%s' or plugin '%s'",$6,$3);
+	}
       }
     }
-#endif
-  }
 ;
 
 
@@ -1667,7 +1674,6 @@ Loop :
 
     tFor '(' FExpr tDOTS FExpr ')'
     {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = $3 ;
       LoopControlVariablesTab[ImbricatedLoop][1] = $5 ;
       LoopControlVariablesTab[ImbricatedLoop][2] = 1.0 ;
@@ -1678,7 +1684,6 @@ Loop :
     }
   | tFor '(' FExpr tDOTS FExpr tDOTS FExpr ')'
     {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = $3 ;
       LoopControlVariablesTab[ImbricatedLoop][1] = $5 ;
       LoopControlVariablesTab[ImbricatedLoop][2] = $7 ;
@@ -1689,7 +1694,6 @@ Loop :
     }
   | tFor tSTRING tIn '{' FExpr tDOTS FExpr '}' 
     {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = $5 ;
       LoopControlVariablesTab[ImbricatedLoop][1] = $7 ;
       LoopControlVariablesTab[ImbricatedLoop][2] = 1.0 ;
@@ -1711,7 +1715,6 @@ Loop :
     }
   | tFor tSTRING tIn '{' FExpr tDOTS FExpr tDOTS FExpr '}' 
     {
-      // here, we seek remember the position in yyin
       LoopControlVariablesTab[ImbricatedLoop][0] = $5 ;
       LoopControlVariablesTab[ImbricatedLoop][1] = $7 ;
       LoopControlVariablesTab[ImbricatedLoop][2] = $9 ;
@@ -1928,7 +1931,7 @@ ExtrudeParameter :
 	extr.mesh.hLayer = (double*)Malloc(extr.mesh.NbLayer*sizeof(double));
 	for(int i=0;i<List_Nbr($3);i++){
 	  List_Read($3,i,&d);
-	  extr.mesh.NbElmLayer[i] = (int)d;
+	  extr.mesh.NbElmLayer[i] = (d>0)?(int)d:1;
 	  List_Read($5,i,&d);
 	  extr.mesh.ZonLayer[i] = (int)d;
 	  List_Read($7,i,&d);
@@ -1954,7 +1957,7 @@ ExtrudeParameter :
 	extr.mesh.hLayer = (double*)Malloc(extr.mesh.NbLayer*sizeof(double));
 	for(int i=0;i<List_Nbr($3);i++){
 	  List_Read($3,i,&d);
-	  extr.mesh.NbElmLayer[i] = (int)d;
+	  extr.mesh.NbElmLayer[i] = (d>0)?(int)d:1;
 	  extr.mesh.ZonLayer[i] = 0;
 	  List_Read($5,i,&d);
 	  extr.mesh.hLayer[i] = d;
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index 5af36e7c608b6e3d68e09ef4089561da09173e5b..89e3e1f0bcad41c788165e0c835015a995bb9d69 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -2,7 +2,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.130 2001-11-14 15:31:00 geuzaine Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.131 2001-12-03 08:41:45 geuzaine Exp $
  */
 
 #define FLEX_SCANNER
@@ -1000,7 +1000,7 @@ char *yytext;
 #define INITIAL 0
 #line 2 "Gmsh.l"
 
-// $Id: Gmsh.yy.cpp,v 1.130 2001-11-14 15:31:00 geuzaine Exp $
+// $Id: Gmsh.yy.cpp,v 1.131 2001-12-03 08:41:45 geuzaine Exp $
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/Parser/Makefile b/Parser/Makefile
index 405ec894305a04349220a56b4ebffc515fd0ab7b..690d8b1a7a0f1d6cb7d89c1f12580cc65bf59f08 100644
--- a/Parser/Makefile
+++ b/Parser/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.33 2001-10-30 09:52:39 geuzaine Exp $
+# $Id: Makefile,v 1.34 2001-12-03 08:41:45 geuzaine Exp $
 #
 # Makefile for "libParser.a"
 #
@@ -88,7 +88,7 @@ OpenFile.o: OpenFile.cpp ../Common/Gmsh.h ../Common/Message.h \
  ../Geo/Geo.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
  ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \
  ../Mesh/Matrix.h ../Common/Views.h ../Common/ColorTable.h \
- ../Geo/MinMax.h ../Geo/Visibility.h ../Common/GmshUI.h \
+ ../Geo/MinMax.h ../Common/GmshUI.h \
  ../Graphics/Draw.h ../Fltk/GUI.h ../Fltk/Opengl_Window.h \
  ../Fltk/Colorbar_Window.h
 FunctionManager.o: FunctionManager.cpp FunctionManager.h
diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp
index 0855457322c51eeab9f4b66c8cbd100c42b7bd27..564071f2079451839d59424c90e6b7f6bb24b4f0 100644
--- a/Parser/OpenFile.cpp
+++ b/Parser/OpenFile.cpp
@@ -1,4 +1,4 @@
-// $Id: OpenFile.cpp,v 1.22 2001-10-30 08:18:50 geuzaine Exp $
+// $Id: OpenFile.cpp,v 1.23 2001-12-03 08:41:45 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Numeric.h"
@@ -83,16 +83,8 @@ void ParseString(char *str){
 }
 
 void MergeProblem(char *name){
-
   ParseFile(name);  
   if (yyerrorstate) return;
-
-#ifndef _BLACKBOX
-  if (!EntitesVisibles) {
-    RemplirEntitesVisibles(1);
-    SHOW_ALL_ENTITIES = 1;
-  }
-#endif
 }
 
 void OpenProblem(char *name){
@@ -130,11 +122,9 @@ void OpenProblem(char *name){
 
   strncpy(THEM->name, CTX.base_filename,255);
 
-  if(!CTX.batch){
 #if _FLTK
-    WID->set_title(CTX.filename);
+  if(!CTX.batch) WID->set_title(CTX.filename);
 #endif
-  }
 
   int nb = List_Nbr(CTX.post.list);
 
@@ -151,6 +141,9 @@ void OpenProblem(char *name){
 
 #ifndef _BLACKBOX
   ZeroHighlight(&M); 
+#if _FLTK
+  if(!CTX.batch) WID->reset_visibility();
+#endif
 #endif
   
   if(List_Nbr(CTX.post.list) > nb)
@@ -165,12 +158,5 @@ void OpenProblem(char *name){
     Msg(INFO, "Got physical %d", 
 	(*(PhysicalGroup **)List_Pointer(THEM->PhysicalGroups,i))->Num);
   
-#ifndef _BLACKBOX
-  if (!EntitesVisibles) {
-    RemplirEntitesVisibles(1);
-    SHOW_ALL_ENTITIES = 1;
-  }
-#endif
-
 }
 
diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp
index 47f883a0c5887f09705a4b55653358b9995bd355..aa47d7e83cfd21842fdcbbb066f93e786c051126 100644
--- a/Plugin/Triangulate.cpp
+++ b/Plugin/Triangulate.cpp
@@ -1,4 +1,4 @@
-// $Id: Triangulate.cpp,v 1.3 2001-11-05 08:37:43 geuzaine Exp $
+// $Id: Triangulate.cpp,v 1.4 2001-12-03 08:41:45 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "Plugin.h"
@@ -88,7 +88,7 @@ void Triangulate(Post_View *vin, Post_View *vout){
     List_Add(points, &v);
   }
 
-  s = Create_Surface(1,MSH_SURF_PLAN,0);
+  s = Create_Surface(1,MSH_SURF_PLAN);
   MeanPlane(points, s);
 
   for(i=0;i<List_Nbr(points);i++){
diff --git a/doc/FAQ b/doc/FAQ
index 90510ce1c42fee43fc1ef8785dd8d1cfe12a4754..a2c60447bf71221d81480aca4196ab5e5389f33f 100644
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,4 +1,4 @@
-GMSH FREQUENTLY ASKED QUESTIONS ($Date: 2001-11-05 16:41:14 $)
+GMSH FREQUENTLY ASKED QUESTIONS ($Date: 2001-12-03 08:41:45 $)
 
 1. GENERAL
 ==========
@@ -89,9 +89,9 @@ problem:
 
 5.1) What should I do when the 2D unstructured algorithm fails?
 
-Try the new (isotropic) algorithm:
+Try the new isotropic algorithm:
 - on the command line: gmsh -algo tri
-- in the interface: Options->Mesh->Algorithm->Isotropic (Triangle)
+- in the interface: Options->Mesh->2D->New isotropic algorithm
 - in input files: Mesh.Algorithm = 3
 The old 2D algorithm will disappear once all its features are
 integrated in the new one, so please don't send bug reports on the
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 536c191a323155deabce7c21f9ba23a1ae659820..5c1e3deaa324f217d3b3fd847e5dd7d46e0bcb0c 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,4 +1,7 @@
-$Date: 2001-11-29 09:16:19 $
+$Date: 2001-12-03 08:41:45 $
+
+New in 1.32: New visibility browser; better floating point exception
+checks;
 
 New in 1.31: Corrected ellipses; PostScript output update (better
 shading, new combined PS/LaTeX output format); more interface polish;
diff --git a/tutorial/t1.geo b/tutorial/t1.geo
index 0578f4c9f00bf60ce1da85917052031ff2c6a02b..eb085acfd9b779e4b12d9369175632cc45003446 100644
--- a/tutorial/t1.geo
+++ b/tutorial/t1.geo
@@ -91,7 +91,8 @@ Physical Point(1) = {1,2} ;
 // for line or surface elements:
 
 Physical Line(10) = {1,2,4} ;
-Physical Surface(100) = {6} ;
+MySurface = 100;
+Physical Surface(MySurface) = {6} ;
 
 // All the line elements which will be created during the mesh of
 // lines 1, 2 and 4 will be saved in the output file with the region
diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html
index b5282703251977d90c24a0b15b2cbb6a1ba2a37c..6b611c297ad241a3c4dd0fb324c629ed6c5374bf 100644
--- a/tutorial/tutorial.html
+++ b/tutorial/tutorial.html
@@ -23,7 +23,7 @@
 <H1>README 1/10</H1>
 [<A HREF="#top">top</A>][prev][<A HREF="#file2">next</A>]
 <PRE>
-$Id: tutorial.html,v 1.29 2001-11-13 09:37:32 geuzaine Exp $
+$Id: tutorial.html,v 1.30 2001-12-03 08:41:45 geuzaine Exp $
 
 Here are the examples in the Gmsh tutorial. These examples are
 commented (both C and C++-style comments can be used in Gmsh input
@@ -227,7 +227,8 @@ Physical Point(1) = {1,2} ;
 </FONT></I><I><FONT COLOR="#B22222">// for line or surface elements:
 </FONT></I>
 Physical Line(10) = {1,2,4} ;
-Physical Surface(100) = {6} ;
+MySurface = 100;
+Physical Surface(MySurface) = {6} ;
 
 <I><FONT COLOR="#B22222">// All the line elements which will be created during the mesh of
 </FONT></I><I><FONT COLOR="#B22222">// lines 1, 2 and 4 will be saved in the output file with the region