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

*** empty log message ***

parent f1a481eb
No related branches found
No related tags found
No related merge requests found
#include "CutPlane.h"
//#include "Views.h"
/*
Plugin Entry : GMSH_RegisterPlugin
*/
GMSH_Plugin *GMSH_RegisterPlugin ()
{
return new GMSH_CutPlanePlugin (1.0,0.0,0.0,0.0);
}
GMSH_CutPlanePlugin::GMSH_CutPlanePlugin(double A, double B, double C, double D)
:a(A),b(B),c(C),d(D)
{
}
void GMSH_CutPlanePlugin::getName(char *name) const
{
strcpy(name,"Cut Plane");
}
void GMSH_CutPlanePlugin::getInfos(char *author, char *copyright, char *help_text) const
{
strcpy(author,"J.-F. Remacle (remacle@scorec.rpi.edu)");
strcpy(copyright,"DGR (www.multiphysics.com)");
strcpy(help_text,"This Plugins cuts a view with a plane a x + b y + c z + d = 0");
}
int GMSH_CutPlanePlugin::getNbOptions() const
{
return 4;
}
void GMSH_CutPlanePlugin:: GetOption (int iopt, char *optionName, void *optionValue) const
{
// geuz, t'es le specialiste des options, regarde comment
// on pourrait faire Plugin.CutPlane.a = 1.0;
}
void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const
{
strcpy(errorMessage,"CutPlane Failed...");
}
Post_View *GMSH_CutPlanePlugin::execute (Post_View *)
{
throw this;
}
void GMSH_CutPlanePlugin::SetOption (char *optionName, void *optionValue)
{
}
#ifndef _CUTPLANE_H_
#define _CUTPLANE_H
#include "Plugin.h"
class GMSH_CutPlanePlugin : public GMSH_Post_Plugin
{
/*Plane a x + b y + c z + d = 0*/
double a,b,c,d;
public:
GMSH_CutPlanePlugin(double A, double B, double C, double D);
virtual void getName (char *name) const;
virtual void getInfos (char *author,
char *copyright,
char *help_text) const;
virtual void CatchErrorMessage (char *errorMessage) const;
virtual void SetOption (char *optionName, void *optionValue);
virtual int getNbOptions() const;
virtual void GetOption (int iopt, char *optionName, void *optionValue) const;
virtual Post_View *execute (Post_View *);
};
#endif
# $Id: Makefile,v 1.1 2001-03-04 20:57:49 remacle Exp $
#
# Makefile for "libAdapt.a"
#
.IGNORE:
CC = c++
AR = c++ -shared -o
RM = rm
RANLIB = ranlib
LIB = ../lib/libCutPlane.so
INCLUDE = -I../../Common -I../
C_FLAGS = -g -Wall
OS_FLAGS =
VERSION_FLAGS =
RMFLAGS = -f
CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(VERSION_FLAGS) $(INCLUDE)
SRC = CutPlane.cpp
OBJ = $(SRC:.cpp=.o)
.SUFFIXES: .o .cpp
$(LIB): $(OBJ)
$(AR) $(LIB) $(OBJ)
.cpp.o:
$(CC) $(CFLAGS) -c $<
clean:
$(RM) $(RMFLAGS) *.o
lint:
$(LINT) $(CFLAGS) $(SRC)
depend:
(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
$(CC) -MM $(CFLAGS) ${SRC} \
) >Makefile.new
cp Makefile Makefile.bak
cp Makefile.new Makefile
$(RM) $(RMFLAGS) Makefile.new
# DO NOT DELETE THIS LINE
# $Id: Makefile,v 1.1 2001-03-04 19:55:25 remacle Exp $
# $Id: Makefile,v 1.2 2001-03-04 20:57:03 remacle Exp $
#
# Makefile for "libAdapt.a"
#
......@@ -11,7 +11,7 @@ RM = rm
RANLIB = ranlib
LIB = ../lib/libPlugin.a
INCLUDE = -I../Common -I../DataStr
INCLUDE = -I../Common
C_FLAGS = -g -Wall
OS_FLAGS =
......
......@@ -2,8 +2,15 @@
#include <dlfcn.h>
#include <map>
#include "Plugin.h"
#include "Message.h"
using namespace std;
#if defined(WIN32) && !defined(__CYGWIN__)
#define SLASH "\\"
#else
#define SLASH "/"
#endif
struct ltstr
{
bool operator()(const char* s1, const char* s2) const
......@@ -42,12 +49,16 @@ GMSH_PluginManager* GMSH_PluginManager::Instance()
if(!instance)
{
instance = new GMSH_PluginManager;
instance->RegisterDefaultPlugins();
}
return instance;
}
void GMSH_PluginManager::RegisterDefaultPlugins()
{
// For testing
AddPlugin ("/cygdrive/c/develop/gmsh/Plugin/lib/","libCutPlane");
return;
char *homeplugins = getenv ("GMSHPLUGINSHOME");
if(!homeplugins)return;
......@@ -55,19 +66,27 @@ void GMSH_PluginManager::RegisterDefaultPlugins()
void GMSH_PluginManager::AddPlugin( char *dirName, char *pluginName)
{
#if defined(WIN32) && !defined(__CYGWIN__)
Msg(WARNING,"Plugins not yet implemented for WIN32 native compiler");
return;
#else
char dynamic_lib[1024];
char plugin_name[256];
class GMSH_Plugin* (*RegisterPlugin)(void);
sprintf(dynamic_lib,"%s/%s.so",dirName,pluginName);
sprintf(dynamic_lib,"%s%s%s.so",dirName,SLASH,pluginName);
Msg(INFO,"Opening Plugin %s",dynamic_lib);
void *hlib = dlopen (dynamic_lib,RTLD_NOW);
char *err = dlerror();
if(hlib == NULL)
{
throw dynamic_lib;
Msg(WARNING,"Error in opening %s (dlerror = %s)",dynamic_lib,err);
return;
}
RegisterPlugin = (class GMSH_Plugin* (*)(void)) dlsym(hlib,GMSH_PluginEntry);
char *err = dlerror();
err = dlerror();
if(err != NULL)
{
Msg(WARNING,"Symbol %s missing in Plugin %s (dlerror = %s)",GMSH_PluginEntry,pluginName,err);
return;
}
......@@ -76,9 +95,11 @@ void GMSH_PluginManager::AddPlugin( char *dirName, char *pluginName)
p->getName(plugin_name);
if(allPlugins->find(plugin_name) != allPlugins->end())
{
Msg(WARNING,"Plugin %s Multiply defined",pluginName);
return;
}
allPlugins->m[plugin_name] = p;
#endif
}
......
......@@ -11,6 +11,8 @@
const char *GMSH_PluginEntry = "GMSH_RegisterPlugin";
class PluginContainer;
class Post_View;
class GMSH_Plugin
{
public :
......@@ -18,11 +20,11 @@ public :
used by the PluginManager, just forget it*/
void *hlib;
/* 3 kind of plugins, one for cad, one for mesh, one for postpro*/
typedef enum GMSH_PLUGIN_TYPE {GMSH_CAD_PLUGIN, GMSH_MESH_PLUGIN, GMSH_POSTPRO_PLUGIN};
typedef enum GMSH_PLUGIN_TYPE {GMSH_CAD_PLUGIN, GMSH_MESH_PLUGIN, GMSH_POST_PLUGIN};
/* returns the type of plugin for downcasting GMSH_Plugin into
GMSH_CAD_Plugin, GMSH_Mesh_Plugin and GMSH_Post_Plugin */
virtual GMSH_PLUGIN_TYPE getType() const = 0;
virtual void getName (char *name);
virtual void getName (char *name) const = 0;
virtual void getInfos (char *author,
char *copyright,
char *help_text) const = 0;
......@@ -31,8 +33,20 @@ public :
virtual void CatchErrorMessage (char *errorMessage) const = 0;
/* gmsh style option, ca be loaded, saved and set*/
virtual void SetOption (char *optionName, void *optionValue) = 0;
virtual int getNbOptions() const;
virtual void GetOption (char *optionName, void *optionValue) const = 0;
virtual int getNbOptions() const = 0;
virtual void GetOption (int iopt, char *optionName, void *optionValue) const = 0;
};
/* Base class for Post-Processing Plugins
The user can either modify or duplicate
a Post_View */
class GMSH_Post_Plugin : public GMSH_Plugin
{
public:
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 Post_View *execute (Post_View *) = 0;
};
class GMSH_PluginManager
......@@ -58,3 +72,4 @@ public :
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment