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"
{
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
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
......@@ -51,10 +51,12 @@ void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const
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)
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
/*we cut the othe map by the iso A of the View iView */
double A;
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:
GMSH_CutMapPlugin(double A, int IVIEW);
virtual void getName (char *name) const;
......@@ -20,6 +20,6 @@ public:
char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const;
virtual StringXNumber* GetOption (int iopt);
};
#endif
......@@ -49,9 +49,9 @@ int GMSH_CutPlanePlugin::getNbOptions() const
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
......@@ -59,7 +59,7 @@ void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const
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;
}
......@@ -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
{
/*Plane a x + b y + c z + d = 0*/
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:
GMSH_CutPlanePlugin(double A, double B, double C, double D);
virtual void getName (char *name) const;
......@@ -20,6 +20,6 @@ public:
char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const;
virtual StringXNumber *GetOption (int iopt);
};
#endif
......@@ -45,9 +45,9 @@ int GMSH_CutSpherePlugin::getNbOptions() const
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
......@@ -55,7 +55,7 @@ void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const
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;
}
......
......@@ -10,7 +10,7 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin
{
/*Sphere (x-a)^2 + (y-b)^2 + (z-c)^2 - r^2 = 0*/
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:
GMSH_CutSpherePlugin(double A, double B, double C, double R);
virtual void getName (char *name) const;
......@@ -19,6 +19,6 @@ public:
char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const;
virtual int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const;
virtual StringXNumber* GetOption (int iopt);
};
#endif
......@@ -24,8 +24,8 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
double *X = (double*)List_Pointer_Fast(v->SS,i);
double *Y = (double*)List_Pointer_Fast(v->SS,i+4);
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);
for(int j=0;j<4;j++)levels[j] = levelset(X[j],Y[j],Z[j],VAL[j]);
int nx = 0;
for(k=0;k<6;k++)
{
......@@ -69,8 +69,11 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v)
sprintf(name,"cut-%s",v->Name);
sprintf(filename,"cut-%s",v->FileName);
EndView(1, filename, name);
Msg(INFO, "new %s view with %d tris\n",name,List_Nbr(ActualView->ST));
return ActualView;
}
Msg(INFO, "nothing ta da\n");
return 0;
}
......
......@@ -4,7 +4,7 @@
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:
virtual Post_View *execute (Post_View *);
};
......
......@@ -37,6 +37,53 @@ GMSH_PluginManager::~GMSH_PluginManager()
++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()
{
if(!instance)
......@@ -51,9 +98,9 @@ void GMSH_PluginManager::RegisterDefaultPlugins()
struct dirent **list;
char ext[6];
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Plane" ,GMSH_RegisterCutPlanePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Sphere" ,GMSH_RegisterCutSpherePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Map" ,GMSH_RegisterCutMapPlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutPlane" ,GMSH_RegisterCutPlanePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutSphere" ,GMSH_RegisterCutSpherePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("CutMap" ,GMSH_RegisterCutMapPlugin()));
char *homeplugins = getenv ("GMSHPLUGINSHOME");
if(!homeplugins)return;
......
......@@ -46,7 +46,9 @@ public :
virtual void CatchErrorMessage (char *errorMessage) const = 0;
/* gmsh style option, ca be loaded, saved and set*/
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
......@@ -55,9 +57,12 @@ public :
class GMSH_Post_Plugin : public GMSH_Plugin
{
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,
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;
};
......
......@@ -37,12 +37,20 @@ public :
static GMSH_PluginManager *Instance();
/** Dynamically add a plugin pluginName.so in dirName*/
void AddPlugin(char *dirName, char *pluginName);
void CallPlugin (char *name);
void DestroyPlugin (char *name);
void StPluginOption (char *pluginName, char *option, void *value);
iter begin() {return allPlugins.begin();}
iter end() {return allPlugins.end();}
iter find(char *c) {return allPlugins.find(c);}
// uninstall a given plugin
void UninstallPlugin (char *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);
// 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment