diff --git a/Common/Iso.cpp b/Common/Iso.cpp index b81aed07b649ba64c6d3aeaa5e5cba31a5ba21e3..faadba61564da2761b8cbbc897a2fb9d93ebb126 100644 --- a/Common/Iso.cpp +++ b/Common/Iso.cpp @@ -1,4 +1,4 @@ -// $Id: Iso.cpp,v 1.1 2001-08-07 21:00:43 remacle Exp $ +// $Id: Iso.cpp,v 1.2 2001-08-09 13:27:41 remacle Exp $ #include "Gmsh.h" #include "Mesh.h" @@ -261,3 +261,24 @@ void CutLine1D(double *X, double *Y, double *Z, double *Val, } +void gradSimplex (double *x, double *y, double *z, double *v, double *grad){ + /* + p = p1 * (1-u-v-w) + p2 u + p3 v + p4 w + */ + + double mat[3][3]; + double det,b[3]; + mat[0][0] = x[1]-x[0]; + mat[1][0] = x[2]-x[0]; + mat[2][0] = x[3]-x[0]; + mat[0][1] = y[1]-y[0]; + mat[1][1] = y[2]-y[0]; + mat[2][1] = y[3]-y[0]; + mat[0][2] = z[1]-z[0]; + mat[1][2] = z[2]-z[0]; + mat[2][2] = z[3]-z[0]; + b[0] = v[1]-v[0]; + b[1] = v[2]-v[0]; + b[2] = v[3]-v[0]; + sys3x3 (mat, b, grad, &det); +} diff --git a/Common/Iso.h b/Common/Iso.h index b62294a81b5132d247a665eb9c8fb47b453babc7..6ac4c4d2b08d19a261038d4b7e4f5f43d2e99089 100644 --- a/Common/Iso.h +++ b/Common/Iso.h @@ -1,6 +1,8 @@ #ifndef _ISO_H_ #define _ISO_H_ +void gradSimplex (double *x, double *y, double *z, double *v, double *grad); + void CutTriangle1D (double *X, double *Y, double *Z, double *Val, double V, double Vmin, double Vmax, double *Xp, double *Yp, double *Zp, int *nb); diff --git a/Graphics/IsoSimplex.cpp b/Graphics/IsoSimplex.cpp index 60c6fb0a161ff33d3385676efa82e2799b3d9b5b..f13ea650dd93f1164384ba5ec885b167a13c5d78 100644 --- a/Graphics/IsoSimplex.cpp +++ b/Graphics/IsoSimplex.cpp @@ -5,34 +5,12 @@ #include "Draw.h" #include "Iso.h" #include "Context.h" -#include "Numeric.h" #include "Views.h" extern Context_T CTX; // compute the gradient of a linear interpolation in a tetrahedron -void gradSimplex (double *x, double *y, double *z, double *v, double *grad){ - /* - p = p1 * (1-u-v-w) + p2 u + p3 v + p4 w - */ - - double mat[3][3]; - double det,b[3]; - mat[0][0] = x[1]-x[0]; - mat[1][0] = x[2]-x[0]; - mat[2][0] = x[3]-x[0]; - mat[0][1] = y[1]-y[0]; - mat[1][1] = y[2]-y[0]; - mat[2][1] = y[3]-y[0]; - mat[0][2] = z[1]-z[0]; - mat[1][2] = z[2]-z[0]; - mat[2][2] = z[3]-z[0]; - b[0] = v[1]-v[0]; - b[1] = v[2]-v[0]; - b[2] = v[3]-v[0]; - sys3x3 (mat, b, grad, &det); -} void EnhanceSimplexPolygon (Post_View *View, int nb, // nb of points in polygon diff --git a/Plugin/LevelsetPlugin.cpp b/Plugin/LevelsetPlugin.cpp index d30a380bce35b141b6edf8f171d236bc2bd501e1..729f2505f7d9ff6040445e3fd07b2e62cd894aca 100644 --- a/Plugin/LevelsetPlugin.cpp +++ b/Plugin/LevelsetPlugin.cpp @@ -1,10 +1,16 @@ -// $Id: LevelsetPlugin.cpp,v 1.11 2001-08-06 11:00:26 geuzaine Exp $ +// $Id: LevelsetPlugin.cpp,v 1.12 2001-08-09 13:27:41 remacle Exp $ #include "LevelsetPlugin.h" #include "List.h" #include "Views.h" #include "Iso.h" +/// Includes are basdly designed, i prefer forward decls. +void prodve (double a[3], double b[3], double c[3]); +void prosca (double a[3], double b[3], double *c); +void norme (double a[3]); +int sys3x3 (double mat[3][3], double b[3], double res[3], double *det); + GMSH_LevelsetPlugin::GMSH_LevelsetPlugin() { processed = 0; @@ -33,6 +39,7 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) 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}}; + double Xpi[6],Ypi[6],Zpi[6]; Post_View *View; // for all scalar simplices @@ -90,6 +97,28 @@ Post_View *GMSH_LevelsetPlugin::execute (Post_View *v) for(k=1;k<4;k++)List_Add(View->ST, &myVals[k %4]); View->NbST++; } + + double v1[3] = {Xp[2]-Xp[0],Yp[2]-Yp[0],Zp[2]-Zp[0]}; + double v2[3] = {Xp[1]-Xp[0],Yp[1]-Yp[0],Zp[1]-Zp[0]}; + double gr[3]; + double n[3],xx; + prodve(v1,v2,n); + norme(n); + gradSimplex(X,Y,Z,VAL,gr); + prosca(gr,n,&xx); + + if(xx > 0){ + for(i=0;i<nb;i++){ + Xpi[i] = Xp[i]; + Ypi[i] = Yp[i]; + Zpi[i] = Zp[i]; + } + for(i=0;i<nb;i++){ + Xp[i] = Xpi[nb-i-1]; + Yp[i] = Ypi[nb-i-1]; + Zp[i] = Zpi[nb-i-1]; + } + } } char name[1024],filename[1024]; diff --git a/Plugin/Makefile b/Plugin/Makefile index 5154754de51b53ba0e58bc26eaea994ff9471c6c..d96359f6226428f94f140dcd4ea390b3281dabf8 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.12 2001-08-07 21:00:10 remacle Exp $ +# $Id: Makefile,v 1.13 2001-08-09 13:27:41 remacle Exp $ # # Makefile for "libAdapt.a" # @@ -11,7 +11,7 @@ RM = rm RANLIB = ranlib LIB = ../lib/libPlugin.a -INCLUDE = -I../Common -I../Graphics -I../DataStr +INCLUDE = -I../Common -I../Graphics -I../DataStr -I../Mesh C_FLAGS = -g -Wall OS_FLAGS =