Skip to content
Snippets Groups Projects
Commit d440a3dd authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

*** empty log message ***

parent 3f259e9a
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ extern "C" ...@@ -14,7 +14,7 @@ extern "C"
{ {
GMSH_Plugin *GMSH_RegisterCutMapPlugin () GMSH_Plugin *GMSH_RegisterCutMapPlugin ()
{ {
return new GMSH_CutMapPlugin (1.0,1); return new GMSH_CutMapPlugin (1.5,1);
} }
} }
...@@ -41,9 +41,9 @@ int GMSH_CutMapPlugin::getNbOptions() const ...@@ -41,9 +41,9 @@ int GMSH_CutMapPlugin::getNbOptions() const
return 2; return 2;
} }
void GMSH_CutMapPlugin:: GetOption (int iopt, StringXNumber *option) const StringXNumber *GMSH_CutMapPlugin:: GetOption (int iopt)
{ {
*option = CutMapOptions_Number[iopt]; return &CutMapOptions_Number[iopt];
} }
void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const
...@@ -51,10 +51,12 @@ void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const ...@@ -51,10 +51,12 @@ void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const
strcpy(errorMessage,"CutMap Failed..."); strcpy(errorMessage,"CutMap Failed...");
} }
double GMSH_CutMapPlugin :: levelset (double x, double y, double z) const double GMSH_CutMapPlugin :: levelset (double x, double y, double z, double val) const
{ {
// we must look into the map for A - Map(x,y,z) // we must look into the map for A - Map(x,y,z)
return A; // this is the case when the map is the same as the view,
// the result is the extraction of isovalue A
return A - val;
} }
......
...@@ -11,7 +11,7 @@ class GMSH_CutMapPlugin : public GMSH_LevelsetPlugin ...@@ -11,7 +11,7 @@ class GMSH_CutMapPlugin : public GMSH_LevelsetPlugin
/*we cut the othe map by the iso A of the View iView */ /*we cut the othe map by the iso A of the View iView */
double A; double A;
int iView; int iView;
virtual double levelset (double x, double y, double z) const; virtual double levelset (double x, double y, double z, double val) const;
public: public:
GMSH_CutMapPlugin(double A, int IVIEW); GMSH_CutMapPlugin(double A, int IVIEW);
virtual void getName (char *name) const; virtual void getName (char *name) const;
...@@ -20,6 +20,6 @@ public: ...@@ -20,6 +20,6 @@ public:
char *help_text) const; char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const; virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const; virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const; virtual StringXNumber* GetOption (int iopt);
}; };
#endif #endif
...@@ -49,9 +49,9 @@ int GMSH_CutPlanePlugin::getNbOptions() const ...@@ -49,9 +49,9 @@ int GMSH_CutPlanePlugin::getNbOptions() const
return 4; return 4;
} }
void GMSH_CutPlanePlugin:: GetOption (int iopt, StringXNumber *option) const StringXNumber* GMSH_CutPlanePlugin:: GetOption (int iopt)
{ {
*option = CutPlaneOptions_Number[iopt]; return &CutPlaneOptions_Number[iopt];
} }
void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const
...@@ -59,7 +59,7 @@ void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const ...@@ -59,7 +59,7 @@ void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const
strcpy(errorMessage,"CutPlane Failed..."); strcpy(errorMessage,"CutPlane Failed...");
} }
double GMSH_CutPlanePlugin :: levelset (double x, double y, double z) const double GMSH_CutPlanePlugin :: levelset (double x, double y, double z, double val) const
{ {
return a * x + b * y + c * z + d; return a * x + b * y + c * z + d;
} }
...@@ -68,5 +68,3 @@ double GMSH_CutPlanePlugin :: levelset (double x, double y, double z) const ...@@ -68,5 +68,3 @@ double GMSH_CutPlanePlugin :: levelset (double x, double y, double z) const
...@@ -11,7 +11,7 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin ...@@ -11,7 +11,7 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin
{ {
/*Plane a x + b y + c z + d = 0*/ /*Plane a x + b y + c z + d = 0*/
double a,b,c,d; double a,b,c,d;
virtual double levelset (double x, double y, double z) const; virtual double levelset (double x, double y, double z, double val) const;
public: public:
GMSH_CutPlanePlugin(double A, double B, double C, double D); GMSH_CutPlanePlugin(double A, double B, double C, double D);
virtual void getName (char *name) const; virtual void getName (char *name) const;
...@@ -20,6 +20,6 @@ public: ...@@ -20,6 +20,6 @@ public:
char *help_text) const; char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const; virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const; virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const; virtual StringXNumber *GetOption (int iopt);
}; };
#endif #endif
...@@ -45,9 +45,9 @@ int GMSH_CutSpherePlugin::getNbOptions() const ...@@ -45,9 +45,9 @@ int GMSH_CutSpherePlugin::getNbOptions() const
return 4; return 4;
} }
void GMSH_CutSpherePlugin:: GetOption (int iopt, StringXNumber *option) const StringXNumber* GMSH_CutSpherePlugin:: GetOption (int iopt)
{ {
*option = CutSphereOptions_Number[iopt]; return &CutSphereOptions_Number[iopt];
} }
void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const
...@@ -55,7 +55,7 @@ void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const ...@@ -55,7 +55,7 @@ void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const
strcpy(errorMessage,"CutSphere Failed..."); strcpy(errorMessage,"CutSphere Failed...");
} }
double GMSH_CutSpherePlugin :: levelset (double x, double y, double z) const double GMSH_CutSpherePlugin :: levelset (double x, double y, double z, double val) const
{ {
return (x-a)*(x-a) + (y-b)*(y-b) + (z-c)*(z-c) - r*r; return (x-a)*(x-a) + (y-b)*(y-b) + (z-c)*(z-c) - r*r;
} }
......
...@@ -10,7 +10,7 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin ...@@ -10,7 +10,7 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin
{ {
/*Sphere (x-a)^2 + (y-b)^2 + (z-c)^2 - r^2 = 0*/ /*Sphere (x-a)^2 + (y-b)^2 + (z-c)^2 - r^2 = 0*/
double a,b,c,r; double a,b,c,r;
virtual double levelset (double x, double y, double z) const; virtual double levelset (double x, double y, double z, double val) const;
public: public:
GMSH_CutSpherePlugin(double A, double B, double C, double R); GMSH_CutSpherePlugin(double A, double B, double C, double R);
virtual void getName (char *name) const; virtual void getName (char *name) const;
...@@ -19,6 +19,6 @@ public: ...@@ -19,6 +19,6 @@ public:
char *help_text) const; char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const; virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const; virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const; virtual StringXNumber* GetOption (int iopt);
}; };
#endif #endif
...@@ -24,8 +24,8 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) ...@@ -24,8 +24,8 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
double *X = (double*)List_Pointer_Fast(v->SS,i); double *X = (double*)List_Pointer_Fast(v->SS,i);
double *Y = (double*)List_Pointer_Fast(v->SS,i+4); double *Y = (double*)List_Pointer_Fast(v->SS,i+4);
double *Z = (double*)List_Pointer_Fast(v->SS,i+8); double *Z = (double*)List_Pointer_Fast(v->SS,i+8);
for(int j=0;j<4;j++)levels[j] = levelset(X[j],Y[j],Z[j]);
double *VAL = (double*)List_Pointer_Fast(v->SS,i+12); double *VAL = (double*)List_Pointer_Fast(v->SS,i+12);
for(int j=0;j<4;j++)levels[j] = levelset(X[j],Y[j],Z[j],VAL[j]);
int nx = 0; int nx = 0;
for(k=0;k<6;k++) for(k=0;k<6;k++)
{ {
...@@ -69,8 +69,11 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) ...@@ -69,8 +69,11 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
sprintf(name,"cut-%s",v->Name); sprintf(name,"cut-%s",v->Name);
sprintf(filename,"cut-%s",v->FileName); sprintf(filename,"cut-%s",v->FileName);
EndView(1, filename, name); EndView(1, filename, name);
Msg(INFO, "new %s view with %d tris\n",name,List_Nbr(ActualView->ST));
return ActualView; return ActualView;
} }
Msg(INFO, "nothing ta da\n");
return 0; return 0;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
class GMSH_LevelsetPlugin : public GMSH_Post_Plugin class GMSH_LevelsetPlugin : public GMSH_Post_Plugin
{ {
virtual double levelset (double x, double y, double z) const = 0; virtual double levelset (double x, double y, double z, double val) const = 0;
public: public:
virtual Post_View *execute (Post_View *); virtual Post_View *execute (Post_View *);
}; };
......
...@@ -37,6 +37,53 @@ GMSH_PluginManager::~GMSH_PluginManager() ...@@ -37,6 +37,53 @@ GMSH_PluginManager::~GMSH_PluginManager()
++it)delete (*it).second; ++it)delete (*it).second;
} }
GMSH_Plugin* GMSH_PluginManager::find (char *pluginName)
{
iter it = allPlugins.find(pluginName);
if ( it == allPlugins.end()) return 0;
return (*it).second;
}
void GMSH_PluginManager::Action( char *pluginName, char *action, void *data)
{
GMSH_Plugin * plugin = find(pluginName);
if(!plugin)
{
throw 1;
}
if(!strcmp(action,"Run"))
{
plugin->Run();
}
else if(!strcmp(action,"Save"))
{
plugin->Save();
}
else
{
throw 1;
}
}
void GMSH_PluginManager::SetPluginOption (char *pluginName, char *option, double value)
{
GMSH_Plugin *plugin = find(pluginName);
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))
{
sxn->def = value;
return;
}
}
throw "Unknown Plugin Option Name";
}
GMSH_PluginManager* GMSH_PluginManager::Instance() GMSH_PluginManager* GMSH_PluginManager::Instance()
{ {
if(!instance) if(!instance)
...@@ -51,9 +98,9 @@ void GMSH_PluginManager::RegisterDefaultPlugins() ...@@ -51,9 +98,9 @@ void GMSH_PluginManager::RegisterDefaultPlugins()
struct dirent **list; struct dirent **list;
char ext[6]; char ext[6];
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Plane" ,GMSH_RegisterCutPlanePlugin())); allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutPlane" ,GMSH_RegisterCutPlanePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Sphere" ,GMSH_RegisterCutSpherePlugin())); allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutSphere" ,GMSH_RegisterCutSpherePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Map" ,GMSH_RegisterCutMapPlugin())); allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutMap" ,GMSH_RegisterCutMapPlugin()));
char *homeplugins = getenv ("GMSHPLUGINSHOME"); char *homeplugins = getenv ("GMSHPLUGINSHOME");
if(!homeplugins)return; if(!homeplugins)return;
......
...@@ -46,7 +46,9 @@ public : ...@@ -46,7 +46,9 @@ public :
virtual void CatchErrorMessage (char *errorMessage) const = 0; virtual void CatchErrorMessage (char *errorMessage) const = 0;
/* gmsh style option, ca be loaded, saved and set*/ /* gmsh style option, ca be loaded, saved and set*/
virtual int getNbOptions() const = 0; virtual int getNbOptions() const = 0;
virtual void GetOption (int iopt, StringXNumber *option) const = 0; virtual StringXNumber *GetOption (int iopt) = 0;
virtual void Save() const = 0;
virtual void Run() const = 0;
}; };
/* Base class for Post-Processing Plugins /* Base class for Post-Processing Plugins
...@@ -55,9 +57,12 @@ public : ...@@ -55,9 +57,12 @@ public :
class GMSH_Post_Plugin : public GMSH_Plugin class GMSH_Post_Plugin : public GMSH_Plugin
{ {
public: public:
GMSH_PLUGIN_TYPE getType() const {return GMSH_Plugin::GMSH_POST_PLUGIN;} inline GMSH_PLUGIN_TYPE getType() const
{return GMSH_Plugin::GMSH_POST_PLUGIN;}
/* If returned pointer is the same as the argument, then view is simply modified, /* If returned pointer is the same as the argument, then view is simply modified,
else, a new view is added in the view list */ else, a new view is added in the view list */
virtual void Run() const {};
virtual void Save() const {};
virtual Post_View *execute (Post_View *) = 0; virtual Post_View *execute (Post_View *) = 0;
}; };
......
...@@ -37,12 +37,20 @@ public : ...@@ -37,12 +37,20 @@ public :
static GMSH_PluginManager *Instance(); static GMSH_PluginManager *Instance();
/** Dynamically add a plugin pluginName.so in dirName*/ /** Dynamically add a plugin pluginName.so in dirName*/
void AddPlugin(char *dirName, char *pluginName); void AddPlugin(char *dirName, char *pluginName);
void CallPlugin (char *name); // uninstall a given plugin
void DestroyPlugin (char *name); void UninstallPlugin (char *pluginName);
void StPluginOption (char *pluginName, char *option, void *value); // set an option to a value in plugin named pluginName
iter begin() {return allPlugins.begin();} void SetPluginOption (char *pluginName, char *option, double value);
iter end() {return allPlugins.end();} void SetPluginOption (char *pluginName, char *option, char * value);
iter find(char *c) {return allPlugins.find(c);} // iterator on plugins
inline iter begin() {return allPlugins.begin();}
inline iter end() {return allPlugins.end();}
// find a plugin named pluginName
GMSH_Plugin *find(char *pluginName);
// 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);
}; };
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment