diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 96b0a07729cf7467b424afc128425e58b821b695..2e00046a9bb511055558729aa6e985df175a3f1e 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -499,6 +499,7 @@ void OpenProject(std::string fileName)
     FlGui::instance()->updateViews();
     FlGui::instance()->updateFields();
     GModel::current()->setSelection(0);
+    GModel::current()->setCompoundVisibility();
   }
 #endif
 }
diff --git a/Common/Options.cpp b/Common/Options.cpp
index db3ab7fff4dfdc9c4a2545b0375f6ec8a3d6cd98..68862c5f2772fdbc993c9fe706b8a73cb450cce3 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -3648,15 +3648,13 @@ double opt_geometry_auto_coherence(OPT_ARGS_NUM)
 
 double opt_geometry_hide_compounds(OPT_ARGS_NUM)
 {
-  if(action & GMSH_SET){
-    if(CTX::instance()->geom.hideCompounds != val)
-      CTX::instance()->mesh.changed |= (ENT_LINE | ENT_SURFACE);
+  if(action & GMSH_SET)
     CTX::instance()->geom.hideCompounds = (int)val;
-  }
 #if defined(HAVE_FLTK)
-  //  if(FlGui::available() && (action & GMSH_GUI))
-  //  FlGui::instance()->options->geo.butt[10]->value
-  //    (CTX::instance()->geom.hideCompounds);
+  if(FlGui::available() && (action & GMSH_GUI)){
+    FlGui::instance()->options->geo.butt[17]->value
+      (CTX::instance()->geom.hideCompounds);
+  }
 #endif
   return CTX::instance()->geom.hideCompounds;
 }
diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp
index 656575673c5348e1c40f85bc0049358a3344cf91..dec0c7e3fe7d18cb5377cb180735f712d4c650c2 100644
--- a/Fltk/optionWindow.cpp
+++ b/Fltk/optionWindow.cpp
@@ -137,7 +137,7 @@ static void view_color_cb(Fl_Widget *w, void *data)
   uchar b = CTX::instance()->unpackBlue
     (fct(FlGui::instance()->options->view.index, GMSH_GET, 0));
   if(fl_color_chooser("Color Chooser", r, g, b))
-    fct(FlGui::instance()->options->view.index, 
+    fct(FlGui::instance()->options->view.index,
         GMSH_SET | GMSH_GUI, CTX::instance()->packColor(r, g, b, 255));
   drawContext::global()->draw();
 }
@@ -237,7 +237,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
       x = o->general.value[2]->value();
       y = o->general.value[3]->value();
       z = o->general.value[4]->value();
-      o->general.sphere->setValue(x, y, z);    
+      o->general.sphere->setValue(x, y, z);
     }
     else if(!strcmp(name, "light_sphere")){
       double x, y, z;
@@ -261,7 +261,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
   double sessionrc = opt_general_session_save(0, GMSH_GET, 0);
   opt_general_session_save(0, GMSH_SET, o->general.butt[8]->value());
   if(sessionrc && !opt_general_session_save(0, GMSH_GET, 0))
-    PrintOptions(0, GMSH_SESSIONRC, 1, 1, 
+    PrintOptions(0, GMSH_SESSIONRC, 1, 1,
                  (CTX::instance()->homeDir + CTX::instance()->sessionFileName).c_str());
   opt_general_options_save(0, GMSH_SET, o->general.butt[9]->value());
   opt_general_expert_mode(0, GMSH_SET, o->general.butt[10]->value());
@@ -272,7 +272,7 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
   opt_general_polygon_offset_always(0, GMSH_SET, o->general.butt[4]->value());
   opt_general_axes_mikado(0, GMSH_SET, o->general.butt[16]->value());
 
-  opt_general_shine_exponent(0, GMSH_SET, o->general.value[0]->value());  
+  opt_general_shine_exponent(0, GMSH_SET, o->general.value[0]->value());
   opt_general_shine(0, GMSH_SET, o->general.value[1]->value());
   opt_general_light00(0, GMSH_SET, o->general.value[2]->value());
   opt_general_light01(0, GMSH_SET, o->general.value[3]->value());
@@ -322,8 +322,8 @@ static void general_options_ok_cb(Fl_Widget *w, void *data)
   opt_general_eye_sep_ratio(0, GMSH_SET, o->general.value[29]->value());
   opt_general_focallength_ratio(0, GMSH_SET, o->general.value[30]->value());
   opt_general_camera_aperture(0, GMSH_SET, o->general.value[31]->value());
-  opt_general_camera_mode(0, GMSH_SET, o->general.butt[18]->value()); 
-  if(opt_general_stereo_mode(0, GMSH_GET, 0) != o->general.butt[17]->value()) {  
+  opt_general_camera_mode(0, GMSH_SET, o->general.butt[18]->value());
+  if(opt_general_stereo_mode(0, GMSH_GET, 0) != o->general.butt[17]->value()) {
     opt_general_stereo_mode(0, GMSH_SET, o->general.butt[17]->value());
     // beginning of test to re-allocate gl for stereo: inspired from
     // "split" method
@@ -390,6 +390,8 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data)
   opt_geometry_occ_sew_faces(0, GMSH_SET, o->geo.butt[13]->value());
   opt_geometry_light_two_side(0, GMSH_SET, o->geo.butt[14]->value());
   opt_geometry_occ_connect_faces(0, GMSH_SET, o->geo.butt[15]->value());
+  int old_hide_compound = (int)opt_geometry_hide_compounds(0, GMSH_GET, 0);
+  opt_geometry_hide_compounds(0, GMSH_SET, o->geo.butt[17]->value());
 
   opt_geometry_normals(0, GMSH_SET, o->geo.value[0]->value());
   opt_geometry_tangents(0, GMSH_SET, o->geo.value[1]->value());
@@ -416,7 +418,13 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data)
   opt_geometry_line_type(0, GMSH_SET, o->geo.choice[1]->value());
   opt_geometry_surface_type(0, GMSH_SET, o->geo.choice[2]->value());
   opt_geometry_transform(0, GMSH_SET, o->geo.choice[3]->value());
-  
+
+  if(old_hide_compound != (int)opt_geometry_hide_compounds(0, GMSH_GET, 0)){
+    GModel::current()->setCompoundVisibility();
+    FlGui::instance()->resetVisibility();
+    CTX::instance()->mesh.changed = ENT_ALL;
+  }
+
   if(CTX::instance()->fastRedraw)
     CTX::instance()->post.draw = CTX::instance()->mesh.draw = 0;
   drawContext::global()->draw();
@@ -482,16 +490,16 @@ static void mesh_options_ok_cb(Fl_Widget *w, void *data)
 
   opt_mesh_point_type(0, GMSH_SET, o->mesh.choice[0]->value());
   opt_mesh_algo2d(0, GMSH_SET,
-                  (o->mesh.choice[2]->value() == 1) ? ALGO_2D_MESHADAPT : 
+                  (o->mesh.choice[2]->value() == 1) ? ALGO_2D_MESHADAPT :
                   (o->mesh.choice[2]->value() == 2) ? ALGO_2D_DELAUNAY :
-                  (o->mesh.choice[2]->value() == 3) ? ALGO_2D_FRONTAL : 
-                  (o->mesh.choice[2]->value() == 4) ? ALGO_2D_FRONTAL_QUAD : 
+                  (o->mesh.choice[2]->value() == 3) ? ALGO_2D_FRONTAL :
+                  (o->mesh.choice[2]->value() == 4) ? ALGO_2D_FRONTAL_QUAD :
                   ALGO_2D_AUTO);
   opt_mesh_algo3d(0, GMSH_SET,
-                  (o->mesh.choice[3]->value() == 0) ? ALGO_3D_DELAUNAY : 
-                  (o->mesh.choice[3]->value() == 2) ? ALGO_3D_FRONTAL_DEL : 
-                  (o->mesh.choice[3]->value() == 3) ? ALGO_3D_FRONTAL_HEX : 
-                  (o->mesh.choice[3]->value() == 4) ? ALGO_3D_MMG3D : 
+                  (o->mesh.choice[3]->value() == 0) ? ALGO_3D_DELAUNAY :
+                  (o->mesh.choice[3]->value() == 2) ? ALGO_3D_FRONTAL_DEL :
+                  (o->mesh.choice[3]->value() == 3) ? ALGO_3D_FRONTAL_HEX :
+                  (o->mesh.choice[3]->value() == 4) ? ALGO_3D_MMG3D :
                   ALGO_3D_FRONTAL);
   opt_mesh_algo_recombine(0, GMSH_SET, o->mesh.choice[1]->value());
   opt_mesh_recombine_all(0, GMSH_SET, o->mesh.butt[21]->value());
@@ -619,7 +627,7 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       }
     }
   }
-  
+
   int force = 0, links = (int)opt_post_link(0, GMSH_GET, 0);
 
   // get the old values for the current view
@@ -756,11 +764,11 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       val = o->view.choice[0]->value() + 1;
       if(force || (val != intervals_type))
         opt_view_intervals_type(i, GMSH_SET, val);
-      
+
       val = o->view.choice[5]->value();
       if(force || (val != point_type))
         opt_view_point_type(i, GMSH_SET, val);
-      
+
       val = o->view.choice[6]->value();
       if(force || (val != line_type))
         opt_view_line_type(i, GMSH_SET, val);
@@ -776,7 +784,7 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       val = o->view.choice[4]->value() + 1;
       if(force || (val != tensor_type))
         opt_view_tensor_type(i, GMSH_SET, val);
-      
+
       val = o->view.choice[7]->value() + 1;
       if(force || (val != range_type))
         opt_view_range_type(i, GMSH_SET, val);
@@ -805,9 +813,9 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       if(force || (val != type))
         opt_view_type(i, GMSH_SET, val);
 
-      val = 
+      val =
         (o->view.choice[14]->value() == 1) ? 1 :
-        (o->view.choice[14]->value() == 2) ? 3 : 
+        (o->view.choice[14]->value() == 2) ? 3 :
         (o->view.choice[14]->value() == 3) ? 9 : 0;
       if(force || (val != force_num_components))
         opt_view_force_num_components(i, GMSH_SET, val);
@@ -927,7 +935,7 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
         opt_view_use_stipple(i, GMSH_SET, val);
 
       // view_values
-      
+
       val = o->view.value[0]->value();
       if(force || (val != normals))
         opt_view_normals(i, GMSH_SET, val);
@@ -1063,7 +1071,7 @@ static void view_options_ok_cb(Fl_Widget *w, void *data)
       val = o->view.value[22]->value();
       if(force || (val != size0))
         opt_view_size0(i, GMSH_SET, val);
-      
+
       val = o->view.value[23]->value();
       if(force || (val != size1))
         opt_view_size1(i, GMSH_SET, val);
@@ -1317,7 +1325,7 @@ optionWindow::optionWindow(int deltaFontSize)
       general.butt[6]->callback(general_options_ok_cb);
 
       general.butt[2] = new Fl_Check_Button
-        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH, 
+        (L + 2 * WB, 2 * WB + 4 * BH, BW, BH,
          "Draw simplified model during user interaction");
       general.butt[2]->tooltip("(Alt+f)");
       general.butt[2]->type(FL_TOGGLE_BUTTON);
@@ -1339,7 +1347,7 @@ optionWindow::optionWindow(int deltaFontSize)
       general.butt[12]->callback(general_options_ok_cb);
 
       general.butt[5] = new Fl_Check_Button
-        (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, 
+        (L + 2 * WB, 2 * WB + 8 * BH, BW, BH,
          "Use trackball rotation instead of Euler angles");
       general.butt[5]->type(FL_TOGGLE_BUTTON);
       general.butt[5]->callback(general_options_ok_cb);
@@ -1467,7 +1475,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
       general.input[5]->align(FL_ALIGN_RIGHT);
       general.input[5]->callback(general_options_ok_cb);
-      
+
       general.input[6] = new Fl_Input
         (L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
       general.input[6]->callback(general_options_ok_cb);
@@ -1484,7 +1492,7 @@ optionWindow::optionWindow(int deltaFontSize)
          "Set position and size of axes automatically");
       general.butt[0]->type(FL_TOGGLE_BUTTON);
       general.butt[0]->callback(general_options_ok_cb, (void*)"general_axes_auto");
-      
+
       general.value[20] = new Fl_Value_Input
         (L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
       general.value[20]->callback(general_options_ok_cb);
@@ -1598,7 +1606,7 @@ optionWindow::optionWindow(int deltaFontSize)
       general.value[7]->step(0.1);
       general.value[7]->align(FL_ALIGN_RIGHT);
       general.value[7]->callback(general_options_ok_cb);
-      
+
       static Fl_Menu_Item menu_genvectype[] = {
         {"Line", 0, 0, 0},
         {"Arrow", 0, 0, 0},
@@ -1767,7 +1775,7 @@ optionWindow::optionWindow(int deltaFontSize)
       general.value[30]->step(.1);
       general.value[30]->align(FL_ALIGN_RIGHT);
       general.value[30]->callback(general_options_ok_cb);
-  
+
       general.value[31] = new Fl_Value_Input
         (L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Camera Aperture (degrees)");
       general.value[31]->minimum(10.);
@@ -1775,7 +1783,7 @@ optionWindow::optionWindow(int deltaFontSize)
       general.value[31]->step(1);
       general.value[31]->align(FL_ALIGN_RIGHT);
       general.value[31]->callback(general_options_ok_cb);
-   
+
       o->end();
 
     }
@@ -1857,7 +1865,7 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.butt[0]->tooltip("(Alt+p)");
       geo.butt[0]->type(FL_TOGGLE_BUTTON);
       geo.butt[0]->callback(geometry_options_ok_cb);
-      
+
       geo.butt[1] = new Fl_Check_Button
         (L + 2 * WB, 2 * WB + 2 * BH, BW / 2 - WB, BH, "Lines");
       geo.butt[1]->tooltip("(Alt+l)");
@@ -1914,13 +1922,18 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.value[1]->when(FL_WHEN_RELEASE);
       geo.value[1]->callback(geometry_options_ok_cb);
 
+      geo.butt[17] = new Fl_Check_Button
+        (L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Hide entities making up coumpounds");
+      geo.butt[17]->type(FL_TOGGLE_BUTTON);
+      geo.butt[17]->callback(geometry_options_ok_cb);
+
       o->end();
     }
     {
       Fl_Group *o = new Fl_Group
         (L + WB, WB + BH, width - 2 * WB, height - 2 * WB - BH, "Transfo");
       o->hide();
-      
+
       static Fl_Menu_Item menu_transform[] = {
         {"None", 0, 0, 0},
         {"Scaling", 0, 0, 0},
@@ -2001,7 +2014,7 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.choice[1] = new Fl_Choice
         (L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display");
       geo.choice[1]->menu(menu_line_display);
-      geo.choice[1]->align(FL_ALIGN_RIGHT);     
+      geo.choice[1]->align(FL_ALIGN_RIGHT);
       geo.choice[1]->callback(geometry_options_ok_cb);
 
       geo.value[4] = new Fl_Value_Input
@@ -2031,7 +2044,7 @@ optionWindow::optionWindow(int deltaFontSize)
       geo.choice[2] = new Fl_Choice
         (L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Surface display");
       geo.choice[2]->menu(menu_surface_display);
-      geo.choice[2]->align(FL_ALIGN_RIGHT);     
+      geo.choice[2]->align(FL_ALIGN_RIGHT);
       geo.choice[2]->callback(geometry_options_ok_cb);
       geo.choice[2]->tooltip("(Alt+d)");
 
@@ -2245,7 +2258,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB, 2 * WB + 6 * BH, BW, BH, "Optimize high order 2D planar meshes (experimental)");
       mesh.butt[3]->type(FL_TOGGLE_BUTTON);
       mesh.butt[3]->callback(mesh_options_ok_cb);
-      
+
       mesh.butt[25] = new Fl_Check_Button
         (L + 2 * WB, 2 * WB + 7 * BH, BW, BH, "Try to remove 4 triangles nodes (experimental)");
       mesh.butt[25]->type(FL_TOGGLE_BUTTON);
@@ -2554,11 +2567,11 @@ optionWindow::optionWindow(int deltaFontSize)
         solver.value[0]->callback(solver_options_ok_cb);
 
         solver.butt[0] = new Fl_Check_Button
-          (L + 2 * WB, 2 * WB + 3 * BH, BW, BH, 
+          (L + 2 * WB, 2 * WB + 3 * BH, BW, BH,
            "Always listen to incoming connection requests");
         solver.butt[0]->type(FL_TOGGLE_BUTTON);
         solver.butt[0]->callback(solver_options_ok_cb);
-        
+
         o->end();
       }
     }
@@ -2691,7 +2704,7 @@ optionWindow::optionWindow(int deltaFontSize)
          "Format");
       view.input[1]->align(FL_ALIGN_RIGHT);
       view.input[1]->callback(view_options_ok_cb);
-      
+
       static Fl_Menu_Item menu_iso[] = {
         {"Iso-values", 0, 0, 0},
         {"Continuous map", 0, 0, 0},
@@ -2841,7 +2854,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB + 2*IW/3, 2 * WB + 3 * BH, IW/3, BH, "Axes format");
       view.input[9]->align(FL_ALIGN_RIGHT);
       view.input[9]->callback(view_options_ok_cb);
-      
+
       view.input[10] = new Fl_Input
         (L + 2 * WB, 2 * WB + 4 * BH, IW/3, BH);
       view.input[10]->callback(view_options_ok_cb);
@@ -2852,12 +2865,12 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB + 2*IW/3, 2 * WB + 4 * BH, IW/3, BH, "Axes labels");
       view.input[12]->align(FL_ALIGN_RIGHT);
       view.input[12]->callback(view_options_ok_cb);
-      
+
       view.butt[25] = new Fl_Check_Button
         (L + 2 * WB, 2 * WB + 5 * BH, BW, BH, "Position 3D axes automatically");
       view.butt[25]->type(FL_TOGGLE_BUTTON);
       view.butt[25]->callback(view_options_ok_cb, (void*)"view_axes_auto_3d");
-      
+
       view.value[13] = new Fl_Value_Input
         (L + 2 * WB, 2 * WB + 6 * BH, IW / 3, BH);
       view.value[13]->callback(view_options_ok_cb);
@@ -2884,7 +2897,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + 2 * WB, 2 * WB + 8 * BH, BW, BH, "Position 2D axes/value scale automatically");
       view.butt[7]->type(FL_TOGGLE_BUTTON);
       view.butt[7]->callback(view_options_ok_cb, (void*)"view_axes_auto_2d");
-      
+
       view.value[20] = new Fl_Value_Input
         (L + 2 * WB, 2 * WB + 9 * BH, IW / 2, BH);
       view.value[20]->minimum(-2000);
@@ -2982,7 +2995,7 @@ optionWindow::optionWindow(int deltaFontSize)
       view.value[6]->align(FL_ALIGN_RIGHT);
       view.value[6]->when(FL_WHEN_RELEASE);
       view.value[6]->callback(view_options_ok_cb);
-      
+
       static Fl_Menu_Item menu_boundary[] = {
         {"None", 0, 0, 0},
         {"Dimension - 1", 0, 0, 0},
@@ -3267,7 +3280,7 @@ optionWindow::optionWindow(int deltaFontSize)
         (L + width - (int)(1.15*BB) - 2 * WB, 2 * WB + 10 * BH, (int)(1.15*BB), BH);
       view.choice[15]->menu(menu_glyph_center);
       view.choice[15]->callback(view_options_ok_cb);
-      
+
       static Fl_Menu_Item menu_tensor[] = {
         {"Von-Mises", 0, 0, 0},
         {"Maximum eigen value", 0, 0, 0},
@@ -3375,7 +3388,7 @@ void optionWindow::showGroup(int num, bool showWindow)
   case 3: win->label("Options - Mesh"); mesh.group->show(); break;
   case 4: win->label("Options - Solver"); solver.group->show(); break;
   case 5: win->label("Options - Post-pro"); post.group->show(); break;
-  default: 
+  default:
     {
       updateViewGroup(num - 6);
       static char str[128];
@@ -3625,7 +3638,7 @@ void optionWindow::updateViewGroup(int index)
   opt_view_color_text3d(index, GMSH_GUI, 0);
   opt_view_color_axes(index, GMSH_GUI, 0);
 
-  view.colorbar->update(data->getName().c_str(), data->getMin(), 
+  view.colorbar->update(data->getName().c_str(), data->getMin(),
                         data->getMax(), &opt->colorTable, &v->getChanged());
 }
 
diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index df1b99bf8f1893b3eb1889a6f5362bd422093149..ede1544fa263236713a046e9b6c8f44361d36988 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -10,7 +10,6 @@
 #include "GmshMessage.h"
 #include "GModel.h"
 #include "GEdge.h"
-#include "GEdgeCompound.h"
 #include "GFace.h"
 #include "MLine.h"
 #include "GaussLegendre1D.h"
@@ -163,21 +162,10 @@ SOrientedBoundingBox GEdge::getOBB()
 
 void GEdge::setVisibility(char val, bool recursive)
 {
-  if (getCompound() && CTX::instance()->geom.hideCompounds) {
-    // use visibility info of compound edge if this edge belongs to it
-    GEntity::setVisibility(0);
-    if(v0) v0->setVisibility(0);
-    if(v1) v1->setVisibility(0);
-    bool val2 = getCompound()->getVisibility();
-    if(getCompound()->v0) getCompound()->v0->setVisibility(val2);
-    if(getCompound()->v1) getCompound()->v1->setVisibility(val2);
-  }
-  else {
-    GEntity::setVisibility(val);
-    if(recursive){
-      if(v0) v0->setVisibility(val);
-      if(v1) v1->setVisibility(val);
-    }
+  GEntity::setVisibility(val);
+  if(recursive){
+    if(v0) v0->setVisibility(val);
+    if(v1) v1->setVisibility(val);
   }
 }
 
diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index 5046574b1176a815f59301f8ec12c7d7c1fc21ba..455a53e182fdb24a5f24d0b955317ce7cfb68d3a 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -9,8 +9,6 @@
 #include "GModel.h"
 #include "GFace.h"
 #include "GEdge.h"
-#include "GFaceCompound.h"
-#include "GEdgeCompound.h"
 #include "MTriangle.h"
 #include "MQuadrangle.h"
 #include "MElementCut.h"
@@ -263,26 +261,10 @@ std::list<GVertex*> GFace::vertices() const
 
 void GFace::setVisibility(char val, bool recursive)
 {
-  if (getCompound() && CTX::instance()->geom.hideCompounds) {
-    GEntity::setVisibility(0);
+  GEntity::setVisibility(val);
+  if(recursive){
     for (std::list<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it)
-      (*it)->setVisibility(0, true);
-    std::list<GEdge*> edgesComp = getCompound()->edges();
-    bool val2 = getCompound()->getVisibility();
-    //show edges of the compound surface
-    for (std::list<GEdge*>::iterator it = edgesComp.begin(); it != edgesComp.end(); ++it) {
-      if((*it)->getCompound())
-        (*it)->getCompound()->setVisibility(val2, true);
-      else
-        (*it)->setVisibility(val2, true);
-    }
-  }
-  else {
-    GEntity::setVisibility(val);
-    if(recursive){
-      for (std::list<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it)
-        (*it)->setVisibility(val, recursive);
-    }
+      (*it)->setVisibility(val, recursive);
   }
 }
 
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index 167c43d4a87f940b39532647359fcbb7bf465c5d..5e0bc72e9fd3f5588517cad186aceb99d42d3496 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -1838,7 +1838,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int
       (*it)->setBoundEdges(this, bcEdges);
     }
   }
-  
+
   Msg::Debug("Done creating topology from faces");
 
   Msg::Debug("Creating topology for %d edges...", discEdges.size());
@@ -2786,3 +2786,48 @@ void GModel::computeHomology()
   Msg::Error("Homology computation requires KBIPACK");
 #endif
 }
+
+void GModel::setCompoundVisibility()
+{
+  // force visibility status of compound entities
+
+  for(eiter eit = firstEdge(); eit != lastEdge(); eit++){
+    GEdge *ge = *eit;
+    if (ge->getCompound()){
+      if(CTX::instance()->geom.hideCompounds) {
+        // use visibility info of compound edge if this edge belongs to it
+        ge->setVisibility(0, true);
+        bool val2 = ge->getCompound()->getVisibility();
+        if(ge->getCompound()->getBeginVertex())
+          ge->getCompound()->getBeginVertex()->setVisibility(val2);
+        if(ge->getCompound()->getEndVertex())
+          ge->getCompound()->getEndVertex()->setVisibility(val2);
+      }
+      else {
+        ge->setVisibility(1, true);
+      }
+    }
+  }
+
+  for(fiter fit = firstFace(); fit != lastFace(); fit++){
+    GFace *gf = *fit;
+    if (gf->getCompound()){
+      if(CTX::instance()->geom.hideCompounds) {
+        gf->setVisibility(0, true);
+        std::list<GEdge*> edgesComp = gf->getCompound()->edges();
+        bool val2 = gf->getCompound()->getVisibility();
+        // show edges of the compound surface
+        for (std::list<GEdge*>::iterator it = edgesComp.begin(); it != edgesComp.end(); ++it) {
+          if((*it)->getCompound())
+            (*it)->getCompound()->setVisibility(val2, true);
+          else
+            (*it)->setVisibility(val2, true);
+        }
+      }
+      else {
+        gf->setVisibility(1, true);
+      }
+    }
+  }
+
+}
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 455c05e5f1867f8d8378064cb1aa4570b799f7e9..820a5b9e90c8c0318d0eb84c5a7f29744b6ac8c2 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -183,6 +183,9 @@ class GModel
   char getVisibility(){ return _visible; }
   void setVisibility(char val){ _visible = val; }
 
+  // set the visibility of compound entities
+  void setCompoundVisibility();
+
   // get the number of entities in this model
   int getNumRegions() const { return regions.size(); }
   int getNumFaces() const { return faces.size(); }
diff --git a/Geo/GModelIO_Geo.cpp b/Geo/GModelIO_Geo.cpp
index 5a8aee90237d2082653df0f026becfe262cc5543..0c05cf7229551caac400c56ecd7536ee4cc12496 100644
--- a/Geo/GModelIO_Geo.cpp
+++ b/Geo/GModelIO_Geo.cpp
@@ -145,9 +145,6 @@ int GModel::importGEOInternals()
           }
           e = new GEdgeCompound(this, c->Num, comp);
           add(e);
-          if(CTX::instance()->geom.hideCompounds)
-            for (std::vector<GEdge*>::iterator it = comp.begin(); it != comp.end(); ++it)
-              (*it)->setVisibility(0, true);
         }
         else if(!e && c->beg && c->end){
           e = new gmshEdge(this, c,
@@ -202,9 +199,6 @@ int GModel::importGEOInternals()
         f->meshAttributes.Method = s->Method;
         f->meshAttributes.extrude = s->Extrude;
         add(f);
-        if (CTX::instance()->geom.hideCompounds)
-          for (std::list<GFace*>::iterator it = comp.begin(); it != comp.end(); ++it)
-            (*it)->setVisibility(0, true);
         if(s->EmbeddedCurves){
           for(int i = 0; i < List_Nbr(s->EmbeddedCurves); i++){
             Curve *c;