From a1781e7c7ca65013df03c9bcdb3e05404a9c4b97 Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Sun, 4 Mar 2001 20:57:49 +0000 Subject: [PATCH] *** empty log message *** --- Plugin/Cutplane/CutPlane.cpp | 54 ++++++++++++++++++++++++++++++++++++ Plugin/Cutplane/CutPlane.h | 20 +++++++++++++ Plugin/Cutplane/Makefile | 49 ++++++++++++++++++++++++++++++++ Plugin/Makefile | 4 +-- Plugin/Plugin.cpp | 27 ++++++++++++++++-- Plugin/Plugin.h | 25 +++++++++++++---- 6 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 Plugin/Cutplane/CutPlane.cpp create mode 100644 Plugin/Cutplane/CutPlane.h create mode 100644 Plugin/Cutplane/Makefile diff --git a/Plugin/Cutplane/CutPlane.cpp b/Plugin/Cutplane/CutPlane.cpp new file mode 100644 index 0000000000..618456f0e1 --- /dev/null +++ b/Plugin/Cutplane/CutPlane.cpp @@ -0,0 +1,54 @@ +#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) +{ +} + + diff --git a/Plugin/Cutplane/CutPlane.h b/Plugin/Cutplane/CutPlane.h new file mode 100644 index 0000000000..5624284d1a --- /dev/null +++ b/Plugin/Cutplane/CutPlane.h @@ -0,0 +1,20 @@ +#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 diff --git a/Plugin/Cutplane/Makefile b/Plugin/Cutplane/Makefile new file mode 100644 index 0000000000..0353e3e665 --- /dev/null +++ b/Plugin/Cutplane/Makefile @@ -0,0 +1,49 @@ +# $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 diff --git a/Plugin/Makefile b/Plugin/Makefile index 8bf2a2e74e..c6c6a64f55 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $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 = diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index 001267d55e..deeb835651 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -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 } diff --git a/Plugin/Plugin.h b/Plugin/Plugin.h index d66966a9a2..dfdf148e41 100644 --- a/Plugin/Plugin.h +++ b/Plugin/Plugin.h @@ -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,9 +33,21 @@ 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 : + -- GitLab