From 49b60399d1bee6939d1fe4ddedf09859c3818151 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 15 Aug 2009 12:58:53 +0000 Subject: [PATCH] refactored plugins to use std::string --- Common/Options.cpp | 12 +-- Fltk/FlGui.cpp | 8 +- Fltk/pluginWindow.cpp | 24 ++--- Parser/Gmsh.tab.cpp | 2 +- Parser/Gmsh.y | 2 +- Plugin/Annotate.cpp | 28 ++---- Plugin/Annotate.h | 5 +- Plugin/Curl.cpp | 20 +--- Plugin/Curl.h | 5 +- Plugin/CutGrid.cpp | 20 +--- Plugin/CutGrid.h | 5 +- Plugin/CutMap.cpp | 20 +--- Plugin/CutMap.h | 5 +- Plugin/CutParametric.cpp | 20 +--- Plugin/CutParametric.h | 5 +- Plugin/CutPlane.cpp | 20 +--- Plugin/CutPlane.h | 5 +- Plugin/CutSphere.cpp | 20 +--- Plugin/CutSphere.h | 5 +- Plugin/Divergence.cpp | 20 +--- Plugin/Divergence.h | 5 +- Plugin/Eigenvalues.cpp | 19 +--- Plugin/Eigenvalues.h | 5 +- Plugin/Eigenvectors.cpp | 19 +--- Plugin/Eigenvectors.h | 5 +- Plugin/Evaluate.cpp | 20 +--- Plugin/Evaluate.h | 5 +- Plugin/Extract.cpp | 19 +--- Plugin/Extract.h | 5 +- Plugin/ExtractEdges.cpp | 24 +---- Plugin/ExtractEdges.h | 7 +- Plugin/ExtractElements.cpp | 19 +--- Plugin/ExtractElements.h | 5 +- Plugin/FieldView.cpp | 18 +--- Plugin/FieldView.h | 6 +- Plugin/FiniteElement.cpp | 20 +--- Plugin/FiniteElement.h | 5 +- Plugin/GSHHS.cpp | 83 ++++++++-------- Plugin/Gradient.cpp | 20 +--- Plugin/Gradient.h | 5 +- Plugin/HarmonicToTime.cpp | 20 +--- Plugin/HarmonicToTime.h | 5 +- Plugin/HomologyComputation.cpp | 21 +--- Plugin/HomologyComputation.h | 6 +- Plugin/Integrate.cpp | 25 +---- Plugin/Integrate.h | 7 +- Plugin/Lambda2.cpp | 25 +---- Plugin/Lambda2.h | 8 +- Plugin/LongitudeLatitude.cpp | 20 +--- Plugin/LongitudeLatitude.h | 6 +- Plugin/MakeSimplex.cpp | 25 +---- Plugin/MakeSimplex.h | 7 +- Plugin/ModulusPhase.cpp | 20 +--- Plugin/ModulusPhase.h | 5 +- Plugin/Plugin.cpp | 7 ++ Plugin/Plugin.h | 11 ++- Plugin/PluginManager.cpp | 174 ++++++++++++++------------------- Plugin/PluginManager.h | 33 +++---- Plugin/Probe.cpp | 20 +--- Plugin/Probe.h | 5 +- Plugin/Remove.cpp | 20 +--- Plugin/Remove.h | 5 +- Plugin/Skin.cpp | 19 +--- Plugin/Skin.h | 5 +- Plugin/Smooth.cpp | 20 +--- Plugin/Smooth.h | 5 +- Plugin/SphericalRaise.cpp | 20 +--- Plugin/SphericalRaise.h | 5 +- Plugin/StreamLines.cpp | 20 +--- Plugin/StreamLines.h | 5 +- Plugin/Transform.cpp | 20 +--- Plugin/Transform.h | 5 +- Plugin/Triangulate.cpp | 20 +--- Plugin/Triangulate.h | 5 +- Plugin/Warp.cpp | 20 +--- Plugin/Warp.h | 5 +- 76 files changed, 336 insertions(+), 878 deletions(-) diff --git a/Common/Options.cpp b/Common/Options.cpp index 040a7225ea..2b63d1dfd5 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -754,14 +754,12 @@ void PrintOptionsDoc() return; } fprintf(file, "%s@ftable @code\n", warn); - char author[256], copyright[256], help[4096]; - for(PluginManager::iter it = PluginManager::instance()->begin(); - it != PluginManager::instance()->end(); ++it) { - GMSH_Plugin *p = (*it).second; + for(std::map<std::string, GMSH_Plugin*>::iterator it = PluginManager:: + instance()->begin(); it != PluginManager::instance()->end(); ++it) { + GMSH_Plugin *p = it->second; if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) { - p->getInfos(author, copyright, help); - fprintf(file, "@item Plugin(%s)\n", (*it).first); - fprintf(file, "%s\n", help); + fprintf(file, "@item Plugin(%s)\n", p->getName().c_str()); + fprintf(file, "%s\n", p->getHelp().c_str()); int m = p->getNbOptionsStr(); if(m){ diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index e88f15a728..7eaad91058 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -661,9 +661,9 @@ void redraw_cb(Fl_Widget *w, void *data) void window_cb(Fl_Widget *w, void *data) { static int oldx = 0, oldy = 0, oldw = 0, oldh = 0, zoom = 1; - const char *str = (const char*)data; + std::string str((const char*)data); - if(!strcmp(str, "minimize")){ + if(str == "minimize"){ for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++) if(FlGui::instance()->graph[i]->win->shown()) FlGui::instance()->graph[i]->win->iconize(); @@ -686,7 +686,7 @@ void window_cb(Fl_Widget *w, void *data) if(FlGui::instance()->menu->win->shown()) FlGui::instance()->menu->win->iconize(); } - else if(!strcmp(str, "zoom")){ + else if(str == "zoom"){ if(zoom){ oldx = FlGui::instance()->graph[0]->win->x(); oldy = FlGui::instance()->graph[0]->win->y(); @@ -704,7 +704,7 @@ void window_cb(Fl_Widget *w, void *data) FlGui::instance()->graph[0]->win->show(); FlGui::instance()->menu->win->show(); } - else if(!strcmp(str, "front")){ + else if(str == "front"){ // the order is important! for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++) FlGui::instance()->graph[i]->win->show(); diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp index 34e82f2050..5d097aeb11 100644 --- a/Fltk/pluginWindow.cpp +++ b/Fltk/pluginWindow.cpp @@ -198,18 +198,14 @@ void pluginWindow::_createDialogBox(GMSH_Plugin *p, int x, int y, Fl_Browser *o = new Fl_Browser (x + WB, y + WB + BH, width - 2 * WB, height - 2 * WB - BH); - - char name[1024], copyright[256], author[256], help[4096]; - p->getName(name); - p->getInfos(author, copyright, help); - o->add(" "); - add_multiline_in_browser(o, "@c@b@.", name, false); + add_multiline_in_browser(o, "@c@b@.", p->getName().c_str(), false); o->add(" "); - add_multiline_in_browser(o, "", help, false); + add_multiline_in_browser(o, "", p->getHelp().c_str(), false); o->add(" "); - add_multiline_in_browser(o, "Author: ", author, false); - add_multiline_in_browser(o, "Copyright (C) ", copyright, false); + add_multiline_in_browser(o, "Author: ", p->getAuthor().c_str(), false); + add_multiline_in_browser(o, "Copyright (C) ", p->getCopyright().c_str(), + false); o->add(" "); g->end(); @@ -245,13 +241,11 @@ pluginWindow::pluginWindow(int deltaFontSize) view_browser->has_scrollbar(Fl_Browser_::VERTICAL); view_browser->callback(plugin_browser_cb); - for(PluginManager::iter it = PluginManager::instance()->begin(); - it != PluginManager::instance()->end(); ++it) { - GMSH_Plugin *p = (*it).second; + for(std::map<std::string, GMSH_Plugin*>::iterator it = PluginManager:: + instance()->begin(); it != PluginManager::instance()->end(); ++it) { + GMSH_Plugin *p = it->second; if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) { - char name[256]; - p->getName(name); - browser->add(name, p); + browser->add(p->getName().c_str(), p); _createDialogBox(p, 2 * WB + L1 + L2, WB, width - L1 - L2 - 3 * WB, height - 2 * WB); // select first plugin by default diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 42e06170ed..69d0a5ded3 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -4654,7 +4654,7 @@ yyreduce: yymsg(0, "Unknown option '%s' or plugin '%s'", (yyvsp[(6) - (9)].c), (yyvsp[(3) - (9)].c)); } #endif - Free((yyvsp[(3) - (9)].c)); Free((yyvsp[(6) - (9)].c)); + Free((yyvsp[(3) - (9)].c)); Free((yyvsp[(6) - (9)].c)); Free((yyvsp[(8) - (9)].c)); ;} break; diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 0bd325df09..a84fb61ce9 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -934,7 +934,7 @@ Affectation : yymsg(0, "Unknown option '%s' or plugin '%s'", $6, $3); } #endif - Free($3); Free($6); + Free($3); Free($6); Free($8); } ; diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp index f7c108b603..b6b21a86f9 100644 --- a/Plugin/Annotate.cpp +++ b/Plugin/Annotate.cpp @@ -180,18 +180,9 @@ std::string GMSH_AnnotatePlugin::callbackAlign(int num, int action, std::string return callbackStr(num, action, value, AnnotateOptions_String[2].def); } -void GMSH_AnnotatePlugin::getName(char *name) const +std::string GMSH_AnnotatePlugin::getHelp() const { - strcpy(name, "Annotate"); -} - -void GMSH_AnnotatePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Annotate) adds the text string `Text',\n" + return "Plugin(Annotate) adds the text string `Text',\n" "in font `Font' and size `FontSize', in the view\n" "`iView'. If `ThreeD' is equal to 1, the plugin inserts\n" "the string in model coordinates at the position\n" @@ -202,7 +193,7 @@ void GMSH_AnnotatePlugin::getInfos(char *author, char *copyright, "is run on the current view.\n" "\n" "Plugin(Annotate) is executed in-place for list-based\n" - "datasets or creates a new view for other datasets.\n"); + "datasets or creates a new view for other datasets.\n"; } int GMSH_AnnotatePlugin::getNbOptions() const @@ -225,11 +216,6 @@ StringXString *GMSH_AnnotatePlugin::getOptionStr(int iopt) return &AnnotateOptions_String[iopt]; } -void GMSH_AnnotatePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Annotate failed..."); -} - PView *GMSH_AnnotatePlugin::execute(PView *v) { double X = AnnotateOptions_Number[0].def; @@ -237,7 +223,7 @@ PView *GMSH_AnnotatePlugin::execute(PView *v) double Z = AnnotateOptions_Number[2].def; int dim3 = (int)AnnotateOptions_Number[3].def; int iView = (int)AnnotateOptions_Number[5].def; - const char *text = AnnotateOptions_String[0].def.c_str(); + std::string text = AnnotateOptions_String[0].def; double style = getStyle(); PView *v1 = getView(iView, v); @@ -257,8 +243,9 @@ PView *GMSH_AnnotatePlugin::execute(PView *v) data2->T3D.push_back(Z); data2->T3D.push_back(style); data2->T3D.push_back(data2->T3C.size()); - for(int i = 0; i < (int)strlen(text) + 1; i++) + for(unsigned int i = 0; i < text.size(); i++) data2->T3C.push_back(text[i]); + data2->T3C.push_back('\0'); data2->NbT3++; } else{ @@ -266,8 +253,9 @@ PView *GMSH_AnnotatePlugin::execute(PView *v) data2->T2D.push_back(Y); data2->T2D.push_back(style); data2->T2D.push_back(data2->T2C.size()); - for(int i = 0; i < (int)strlen(text) + 1; i++) + for(unsigned int i = 0; i < text.size(); i++) data2->T2C.push_back(text[i]); + data2->T2C.push_back('\0'); data2->NbT2++; } diff --git a/Plugin/Annotate.h b/Plugin/Annotate.h index c10648a2f1..26ef63615c 100644 --- a/Plugin/Annotate.h +++ b/Plugin/Annotate.h @@ -23,9 +23,8 @@ class GMSH_AnnotatePlugin : public GMSH_PostPlugin std::string &opt); public: GMSH_AnnotatePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Annotate"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/Curl.cpp b/Plugin/Curl.cpp index 434b11ab76..3e23e45ed5 100644 --- a/Plugin/Curl.cpp +++ b/Plugin/Curl.cpp @@ -19,22 +19,13 @@ extern "C" } } -void GMSH_CurlPlugin::getName(char *name) const +std::string GMSH_CurlPlugin::getHelp() const { - strcpy(name, "Curl"); -} - -void GMSH_CurlPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Curl) computes the curl of the field\n" + return "Plugin(Curl) computes the curl of the field\n" "in the view `iView'. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(Curl) creates one new view.\n"); + "Plugin(Curl) creates one new view.\n"; } int GMSH_CurlPlugin::getNbOptions() const @@ -47,11 +38,6 @@ StringXNumber *GMSH_CurlPlugin::getOption(int iopt) return &CurlOptions_Number[iopt]; } -void GMSH_CurlPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Curl failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data2, int type) { switch(type){ diff --git a/Plugin/Curl.h b/Plugin/Curl.h index 9127bb6118..d6156f1c23 100644 --- a/Plugin/Curl.h +++ b/Plugin/Curl.h @@ -17,9 +17,8 @@ class GMSH_CurlPlugin : public GMSH_PostPlugin { public: GMSH_CurlPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Curl"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp index 8fbf779347..f93bf1071c 100644 --- a/Plugin/CutGrid.cpp +++ b/Plugin/CutGrid.cpp @@ -169,18 +169,9 @@ double GMSH_CutGridPlugin::callbackConnect(int num, int action, double value) 1, 0, 1); } -void GMSH_CutGridPlugin::getName(char *name) const +std::string GMSH_CutGridPlugin::getHelp() const { - strcpy(name, "Cut Grid"); -} - -void GMSH_CutGridPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(CutGrid) cuts the view `iView' with a\n" + return "Plugin(CutGrid) cuts the view `iView' with a\n" "rectangular grid defined by the 3 points\n" "(`X0',`Y0',`Z0') (origin), (`X1',`Y1',`Z1') (axis of\n" "U) and (`X2',`Y2',`Z2') (axis of V). The number of\n" @@ -192,7 +183,7 @@ void GMSH_CutGridPlugin::getInfos(char *author, char *copyright, "`nPointsV'. If `iView' < 0, the plugin is run on\n" "the current view.\n" "\n" - "Plugin(CutGrid) creates one new view.\n"); + "Plugin(CutGrid) creates one new view.\n"; } int GMSH_CutGridPlugin::getNbOptions() const @@ -205,11 +196,6 @@ StringXNumber *GMSH_CutGridPlugin::getOption(int iopt) return &CutGridOptions_Number[iopt]; } -void GMSH_CutGridPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutGrid failed..."); -} - int GMSH_CutGridPlugin::getNbU() { return (int)CutGridOptions_Number[9].def; diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h index 1bf062abb6..1f86da5e1e 100644 --- a/Plugin/CutGrid.h +++ b/Plugin/CutGrid.h @@ -25,9 +25,8 @@ class GMSH_CutGridPlugin : public GMSH_PostPlugin PView *GenerateView (PView *v, int connectPoints); public: GMSH_CutGridPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "CutGrid"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp index 8ed33d25d0..a92f188708 100644 --- a/Plugin/CutMap.cpp +++ b/Plugin/CutMap.cpp @@ -77,18 +77,9 @@ double GMSH_CutMapPlugin::callbackTarget(int num, int action, double value) return 0.; } -void GMSH_CutMapPlugin::getName(char *name) const +std::string GMSH_CutMapPlugin::getHelp() const { - strcpy(name, "Cut Map"); -} - -void GMSH_CutMapPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(CutMap) extracts the isosurface of value\n" + return "Plugin(CutMap) extracts the isosurface of value\n" "`A' from the view `iView' and draws the\n" "`dTimeStep'-th value of the view `dView' on the\n" "isosurface. If `iView' < 0, the plugin is run\n" @@ -102,7 +93,7 @@ void GMSH_CutMapPlugin::getInfos(char *author, char *copyright, "< 0) than the isosurface `A'.\n" "\n" "Plugin(CutMap) creates as many views as there\n" - "are time steps in `iView'.\n"); + "are time steps in `iView'.\n"; } int GMSH_CutMapPlugin::getNbOptions() const @@ -115,11 +106,6 @@ StringXNumber *GMSH_CutMapPlugin::getOption(int iopt) return &CutMapOptions_Number[iopt]; } -void GMSH_CutMapPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutMap failed..."); -} - double GMSH_CutMapPlugin::levelset(double x, double y, double z, double val) const { // we must look into the map for Map(x,y,z) - A diff --git a/Plugin/CutMap.h b/Plugin/CutMap.h index b471a28c06..6ca74cf579 100644 --- a/Plugin/CutMap.h +++ b/Plugin/CutMap.h @@ -18,9 +18,8 @@ class GMSH_CutMapPlugin : public GMSH_LevelsetPlugin double levelset(double x, double y, double z, double val) const; public: GMSH_CutMapPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "CutMap"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp index 56ad15a07f..df6106e678 100644 --- a/Plugin/CutParametric.cpp +++ b/Plugin/CutParametric.cpp @@ -192,18 +192,9 @@ std::string GMSH_CutParametricPlugin::callbackZ(int num, int action, std::string return callbackStr(num, action, value, CutParametricOptions_String[2].def); } -void GMSH_CutParametricPlugin::getName(char *name) const +std::string GMSH_CutParametricPlugin::getHelp() const { - strcpy(name, "Cut Parametric"); -} - -void GMSH_CutParametricPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(CutParametric) cuts the view `iView' with\n" + return "Plugin(CutParametric) cuts the view `iView' with\n" "the parametric function (`X'(u), `Y'(u), `Z'(u)),\n" "using `nPointsU' values of the parameter u in\n" "[`MinU', `MaxU']. If `ConnectPoints' is set, the\n" @@ -211,7 +202,7 @@ void GMSH_CutParametricPlugin::getInfos(char *author, char *copyright, "plugin generates points. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(CutParametric) creates one new view.\n"); + "Plugin(CutParametric) creates one new view.\n"; } int GMSH_CutParametricPlugin::getNbOptions() const @@ -234,11 +225,6 @@ StringXString *GMSH_CutParametricPlugin::getOptionStr(int iopt) return &CutParametricOptions_String[iopt]; } -void GMSH_CutParametricPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutParametric failed..."); -} - static void addInView(int connect, int i, int nbcomp, int nbtime, double x0, double y0, double z0, double *res0, double x, double y, double z, double *res, diff --git a/Plugin/CutParametric.h b/Plugin/CutParametric.h index 3acd85b8a7..e45705c64e 100644 --- a/Plugin/CutParametric.h +++ b/Plugin/CutParametric.h @@ -27,9 +27,8 @@ class GMSH_CutParametricPlugin : public GMSH_PostPlugin static std::vector<double> x, y, z; public: GMSH_CutParametricPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "CutParametric"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp index 009fc8c8de..28317c0de0 100644 --- a/Plugin/CutPlane.cpp +++ b/Plugin/CutPlane.cpp @@ -113,25 +113,16 @@ double GMSH_CutPlanePlugin::callbackTarget(int num, int action, double value) 0.01, 0., 1.); } -void GMSH_CutPlanePlugin::getName(char *name) const +std::string GMSH_CutPlanePlugin::getHelp() const { - strcpy(name, "Cut Plane"); -} - -void GMSH_CutPlanePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(CutPlane) cuts the view `iView' with\n" + return "Plugin(CutPlane) cuts the view `iView' with\n" "the plane `A'*X + `B'*Y + `C'*Z + `D' = 0. If\n" "`ExtractVolume' is nonzero, the plugin extracts\n" "the elements on one side of the plane (depending\n" "on the sign of `ExtractVolume'). If `iView' < 0,\n" "the plugin is run on the current view.\n" "\n" - "Plugin(CutPlane) creates one new view.\n"); + "Plugin(CutPlane) creates one new view.\n"; } int GMSH_CutPlanePlugin::getNbOptions() const @@ -144,11 +135,6 @@ StringXNumber *GMSH_CutPlanePlugin::getOption(int iopt) return &CutPlaneOptions_Number[iopt]; } -void GMSH_CutPlanePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutPlane failed..."); -} - double GMSH_CutPlanePlugin::levelset(double x, double y, double z, double val) const { return CutPlaneOptions_Number[0].def * x + CutPlaneOptions_Number[1].def * y + diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h index be1bcab398..7aa9efdf6f 100644 --- a/Plugin/CutPlane.h +++ b/Plugin/CutPlane.h @@ -21,9 +21,8 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin static int iview; public: GMSH_CutPlanePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "CutPlane"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp index 0e8a2523c0..bbb38d1cc0 100644 --- a/Plugin/CutSphere.cpp +++ b/Plugin/CutSphere.cpp @@ -103,25 +103,16 @@ double GMSH_CutSpherePlugin::callbackRecur(int num, int action, double value) 1, 0, 10); } -void GMSH_CutSpherePlugin::getName(char *name) const +std::string GMSH_CutSpherePlugin::getHelp() const { - strcpy(name, "Cut Sphere"); -} - -void GMSH_CutSpherePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(CutSphere) cuts the view `iView' with the\n" + return "Plugin(CutSphere) cuts the view `iView' with the\n" "sphere (X-`Xc')^2 + (Y-`Yc')^2 + (Z-`Zc')^2 = `R'^2.\n" "If `ExtractVolume' is nonzero, the plugin extracts\n" "the elements inside (if `ExtractVolume' < 0) or\n" "outside (if `ExtractVolume' > 0) the sphere. If\n" "`iView' < 0, the plugin is run on the current view.\n" "\n" - "Plugin(CutSphere) creates one new view.\n"); + "Plugin(CutSphere) creates one new view.\n"; } int GMSH_CutSpherePlugin::getNbOptions() const @@ -134,11 +125,6 @@ StringXNumber *GMSH_CutSpherePlugin::getOption(int iopt) return &CutSphereOptions_Number[iopt]; } -void GMSH_CutSpherePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "CutSphere failed..."); -} - double GMSH_CutSpherePlugin::levelset(double x, double y, double z, double val) const { diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h index d0692fecd3..ec634d64e3 100644 --- a/Plugin/CutSphere.h +++ b/Plugin/CutSphere.h @@ -20,9 +20,8 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin double step, double min, double max); public: GMSH_CutSpherePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "CutSphere"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp index a64144152f..171bb74fcc 100644 --- a/Plugin/Divergence.cpp +++ b/Plugin/Divergence.cpp @@ -19,22 +19,13 @@ extern "C" } } -void GMSH_DivergencePlugin::getName(char *name) const +std::string GMSH_DivergencePlugin::getHelp() const { - strcpy(name, "Divergence"); -} - -void GMSH_DivergencePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Divergence) computes the divergence of the\n" + return "Plugin(Divergence) computes the divergence of the\n" "field in the view `iView'. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(Divergence) creates one new view.\n"); + "Plugin(Divergence) creates one new view.\n"; } int GMSH_DivergencePlugin::getNbOptions() const @@ -47,11 +38,6 @@ StringXNumber *GMSH_DivergencePlugin::getOption(int iopt) return &DivergenceOptions_Number[iopt]; } -void GMSH_DivergencePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Divergence failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data2, int type) { switch(type){ diff --git a/Plugin/Divergence.h b/Plugin/Divergence.h index 184aeaa6c3..d100c25c7d 100644 --- a/Plugin/Divergence.h +++ b/Plugin/Divergence.h @@ -17,9 +17,8 @@ class GMSH_DivergencePlugin : public GMSH_PostPlugin { public: GMSH_DivergencePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Divergence"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Eigenvalues.cpp b/Plugin/Eigenvalues.cpp index 6dc711a456..eba0160e7c 100644 --- a/Plugin/Eigenvalues.cpp +++ b/Plugin/Eigenvalues.cpp @@ -19,21 +19,13 @@ extern "C" } } -void GMSH_EigenvaluesPlugin::getName(char *name) const +std::string GMSH_EigenvaluesPlugin::getHelp() const { - strcpy(name, "Eigenvalues"); -} - -void GMSH_EigenvaluesPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Eigenvalues) computes the three real\n" + return "Plugin(Eigenvalues) computes the three real\n" "eigenvalues of each tensor in the view `iView'.\n" "If `iView' < 0, the plugin is run on the current view.\n" "\n" - "Plugin(Eigenvalues) creates three new scalar views.\n"); + "Plugin(Eigenvalues) creates three new scalar views.\n"; } int GMSH_EigenvaluesPlugin::getNbOptions() const @@ -46,11 +38,6 @@ StringXNumber *GMSH_EigenvaluesPlugin::getOption(int iopt) return &EigenvaluesOptions_Number[iopt]; } -void GMSH_EigenvaluesPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Eigenvalues failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data2, int type) { switch(type){ diff --git a/Plugin/Eigenvalues.h b/Plugin/Eigenvalues.h index 88ed35ee88..219ce4238a 100644 --- a/Plugin/Eigenvalues.h +++ b/Plugin/Eigenvalues.h @@ -17,9 +17,8 @@ class GMSH_EigenvaluesPlugin : public GMSH_PostPlugin { public: GMSH_EigenvaluesPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Eigenvalues"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Eigenvectors.cpp b/Plugin/Eigenvectors.cpp index 8992a1624e..14cda42fc6 100644 --- a/Plugin/Eigenvectors.cpp +++ b/Plugin/Eigenvectors.cpp @@ -21,17 +21,9 @@ extern "C" } } -void GMSH_EigenvectorsPlugin::getName(char *name) const +std::string GMSH_EigenvectorsPlugin::getHelp() const { - strcpy(name, "Eigenvectors"); -} - -void GMSH_EigenvectorsPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Eigenvectors) computes the three (right)\n" + return "Plugin(Eigenvectors) computes the three (right)\n" "eigenvectors of each tensor in the view `iView'\n" "and sorts them according to the value of the\n" "associated eigenvalues. If `ScaleByEigenvalues'\n" @@ -41,7 +33,7 @@ void GMSH_EigenvectorsPlugin::getInfos(char *author, char *copyright, char *help "the plugin is run on the current view.\n" "\n" "Plugin(Eigenvectors) creates three new\n" - "vector views.\n"); + "vector views.\n"; } int GMSH_EigenvectorsPlugin::getNbOptions() const @@ -54,11 +46,6 @@ StringXNumber *GMSH_EigenvectorsPlugin::getOption(int iopt) return &EigenvectorsOptions_Number[iopt]; } -void GMSH_EigenvectorsPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Eigenvectors failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data2, int type) { switch(type){ diff --git a/Plugin/Eigenvectors.h b/Plugin/Eigenvectors.h index b68e861536..b1a89b09db 100644 --- a/Plugin/Eigenvectors.h +++ b/Plugin/Eigenvectors.h @@ -17,9 +17,8 @@ class GMSH_EigenvectorsPlugin : public GMSH_PostPlugin { public: GMSH_EigenvectorsPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Eigenvectors"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Evaluate.cpp b/Plugin/Evaluate.cpp index f06e8a5fb5..2f101e6454 100644 --- a/Plugin/Evaluate.cpp +++ b/Plugin/Evaluate.cpp @@ -32,18 +32,9 @@ extern "C" } } -void GMSH_EvaluatePlugin::getName(char *name) const +std::string GMSH_EvaluatePlugin::getHelp() const { - strcpy(name, "Evaluate"); -} - -void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Evaluate) sets the `Component'-th\n" + return "Plugin(Evaluate) sets the `Component'-th\n" "component of the `TimeStep'-th time step in the\n" "view `iView' to the expression `Expression'.\n" "`Expression' can contain:\n" @@ -87,7 +78,7 @@ void GMSH_EvaluatePlugin::getInfos(char *author, char *copyright, "`ExternalView' < 0, the plugin uses `iView'\n" "instead.\n" "\n" - "Plugin(Evaluate) is executed in-place.\n"); + "Plugin(Evaluate) is executed in-place.\n"; } int GMSH_EvaluatePlugin::getNbOptions() const @@ -110,11 +101,6 @@ StringXString *GMSH_EvaluatePlugin::getOptionStr(int iopt) return &EvaluateOptions_String[iopt]; } -void GMSH_EvaluatePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Evaluate failed..."); -} - PView *GMSH_EvaluatePlugin::execute(PView *v) { int component = (int)EvaluateOptions_Number[0].def; diff --git a/Plugin/Evaluate.h b/Plugin/Evaluate.h index adf2937e07..0fb3207aee 100644 --- a/Plugin/Evaluate.h +++ b/Plugin/Evaluate.h @@ -17,9 +17,8 @@ class GMSH_EvaluatePlugin : public GMSH_PostPlugin { public: GMSH_EvaluatePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Evaluate"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp index a515275fe4..9f0168c5c4 100644 --- a/Plugin/Extract.cpp +++ b/Plugin/Extract.cpp @@ -40,17 +40,9 @@ extern "C" } } -void GMSH_ExtractPlugin::getName(char *name) const +std::string GMSH_ExtractPlugin::getHelp() const { - strcpy(name, "Extract"); -} - -void GMSH_ExtractPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Extract) extracts a combination of\n" + return "Plugin(Extract) extracts a combination of\n" "components from the `TimeStep'th time step\n" "in the view `iView'. If only `Expression0' is\n" "given (and `Expression1', ..., `Expression8' are\n" @@ -70,7 +62,7 @@ void GMSH_ExtractPlugin::getInfos(char *author, char *copyright, char *help_text "in the view. If `iView' < 0, the plugin is run on\n" "the current view.\n" "\n" - "Plugin(Extract) creates one new view.\n"); + "Plugin(Extract) creates one new view.\n"; } int GMSH_ExtractPlugin::getNbOptions() const @@ -93,11 +85,6 @@ StringXString *GMSH_ExtractPlugin::getOptionStr(int iopt) return &ExtractOptions_String[iopt]; } -void GMSH_ExtractPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Extract failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data, int numComp, int type) { diff --git a/Plugin/Extract.h b/Plugin/Extract.h index 90bc5a128c..142e1e7f58 100644 --- a/Plugin/Extract.h +++ b/Plugin/Extract.h @@ -17,9 +17,8 @@ class GMSH_ExtractPlugin : public GMSH_PostPlugin { public: GMSH_ExtractPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Extract"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/ExtractEdges.cpp b/Plugin/ExtractEdges.cpp index 8a6749d4e8..8849874841 100644 --- a/Plugin/ExtractEdges.cpp +++ b/Plugin/ExtractEdges.cpp @@ -18,27 +18,14 @@ extern "C" } } -GMSH_ExtractEdgesPlugin::GMSH_ExtractEdgesPlugin() +std::string GMSH_ExtractEdgesPlugin::getHelp() const { - ; -} - -void GMSH_ExtractEdgesPlugin::getName(char *name) const -{ - strcpy(name, "Extract Edges"); -} - -void GMSH_ExtractEdgesPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(ExtractEdges) extracts the geometry edges\n" + return "Plugin(ExtractEdges) extracts the geometry edges\n" "from the surface view `iView', using `Angle' as\n" "the dihedral angle tolerance. If `iView' < 0, then\n" "plugin is run on the current view.\n" "\n" - "Plugin(ExtractEdges) creates one new view.\n"); + "Plugin(ExtractEdges) creates one new view.\n"; } int GMSH_ExtractEdgesPlugin::getNbOptions() const @@ -51,11 +38,6 @@ StringXNumber *GMSH_ExtractEdgesPlugin::getOption(int iopt) return &ExtractEdgesOptions_Number[iopt]; } -void GMSH_ExtractEdgesPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Extract Edges failed..."); -} - PView *GMSH_ExtractEdgesPlugin::execute(PView *v) { int iView = (int)ExtractEdgesOptions_Number[1].def; diff --git a/Plugin/ExtractEdges.h b/Plugin/ExtractEdges.h index 278c105004..443be94e5b 100644 --- a/Plugin/ExtractEdges.h +++ b/Plugin/ExtractEdges.h @@ -16,10 +16,9 @@ extern "C" class GMSH_ExtractEdgesPlugin : public GMSH_PostPlugin { public: - GMSH_ExtractEdgesPlugin(); - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + GMSH_ExtractEdgesPlugin(){} + std::string getName() const { return "ExtractEdges"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp index aa0b6a8290..6171bb1f6e 100644 --- a/Plugin/ExtractElements.cpp +++ b/Plugin/ExtractElements.cpp @@ -23,23 +23,15 @@ extern "C" } } -void GMSH_ExtractElementsPlugin::getName(char *name) const +std::string GMSH_ExtractElementsPlugin::getHelp() const { - strcpy(name, "Extract Elements"); -} - -void GMSH_ExtractElementsPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(ExtractElements) extracts the elements\n" + return "Plugin(ExtractElements) extracts the elements\n" "from the view `iView' whose `TimeStep'-th values\n" "(averaged by element) are comprised between\n" "`MinVal' and `MaxVal'. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(ExtractElements) creates one new view.\n"); + "Plugin(ExtractElements) creates one new view.\n"; } int GMSH_ExtractElementsPlugin::getNbOptions() const @@ -52,11 +44,6 @@ StringXNumber *GMSH_ExtractElementsPlugin::getOption(int iopt) return &ExtractElementsOptions_Number[iopt]; } -void GMSH_ExtractElementsPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "ExtractElements failed..."); -} - static void extract(std::vector<double> &inList, int inNb, std::vector<double> &outList, int *outNb, int timeStep, int nbNod, int nbComp) diff --git a/Plugin/ExtractElements.h b/Plugin/ExtractElements.h index d2278b215f..66611d0219 100644 --- a/Plugin/ExtractElements.h +++ b/Plugin/ExtractElements.h @@ -17,9 +17,8 @@ class GMSH_ExtractElementsPlugin : public GMSH_PostPlugin { public: GMSH_ExtractElementsPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "ExtractElements"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/FieldView.cpp b/Plugin/FieldView.cpp index 80b2fdea46..84becb32d7 100644 --- a/Plugin/FieldView.cpp +++ b/Plugin/FieldView.cpp @@ -21,18 +21,9 @@ extern "C" } } -void GMSH_FieldViewPlugin::getName(char *name) const +std::string GMSH_FieldViewPlugin::getHelp() const { - strcpy(name, "FieldView"); -} - -void GMSH_FieldViewPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "J. Lambrechts"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(FieldView) evaluates a field on the choosen view.\n"); + return "Plugin(FieldView) evaluates a field on the choosen view.\n"; } int GMSH_FieldViewPlugin::getNbOptions() const @@ -45,11 +36,6 @@ StringXNumber *GMSH_FieldViewPlugin::getOption(int iopt) return &FieldViewOptions_Number[iopt]; } -void GMSH_FieldViewPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "FieldView failed..."); -} - PView *GMSH_FieldViewPlugin::execute(PView *v) { //int comp = (int)FieldViewOptions_Number[0].def; diff --git a/Plugin/FieldView.h b/Plugin/FieldView.h index ed692f32a5..b381159e02 100644 --- a/Plugin/FieldView.h +++ b/Plugin/FieldView.h @@ -16,9 +16,9 @@ extern "C" class GMSH_FieldViewPlugin : public GMSH_PostPlugin { public: - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "FieldView"; } + std::string getHelp() const; + std::string getAuthor() const { return "J. Lambrechts"; } int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/FiniteElement.cpp b/Plugin/FiniteElement.cpp index b10fd745f1..ff06c77d93 100644 --- a/Plugin/FiniteElement.cpp +++ b/Plugin/FiniteElement.cpp @@ -40,23 +40,14 @@ extern "C" } } -void GMSH_FiniteElementPlugin::getName(char *name) const +std::string GMSH_FiniteElementPlugin::getHelp() const { - strcpy(name, "Finite Element"); -} - -void GMSH_FiniteElementPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(FiniteElement) solves simple PDEs\n" + return "Plugin(FiniteElement) solves simple PDEs\n" "using the finite element method. This is only\n" "intended as a demonstration tool: it is NOT\n" "intended for general use." "\n" - "Plugin(FiniteElement) creates a new view.\n"); + "Plugin(FiniteElement) creates a new view.\n"; } int GMSH_FiniteElementPlugin::getNbOptions() const @@ -79,11 +70,6 @@ StringXString *GMSH_FiniteElementPlugin::getOptionStr(int iopt) return &FiniteElementOptions_String[iopt]; } -void GMSH_FiniteElementPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "FiniteElement failed..."); -} - template<class scalar> class gmshMathEvalFunction : public gmshFunction<scalar> { private: diff --git a/Plugin/FiniteElement.h b/Plugin/FiniteElement.h index fd8c92b75e..b22e8357e0 100644 --- a/Plugin/FiniteElement.h +++ b/Plugin/FiniteElement.h @@ -17,9 +17,8 @@ class GMSH_FiniteElementPlugin : public GMSH_PostPlugin { public: GMSH_FiniteElementPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "FiniteElement"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/GSHHS.cpp b/Plugin/GSHHS.cpp index 37af2a83b4..951efd178d 100644 --- a/Plugin/GSHHS.cpp +++ b/Plugin/GSHHS.cpp @@ -56,7 +56,7 @@ public: } }; class reader_gshhs : public reader{ - /* $Id: GSHHS.cpp,v 1.31 2009-08-14 08:25:16 geuzaine Exp $ + /* $Id: GSHHS.cpp,v 1.32 2009-08-15 12:58:51 geuzaine Exp $ * * Include file defining structures used in gshhs.c * @@ -865,9 +865,9 @@ public: new_attractor(); } }; - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "GSHHS"; } + std::string getHelp() const; + std::string getAuthor() const { return "J. Lambrechts"; } int getNbOptions() const; int getNbOptionsStr() const; StringXNumber *getOption(int iopt); @@ -900,41 +900,43 @@ extern "C" } } -void GMSH_GSHHSPlugin::getName(char *name) const +std::string GMSH_GSHHSPlugin::getHelp() const { - strcpy(name, "GSHHS"); -} - -void GMSH_GSHHSPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "J. Lambrechts"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(GSHHS) read different kind of contour lines data and write a .geo file on the surface of a sphere (the Earth).\n" - "The principal application is to load GSHHS data\n (see http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html).\n" - "Valid values for \"Format\" are ):\n" - " -\"gshhs\" : open GSHHS file\n" - " -\"loops2\" : import 2D contour lines in simple text format :\n" - " NB_POINTS_IN_FIRST_LOOP FIRST_LOOP_IS_CLOSED\n" - " COORD1 COORD2\n" - " COORD1 COORD2\n" - " ... ...\n" - " NB_POINTS_IN_SECOND_LOOP SECOND_LOOP_IS_CLOSED\n" - " ...\n" - " (LOOP_IS_CLOSED specify if this coast line describe a closed curve (0=no, 1=yes).\n" - "In the case of \"loops2\" format, you can specify the the coordinate system used in the input file with the" - "\"Coordinate\" option, valid values are\n" - " -\"lonlat\" for longitude-latidute radian,\n" - " -\"lonlat_degrees\" for longitude-latitude degrees,\n" - " -\"UTM\" for universal transverse mercartor (\"UTMZone\" option should be specified)\n" - " -\"cartesian\" for full 3D coordinates\n" - "\"radius\" specify the earth radius.\n" - "If the \"iField\" option is set, consecutive points closer than the value of the field iField (in meters) will not be added.\n" - "If \"MinStraitsFactor\" >0 and if a field iField is provided, coastlines closer than MinStraitsFactor*field(IField) are merged and inner corners which form an angle < pi/3 are removed.\n" - "The output is always in stereographic coordinates, if the \"WritePolarSphere\" option is not 0, a sphere is added to the geo file.\n" - "WARNING : this plugin is still experimental and need polishing and error-handling. In particular, it will probably crash if an inexistant field id is given or if the input/output cannot be open." - ); + return + "Plugin(GSHHS) read different kind of contour lines data\n" + "and write a .geo file on the surface of a sphere (the Earth).\n" + "The principal application is to load GSHHS data\n (see\n" + "http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html).\n" + "Valid values for \"Format\" are ):\n" + " -\"gshhs\" : open GSHHS file\n" + " -\"loops2\" : import 2D contour lines in simple text format :\n" + " NB_POINTS_IN_FIRST_LOOP FIRST_LOOP_IS_CLOSED\n" + " COORD1 COORD2\n" + " COORD1 COORD2\n" + " ... ...\n" + " NB_POINTS_IN_SECOND_LOOP SECOND_LOOP_IS_CLOSED\n" + " ...\n" + " (LOOP_IS_CLOSED specify if this coast line describe a closed curve\n" + " (0=no, 1=yes).\n" + "In the case of \"loops2\" format, you can specify the the coordinate\n" + "system used in the input file with the \"Coordinate\" option, valid\n" + "values are\n" + " -\"lonlat\" for longitude-latidute radian,\n" + " -\"lonlat_degrees\" for longitude-latitude degrees,\n" + " -\"UTM\" for universal transverse mercartor (\"UTMZone\" option should\n" + " be specified)\n" + " -\"cartesian\" for full 3D coordinates\n" + " -\"radius\" specify the earth radius.\n" + "If the \"iField\" option is set, consecutive points closer than the\n" + "value of the field iField (in meters) will not be added.\n" + "If \"MinStraitsFactor\" >0 and if a field iField is provided, coastlines\n" + "closer than MinStraitsFactor*field(IField) are merged and inner corners\n" + " which form an angle < pi/3 are removed.\n" + "The output is always in stereographic coordinates, if the \"WritePolarSphere\"\n" + "option is not 0, a sphere is added to the geo file.\n" + "WARNING : this plugin is still experimental and need polishing and\n" + "error-handling. In particular, it will probably crash if an inexistant\n" + "field id is given or if the input/output cannot be open.\n"; } int GMSH_GSHHSPlugin::getNbOptions() const @@ -957,11 +959,6 @@ StringXString *GMSH_GSHHSPlugin::getOptionStr(int iopt) return &GSHHSOptions_String[iopt]; } -void GMSH_GSHHSPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "GSHHS failed..."); -} - PView *GMSH_GSHHSPlugin::execute(PView * v) { void projector(SPoint2,SPoint3); diff --git a/Plugin/Gradient.cpp b/Plugin/Gradient.cpp index 0cdecde311..5c6c1cc1a8 100644 --- a/Plugin/Gradient.cpp +++ b/Plugin/Gradient.cpp @@ -19,22 +19,13 @@ extern "C" } } -void GMSH_GradientPlugin::getName(char *name) const +std::string GMSH_GradientPlugin::getHelp() const { - strcpy(name, "Gradient"); -} - -void GMSH_GradientPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Gradient) computes the gradient of the\n" + return "Plugin(Gradient) computes the gradient of the\n" "field in the view `iView'. If `iView' < 0, the\n" "plugin is run on the current view.\n" "\n" - "Plugin(Gradient) creates one new view.\n"); + "Plugin(Gradient) creates one new view.\n"; } int GMSH_GradientPlugin::getNbOptions() const @@ -47,11 +38,6 @@ StringXNumber *GMSH_GradientPlugin::getOption(int iopt) return &GradientOptions_Number[iopt]; } -void GMSH_GradientPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Gradient failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data2, int numComp, int type) { if(numComp == 1){ diff --git a/Plugin/Gradient.h b/Plugin/Gradient.h index fb367dddef..0bf3355901 100644 --- a/Plugin/Gradient.h +++ b/Plugin/Gradient.h @@ -17,9 +17,8 @@ class GMSH_GradientPlugin : public GMSH_PostPlugin { public: GMSH_GradientPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Gradient"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/HarmonicToTime.cpp b/Plugin/HarmonicToTime.cpp index 7132eb45d3..97288ab714 100644 --- a/Plugin/HarmonicToTime.cpp +++ b/Plugin/HarmonicToTime.cpp @@ -21,18 +21,9 @@ extern "C" } } -void GMSH_HarmonicToTimePlugin::getName(char *name) const +std::string GMSH_HarmonicToTimePlugin::getHelp() const { - strcpy(name, "Harmonic to Time"); -} - -void GMSH_HarmonicToTimePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(HarmonicToTime) takes the values in the\n" + return "Plugin(HarmonicToTime) takes the values in the\n" "time steps `RealPart' and `ImaginaryPart' of\n" "the view `iView', and creates a new view\n" "containing (`iView'[`RealPart'] * cos(p) -\n" @@ -41,7 +32,7 @@ void GMSH_HarmonicToTimePlugin::getInfos(char *author, char *copyright, "If `iView' < 0, the plugin is run on the\n" "current view.\n" "\n" - "Plugin(HarmonicToTime) creates one new view.\n"); + "Plugin(HarmonicToTime) creates one new view.\n"; } int GMSH_HarmonicToTimePlugin::getNbOptions() const @@ -54,11 +45,6 @@ StringXNumber *GMSH_HarmonicToTimePlugin::getOption(int iopt) return &HarmonicToTimeOptions_Number[iopt]; } -void GMSH_HarmonicToTimePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "HarmonicToTime failed..."); -} - static std::vector<double> *incrementList(PViewDataList *data, int numComp, int type) { diff --git a/Plugin/HarmonicToTime.h b/Plugin/HarmonicToTime.h index 731f434f61..df6cc92ef9 100644 --- a/Plugin/HarmonicToTime.h +++ b/Plugin/HarmonicToTime.h @@ -17,9 +17,8 @@ class GMSH_HarmonicToTimePlugin : public GMSH_PostPlugin { public: GMSH_HarmonicToTimePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "HarmonicToTime"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/HomologyComputation.cpp b/Plugin/HomologyComputation.cpp index 80cc7e6155..0f0fa194c1 100644 --- a/Plugin/HomologyComputation.cpp +++ b/Plugin/HomologyComputation.cpp @@ -38,21 +38,12 @@ extern "C" } } -void GMSH_HomologyComputationPlugin::getName(char *name) const +std::string GMSH_HomologyComputationPlugin::getHelp() const { - strcpy(name, "Homology Computation"); -} - -void GMSH_HomologyComputationPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "Matti Pellikka (matti.pellikka@tut.fi)"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(HomologyComputation) computes generators \n" + return "Plugin(HomologyComputation) computes generators \n" "for (relative) homology groups and their thick cuts. \n" "\n" - "Plugin(HomologyComputation) creates new views.\n"); + "Plugin(HomologyComputation) creates new views.\n"; } int GMSH_HomologyComputationPlugin::getNbOptions() const @@ -75,12 +66,6 @@ StringXString *GMSH_HomologyComputationPlugin::getOptionStr(int iopt) return &HomologyComputationOptions_String[iopt]; } -void GMSH_HomologyComputationPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Homology Computation failed..."); -} - - PView *GMSH_HomologyComputationPlugin::execute(PView *v) { std::string fileName = HomologyComputationOptions_String[0].def; diff --git a/Plugin/HomologyComputation.h b/Plugin/HomologyComputation.h index b832be52c7..26f5103073 100644 --- a/Plugin/HomologyComputation.h +++ b/Plugin/HomologyComputation.h @@ -22,9 +22,9 @@ class GMSH_HomologyComputationPlugin : public GMSH_PostPlugin { public: GMSH_HomologyComputationPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "HomologyComputation"; } + std::string getHelp() const; + std::string getAuthor() const { return "M. Pellikka"; } int getNbOptions() const; StringXNumber *getOption(int iopt); int getNbOptionsStr() const; diff --git a/Plugin/Integrate.cpp b/Plugin/Integrate.cpp index 3b24166ac7..db91fa15c9 100644 --- a/Plugin/Integrate.cpp +++ b/Plugin/Integrate.cpp @@ -19,29 +19,15 @@ extern "C" } } -GMSH_IntegratePlugin::GMSH_IntegratePlugin() +std::string GMSH_IntegratePlugin::getHelp() const { - ; -} - -void GMSH_IntegratePlugin::getName(char *name) const -{ - strcpy(name, "Integrate"); -} - -void GMSH_IntegratePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Integrate) integrates scalar fields over\n" + return "Plugin(Integrate) integrates scalar fields over\n" "all the elements in the view `iView', as well\n" "as the circulation/flux of vector fields over\n" "line/surface elements. If `iView' < 0, the\n" "plugin is run on the current view.\n" "\n" - "Plugin(Integrate) creates one new view.\n"); + "Plugin(Integrate) creates one new view.\n"; } int GMSH_IntegratePlugin::getNbOptions() const @@ -54,11 +40,6 @@ StringXNumber *GMSH_IntegratePlugin::getOption(int iopt) return &IntegrateOptions_Number[iopt]; } -void GMSH_IntegratePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Integrate failed..."); -} - PView *GMSH_IntegratePlugin::execute(PView * v) { int iView = (int)IntegrateOptions_Number[0].def; diff --git a/Plugin/Integrate.h b/Plugin/Integrate.h index 0ed2e6935b..1433e5f096 100644 --- a/Plugin/Integrate.h +++ b/Plugin/Integrate.h @@ -16,10 +16,9 @@ extern "C" class GMSH_IntegratePlugin : public GMSH_PostPlugin { public: - GMSH_IntegratePlugin(); - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + GMSH_IntegratePlugin(){} + std::string getName() const { return "Integrate"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Lambda2.cpp b/Plugin/Lambda2.cpp index a1301e4787..66bfddb644 100644 --- a/Plugin/Lambda2.cpp +++ b/Plugin/Lambda2.cpp @@ -19,23 +19,9 @@ extern "C" } } -GMSH_Lambda2Plugin::GMSH_Lambda2Plugin() +std::string GMSH_Lambda2Plugin::getHelp() const { - ; -} - -void GMSH_Lambda2Plugin::getName(char *name) const -{ - strcpy(name, "Lambda2"); -} - -void GMSH_Lambda2Plugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "E. Marchandise"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Lambda2) computes the eigenvalues\n" + return "Plugin(Lambda2) computes the eigenvalues\n" "Lambda(1,2,3) of the tensor (S_ik S_kj +\n" "Om_ik Om_kj), where S_ij = 0.5 (ui,j + uj,i)\n" "and Om_ij = 0.5 (ui,j - uj,i) are respectively\n" @@ -50,7 +36,7 @@ void GMSH_Lambda2Plugin::getInfos(char *author, char *copyright, "the velocity gradient tensor. If `iView' < 0,\n" "the plugin is run on the current view.\n" "\n" - "Plugin(Lambda2) creates one new view.\n"); + "Plugin(Lambda2) creates one new view.\n"; } int GMSH_Lambda2Plugin::getNbOptions() const @@ -63,11 +49,6 @@ StringXNumber *GMSH_Lambda2Plugin::getOption(int iopt) return &Lambda2Options_Number[iopt]; } -void GMSH_Lambda2Plugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Lambda2 failed..."); -} - static int inv3x3tran(double mat[3][3], double inv[3][3], double *det) { double ud; diff --git a/Plugin/Lambda2.h b/Plugin/Lambda2.h index 9a6bf6935d..f6b4aa586a 100644 --- a/Plugin/Lambda2.h +++ b/Plugin/Lambda2.h @@ -16,10 +16,10 @@ extern "C" class GMSH_Lambda2Plugin : public GMSH_PostPlugin { public: - GMSH_Lambda2Plugin(); - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + GMSH_Lambda2Plugin(){} + std::string getName() const { return "Lambda2"; } + std::string getHelp() const; + std::string getAuthor() const { return "E. Marchandise"; } int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/LongitudeLatitude.cpp b/Plugin/LongitudeLatitude.cpp index 077a761f72..2838fb322d 100644 --- a/Plugin/LongitudeLatitude.cpp +++ b/Plugin/LongitudeLatitude.cpp @@ -18,22 +18,13 @@ extern "C" } } -void GMSH_LongituteLatitudePlugin::getName(char *name) const +std::string GMSH_LongituteLatitudePlugin::getHelp() const { - strcpy(name, "LongituteLatitude"); -} - -void GMSH_LongituteLatitudePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "J. Lambrechts"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(LongituteLatitude) Project the view `iView'\n" + return "Plugin(LongituteLatitude) Project the view `iView'\n" "in Longitude-Latitude. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(LongituteLatitude) is executed in place.\n"); + "Plugin(LongituteLatitude) is executed in place.\n"; } int GMSH_LongituteLatitudePlugin::getNbOptions() const @@ -46,11 +37,6 @@ StringXNumber *GMSH_LongituteLatitudePlugin::getOption(int iopt) return &LongituteLatitudeOptions_Number[iopt]; } -void GMSH_LongituteLatitudePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "LongituteLatitude failed..."); -} - PView *GMSH_LongituteLatitudePlugin::execute(PView *v) { int iView = (int)LongituteLatitudeOptions_Number[0].def; diff --git a/Plugin/LongitudeLatitude.h b/Plugin/LongitudeLatitude.h index cdb84c437e..8c44703db3 100644 --- a/Plugin/LongitudeLatitude.h +++ b/Plugin/LongitudeLatitude.h @@ -16,9 +16,9 @@ extern "C" class GMSH_LongituteLatitudePlugin : public GMSH_PostPlugin { public: - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "LongitudeLatitude"; } + std::string getHelp() const; + std::string getAuthor() const { return "J. Lambrechts"; } int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/MakeSimplex.cpp b/Plugin/MakeSimplex.cpp index 62f6a85364..c4409248ed 100644 --- a/Plugin/MakeSimplex.cpp +++ b/Plugin/MakeSimplex.cpp @@ -17,30 +17,16 @@ extern "C" } } -GMSH_MakeSimplexPlugin::GMSH_MakeSimplexPlugin() +std::string GMSH_MakeSimplexPlugin::getHelp() const { - ; -} - -void GMSH_MakeSimplexPlugin::getName(char *name) const -{ - strcpy(name, "Make Simplex"); -} - -void GMSH_MakeSimplexPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(MakeSimplex) decomposes all non-\n" + return "Plugin(MakeSimplex) decomposes all non-\n" "simplectic elements (quadrangles, prisms,\n" "hexahedra, pyramids) in the view `iView' into\n" "simplices (triangles, tetrahedra). If `iView' < 0,\n" "the plugin is run on the current view.\n" "\n" "Plugin(MakeSimplex) is executed\n" - "in-place.\n"); + "in-place.\n"; } int GMSH_MakeSimplexPlugin::getNbOptions() const @@ -53,11 +39,6 @@ StringXNumber *GMSH_MakeSimplexPlugin::getOption(int iopt) return &MakeSimplexOptions_Number[iopt]; } -void GMSH_MakeSimplexPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "MakeSimplex failed..."); -} - static void decomposeList(PViewDataList *data, int nbNod, int nbComp, std::vector<double> &listIn, int *nbIn, std::vector<double> &listOut, int *nbOut) diff --git a/Plugin/MakeSimplex.h b/Plugin/MakeSimplex.h index 2a4531b0ce..e9ec5ca910 100644 --- a/Plugin/MakeSimplex.h +++ b/Plugin/MakeSimplex.h @@ -16,10 +16,9 @@ extern "C" class GMSH_MakeSimplexPlugin : public GMSH_PostPlugin { public: - GMSH_MakeSimplexPlugin(); - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + GMSH_MakeSimplexPlugin(){} + std::string getName() const { return "MakeSimplex"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/ModulusPhase.cpp b/Plugin/ModulusPhase.cpp index d77ac7dcc4..5a9df02caf 100644 --- a/Plugin/ModulusPhase.cpp +++ b/Plugin/ModulusPhase.cpp @@ -19,25 +19,16 @@ extern "C" } } -void GMSH_ModulusPhasePlugin::getName(char *name) const +std::string GMSH_ModulusPhasePlugin::getHelp() const { - strcpy(name, "Modulus Phase"); -} - -void GMSH_ModulusPhasePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(ModulusPhase) interprets the time steps\n" + return "Plugin(ModulusPhase) interprets the time steps\n" "`realPart' and `imaginaryPart' in the view `iView'\n" "as the real and imaginary parts of a complex field\n" "and replaces them with their corresponding\n" "modulus and phase. If `iView' < 0, the plugin is\n" "run on the current view.\n" "\n" - "Plugin(ModulusPhase) is executed in-place.\n"); + "Plugin(ModulusPhase) is executed in-place.\n"; } int GMSH_ModulusPhasePlugin::getNbOptions() const @@ -50,11 +41,6 @@ StringXNumber *GMSH_ModulusPhasePlugin::getOption(int iopt) return &ModulusPhaseOptions_Number[iopt]; } -void GMSH_ModulusPhasePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "ModulusPhase failed..."); -} - PView *GMSH_ModulusPhasePlugin::execute(PView *v) { int rIndex = (int)ModulusPhaseOptions_Number[0].def; diff --git a/Plugin/ModulusPhase.h b/Plugin/ModulusPhase.h index ca8210dfa5..7b73954208 100644 --- a/Plugin/ModulusPhase.h +++ b/Plugin/ModulusPhase.h @@ -17,9 +17,8 @@ class GMSH_ModulusPhasePlugin : public GMSH_PostPlugin { public: GMSH_ModulusPhasePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "ModulusPhase"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index ca4725e1b3..c7057a26a1 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -3,8 +3,15 @@ // See the LICENSE.txt file for license information. Please report all // bugs and problems to <gmsh@geuz.org>. +#include <stdio.h> #include "Plugin.h" +void GMSH_Plugin::catchErrorMessage(char *errorMessage) const +{ + std::string str = getName() + "failed..."; + strcpy(errorMessage, str.c_str()); +} + PView *GMSH_PostPlugin::getView(int index, PView *view) { if(index < 0) diff --git a/Plugin/Plugin.h b/Plugin/Plugin.h index 63dcadcb33..daef4658d9 100644 --- a/Plugin/Plugin.h +++ b/Plugin/Plugin.h @@ -13,8 +13,7 @@ // Some Plugins are default gmsh plugins and are insterted directly // in the executable. I think that it's a good way to start. -#include <string.h> -#include <stdio.h> +#include <string> #include "Options.h" #include "GmshMessage.h" #include "PView.h" @@ -46,12 +45,14 @@ class GMSH_Plugin // return plugin type, name and info virtual GMSH_PLUGIN_TYPE getType() const = 0; - virtual void getName(char *name) const = 0; - virtual void getInfos(char *author, char *copyright, char *helpText) const = 0; + virtual std::string getName() const = 0; + virtual std::string getHelp() const = 0; + virtual std::string getAuthor() const { return "C. Geuzaine, J.-F. Remacle"; } + virtual std::string getCopyright() const { return "C. Geuzaine, J.-F. Remacle"; } // when an error is thrown by the plugin, the plugin manager will // show the message and hopefully continue - virtual void catchErrorMessage(char *errorMessage) const = 0; + virtual void catchErrorMessage(char *errorMessage) const; // gmsh-style numeric options virtual int getNbOptions() const = 0; diff --git a/Plugin/PluginManager.cpp b/Plugin/PluginManager.cpp index 54a7232cff..59e04320ad 100644 --- a/Plugin/PluginManager.cpp +++ b/Plugin/PluginManager.cpp @@ -5,8 +5,8 @@ #include <map> #include <stdlib.h> - #include "GmshConfig.h" +#include "StringUtils.h" #include "Context.h" #include "Plugin.h" #include "PluginManager.h" @@ -58,19 +58,16 @@ const char *GMSH_PluginEntry = "GMSH_RegisterPlugin"; PluginManager *PluginManager::_instance = 0; -PluginManager::PluginManager() -{ -} - PluginManager::~PluginManager() { - for(iter it = allPlugins.begin(); it != allPlugins.end(); ++it) + for(std::map<std::string, GMSH_Plugin*>::iterator it = allPlugins.begin(); + it != allPlugins.end(); ++it) delete(*it).second; } -GMSH_Plugin *PluginManager::find(char *pluginName) +GMSH_Plugin *PluginManager::find(std::string pluginName) { - iter it = allPlugins.find(pluginName); + std::map<std::string, GMSH_Plugin*>::iterator it = allPlugins.find(pluginName); if(it == allPlugins.end()) return 0; return (*it).second; @@ -78,8 +75,8 @@ GMSH_Plugin *PluginManager::find(char *pluginName) GMSH_SolverPlugin *PluginManager::findSolverPlugin() { - iter it = allPlugins.begin(); - iter ite = allPlugins.end(); + std::map<std::string, GMSH_Plugin*>::iterator it = allPlugins.begin(); + std::map<std::string, GMSH_Plugin*>::iterator ite = allPlugins.end(); for (; it != ite; ++it) { GMSH_Plugin *p = (*it).second; if(p->getType() == GMSH_Plugin::GMSH_SOLVER_PLUGIN) { @@ -89,54 +86,42 @@ GMSH_SolverPlugin *PluginManager::findSolverPlugin() return 0; } -void PluginManager::action(char *pluginName, char *action, void *data) +void PluginManager::action(std::string pluginName, std::string action, void *data) { GMSH_Plugin *plugin = find(pluginName); - if(!plugin) - throw "Unknown plugin name"; + if(!plugin) throw "Unknown plugin name"; - if(!strcmp(action, "Run")) + if(action == "Run") plugin->run(); else throw "Unknown plugin action"; } -void PluginManager::setPluginOption(char *pluginName, char *option, - char *value) +void PluginManager::setPluginOption(std::string pluginName, std::string option, + std::string value) { GMSH_Plugin *plugin = find(pluginName); - - if(!plugin) - throw "Unknown plugin name"; + if(!plugin) throw "Unknown plugin name"; for(int i = 0; i < plugin->getNbOptionsStr(); i++) { - StringXString *sxs; - // get the ith option of the plugin - sxs = plugin->getOptionStr(i); - // look if it's the good option name - if(!strcmp(sxs->str, option)) { + StringXString *sxs = plugin->getOptionStr(i); + if(option == std::string(sxs->str)) { sxs->def = value; return; } } - throw "Unknown plugin option name"; } -void PluginManager::setPluginOption(char *pluginName, char *option, +void PluginManager::setPluginOption(std::string pluginName, std::string option, double value) { GMSH_Plugin *plugin = find(pluginName); - - if(!plugin) - throw "Unknown plugin name"; + if(!plugin) throw "Unknown plugin name"; for(int i = 0; i < plugin->getNbOptions(); i++) { - StringXNumber *sxn; - // get the ith option of the plugin - sxn = plugin->getOption(i); - // look if it's the good option name - if(!strcmp(sxn->str, option)) { + StringXNumber *sxn = plugin->getOption(i); + if(option == std::string(sxn->str)) { sxn->def = value; return; } @@ -146,9 +131,7 @@ void PluginManager::setPluginOption(char *pluginName, char *option, PluginManager *PluginManager::instance() { - if(!_instance) { - _instance = new PluginManager; - } + if(!_instance) _instance = new PluginManager; return _instance; } @@ -159,98 +142,93 @@ void PluginManager::registerDefaultPlugins() } if(CTX::instance()->post.plugins){ - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("StreamLines", GMSH_RegisterStreamLinesPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutGrid", GMSH_RegisterCutGridPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutMap", GMSH_RegisterCutMapPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutPlane", GMSH_RegisterCutPlanePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutSphere", GMSH_RegisterCutSpherePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Skin", GMSH_RegisterSkinPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Extract", GMSH_RegisterExtractPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ExtractElements", GMSH_RegisterExtractElementsPlugin())); #if 0 // waiting for BDS rewrite - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ExtractEdges", GMSH_RegisterExtractEdgesPlugin())); #endif - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("MakeSimplex", GMSH_RegisterMakeSimplexPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Smooth", GMSH_RegisterSmoothPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Transform", GMSH_RegisterTransformPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("LongitudeLatitude",GMSH_RegisterLongituteLatitudePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Warp", GMSH_RegisterWarpPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("SphericalRaise", GMSH_RegisterSphericalRaisePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ModulusPhase", GMSH_RegisterModulusPhasePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Integrate", GMSH_RegisterIntegratePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Gradient", GMSH_RegisterGradientPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Curl", GMSH_RegisterCurlPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Divergence", GMSH_RegisterDivergencePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Annotate", GMSH_RegisterAnnotatePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Remove", GMSH_RegisterRemovePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Eigenvectors", GMSH_RegisterEigenvectorsPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Eigenvalues", GMSH_RegisterEigenvaluesPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Lambda2", GMSH_RegisterLambda2Plugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Probe", GMSH_RegisterProbePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("FieldView", GMSH_RegisterFieldViewPlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Triangulate", GMSH_RegisterTriangulatePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("GSHHS", GMSH_RegisterGSHHSPlugin())); #if defined(HAVE_MATH_EVAL) - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Evaluate", GMSH_RegisterEvaluatePlugin())); - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutParametric", GMSH_RegisterCutParametricPlugin())); #endif - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("FiniteElement", GMSH_RegisterFiniteElementPlugin())); #if defined(HAVE_KBIPACK) - allPlugins.insert(std::pair<const char*, GMSH_Plugin*> + allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("HomologyComputation", GMSH_RegisterHomologyComputationPlugin())); #endif } #if defined(HAVE_FLTK) - char *homeplugins = getenv("GMSHPLUGINSHOME"); - if(!homeplugins) return; + char *pluginsHome = getenv("GMSHPLUGINSHOME"); + if(!pluginsHome) return; struct dirent **list; - int nbFiles = fl_filename_list(homeplugins, &list); + int nbFiles = fl_filename_list(pluginsHome, &list); if(nbFiles <= 0) return; for(int i = 0; i < nbFiles; i++) { - char *name = list[i]->d_name; - if(strlen(name) > 3) { - char ext[6]; - strcpy(ext, name + (strlen(name) - 3)); - if(!strcmp(ext, ".so") || !strcmp(ext, "dll")) { - addPlugin(homeplugins, name); - } - } + std::string ext = SplitFileName(list[i]->d_name)[2]; + if(ext == ".so" || ext == ".dll") + addPlugin(list[i]->d_name); } for(int i = 0; i < nbFiles; i++) free(list[i]); @@ -258,42 +236,36 @@ void PluginManager::registerDefaultPlugins() #endif } -void PluginManager::addPlugin(char *dirName, char *pluginName) +void PluginManager::addPlugin(std::string fileName) { #if defined(HAVE_NO_DLL) || !defined(HAVE_FLTK) Msg::Warning("No dynamic plugin loading on this platform"); #else - char dynamic_lib[1024]; - char plugin_name[256]; - char plugin_author[256]; - char plugin_copyright[256]; - char plugin_help[1024]; - class GMSH_Plugin *(*registerPlugin) (void); - sprintf(dynamic_lib, "%s/%s", dirName, pluginName); - Msg::Info("Opening Plugin '%s'", dynamic_lib); - void *hlib = dlopen(dynamic_lib, RTLD_NOW); + Msg::Info("Opening Plugin '%s'", fileName.c_str()); + void *hlib = dlopen(fileName.c_str(), RTLD_NOW); const char *err = dlerror(); if(!hlib){ - Msg::Warning("Error in opening %s (dlerror = %s)", dynamic_lib, err); + Msg::Warning("Could not open '%s' (dlerror = %s)", fileName.c_str(), err); return; } + + class GMSH_Plugin *(*registerPlugin) (void); registerPlugin = (class GMSH_Plugin * (*)(void))dlsym(hlib, GMSH_PluginEntry); err = dlerror(); if(err){ - Msg::Warning("Symbol '%s' missing in plugin '%s' (dlerror = %s)", - GMSH_PluginEntry, pluginName, err); + Msg::Warning("Symbol '%s' missing in '%s' (dlerror = %s)", + GMSH_PluginEntry, fileName.c_str(), err); return; } GMSH_Plugin *p = registerPlugin(); p->hlib = hlib; - p->getName(plugin_name); - p->getInfos(plugin_author, plugin_copyright, plugin_help); - if(allPlugins.find(plugin_name) != allPlugins.end()) { - Msg::Warning("Plugin '%s' multiply defined", pluginName); + if(allPlugins.find(p->getName()) != allPlugins.end()) { + Msg::Warning("Plugin '%s' multiply defined", fileName.c_str()); return; } - allPlugins.insert(std::pair<const char*, GMSH_Plugin*>(plugin_name, p)); - Msg::Info("Loaded Plugin '%s' (%s)", plugin_name, plugin_author); + + allPlugins.insert(std::pair<std::string, GMSH_Plugin*>(p->getName(), p)); + Msg::Info("Loaded Plugin '%s' (%s)", p->getName().c_str(), p->getAuthor().c_str()); #endif } diff --git a/Plugin/PluginManager.h b/Plugin/PluginManager.h index c43d2e0638..6504545408 100644 --- a/Plugin/PluginManager.h +++ b/Plugin/PluginManager.h @@ -6,30 +6,21 @@ #ifndef _PLUGIN_MANAGER_H_ #define _PLUGIN_MANAGER_H_ -#include <cstring> #include <map> +#include <string> class GMSH_Plugin; class GMSH_SolverPlugin; -struct ltstrpg -{ - bool operator()(const char* s1, const char* s2) const - { - return strcmp(s1, s2) < 0; - } -}; - class PluginManager { private: - PluginManager(); + PluginManager(){} static PluginManager *_instance; - std::map<const char*, GMSH_Plugin*, ltstrpg> allPlugins; + std::map<std::string, GMSH_Plugin*> allPlugins; public : virtual ~PluginManager(); - typedef std::map<const char*, GMSH_Plugin*, ltstrpg>::iterator iter; // register all the plugins that are in $(GMSHPLUGINSHOME). (Note // that loading a .so is not what is usually called a 'plugin': we @@ -39,28 +30,30 @@ class PluginManager static PluginManager *instance(); // Dynamically add a plugin pluginName.so in dirName - void addPlugin(char *dirName, char *pluginName); + void addPlugin(std::string fileName); // Uninstall a given plugin - void uninstallPlugin(char *pluginName); + void uninstallPlugin(std::string pluginName); // Set an option to a value in plugin named pluginName - void setPluginOption(char *pluginName, char *option, double value); - void setPluginOption(char *pluginName, char *option, char *value); + void setPluginOption(std::string pluginName, std::string option, + double value); + void setPluginOption(std::string pluginName, std::string option, + std::string value); // Iterator on plugins - inline iter begin(){ return allPlugins.begin(); } - inline iter end(){ return allPlugins.end(); } + std::map<std::string, GMSH_Plugin*>::iterator begin(){ return allPlugins.begin(); } + std::map<std::string, GMSH_Plugin*>::iterator end(){ return allPlugins.end(); } // Find a plugin named pluginName - GMSH_Plugin *find(char *pluginName); + GMSH_Plugin *find(std::string pluginName); // Get The ONLY Solver Plugin GMSH_SolverPlugin *findSolverPlugin(); // Perform an action on the plugin. Default action are Run and // Save. Other plugins may perform other actions. - void action(char *pluginMane, char *action, void *data); + void action(std::string pluginName, std::string action, void *data); }; #endif diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp index 0090235a7e..28baaf2db4 100644 --- a/Plugin/Probe.cpp +++ b/Plugin/Probe.cpp @@ -99,22 +99,13 @@ double GMSH_ProbePlugin::callbackZ(int num, int action, double value) return callback(num, action, value, &ProbeOptions_Number[2].def); } -void GMSH_ProbePlugin::getName(char *name) const +std::string GMSH_ProbePlugin::getHelp() const { - strcpy(name, "Probe"); -} - -void GMSH_ProbePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Probe) gets the value of the view `iView' at\n" + return "Plugin(Probe) gets the value of the view `iView' at\n" "the point (`X',`Y',`Z'). If `iView' < 0, the plugin is\n" "run on the current view.\n" "\n" - "Plugin(Probe) creates one new view.\n"); + "Plugin(Probe) creates one new view.\n"; } int GMSH_ProbePlugin::getNbOptions() const @@ -127,11 +118,6 @@ StringXNumber *GMSH_ProbePlugin::getOption(int iopt) return &ProbeOptions_Number[iopt]; } -void GMSH_ProbePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Probe failed..."); -} - PView *GMSH_ProbePlugin::execute(PView *v) { double x = ProbeOptions_Number[0].def; diff --git a/Plugin/Probe.h b/Plugin/Probe.h index bd8879111e..8a4eab7a7d 100644 --- a/Plugin/Probe.h +++ b/Plugin/Probe.h @@ -20,9 +20,8 @@ class GMSH_ProbePlugin : public GMSH_PostPlugin static int iview; public: GMSH_ProbePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Probe"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Remove.cpp b/Plugin/Remove.cpp index 325db88e29..2c7c56e0fc 100644 --- a/Plugin/Remove.cpp +++ b/Plugin/Remove.cpp @@ -30,22 +30,13 @@ extern "C" } } -void GMSH_RemovePlugin::getName(char *name) const +std::string GMSH_RemovePlugin::getHelp() const { - strcpy(name, "Remove"); -} - -void GMSH_RemovePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Remove) removes the marked items\n" + return "Plugin(Remove) removes the marked items\n" "from the view `iView'. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(Remove) is executed in-place.\n"); + "Plugin(Remove) is executed in-place.\n"; } int GMSH_RemovePlugin::getNbOptions() const @@ -58,11 +49,6 @@ StringXNumber *GMSH_RemovePlugin::getOption(int iopt) return &RemoveOptions_Number[iopt]; } -void GMSH_RemovePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Remove failed..."); -} - PView *GMSH_RemovePlugin::execute(PView *v) { int iView = (int)RemoveOptions_Number[13].def; diff --git a/Plugin/Remove.h b/Plugin/Remove.h index aec2d06d93..7f3f5793a0 100644 --- a/Plugin/Remove.h +++ b/Plugin/Remove.h @@ -17,9 +17,8 @@ class GMSH_RemovePlugin : public GMSH_PostPlugin { public: GMSH_RemovePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Remove"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index 3156d783ac..efe2b03332 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -20,21 +20,13 @@ extern "C" } } -void GMSH_SkinPlugin::getName(char *name) const +std::string GMSH_SkinPlugin::getHelp() const { - strcpy(name, "Skin"); -} - -void GMSH_SkinPlugin::getInfos(char *author, char *copyright, char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Skin) extracts the skin (the boundary) of\n" + return "Plugin(Skin) extracts the skin (the boundary) of\n" "the view `iView'. If `iView' < 0, the plugin is run\n" "on the current view.\n" "\n" - "Plugin(Skin) creates one new view.\n"); + "Plugin(Skin) creates one new view.\n"; } int GMSH_SkinPlugin::getNbOptions() const @@ -47,11 +39,6 @@ StringXNumber *GMSH_SkinPlugin::getOption(int iopt) return &SkinOptions_Number[iopt]; } -void GMSH_SkinPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Skin failed..."); -} - class ElmData { public: int numComp; diff --git a/Plugin/Skin.h b/Plugin/Skin.h index f7082cf5ff..150ca9e613 100644 --- a/Plugin/Skin.h +++ b/Plugin/Skin.h @@ -17,9 +17,8 @@ class GMSH_SkinPlugin : public GMSH_PostPlugin { public: GMSH_SkinPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Skin"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp index 28a1531ce2..1aea6a82c7 100644 --- a/Plugin/Smooth.cpp +++ b/Plugin/Smooth.cpp @@ -17,22 +17,13 @@ extern "C" } } -void GMSH_SmoothPlugin::getName(char *name) const +std::string GMSH_SmoothPlugin::getHelp() const { - strcpy(name, "Smooth"); -} - -void GMSH_SmoothPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Smooth) averages the values at the nodes\n" + return "Plugin(Smooth) averages the values at the nodes\n" "of the scalar view `iView'. If `iView' < 0, the\n" "plugin is run on the current view.\n" "\n" - "Plugin(Smooth) is executed in-place.\n"); + "Plugin(Smooth) is executed in-place.\n"; } int GMSH_SmoothPlugin::getNbOptions() const @@ -45,11 +36,6 @@ StringXNumber *GMSH_SmoothPlugin::getOption(int iopt) return &SmoothOptions_Number[iopt]; } -void GMSH_SmoothPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Smooth failed..."); -} - PView *GMSH_SmoothPlugin::execute(PView *v) { int iView = (int)SmoothOptions_Number[0].def; diff --git a/Plugin/Smooth.h b/Plugin/Smooth.h index 8ac56c603a..d53c57a36e 100644 --- a/Plugin/Smooth.h +++ b/Plugin/Smooth.h @@ -17,9 +17,8 @@ class GMSH_SmoothPlugin : public GMSH_PostPlugin { public: GMSH_SmoothPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Smooth"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp index f74f07eaf0..53de2a7023 100644 --- a/Plugin/SphericalRaise.cpp +++ b/Plugin/SphericalRaise.cpp @@ -24,18 +24,9 @@ extern "C" } } -void GMSH_SphericalRaisePlugin::getName(char *name) const +std::string GMSH_SphericalRaisePlugin::getHelp() const { - strcpy(name, "Spherical Raise"); -} - -void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(SphericalRaise) transforms the\n" + return "Plugin(SphericalRaise) transforms the\n" "coordinates of the elements in the view\n" "`iView' using the values associated with the\n" "`TimeStep'-th time step. Instead of elevating\n" @@ -49,7 +40,7 @@ void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, "If `iView' < 0, the plugin is run on the current\n" "view.\n" "\n" - "Plugin(SphericalRaise) is executed in-place.\n"); + "Plugin(SphericalRaise) is executed in-place.\n"; } int GMSH_SphericalRaisePlugin::getNbOptions() const @@ -62,11 +53,6 @@ StringXNumber *GMSH_SphericalRaisePlugin::getOption(int iopt) return &SphericalRaiseOptions_Number[iopt]; } -void GMSH_SphericalRaisePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "SphericalRaise failed..."); -} - PView *GMSH_SphericalRaisePlugin::execute(PView *v) { double center[3]; diff --git a/Plugin/SphericalRaise.h b/Plugin/SphericalRaise.h index 8ee260113d..8dec8f7bdd 100644 --- a/Plugin/SphericalRaise.h +++ b/Plugin/SphericalRaise.h @@ -17,9 +17,8 @@ class GMSH_SphericalRaisePlugin : public GMSH_PostPlugin { public: GMSH_SphericalRaisePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "SphericalRaise"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp index 6800e1bd46..93a55f8b54 100644 --- a/Plugin/StreamLines.cpp +++ b/Plugin/StreamLines.cpp @@ -140,18 +140,9 @@ double GMSH_StreamLinesPlugin::callbackV(int num, int action, double value) 1, 1, 100); } -void GMSH_StreamLinesPlugin::getName(char *name) const +std::string GMSH_StreamLinesPlugin::getHelp() const { - strcpy(name, "Stream Lines"); -} - -void GMSH_StreamLinesPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(StreamLines) computes stream lines\n" + return "Plugin(StreamLines) computes stream lines\n" "from the `TimeStep'-th time step of a vector\n" "view `iView' and optionally interpolates the\n" "scalar view `dView' on the resulting stream\n" @@ -172,7 +163,7 @@ void GMSH_StreamLinesPlugin::getInfos(char *author, char *copyright, "\n" "Plugin(StreamLines) creates one new view. This\n" "view contains multi-step vector points if `dView'\n" - "< 0, or single-step scalar lines if `dView' >= 0.\n"); + "< 0, or single-step scalar lines if `dView' >= 0.\n"; } int GMSH_StreamLinesPlugin::getNbOptions() const @@ -185,11 +176,6 @@ StringXNumber *GMSH_StreamLinesPlugin::getOption(int iopt) return &StreamLinesOptions_Number[iopt]; } -void GMSH_StreamLinesPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "StreamLines failed..."); -} - int GMSH_StreamLinesPlugin::getNbU() { return (int)StreamLinesOptions_Number[9].def; diff --git a/Plugin/StreamLines.h b/Plugin/StreamLines.h index 4207529888..a3a4800951 100644 --- a/Plugin/StreamLines.h +++ b/Plugin/StreamLines.h @@ -19,9 +19,8 @@ class GMSH_StreamLinesPlugin : public GMSH_PostPlugin double step, double min, double max); public: GMSH_StreamLinesPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "StreamLines"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp index 2319b2f5ca..74f385cba9 100644 --- a/Plugin/Transform.cpp +++ b/Plugin/Transform.cpp @@ -30,18 +30,9 @@ extern "C" } } -void GMSH_TransformPlugin::getName(char *name) const +std::string GMSH_TransformPlugin::getHelp() const { - strcpy(name, "Transform"); -} - -void GMSH_TransformPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Transform) transforms the homogeneous\n" + return "Plugin(Transform) transforms the homogeneous\n" "node coordinates (x,y,z,1) of the elements in\n" "the view `iView' by the matrix\n" "[`A11' `A12' `A13' `Tx']\n" @@ -51,7 +42,7 @@ void GMSH_TransformPlugin::getInfos(char *author, char *copyright, "elements is reversed. If `iView' < 0, the plugin\n" "is run on the current view.\n" "\n" - "Plugin(Transform) is executed in-place.\n"); + "Plugin(Transform) is executed in-place.\n"; } int GMSH_TransformPlugin::getNbOptions() const @@ -64,11 +55,6 @@ StringXNumber *GMSH_TransformPlugin::getOption(int iopt) return &TransformOptions_Number[iopt]; } -void GMSH_TransformPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Transform failed..."); -} - PView *GMSH_TransformPlugin::execute(PView *v) { double mat[3][4]; diff --git a/Plugin/Transform.h b/Plugin/Transform.h index 6732293f2d..2384d9bad3 100644 --- a/Plugin/Transform.h +++ b/Plugin/Transform.h @@ -17,9 +17,8 @@ class GMSH_TransformPlugin : public GMSH_PostPlugin { public: GMSH_TransformPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Transform"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 17738fcb03..971da9cc5c 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -24,24 +24,15 @@ extern "C" } } -void GMSH_TriangulatePlugin::getName(char *name) const +std::string GMSH_TriangulatePlugin::getHelp() const { - strcpy(name, "Triangulate"); -} - -void GMSH_TriangulatePlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Triangulate) triangulates the points in the\n" + return "Plugin(Triangulate) triangulates the points in the\n" "view `iView', assuming that all the points belong\n" "to a surface that can be projected one-to-one\n" "onto a plane. If `iView' < 0, the plugin is run on\n" "the current view.\n" "\n" - "Plugin(Triangulate) creates one new view.\n"); + "Plugin(Triangulate) creates one new view.\n"; } int GMSH_TriangulatePlugin::getNbOptions() const @@ -54,11 +45,6 @@ StringXNumber *GMSH_TriangulatePlugin::getOption(int iopt) return &TriangulateOptions_Number[iopt]; } -void GMSH_TriangulatePlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Triangulate failed..."); -} - class PointData : public MVertex { public: std::vector<double> v; diff --git a/Plugin/Triangulate.h b/Plugin/Triangulate.h index f8a280ab19..4b804c7ad0 100644 --- a/Plugin/Triangulate.h +++ b/Plugin/Triangulate.h @@ -17,9 +17,8 @@ class GMSH_TriangulatePlugin : public GMSH_PostPlugin { public: GMSH_TriangulatePlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *helpText) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Triangulate"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber* getOption(int iopt); PView *execute(PView *); diff --git a/Plugin/Warp.cpp b/Plugin/Warp.cpp index 207f5487da..dacea71d84 100644 --- a/Plugin/Warp.cpp +++ b/Plugin/Warp.cpp @@ -23,18 +23,9 @@ extern "C" } } -void GMSH_WarpPlugin::getName(char *name) const +std::string GMSH_WarpPlugin::getHelp() const { - strcpy(name, "Warp"); -} - -void GMSH_WarpPlugin::getInfos(char *author, char *copyright, - char *help_text) const -{ - strcpy(author, "C. Geuzaine, J.-F. Remacle"); - strcpy(copyright, "C. Geuzaine, J.-F. Remacle"); - strcpy(help_text, - "Plugin(Warp) transforms the elements in the\n" + return "Plugin(Warp) transforms the elements in the\n" "view `iView' by adding to their node coordinates\n" "the vector field stored in the `TimeStep'-th time\n" "step of the view `dView', scaled by `Factor'. If\n" @@ -45,7 +36,7 @@ void GMSH_WarpPlugin::getInfos(char *author, char *copyright, "parameter.) If `iView' < 0, the plugin is run on\n" "the current view.\n" "\n" - "Plugin(Warp) is executed in-place.\n"); + "Plugin(Warp) is executed in-place.\n"; } int GMSH_WarpPlugin::getNbOptions() const @@ -58,11 +49,6 @@ StringXNumber *GMSH_WarpPlugin::getOption(int iopt) return &WarpOptions_Number[iopt]; } -void GMSH_WarpPlugin::catchErrorMessage(char *errorMessage) const -{ - strcpy(errorMessage, "Warp failed..."); -} - PView *GMSH_WarpPlugin::execute(PView *v) { double factor = WarpOptions_Number[0].def; diff --git a/Plugin/Warp.h b/Plugin/Warp.h index deb87e3cc8..fbd8cee35d 100644 --- a/Plugin/Warp.h +++ b/Plugin/Warp.h @@ -17,9 +17,8 @@ class GMSH_WarpPlugin : public GMSH_PostPlugin { public: GMSH_WarpPlugin(){} - void getName(char *name) const; - void getInfos(char *author, char *copyright, char *help_text) const; - void catchErrorMessage(char *errorMessage) const; + std::string getName() const { return "Warp"; } + std::string getHelp() const; int getNbOptions() const; StringXNumber *getOption(int iopt); PView *execute(PView *); -- GitLab