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

*** empty log message ***

parent 9fac4d7b
No related branches found
No related tags found
No related merge requests found
#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;
}
#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;
}
#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;
}
#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;
}
# $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" # Makefile for "libAdapt.a"
# #
...@@ -20,7 +20,7 @@ VERSION_FLAGS = ...@@ -20,7 +20,7 @@ VERSION_FLAGS =
RMFLAGS = -f RMFLAGS = -f
CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(VERSION_FLAGS) $(INCLUDE) $(GUI_INCLUDE) 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) OBJ = $(SRC:.cpp=.o)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <FL/filename.H> #include <FL/filename.H>
#include "CutPlane.h" #include "CutPlane.h"
#include "CutSphere.h" #include "CutSphere.h"
#include "CutMap.h"
using namespace std; using namespace std;
...@@ -48,7 +49,7 @@ void GMSH_PluginManager::RegisterDefaultPlugins() ...@@ -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 Plane" ,GMSH_RegisterCutPlanePlugin()));
allPlugins.insert(std::pair<char*,GMSH_Plugin*>("Cut Sphere" ,GMSH_RegisterCutSpherePlugin())); 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"); char *homeplugins = getenv ("GMSHPLUGINSHOME");
if(!homeplugins)return; if(!homeplugins)return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment