From edda69e0b068e50f45598425285532702319c59b Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Tue, 13 Mar 2001 22:51:23 +0000 Subject: [PATCH] *** empty log message *** --- Plugin/CutMap.cpp | 64 +++++++++++++++++++++++++++++ Plugin/CutPlane.cpp | 71 +++++++++++++++++++++++++++++++++ Plugin/CutSphere.cpp | 65 ++++++++++++++++++++++++++++++ Plugin/LevelsetPlugin.cpp | 84 +++++++++++++++++++++++++++++++++++++++ Plugin/Makefile | 4 +- Plugin/Plugin.cpp | 3 +- 6 files changed, 288 insertions(+), 3 deletions(-) create mode 100644 Plugin/CutMap.cpp create mode 100644 Plugin/CutPlane.cpp create mode 100644 Plugin/CutSphere.cpp create mode 100644 Plugin/LevelsetPlugin.cpp diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp new file mode 100644 index 0000000000..de1bdb99a7 --- /dev/null +++ b/Plugin/CutMap.cpp @@ -0,0 +1,64 @@ +#include "CutMap.h" + +double opt_cut_map_A(OPT_ARGS_NUM) +{ +} + +StringXNumber CutMapOptions_Number[] = { + { GMSH_FULLRC, "A" , opt_cut_map_A , 1. }, + { GMSH_FULLRC, "iView" , opt_cut_map_A , 1. } +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutMapPlugin () + { + return new GMSH_CutMapPlugin (1.0,1.); + } +} + + +GMSH_CutMapPlugin::GMSH_CutMapPlugin(double a, int I) + :A(a),iView(I) +{ +} + +void GMSH_CutMapPlugin::getName(char *name) const +{ + strcpy(name,"Cut Map"); +} + +void GMSH_CutMapPlugin::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 \n with a plane (x-xc)^2 + (y-yc)^2 + (z-zc)^2 = r^20\n"); +} + +int GMSH_CutMapPlugin::getNbOptions() const +{ + return 2; +} + +void GMSH_CutMapPlugin:: GetOption (int iopt, StringXNumber *option) const +{ + *option = CutMapOptions_Number[iopt]; +} + +void GMSH_CutMapPlugin::CatchErrorMessage (char *errorMessage) const +{ + strcpy(errorMessage,"CutMap Failed..."); +} + +double GMSH_CutMapPlugin :: levelset (double x, double y, double z) const +{ + // we must look into the map for A - Map(x,y,z) + return A; +} + + + + + + + diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp new file mode 100644 index 0000000000..d0dbb20f5e --- /dev/null +++ b/Plugin/CutPlane.cpp @@ -0,0 +1,71 @@ +#include "CutPlane.h" + +/* + Plugin Entry : GMSH_RegisterPlugin + */ + +// that's the bad part of the story ... + +double opt_cut_plane_A(OPT_ARGS_NUM) +{ +} + +StringXNumber CutPlaneOptions_Number[] = { + { GMSH_FULLRC, "A" , opt_cut_plane_A , 1. }, + { GMSH_FULLRC, "B" , opt_cut_plane_A , 1. }, + { GMSH_FULLRC, "C" , opt_cut_plane_A , 1. }, + { GMSH_FULLRC, "D" , opt_cut_plane_A , 1. } +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutPlanePlugin () + { + return new GMSH_CutPlanePlugin (1.0,0.0,0.0,0.01); + } +} + + +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 \n with a plane a x + b y + c z + d = 0\n"); +} + +int GMSH_CutPlanePlugin::getNbOptions() const +{ + return 4; +} + +void GMSH_CutPlanePlugin:: GetOption (int iopt, StringXNumber *option) const +{ + *option = CutPlaneOptions_Number[iopt]; +} + +void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const +{ + strcpy(errorMessage,"CutPlane Failed..."); +} + +double GMSH_CutPlanePlugin :: levelset (double x, double y, double z) const +{ + return a * x + b * y + c * z + d; +} + + + + + + + diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp new file mode 100644 index 0000000000..460b9bb6c3 --- /dev/null +++ b/Plugin/CutSphere.cpp @@ -0,0 +1,65 @@ +#include "CutSphere.h" + +double opt_cut_sphere_Xc(OPT_ARGS_NUM) +{ +} + +StringXNumber CutSphereOptions_Number[] = { + { GMSH_FULLRC, "Xc" , opt_cut_sphere_Xc , 1. }, + { GMSH_FULLRC, "Yc" , opt_cut_sphere_Xc , 1. }, + { GMSH_FULLRC, "Zc" , opt_cut_sphere_Xc , 1. }, + { GMSH_FULLRC, "R" , opt_cut_sphere_Xc , 1. } +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutSpherePlugin () + { + return new GMSH_CutSpherePlugin (0.0,0.0,0.0,.25); + } +} + + +GMSH_CutSpherePlugin::GMSH_CutSpherePlugin(double A, double B, double C, double D) + :a(A),b(B),c(C),r(D) +{ +} + +void GMSH_CutSpherePlugin::getName(char *name) const +{ + strcpy(name,"Cut Sphere"); +} + +void GMSH_CutSpherePlugin::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 \n with a plane (x-xc)^2 + (y-yc)^2 + (z-zc)^2 = r^20\n"); +} + +int GMSH_CutSpherePlugin::getNbOptions() const +{ + return 4; +} + +void GMSH_CutSpherePlugin:: GetOption (int iopt, StringXNumber *option) const +{ + *option = CutSphereOptions_Number[iopt]; +} + +void GMSH_CutSpherePlugin::CatchErrorMessage (char *errorMessage) const +{ + strcpy(errorMessage,"CutSphere Failed..."); +} + +double GMSH_CutSpherePlugin :: levelset (double x, double y, double z) const +{ + return (x-a)*(x-a) + (y-b)*(y-b) + (z-c)*(z-c) - r*r; +} + + + + + + + diff --git a/Plugin/LevelsetPlugin.cpp b/Plugin/LevelsetPlugin.cpp new file mode 100644 index 0000000000..1e8c8f95fe --- /dev/null +++ b/Plugin/LevelsetPlugin.cpp @@ -0,0 +1,84 @@ +#include "LevelSetPlugin.h" +#include "List.h" +#include "Views.h" +#include "Iso.h" +#include "Message.h" + +// that's the bad part of the story ... +extern Post_View *ActualView; + +Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) +{ + /* + This plugin creates a new view which is the result of + a cut of the actual view with a levelset. + */ + int k,i,nb,edtet[6][2] = {{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}}; + // for all scalar simplices + if(v->NbSS) + { + BeginView(1,0); + nb = List_Nbr(v->SS) / v->NbSS ; + for(i = 0 ; i < List_Nbr(v->SS) ; i+=nb) + { + double levels[6],Xp[6],Yp[6],Zp[6],myVals[6]; + 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); + int nx = 0; + for(k=0;k<6;k++) + { + if(levels[edtet[k][0]] * levels[edtet[k][1]] <= 0.0) + { + double coef = InterpolateIso(X,Y,Z,levels,0.0, + edtet[k][0],edtet[k][1], + &Xp[nx],&Yp[nx],&Zp[nx]); + myVals[nx] = coef * (VAL[edtet[k][1]] - VAL[edtet[k][0]]) + + VAL[edtet[k][0]]; + nx++; + } + } + if(nx == 3 || nx == 4) + { + for(k=0;k<3;k++)List_Add(ActualView->ST, &Xp[k]); + for(k=0;k<3;k++)List_Add(ActualView->ST, &Yp[k]); + for(k=0;k<3;k++)List_Add(ActualView->ST, &Zp[k]); + for(k=0;k<3;k++)List_Add(ActualView->ST, &myVals[k]); + ActualView->NbST++; + } + if(nx == 4) + { + double xx = Xp[3]; + double yy = Yp[3]; + double zz = Zp[3]; + Xp[3] = Xp[2]; + Yp[3] = Yp[2]; + Zp[3] = Zp[2]; + Xp[2] = xx; + Yp[2] = yy; + Zp[2] = zz; + for(k=1;k<4;k++)List_Add(ActualView->ST, &Xp[k %4]); + for(k=1;k<4;k++)List_Add(ActualView->ST, &Yp[k % 4]); + for(k=1;k<4;k++)List_Add(ActualView->ST, &Zp[k % 4]); + for(k=1;k<4;k++)List_Add(ActualView->ST, &myVals[k %4]); + ActualView->NbST++; + } + } + char name[1024],filename[1024]; + sprintf(name,"cut-%s",v->Name); + sprintf(filename,"cut-%s",v->FileName); + EndView(1, 0, filename, name); + return ActualView; + } + return 0; +} + + + + + + + + diff --git a/Plugin/Makefile b/Plugin/Makefile index c51c18aa27..1ee00ce503 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.5 2001-03-10 20:27:02 remacle Exp $ +# $Id: Makefile,v 1.6 2001-03-13 22:51:23 remacle Exp $ # # Makefile for "libAdapt.a" # @@ -20,7 +20,7 @@ VERSION_FLAGS = RMFLAGS = -f CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(VERSION_FLAGS) $(INCLUDE) $(GUI_INCLUDE) -SRC = Plugin.cpp CutPlane.cpp CutSphere.cpp LevelsetPlugin.cpp +SRC = Plugin.cpp CutPlane.cpp CutSphere.cpp LevelsetPlugin.cpp CutMap.cpp OBJ = $(SRC:.cpp=.o) diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index e594d36d94..f7f8cf66e3 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -7,6 +7,7 @@ #include <FL/filename.H> #include "CutPlane.h" #include "CutSphere.h" +#include "CutMap.h" using namespace std; @@ -48,7 +49,7 @@ void GMSH_PluginManager::RegisterDefaultPlugins() 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())); char *homeplugins = getenv ("GMSHPLUGINSHOME"); if(!homeplugins)return; -- GitLab