From 24aadcac01f2d3d4ede3a1f692c94c03926456cc Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 15 Jun 2004 18:20:53 +0000 Subject: [PATCH] replace CutCircle/CutCurve with CutParametric --- Common/Makefile | 4 +- Plugin/CutCircle.cpp | 119 --------------- Plugin/CutCurve.cpp | 66 --------- Plugin/CutCurve.h | 35 ----- Plugin/CutParametric.cpp | 187 ++++++++++++++++++++++++ Plugin/{CutCircle.h => CutParametric.h} | 16 +- Plugin/Makefile | 18 +-- Plugin/Plugin.cpp | 6 +- doc/VERSIONS | 5 +- 9 files changed, 210 insertions(+), 246 deletions(-) delete mode 100644 Plugin/CutCircle.cpp delete mode 100644 Plugin/CutCurve.cpp delete mode 100644 Plugin/CutCurve.h create mode 100644 Plugin/CutParametric.cpp rename Plugin/{CutCircle.h => CutParametric.h} (78%) diff --git a/Common/Makefile b/Common/Makefile index 265405943d..aba189345f 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.57 2004-05-29 10:11:10 geuzaine Exp $ +# $Id: Makefile,v 1.58 2004-06-15 18:20:53 geuzaine Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -101,6 +101,6 @@ Visibility.o: Visibility.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ Trackball.o: Trackball.cpp Trackball.h VertexArray.o: VertexArray.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ - VertexArray.h Context.h + VertexArray.h Context.h ../Numeric/Numeric.h License.o: License.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h diff --git a/Plugin/CutCircle.cpp b/Plugin/CutCircle.cpp deleted file mode 100644 index 4e31bea1ef..0000000000 --- a/Plugin/CutCircle.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// $Id: CutCircle.cpp,v 1.1 2004-06-15 16:17:58 remacle Exp $ -// -// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to <gmsh@geuz.org>. - -#include "CutCircle.h" -#include "List.h" -#include "Context.h" -#include <math.h> - -extern Context_T CTX; - -StringXNumber CutCircleOptions_Number[] = { - {GMSH_FULLRC, "Xc", NULL, 0.}, - {GMSH_FULLRC, "Yc", NULL, 0.}, - {GMSH_FULLRC, "Zc", NULL, 0.}, - {GMSH_FULLRC, "R", NULL, 1}, - {GMSH_FULLRC, "nbPoints", NULL, 360}, - {GMSH_FULLRC, "iView", NULL, -1.} -}; - -extern "C" -{ - GMSH_Plugin *GMSH_RegisterCutCirclePlugin() - { - return new GMSH_CutCirclePlugin(); - } -} - - -GMSH_CutCirclePlugin::GMSH_CutCirclePlugin() -{ - ; -} - -void GMSH_CutCirclePlugin::getName(char *name) const -{ - strcpy(name, "Cut circle"); -} - -void GMSH_CutCirclePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "J.-F. Remacle (remacle@gce.ucl.ac.be)"); - strcpy(copyright, "DGR (www.multiphysics.com)"); - strcpy(help_text, - "Plugin(CutCircle) cuts the view `iView' with\n" - "the circle centered at Xc,Yc,Zc and of Radius R If\n" - "`iView' < 0, the plugin is run on the current\n" - "view.\n" - "\n" - "Plugin(CutCircle) creates one new view.\n"); -} - -int GMSH_CutCirclePlugin::getNbOptions() const -{ - return sizeof(CutCircleOptions_Number) / sizeof(StringXNumber); -} - -StringXNumber *GMSH_CutCirclePlugin::getOption(int iopt) -{ - return &CutCircleOptions_Number[iopt]; -} - -void GMSH_CutCirclePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutCircle failed..."); -} - -void GMSH_CutCirclePlugin::getPoint(const double &u, double &x, double &y, double &z) const -{ - const double Xc =CutCircleOptions_Number[0].def; - const double Yc =CutCircleOptions_Number[1].def; - const double Zc =CutCircleOptions_Number[2].def; - const double R =CutCircleOptions_Number[3].def; - - const double theta = u * 2 * 3.1415926; - x = Xc + R * cos (theta); - y = Yc + R * sin (theta); - z = 0.0; -} - -int GMSH_CutCirclePlugin::getNbPoints() const -{ - return (int)CutCircleOptions_Number[4].def; -} - -Post_View *GMSH_CutCirclePlugin::execute(Post_View * v) -{ - int iView = (int)CutCircleOptions_Number[5].def; - - if(iView < 0) - iView = v ? v->Index : 0; - - if(!List_Pointer_Test(CTX.post.list, iView)) { - Msg(GERROR, "View[%d] does not exist", iView); - return v; - } - - Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView); - - return GMSH_CutCurvePlugin:: GenerateView(v1); -} diff --git a/Plugin/CutCurve.cpp b/Plugin/CutCurve.cpp deleted file mode 100644 index 7ed63598f4..0000000000 --- a/Plugin/CutCurve.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// $Id: CutCurve.cpp,v 1.1 2004-06-15 16:17:58 remacle Exp $ -// -// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to <gmsh@geuz.org>. - -#include "OctreePost.h" -#include "CutCurve.h" -#include "List.h" -#include "Context.h" -#include "Views.h" -#include "Message.h" - -extern Context_T CTX; - - -GMSH_CutCurvePlugin::GMSH_CutCurvePlugin() -{ - ; -} - -Post_View * GMSH_CutCurvePlugin::GenerateView(Post_View * v) const -{ - Post_View * View = BeginView(1); - - double *VALUES = new double [9*v->NbTimeStep]; - OctreePost o(v); - - for(int i = 0; i < getNbPoints(); ++i){ - const double xi = (double)(i)/(double)(getNbPoints()-1); - double x,y,z; - getPoint (xi,x,y,z); - if(v->NbSS || v->NbSH || v->NbST || v->NbSQ){ - List_Add(View->SP, &x); - List_Add(View->SP, &y); - List_Add(View->SP, &z); - View->NbSP++; - o.searchScalar(x, y, z, VALUES); - for(int k = 0; k < v->NbTimeStep; ++k){ - List_Add(View->SP, &VALUES[k]); - } - } - } - char name[1024], filename[1024]; - sprintf(name, "%s_CutCurve", v->Name); - sprintf(filename, "%s_CutCurve.pos", v->Name); - EndView(View, v->NbTimeStep, filename, name); - delete [] VALUES; - return View; -} - diff --git a/Plugin/CutCurve.h b/Plugin/CutCurve.h deleted file mode 100644 index fca9071fff..0000000000 --- a/Plugin/CutCurve.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _CUT_GRID_H_ -#define _CUT_GRID_H - -// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to <gmsh@geuz.org>. - -#include "Plugin.h" - -class GMSH_CutCurvePlugin : public GMSH_Post_Plugin -{ - protected: - virtual void getPoint ( const double &u , double &x, double &y, double &z) const = 0; - virtual int getNbPoints ( ) const = 0; -public: - GMSH_CutCurvePlugin(); - virtual Post_View * GenerateView (Post_View * v) const ; -}; - -#endif diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp new file mode 100644 index 0000000000..6015d7a456 --- /dev/null +++ b/Plugin/CutParametric.cpp @@ -0,0 +1,187 @@ +// $Id: CutParametric.cpp,v 1.1 2004-06-15 18:20:53 geuzaine Exp $ +// +// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to <gmsh@geuz.org>. + +#include "OctreePost.h" +#include "CutParametric.h" +#include "List.h" +#include "Context.h" +#include <math.h> + +#if defined(HAVE_MATH_EVAL) +#include "matheval.h" +#endif + +extern Context_T CTX; + +StringXNumber CutParametricOptions_Number[] = { + {GMSH_FULLRC, "minU", NULL, 0.}, + {GMSH_FULLRC, "maxU", NULL, 2*M_PI}, + {GMSH_FULLRC, "nbU", NULL, 360.}, + //{GMSH_FULLRC, "minV", NULL, 0.}, + //{GMSH_FULLRC, "maxV", NULL, 1.}, + //{GMSH_FULLRC, "nbV", NULL, 0.}, + //{GMSH_FULLRC, "minW", NULL, 0.}, + //{GMSH_FULLRC, "maxW", NULL, 1.}, + //{GMSH_FULLRC, "nbW", NULL, 0.}, + {GMSH_FULLRC, "iView", NULL, -1.} +}; + +StringXString CutParametricOptions_String[] = { + {GMSH_FULLRC, "X", NULL, "0 + 1 * Cos(u)"}, + {GMSH_FULLRC, "Y", NULL, "0 + 1 * Sin(u)"}, + {GMSH_FULLRC, "Z", NULL, "0"}, +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutParametricPlugin() + { + return new GMSH_CutParametricPlugin(); + } +} + + +GMSH_CutParametricPlugin::GMSH_CutParametricPlugin() +{ + ; +} + +void GMSH_CutParametricPlugin::getName(char *name) const +{ + strcpy(name, "Cut parametric"); +} + +void GMSH_CutParametricPlugin::getInfos(char *author, char *copyright, + char *help_text) const +{ + strcpy(author, "C. Geuzaine (geuzaine@acm.caltech.edu)"); + strcpy(copyright, "DGR (www.multiphysics.com)"); + strcpy(help_text, + "Plugin(CutParametric) cuts the view `iView' with\n" + "the parametric function (`X'(u), `Y'(u), `Z'(u)),\n" + "using `nbU' values of the parameter u in [`minU',\n" + "`maxU']. If `iView' < 0, the plugin is run on the\n" + "current view.\n" + "\n" + "Plugin(CutParametric) creates one new view.\n"); +} + +int GMSH_CutParametricPlugin::getNbOptions() const +{ + return sizeof(CutParametricOptions_Number) / sizeof(StringXNumber); +} + +StringXNumber *GMSH_CutParametricPlugin::getOption(int iopt) +{ + return &CutParametricOptions_Number[iopt]; +} + +int GMSH_CutParametricPlugin::getNbOptionsStr() const +{ + return sizeof(CutParametricOptions_String) / sizeof(StringXString); +} + +StringXString *GMSH_CutParametricPlugin::getOptionStr(int iopt) +{ + return &CutParametricOptions_String[iopt]; +} + +void GMSH_CutParametricPlugin::catchErrorMessage(char *errorMessage) const +{ + strcpy(errorMessage, "CutParametric failed..."); +} + +Post_View *GMSH_CutParametricPlugin::execute(Post_View * v) +{ + int iView = (int)CutParametricOptions_Number[3].def; + + if(iView < 0) + iView = v ? v->Index : 0; + + if(!List_Pointer_Test(CTX.post.list, iView)) { + Msg(GERROR, "View[%d] does not exist", iView); + return v; + } + +#if !defined(HAVE_MATH_EVAL) + + Msg(GERROR, "MathEval is not compiled in this version of Gmsh"); + return v; + +#else + + double minU = CutParametricOptions_Number[0].def; + double maxU = CutParametricOptions_Number[1].def; + int nbU = (int)CutParametricOptions_Number[2].def; + + char *exprx = CutParametricOptions_String[0].def; + char *expry = CutParametricOptions_String[1].def; + char *exprz = CutParametricOptions_String[2].def; + + void *fx = evaluator_create(exprx); + if(!fx){ + Msg(GERROR, "Invalid expression '%s'", exprx); + return v; + } + + void *fy = evaluator_create(expry); + if(!fy){ + Msg(GERROR, "Invalid expression '%s'", expry); + return v; + } + + void *fz = evaluator_create(exprz); + if(!fz){ + Msg(GERROR, "Invalid expression '%s'", exprz); + return v; + } + + Post_View *v2 = BeginView(1); + Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView); + OctreePost o(v1); + double *res = new double[9*v1->NbTimeStep]; + + for(int i = 0; i < nbU; ++i){ + double u = minU + (double)(i)/(double)(nbU-1) * (maxU - minU); + char *names[] = { "u" }; + double values[] = { u }; + double x = evaluator_evaluate(fx, sizeof(names)/sizeof(names[0]), names, values); + double y = evaluator_evaluate(fy, sizeof(names)/sizeof(names[0]), names, values); + double z = evaluator_evaluate(fz, sizeof(names)/sizeof(names[0]), names, values); + List_Add(v2->SP, &x); + List_Add(v2->SP, &y); + List_Add(v2->SP, &z); + v2->NbSP++; + o.searchScalar(x, y, z, res); + for(int k = 0; k < v1->NbTimeStep; ++k){ + List_Add(v2->SP, &res[k]); + } + } + + char name[1024], filename[1024]; + sprintf(name, "%s_CutParametric", v1->Name); + sprintf(filename, "%s_CutParametric.pos", v1->Name); + EndView(v2, 1, filename, name); + delete [] res; + return v2; + +#endif +} diff --git a/Plugin/CutCircle.h b/Plugin/CutParametric.h similarity index 78% rename from Plugin/CutCircle.h rename to Plugin/CutParametric.h index 658a0443b5..442894c3f9 100644 --- a/Plugin/CutCircle.h +++ b/Plugin/CutParametric.h @@ -1,5 +1,5 @@ -#ifndef _CUT_CIRCLE_H_ -#define _CUT_CIRCLE_H +#ifndef _CUT_PARAMETRIC_H_ +#define _CUT_PARAMETRIC_H // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -20,19 +20,17 @@ // // Please report all bugs and problems to <gmsh@geuz.org>. -#include "CutCurve.h" +#include "Plugin.h" extern "C" { - GMSH_Plugin *GMSH_RegisterCutCirclePlugin (); + GMSH_Plugin *GMSH_RegisterCutParametricPlugin (); } -class GMSH_CutCirclePlugin : public GMSH_CutCurvePlugin +class GMSH_CutParametricPlugin : public GMSH_Post_Plugin { - virtual void getPoint ( const double &u , double &x, double &y, double &z) const ; - virtual int getNbPoints ( ) const ; public: - GMSH_CutCirclePlugin(); + GMSH_CutParametricPlugin(); void getName (char *name) const; void getInfos (char *author, char *copyright, @@ -40,6 +38,8 @@ public: void catchErrorMessage (char *errorMessage) const; int getNbOptions() const; StringXNumber *getOption (int iopt); + int getNbOptionsStr() const; + StringXString* getOptionStr(int iopt); Post_View *execute (Post_View *); }; diff --git a/Plugin/Makefile b/Plugin/Makefile index 5539fee85d..5e9fa8d172 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.50 2004-06-15 16:17:58 remacle Exp $ +# $Id: Makefile,v 1.51 2004-06-15 18:20:53 geuzaine Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -29,7 +29,7 @@ CFLAGS = -DMPICH_SKIP_MPICXX ${OPTIM} ${FLAGS} ${INCLUDE} SRC = Plugin.cpp\ Levelset.cpp\ CutPlane.cpp CutSphere.cpp CutMap.cpp \ - Smooth.cpp CutCurve.cpp CutCircle.cpp\ + Smooth.cpp CutParametric.cpp\ Octree.cpp OctreeInternals.cpp OctreePost.cpp\ StreamLines.cpp CutGrid.cpp\ Transform.cpp\ @@ -68,7 +68,7 @@ depend: Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ ../Common/VertexArray.h PluginManager.h CutMap.h Levelset.h CutGrid.h \ - StreamLines.h CutPlane.h CutCircle.h CutCurve.h CutSphere.h Skin.h \ + StreamLines.h CutPlane.h CutParametric.h CutSphere.h Skin.h \ ../DataStr/Tree.h ../DataStr/avl.h Extract.h Harmonic2Time.h \ DecomposeInSimplex.h Smooth.h Transform.h Triangulate.h \ SphericalRaise.h DisplacementRaise.h Evaluate.h @@ -91,14 +91,10 @@ CutMap.o: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \ Smooth.o: Smooth.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ ../Common/VertexArray.h Smooth.h ../Common/Context.h -CutCurve.o: CutCurve.cpp OctreePost.h Octree.h OctreeInternals.h \ - CutCurve.h Plugin.h ../Common/Options.h ../Common/Message.h \ - ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ - ../Common/VertexArray.h ../Common/Context.h -CutCircle.o: CutCircle.cpp CutCircle.h CutCurve.h Plugin.h \ - ../Common/Options.h ../Common/Message.h ../Common/Views.h \ - ../Common/ColorTable.h ../DataStr/List.h ../Common/VertexArray.h \ - ../Common/Context.h +CutParametric.o: CutParametric.cpp OctreePost.h Octree.h \ + OctreeInternals.h CutParametric.h Plugin.h ../Common/Options.h \ + ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ + ../DataStr/List.h ../Common/VertexArray.h ../Common/Context.h Octree.o: Octree.cpp Octree.h OctreeInternals.h OctreeInternals.o: OctreeInternals.cpp ../Common/Message.h \ OctreeInternals.h diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index 62c652a5d1..ea69aef1ca 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -1,4 +1,4 @@ -// $Id: Plugin.cpp,v 1.53 2004-06-15 16:17:59 remacle Exp $ +// $Id: Plugin.cpp,v 1.54 2004-06-15 18:20:53 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -36,7 +36,7 @@ #include "CutGrid.h" #include "StreamLines.h" #include "CutPlane.h" -#include "CutCircle.h" +#include "CutParametric.h" #include "CutSphere.h" #include "Skin.h" #include "Extract.h" @@ -147,7 +147,7 @@ void GMSH_PluginManager::registerDefaultPlugins() allPlugins.insert(std::pair < char *, GMSH_Plugin * > ("CutPlane", GMSH_RegisterCutPlanePlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > - ("CutCircle", GMSH_RegisterCutCirclePlugin())); + ("CutParametric", GMSH_RegisterCutParametricPlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > ("CutSphere", GMSH_RegisterCutSpherePlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > diff --git a/doc/VERSIONS b/doc/VERSIONS index be87d5ca3c..c4131bc79f 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,8 +1,9 @@ -$Id: VERSIONS,v 1.223 2004-06-12 18:48:29 geuzaine Exp $ +$Id: VERSIONS,v 1.224 2004-06-15 18:20:53 geuzaine Exp $ New since 1.53: fixed UNV output; make Layers' region numbering consistent between lines/surfaces/volumes; fixed home directory -problem on Win98; small bug fixes and cleanups. +problem on Win98; new Plugin(CutParametric); small bug fixes and +cleanups. New in 1.53: completed support for second order elements in the mesh module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms -- GitLab