From 758bd8e62738f82cea45761c8cde5a7daab03c57 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 6 Aug 2001 10:35:47 +0000 Subject: [PATCH] fixed iView --- Common/Views.cpp | 8 +++----- Plugin/CutMap.cpp | 34 ++++++++++++++++------------------ Plugin/CutMap.h | 1 + Plugin/CutPlane.cpp | 27 ++++++++++++++++----------- Plugin/CutPlane.h | 1 + Plugin/CutSphere.cpp | 28 +++++++++++++++++----------- Plugin/CutSphere.h | 1 + Plugin/LevelsetPlugin.cpp | 6 ++---- Plugin/Skin.cpp | 21 +++++++++------------ Plugin/Smooth.cpp | 18 ++++++++---------- Plugin/Transform.cpp | 17 ++++++++--------- tutorial/t9.geo | 1 + 12 files changed, 83 insertions(+), 80 deletions(-) diff --git a/Common/Views.cpp b/Common/Views.cpp index 83ecb2ae12..284dd010f6 100644 --- a/Common/Views.cpp +++ b/Common/Views.cpp @@ -1,4 +1,4 @@ -// $Id: Views.cpp,v 1.48 2001-08-06 08:09:51 geuzaine Exp $ +// $Id: Views.cpp,v 1.49 2001-08-06 10:35:47 geuzaine Exp $ #include <set> #include "Gmsh.h" @@ -793,8 +793,6 @@ void smooth_list (List_T *SS , } } - Msg(DEBUG, "Smotthing phase 2"); - for(i = 0 ; i < List_Nbr(SS) ; i+=nb){ x = (double*)List_Pointer_Fast(SS,i); y = (double*)List_Pointer_Fast(SS,i+nbvert); @@ -821,14 +819,14 @@ void Post_View :: smooth (){ if(NbSS){ mycont conSS; - Msg(INFO,"Smoothing SS vector in a view ..."); + Msg(INFO,"Smoothing scalar tetrahedra in view..."); nb = List_Nbr(SS) / NbSS ; smooth_list (SS , &Min, &Max, NbTimeStep, 4, nb, conSS); Msg(INFO,"...done"); } if(NbST){ mycont conST; - Msg(INFO,"Smoothing ST vector in a view ..."); + Msg(INFO,"Smoothing scalar triangles in view..."); nb = List_Nbr(ST) / NbST ; smooth_list (ST , &Min, &Max, NbTimeStep, 3, nb, conST); Msg(INFO,"...done"); diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index 79a04fb841..5a0ebc8ce9 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -1,11 +1,11 @@ -// $Id: CutMap.cpp,v 1.15 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: CutMap.cpp,v 1.16 2001-08-06 10:35:47 geuzaine Exp $ #include "CutMap.h" #include "List.h" StringXNumber CutMapOptions_Number[] = { { GMSH_FULLRC, "A" , NULL , 1. }, - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -64,25 +64,23 @@ extern List_T *Post_ViewList; Post_View *GMSH_CutMapPlugin::execute (Post_View *v) { - + Post_View *vv; A = CutMapOptions_Number[0].def; iView = (int)CutMapOptions_Number[1].def; - Msg(INFO, "View %d -> iso %g",iView, A); - - if(v) - return GMSH_LevelsetPlugin::execute(v); - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin CutMap, view %d not loaded",iView); - return 0; - } - return GMSH_LevelsetPlugin::execute((Post_View*)List_Pointer_Test(Post_ViewList,iView-1)); + if(v && iView < 0) + vv = v; + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin CutMap: View[%d] does not exist",iView); + return 0; } -} - - - - + return GMSH_LevelsetPlugin::execute(vv); +} +void GMSH_CutMapPlugin::Run () +{ + int iView = (int)CutMapOptions_Number[1].def; + if(iView < 0) CutMapOptions_Number[1].def = 0; + execute (0); +} diff --git a/Plugin/CutMap.h b/Plugin/CutMap.h index a1aa27cd4a..dacb411dc5 100644 --- a/Plugin/CutMap.h +++ b/Plugin/CutMap.h @@ -22,5 +22,6 @@ public: virtual int getNbOptions() const; virtual StringXNumber* GetOption (int iopt); virtual Post_View *execute (Post_View *); + virtual void Run(); }; #endif diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index b1406c1e68..008bda943c 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -1,4 +1,4 @@ -// $Id: CutPlane.cpp,v 1.13 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: CutPlane.cpp,v 1.14 2001-08-06 10:35:47 geuzaine Exp $ #include "CutPlane.h" #include "List.h" @@ -8,7 +8,7 @@ StringXNumber CutPlaneOptions_Number[] = { { GMSH_FULLRC, "B" , NULL , 0. }, { GMSH_FULLRC, "C" , NULL , 0. }, { GMSH_FULLRC, "D" , NULL , 0.01 }, - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -67,24 +67,29 @@ extern List_T *Post_ViewList; Post_View *GMSH_CutPlanePlugin::execute (Post_View *v) { - + Post_View *vv; a = CutPlaneOptions_Number[0].def; b = CutPlaneOptions_Number[1].def; c = CutPlaneOptions_Number[2].def; d = CutPlaneOptions_Number[3].def; int iView = (int)CutPlaneOptions_Number[4].def; - if(v) - return GMSH_LevelsetPlugin::execute(v); - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin CutPlane, view %d not loaded",iView); - return 0; - } - return GMSH_LevelsetPlugin::execute((Post_View*)List_Pointer_Test(Post_ViewList,iView-1)); + if(v && iView < 0) + vv = v; + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin CutPlane: View[%d] does not exist",iView); + return 0; } + + return GMSH_LevelsetPlugin::execute(vv); } +void GMSH_CutPlanePlugin::Run () +{ + int iView = (int)CutPlaneOptions_Number[4].def; + if(iView < 0) CutPlaneOptions_Number[4].def = 0; + execute (0); +} diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h index 4575add1a9..89abdb196a 100644 --- a/Plugin/CutPlane.h +++ b/Plugin/CutPlane.h @@ -23,6 +23,7 @@ public: virtual int getNbOptions() const; virtual StringXNumber *GetOption (int iopt); virtual Post_View *execute (Post_View *); + virtual void Run(); }; #endif diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index 9429fb624c..eb6634096c 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -1,4 +1,4 @@ -// $Id: CutSphere.cpp,v 1.12 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: CutSphere.cpp,v 1.13 2001-08-06 10:35:47 geuzaine Exp $ #include <string.h> #include "CutSphere.h" @@ -9,7 +9,7 @@ StringXNumber CutSphereOptions_Number[] = { { GMSH_FULLRC, "Yc" , NULL , 0. }, { GMSH_FULLRC, "Zc" , NULL , 0. }, { GMSH_FULLRC, "R" , NULL , 0.25 }, - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -68,20 +68,26 @@ extern List_T *Post_ViewList; Post_View *GMSH_CutSpherePlugin::execute (Post_View *v) { - + Post_View *vv; a = CutSphereOptions_Number[0].def; b = CutSphereOptions_Number[1].def; c = CutSphereOptions_Number[2].def; r = CutSphereOptions_Number[3].def; int iView = (int)CutSphereOptions_Number[4].def; - if(v) - return GMSH_LevelsetPlugin::execute(v); - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin CutSphere, view %d not loaded",iView); - return 0; - } - return GMSH_LevelsetPlugin::execute((Post_View*)List_Pointer_Test(Post_ViewList,iView-1)); + if(v && iView < 0) + vv = v; + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin CutSphere: View[%d] does not exist",iView); + return 0; } + + return GMSH_LevelsetPlugin::execute(vv); +} + +void GMSH_CutSpherePlugin::Run () +{ + int iView = (int)CutSphereOptions_Number[4].def; + if(iView < 0) CutSphereOptions_Number[4].def = 0; + execute (0); } diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h index bee21ba1e2..cb3493c842 100644 --- a/Plugin/CutSphere.h +++ b/Plugin/CutSphere.h @@ -23,6 +23,7 @@ public: virtual int getNbOptions() const; virtual StringXNumber* GetOption (int iopt); virtual Post_View *execute (Post_View *); + virtual void Run(); }; #endif diff --git a/Plugin/LevelsetPlugin.cpp b/Plugin/LevelsetPlugin.cpp index 69a8b522c4..a701760bb4 100644 --- a/Plugin/LevelsetPlugin.cpp +++ b/Plugin/LevelsetPlugin.cpp @@ -1,4 +1,4 @@ -// $Id: LevelsetPlugin.cpp,v 1.9 2001-08-06 08:09:51 geuzaine Exp $ +// $Id: LevelsetPlugin.cpp,v 1.10 2001-08-06 10:35:47 geuzaine Exp $ #include "LevelsetPlugin.h" #include "List.h" @@ -23,7 +23,6 @@ void GMSH_LevelsetPlugin::Save () void GMSH_LevelsetPlugin::Run () { - Msg(INFO, "Running Levelset plugin"); execute (0); } @@ -98,8 +97,7 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) sprintf(filename,"cut-%s",v->FileName); EndView(1, filename, name); - Msg(INFO, "Levelset plugin OK: created view '%s' (%d triangles)", - name, View->NbST); + Msg(INFO, "Levelset: created view '%s' (%d triangles)", name, View->NbST); processed = View; return View; } diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index aafa1024e2..c80e564260 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -1,4 +1,4 @@ -// $Id: Skin.cpp,v 1.2 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: Skin.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $ #include "Plugin.h" #include "Skin.h" @@ -10,7 +10,7 @@ extern Context_T CTX; StringXNumber SkinOptions_Number[] = { - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -115,15 +115,11 @@ Post_View *GMSH_SkinPlugin::execute (Post_View *v) struct elm elm; int iView = (int)SkinOptions_Number[0].def; - - if(v) + if(v && iView < 0) vv = v; - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin CutPlane, view %d not loaded",iView); - return 0; - } - vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView-1); + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin Skin: View[%d] does not exist",iView); + return 0; } if(vv->NbSS){ @@ -151,8 +147,7 @@ Post_View *GMSH_SkinPlugin::execute (Post_View *v) sprintf(name,"skin-%s",vv->Name); sprintf(filename,"skin-%s",vv->FileName); EndView(1, filename, name); - Msg(INFO, "Skin plugin OK: created view '%s' (%d triangles)", - name, View->NbST); + Msg(INFO, "Skin: created view '%s' (%d triangles)", name, View->NbST); return View; } @@ -161,6 +156,8 @@ Post_View *GMSH_SkinPlugin::execute (Post_View *v) void GMSH_SkinPlugin::Run () { + int iView = (int)SkinOptions_Number[0].def; + if(iView < 0) SkinOptions_Number[0].def = 0; execute(0); } diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp index 9fe472f112..4cfe690459 100644 --- a/Plugin/Smooth.cpp +++ b/Plugin/Smooth.cpp @@ -1,4 +1,4 @@ -// $Id: Smooth.cpp,v 1.2 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: Smooth.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $ #include "Plugin.h" #include "Smooth.h" @@ -6,7 +6,7 @@ #include "Views.h" StringXNumber SmoothOptions_Number[] = { - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -59,23 +59,21 @@ Post_View *GMSH_SmoothPlugin::execute (Post_View *v) Post_View *vv; int iView = (int)SmoothOptions_Number[0].def; - if(v) + if(v && iView < 0) vv = v; - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin Smooth, view %d not loaded",iView); - return 0; - } - vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView-1); + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin Smooth: View[%d] does not exist",iView); + return 0; } - Msg(INFO, "Executing Smooth on View num %d", vv->Num); vv->smooth(); return vv; } void GMSH_SmoothPlugin::Run () { + int iView = (int)SmoothOptions_Number[0].def; + if(iView < 0) SmoothOptions_Number[0].def = 0; execute(0); } diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp index 18bcba2a45..89e6374a3c 100644 --- a/Plugin/Transform.cpp +++ b/Plugin/Transform.cpp @@ -1,4 +1,4 @@ -// $Id: Transform.cpp,v 1.2 2001-08-06 09:44:22 geuzaine Exp $ +// $Id: Transform.cpp,v 1.3 2001-08-06 10:35:47 geuzaine Exp $ #include "Plugin.h" #include "Transform.h" @@ -15,7 +15,7 @@ StringXNumber TransformOptions_Number[] = { { GMSH_FULLRC, "A31" , NULL , 0. }, { GMSH_FULLRC, "A32" , NULL , 0. }, { GMSH_FULLRC, "A33" , NULL , 1. }, - { GMSH_FULLRC, "iView" , NULL , 1. } + { GMSH_FULLRC, "iView" , NULL , -1. } }; extern "C" @@ -93,14 +93,11 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v) mat[2][2] = TransformOptions_Number[8].def; int iView = (int)TransformOptions_Number[9].def; - if(v) + if(v && iView < 0) vv = v; - else{ - if(List_Nbr(Post_ViewList) < iView){ - Msg(WARNING,"Plugin CutTransform, view %d not loaded",iView); - return 0; - } - vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView-1); + else if(!(vv = (Post_View*)List_Pointer_Test(Post_ViewList,iView))){ + Msg(WARNING,"Plugin Transform: View[%d] does not exist",iView); + return 0; } vv->transform(mat); @@ -109,6 +106,8 @@ Post_View *GMSH_TransformPlugin::execute (Post_View *v) void GMSH_TransformPlugin::Run () { + int iView = (int)TransformOptions_Number[9].def; + if(iView < 0) TransformOptions_Number[9].def = 0; execute(0); } diff --git a/tutorial/t9.geo b/tutorial/t9.geo index 16cd9c01ed..dea8f3b37f 100644 --- a/tutorial/t9.geo +++ b/tutorial/t9.geo @@ -28,6 +28,7 @@ Include "view3.pos" ; // documentation of each plugin), and runs the plugin: Plugin(CutMap).A = 0.67 ; +Plugin(CutMap).iView = 0 ; //select View[0] as the working view Plugin(CutMap).Run ; Plugin(CutPlane).A = 0 ; -- GitLab