From 281355462fce10b2be880a338e73d8753e3f1efe Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 23 Jul 2004 01:28:57 +0000 Subject: [PATCH] added an option to cut only volume elements --- Common/Context.h | 2 +- Common/DefaultOptions.h | 2 ++ Common/Options.cpp | 15 ++++++++++++++- Common/Options.h | 1 + Fltk/Callbacks.cpp | 3 ++- Fltk/GUI.cpp | 24 +++++++++++++++--------- Graphics/Mesh.cpp | 10 +++++----- 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index c221ccba97..ec302470af 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -174,7 +174,7 @@ public : int histogram, initial_only; double normals, tangents, explode; int color_carousel ; - int use_cut_plane, cut_plane_as_surface; + int use_cut_plane, cut_plane_as_surface, cut_plane_only_volume; double cut_planea,cut_planeb,cut_planec,cut_planed; double evalCutPlane (double x, double y, double z){ double val = cut_planea * x + cut_planeb * y + cut_planec * z + cut_planed; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index d4a2fa9b85..54bda6242e 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -723,6 +723,8 @@ StringXNumber MeshOptions_Number[] = { "Enable mesh cut plane" }, { F, "CutPlaneAsSurface" , opt_mesh_cut_plane_as_surface , 0 , "Draw the intersection volume layer as a surface" }, + { F, "CutPlaneOnlyVolume" , opt_mesh_cut_plane_only_volume , 0 , + "Cut only the volume elements" }, { F, "CutPlaneA" , opt_mesh_cut_planea , 1. , "First cut plane equation coefficient (`A' in `AX+BY+CZ+D=0')" }, { F, "CutPlaneB" , opt_mesh_cut_planeb , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index ae7a7100e3..7770ed07d3 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.173 2004-07-22 05:47:45 geuzaine Exp $ +// $Id: Options.cpp,v 1.174 2004-07-23 01:28:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -3780,6 +3780,19 @@ double opt_mesh_cut_plane_as_surface(OPT_ARGS_NUM) return CTX.mesh.cut_plane_as_surface; } +double opt_mesh_cut_plane_only_volume(OPT_ARGS_NUM) +{ + if(action & GMSH_SET){ + if(CTX.mesh.cut_plane_only_volume != (int)val) CTX.mesh.changed = 1; + CTX.mesh.cut_plane_only_volume = (int)val; + } +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->mesh_butt[23]->value(CTX.mesh.cut_plane_only_volume); +#endif + return CTX.mesh.cut_plane_only_volume; +} + double opt_mesh_cut_planea(OPT_ARGS_NUM) { if(action & GMSH_SET){ diff --git a/Common/Options.h b/Common/Options.h index 473bff6960..5de90160e3 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -383,6 +383,7 @@ double opt_mesh_dual(OPT_ARGS_NUM); double opt_mesh_interactive(OPT_ARGS_NUM); double opt_mesh_use_cut_plane(OPT_ARGS_NUM); double opt_mesh_cut_plane_as_surface(OPT_ARGS_NUM); +double opt_mesh_cut_plane_only_volume(OPT_ARGS_NUM); double opt_mesh_cut_planea(OPT_ARGS_NUM); double opt_mesh_cut_planeb(OPT_ARGS_NUM); double opt_mesh_cut_planec(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 96425c6a2a..cbaeb50f00 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.257 2004-07-22 05:47:45 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.258 2004-07-23 01:28:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -978,6 +978,7 @@ void mesh_options_ok_cb(CALLBACK_ARGS) opt_mesh_volumes_num(0, GMSH_SET, WID->mesh_butt[15]->value()); opt_mesh_use_cut_plane(0, GMSH_SET, WID->mesh_butt[16]->value()); opt_mesh_cut_plane_as_surface(0, GMSH_SET, WID->mesh_butt[22]->value()); + opt_mesh_cut_plane_only_volume(0, GMSH_SET, WID->mesh_butt[23]->value()); opt_mesh_light(0, GMSH_SET, WID->mesh_butt[17]->value()); opt_mesh_light_two_side(0, GMSH_SET, WID->mesh_butt[18]->value()); opt_mesh_smooth_normals(0, GMSH_SET, WID->mesh_butt[19]->value()); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 71a01f13c3..5ec5098e7d 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.326 2004-07-22 05:47:46 geuzaine Exp $ +// $Id: GUI.cpp,v 1.327 2004-07-23 01:28:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1884,18 +1884,24 @@ void GUI::create_option_window() mesh_butt[16]->type(FL_TOGGLE_BUTTON); mesh_butt[16]->down_box(TOGGLE_BOX); mesh_butt[16]->selection_color(TOGGLE_COLOR); - mesh_butt[22] = new Fl_Check_Button(2 * WB, 2 * WB + 2 * BH, BW, BH, "Draw intersecting volume layer as surface"); - mesh_butt[22]->type(FL_TOGGLE_BUTTON); - mesh_butt[22]->down_box(TOGGLE_BOX); - mesh_butt[22]->selection_color(TOGGLE_COLOR); - mesh_value[14] = new Fl_Value_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "A"); - mesh_value[15] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "B"); - mesh_value[16] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "C"); - mesh_value[17] = new Fl_Value_Input(2 * WB, 2 * WB + 6 * BH, IW, BH, "D"); + mesh_value[14] = new Fl_Value_Input(2 * WB, 2 * WB + 2 * BH, IW, BH, "A"); + mesh_value[15] = new Fl_Value_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "B"); + mesh_value[16] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "C"); + mesh_value[17] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "D"); for(i = 14; i <= 17; i++) { mesh_value[i]->align(FL_ALIGN_RIGHT); } + + mesh_butt[22] = new Fl_Check_Button(2 * WB, 2 * WB + 6 * BH, BW, BH, "Draw intersecting volume layer as surface"); + mesh_butt[22]->type(FL_TOGGLE_BUTTON); + mesh_butt[22]->down_box(TOGGLE_BOX); + mesh_butt[22]->selection_color(TOGGLE_COLOR); + mesh_butt[23] = new Fl_Check_Button(2 * WB, 2 * WB + 7 * BH, BW, BH, "Cut only volume elements"); + mesh_butt[23]->type(FL_TOGGLE_BUTTON); + mesh_butt[23]->down_box(TOGGLE_BOX); + mesh_butt[23]->selection_color(TOGGLE_COLOR); + o->end(); } { diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index c8800c5d1f..50fa6e898d 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.105 2004-07-22 19:32:02 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.106 2004-07-23 01:28:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -354,7 +354,7 @@ void Draw_Mesh_Point(void *a, void *b) if(!(v->Visible & VIS_MESH)) return; - if(intersectCutPlane(1, &v) < 0) + if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(1, &v) < 0) return; if(v->Degree == 2) @@ -399,7 +399,7 @@ void Draw_Mesh_Line(void *a, void *b) if(part && !(*part)->Visible) return; - if(intersectCutPlane(2, s->V) < 0) + if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(2, s->V) < 0) return; Xc = 0.5 * (s->V[0]->Pos.X + s->V[1]->Pos.X); @@ -663,7 +663,7 @@ void Draw_Mesh_Triangle(void *a, void *b) if(part && !(*part)->Visible) return; - if(intersectCutPlane(3, s->V) < 0) + if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(3, s->V) < 0) return; unsigned int col; @@ -809,7 +809,7 @@ void Draw_Mesh_Quadrangle(void *a, void *b) if(part && !(*part)->Visible) return; - if(intersectCutPlane(4, q->V) < 0) + if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(4, q->V) < 0) return; unsigned int col; -- GitLab