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

*** empty log message ***

parent e369b79b
No related branches found
No related tags found
No related merge requests found
#include "CutPlane.h"
#include "List.h"
#include "Views.h"
#include "Iso.h"
/*
Plugin Entry : GMSH_RegisterPlugin
*/
double opt_cut_plane_A(OPT_ARGS_NUM)
{
}
StringXNumber CutPlaneOptions_Number[] = {
{ GMSH_FULLRC, "A" , opt_cut_plane_A , 1. }
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutPlanePlugin ()
{
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, StringXNumber *option) const
{
*option = CutPlaneOptions_Number[iopt];
}
void GMSH_CutPlanePlugin::CatchErrorMessage (char *errorMessage) const
{
strcpy(errorMessage,"CutPlane Failed...");
}
Post_View *GMSH_CutPlanePlugin::execute (Post_View *v)
{
int i,nb,edtet[6][2] = {{0,1},{0,2},{0,3},{1,2},{1,3},{2,3}};
// for all scalar simplices
if(v->NbSS)
{
nb = List_Nbr(v->ST) / v->NbST ;
for(i = 0 ; i < List_Nbr(v->ST) ; i+=nb)
{
double levels[4],Xp[4],Yp[4],Zp[4];
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(int k=0;k<6;k++)
{
if(levels[edtet[k][0]] * levels[edtet[k][1]] <= 0.0)
{
InterpolateIso(X,Y,Z,levels,0.0,
edtet[k][0],edtet[k][1],
&Xp[nx],&Yp[nx],&Zp[nx]);
nx++;
}
}
if(nx == 3)
{
}
}
}
return 0;
}
double GMSH_CutPlanePlugin :: levelset (double x, double y, double z)
{
return a * x + b * y + c * z + d;
}
#ifndef _CUTPLANE_H_
#define _CUTPLANE_H
#include "../Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterCutPlanePlugin ();
}
class GMSH_CutPlanePlugin : public GMSH_Post_Plugin
{
/*Plane a x + b y + c z + d = 0*/
double a,b,c,d;
virtual double levelset (double x, double y, double z);
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 int getNbOptions() const;
virtual void GetOption (int iopt, StringXNumber *option) const;
virtual Post_View *execute (Post_View *);
};
#endif
# $Id: Makefile,v 1.5 2001-03-10 19:55:07 remacle Exp $
#
# Makefile for "libAdapt.a"
#
.IGNORE:
CC = c++
AR = ar ruvs
RM = rm
RANLIB = ranlib
LIB = ../../lib/libCutPlane.a
INCLUDE = -I../../Common -I../../DataStr -I../ -I../../Graphics
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
CutPlane.o: CutPlane.cpp CutPlane.h ../Plugin.h
# $Id: Makefile,v 1.4 2001-03-10 19:55:07 remacle Exp $ # $Id: Makefile,v 1.5 2001-03-10 20:27:02 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 SRC = Plugin.cpp CutPlane.cpp CutSphere.cpp LevelsetPlugin.cpp
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include "PluginManager.h" #include "PluginManager.h"
#include "Message.h" #include "Message.h"
#include <FL/filename.H> #include <FL/filename.H>
#include "CutPlane/CutPlane.h" #include "CutPlane.h"
#include "CutSphere.h"
using namespace std; using namespace std;
...@@ -46,6 +47,7 @@ void GMSH_PluginManager::RegisterDefaultPlugins() ...@@ -46,6 +47,7 @@ void GMSH_PluginManager::RegisterDefaultPlugins()
char ext[6]; char ext[6];
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()));
char *homeplugins = getenv ("GMSHPLUGINSHOME"); char *homeplugins = getenv ("GMSHPLUGINSHOME");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment