From 0eec360c2112c5a03050b17e6c827f66f7719e52 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 29 Mar 2015 08:45:12 +0000 Subject: [PATCH] better treatment of hide compound sub-entities --- Common/Options.cpp | 9 ++++++++- Fltk/optionWindow.cpp | 7 ------- tutorial/t12.geo | 9 +++++---- tutorial/t13.geo | 10 ++++++++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Common/Options.cpp b/Common/Options.cpp index df4c02dfad..0e910764ea 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -4232,8 +4232,15 @@ double opt_geometry_auto_coherence(OPT_ARGS_NUM) double opt_geometry_hide_compounds(OPT_ARGS_NUM) { - if(action & GMSH_SET) + if(action & GMSH_SET){ + int old = CTX::instance()->geom.hideCompounds; CTX::instance()->geom.hideCompounds = (int)val; + if(old != (int)val){ + GModel::current()->setCompoundVisibility(); + CTX::instance()->mesh.changed = ENT_ALL; + if(FlGui::available()) FlGui::instance()->resetVisibility(); + } + } #if defined(HAVE_FLTK) if(FlGui::available() && (action & GMSH_GUI)){ FlGui::instance()->options->geo.butt[17]->value diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 256112a60a..6e9a2293d3 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -432,7 +432,6 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data) opt_geometry_occ_connect_faces(0, GMSH_SET, o->geo.butt[15]->value()); opt_geometry_light_two_side(0, GMSH_SET, o->geo.butt[14]->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()); @@ -462,12 +461,6 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data) opt_geometry_transform(0, GMSH_SET, o->geo.choice[3]->value()); opt_geometry_label_type(0, GMSH_SET, o->geo.choice[4]->value() + 1); - 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(); diff --git a/tutorial/t12.geo b/tutorial/t12.geo index 74d8a98c8f..e698d2b193 100644 --- a/tutorial/t12.geo +++ b/tutorial/t12.geo @@ -11,7 +11,7 @@ // parametrization can then be used for remeshing the compound as if // it were a single CAD entity. -lc = 0.2; +lc = 0.1; Point(1) = {0, 0, 0, lc}; Point(2) = {1, 0, 0, lc}; Point(3) = {1, 1, 0.5, lc}; Point(4) = {0, 1, 0.4, lc}; @@ -36,9 +36,10 @@ Compound Line(101) = {6, 7, 8}; // Treat surfaces 12, 14 and 16 as a single surface Compound Surface(200) = {12, 14, 16}; -// Hide the original surfaces so we only see the compound -// (cross-patch) mesh -//Hide {Surface{12, 14, 16}; } +// Add option to toggle visibility of sub-entities +DefineConstant[ hide = {Geometry.HideCompounds, Choices{0,1}, + Name "Hide compound sub-entities", GmshOption "Geometry.HideCompounds", + AutoCheck 0} ]; // More details about the reparametrization technique can be found in // the following papers: diff --git a/tutorial/t13.geo b/tutorial/t13.geo index 4e2ca14a4f..b76be2a8be 100644 --- a/tutorial/t13.geo +++ b/tutorial/t13.geo @@ -46,12 +46,18 @@ Field[1] = MathEval; Field[1].F = "2.5"; Background Field = 1; -DefineConstant[ funny = {0, Choices{0,1}, Name "Apply funny mesh size field?"} ]; +DefineConstant[ + funny = {0, Choices{0,1}, Name "Apply funny mesh size field?"}, + hide = {0, Choices{0,1}, Name "Hide compound sub-entities"} +]; + If(funny) Field[1].F = "2*Sin((x+y)/5) + 3"; EndIf +DefineConstant[ ]; + Mesh.RemeshAlgorithm = 1; // automatic Mesh.RemeshParametrization = 7; // conformal finite element -Geometry.HideCompounds = 0; // don't hide the compound entities +Geometry.HideCompounds = hide; // hide the compound sub-entities? Mesh.Algorithm = 6; // Frontal -- GitLab