From 6a56611116c2ec1f515958ed2507aaa37fa5d0b3 Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Thu, 22 Apr 2004 09:35:01 +0000 Subject: [PATCH] *** empty log message *** --- Common/Makefile | 18 +- Geo/Makefile | 23 +- Mesh/Makefile | 49 +++-- Numeric/Numeric.cpp | 6 +- Plugin/CutGrid.cpp | 237 ++++++++++++++++++++ Plugin/CutGrid.h | 50 +++++ Plugin/Makefile | 11 +- Plugin/Octree.h | 23 ++ Plugin/OctreePost.cpp | 426 ++++++++++++++++++++++++++++++++++++ Plugin/OctreePost.h | 52 +++++ Plugin/OctreeSrc.cpp | 102 +++++++++ Plugin/Plugin.cpp | 8 +- Plugin/StreamLines.cpp | 217 ++++++++++++++++++ Plugin/StreamLines.h | 50 +++++ doc/texinfo/opt_plugin.texi | 22 ++ 15 files changed, 1251 insertions(+), 43 deletions(-) create mode 100644 Plugin/CutGrid.cpp create mode 100644 Plugin/CutGrid.h create mode 100644 Plugin/Octree.h create mode 100644 Plugin/OctreePost.cpp create mode 100644 Plugin/OctreePost.h create mode 100644 Plugin/OctreeSrc.cpp create mode 100644 Plugin/StreamLines.cpp create mode 100644 Plugin/StreamLines.h diff --git a/Common/Makefile b/Common/Makefile index 4f2bbbb7c1..511cfb7ee8 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.53 2004-04-18 03:36:06 geuzaine Exp $ +# $Id: Makefile,v 1.54 2004-04-22 09:35:01 remacle Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -65,19 +65,19 @@ Context.o: Context.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h Context.h \ - Options.h DefaultOptions.h Trackball.h + Options.h DefaultOptions.h Views.h Trackball.h Views.o: Views.cpp Gmsh.h Message.h ../DataStr/Malloc.h ../DataStr/List.h \ ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ ../Numeric/Numeric.h Views.h ColorTable.h Context.h Options.h Options.o: Options.cpp ../Plugin/PluginManager.h ../Plugin/Plugin.h \ ../Common/Options.h ../Common/Message.h ../Common/Views.h \ - ../Common/ColorTable.h ../DataStr/List.h Gmsh.h ../DataStr/Malloc.h \ - ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h GmshUI.h \ - ../Geo/Geo.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ - ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h ../Graphics/Draw.h Context.h \ - ../Fltk/Solvers.h ../Fltk/GUI.h ../Fltk/Opengl_Window.h \ - ../Fltk/Colorbar_Window.h + ../Common/ColorTable.h ../DataStr/List.h Gmsh.h Message.h \ + ../DataStr/Malloc.h ../DataStr/Tree.h ../DataStr/avl.h \ + ../DataStr/Tools.h GmshUI.h ../Geo/Geo.h ../Mesh/Mesh.h \ + ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ + ../Graphics/Draw.h Context.h Options.h ../Fltk/Solvers.h ../Fltk/GUI.h \ + ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h ../Common/GmshUI.h CommandLine.o: CommandLine.cpp Gmsh.h Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ GmshUI.h GmshVersion.h CommandLine.h ../Numeric/Numeric.h Context.h \ diff --git a/Geo/Makefile b/Geo/Makefile index 38d1834b82..0f4b53000c 100644 --- a/Geo/Makefile +++ b/Geo/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.46 2004-04-18 03:36:06 geuzaine Exp $ +# $Id: Makefile,v 1.47 2004-04-22 09:35:01 remacle Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -63,8 +63,8 @@ CAD.o: CAD.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../Numeric/Numeric.h Geo.h ../Mesh/Mesh.h ../Mesh/Vertex.h \ ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ - ../Mesh/Interpolation.h ../Mesh/Create.h CAD.h ../Common/Visibility.h \ - ../Common/Context.h + ../Mesh/Interpolation.h ../Mesh/Create.h CAD.h ExtrudeParams.h \ + ../Common/Visibility.h ../Common/Context.h MinMax.o: MinMax.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h \ @@ -73,34 +73,37 @@ ExtrudeParams.o: ExtrudeParams.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h Geo.h CAD.h ../Mesh/Mesh.h \ ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ - ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ + ExtrudeParams.h Geo.o: Geo.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ ../Numeric/Numeric.h Geo.h CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h \ ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ - ../Parser/Parser.h ../Common/Context.h + ExtrudeParams.h ../Parser/Parser.h ../Common/Context.h GeoUtils.o: GeoUtils.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h Geo.h CAD.h ../Mesh/Mesh.h \ ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ - ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ + ExtrudeParams.h StepGeomDatabase.o: StepGeomDatabase.cpp ../Common/Gmsh.h \ ../Common/Message.h ../DataStr/Malloc.h ../DataStr/List.h \ ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ ../Numeric/Numeric.h Geo.h GeoUtils.h ../Mesh/Mesh.h ../Mesh/Vertex.h \ ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ - ../Mesh/Nurbs.h CAD.h StepGeomDatabase.h ../Mesh/Create.h \ - ../Common/Context.h + ../Mesh/Nurbs.h CAD.h ExtrudeParams.h StepGeomDatabase.h \ + ../Mesh/Create.h ../Common/Context.h ExtractContour.o: ExtractContour.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h Geo.h CAD.h ../Mesh/Mesh.h \ ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ - ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ + ExtrudeParams.h Print_Geo.o: Print_Geo.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h Geo.h ../Mesh/Mesh.h \ ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.h \ - CAD.h ../Common/Context.h + CAD.h ExtrudeParams.h ../Common/Context.h diff --git a/Mesh/Makefile b/Mesh/Makefile index ce3d60d9a7..ce3a78bd3f 100644 --- a/Mesh/Makefile +++ b/Mesh/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.59 2004-04-18 03:36:07 geuzaine Exp $ +# $Id: Makefile,v 1.60 2004-04-22 09:35:01 remacle Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -107,8 +107,8 @@ depend: ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Utils.h Create.h 2D_Mesh.h \ - ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Utils.h Vertex.h Create.h \ + 2D_Mesh.h ../Common/Context.h 2D_SMesh.o: 2D_SMesh.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Geo/Geo.h Mesh.h Vertex.h \ @@ -119,7 +119,7 @@ depend: ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h 2D_BGMesh.o: 2D_BGMesh.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h Mesh.h \ @@ -174,15 +174,15 @@ depend: ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.h 2D_Mesh.h Create.h \ - ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.h Vertex.h Mesh.h \ + 2D_Mesh.h Create.h ../Common/Context.h 2D_Mesh_Aniso.o: 2D_Mesh_Aniso.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.h Create.h \ - ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Interpolation.h Vertex.h \ + Create.h ../Common/Context.h 2D_Mesh_Triangle.o: 2D_Mesh_Triangle.cpp ../Common/Gmsh.h \ ../Common/Message.h ../DataStr/Malloc.h ../DataStr/List.h \ ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h Mesh.h Vertex.h \ @@ -209,13 +209,15 @@ depend: ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h ../Common/Context.h Create.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h ../Common/Context.h Create.h \ + Vertex.h 3D_Extrude_Old.o: 3D_Extrude_Old.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h ../Common/Context.h Create.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h ../Common/Context.h Create.h \ + Vertex.h 3D_Coherence.o: 3D_Coherence.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ @@ -241,7 +243,8 @@ Create.o: Create.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Utils.h ../Common/Context.h Create.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Utils.h Vertex.h \ + ../Common/Context.h Create.h Generator.o: Generator.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h Mesh.h \ @@ -252,23 +255,26 @@ Print_Mesh.o: Print_Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Create.h ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Create.h Vertex.h \ + ../Common/Context.h Read_Mesh.o: Read_Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Geo/Geo.h ../Geo/CAD.h \ ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h \ ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h \ - ../Mesh/Matrix.h 3D_Mesh.h Create.h ../Geo/MinMax.h ../Common/Context.h + ../Mesh/Matrix.h Mesh.h 3D_Mesh.h Create.h Vertex.h ../Geo/MinMax.h \ + ../Common/Context.h STL.o: STL.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ ../Numeric/Numeric.h Mesh.h Vertex.h Element.h Simplex.h Edge.h \ ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h ../Geo/CAD.h \ - ../Geo/Geo.h Create.h Interpolation.h ../Common/Context.h + ../Mesh/Mesh.h ../Mesh/Vertex.h ../Geo/Geo.h Create.h Interpolation.h \ + ../Common/Context.h SMS.o: SMS.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \ ../Geo/Geo.h Mesh.h Vertex.h Element.h Simplex.h Edge.h \ ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h Create.h ../Geo/MinMax.h \ - ../Geo/CAD.h ../Common/Context.h + ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Common/Context.h SwapEdge.o: SwapEdge.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h Mesh.h \ @@ -279,24 +285,27 @@ Utils.o: Utils.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.h ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Interpolation.h Vertex.h \ + ../Common/Context.h Metric.o: Metric.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \ ../Mesh/Simplex.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/STL.h \ - ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.h + ../Mesh/Metric.h ../Mesh/Matrix.h Mesh.h Matrix.h Interpolation.h \ + Vertex.h Nurbs.o: Nurbs.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h Nurbs.h Vertex.h Mesh.h Element.h \ Simplex.h Edge.h ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h \ - ../Geo/Geo.h ../Geo/GeoUtils.h Create.h ../Geo/CAD.h + ../Geo/Geo.h ../Geo/GeoUtils.h ../Mesh/Mesh.h Create.h ../Geo/CAD.h \ + ../Mesh/Vertex.h Interpolation.o: Interpolation.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Numeric/Numeric.h ../Geo/Geo.h \ Nurbs.h Vertex.h Mesh.h Element.h Simplex.h Edge.h \ - ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h ../Geo/CAD.h Utils.h \ - Interpolation.h + ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h ../Geo/CAD.h \ + ../Mesh/Mesh.h ../Mesh/Vertex.h Utils.h Interpolation.h SecondOrder.o: SecondOrder.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Geo/Geo.h Mesh.h Vertex.h \ diff --git a/Numeric/Numeric.cpp b/Numeric/Numeric.cpp index 96a51c2704..e9e3bd7d2f 100644 --- a/Numeric/Numeric.cpp +++ b/Numeric/Numeric.cpp @@ -1,4 +1,4 @@ -// $Id: Numeric.cpp,v 1.13 2004-04-13 19:27:09 geuzaine Exp $ +// $Id: Numeric.cpp,v 1.14 2004-04-22 09:35:01 remacle Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -126,10 +126,11 @@ int sys2x2(double mat[2][2], double b[2], double res[2]) DSQR(mat[0][0]) + DSQR(mat[1][1]) + DSQR(mat[0][1]) + DSQR(mat[1][0]); det = mat[0][0] * mat[1][1] - mat[1][0] * mat[0][1]; + // TOLERANCE ! WARNING WARNING if(norm == 0.0 || fabs(det) / norm < 1.e-12) { if(norm) - Msg(DEBUG, "Assuming 2x2 matrix is singular (det/norm == %g)", + Msg(WARNING, "Assuming 2x2 matrix is singular (det/norm == %g)", fabs(det) / norm); res[0] = res[1] = 0.0; return 0; @@ -141,6 +142,7 @@ int sys2x2(double mat[2][2], double b[2], double res[2]) for(i = 0; i < 2; i++) res[i] *= ud; + return (1); } diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp new file mode 100644 index 0000000000..f7ed560145 --- /dev/null +++ b/Plugin/CutGrid.cpp @@ -0,0 +1,237 @@ +// $Id: CutGrid.cpp,v 1.1 2004-04-22 09:35:01 remacle Exp $ +// +// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + +#include "OctreePost.h" +#include "CutGrid.h" +#include "List.h" +#include "Context.h" +#include "Views.h" +#include "Message.h" + +extern Context_T CTX; + +StringXNumber CutGridOptions_Number[] = { + {GMSH_FULLRC, "X0", NULL, -1.}, + {GMSH_FULLRC, "Y0", NULL, -1.}, + {GMSH_FULLRC, "Z0", NULL, 0.}, + {GMSH_FULLRC, "X1", NULL, -1.}, + {GMSH_FULLRC, "Y1", NULL, 0.}, + {GMSH_FULLRC, "Z1", NULL, 0.}, + {GMSH_FULLRC, "X2", NULL, 0.}, + {GMSH_FULLRC, "Y2", NULL, -1.}, + {GMSH_FULLRC, "Z2", NULL, 0.}, + {GMSH_FULLRC, "nPoints", NULL, 20}, + {GMSH_FULLRC, "iView", NULL, -1.} +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutGridPlugin() + { + return new GMSH_CutGridPlugin(); + } +} + + +GMSH_CutGridPlugin::GMSH_CutGridPlugin() +{ + ; +} + +void GMSH_CutGridPlugin::getName(char *name) const +{ + strcpy(name, "Cut grid"); +} + +void GMSH_CutGridPlugin::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, + "Cuts a 3D view with a rectangular {X0,Y0,Z0}-{X1,Y1,Z1} grid\n" + "using nbPoints x nbPoints\n" "Script name: Plugin(CutGrid)."); +} + +int GMSH_CutGridPlugin::getNbOptions() const +{ + return sizeof(CutGridOptions_Number) / sizeof(StringXNumber); +} + +StringXNumber *GMSH_CutGridPlugin::getOption(int iopt) +{ + return &CutGridOptions_Number[iopt]; +} + +void GMSH_CutGridPlugin::catchErrorMessage(char *errorMessage) const +{ + strcpy(errorMessage, "CutGrid failed..."); +} + +int GMSH_CutGridPlugin::getNbU()const +{ + return (int)CutGridOptions_Number[9].def; +} + +int GMSH_CutGridPlugin::getNbV()const +{ + return (int)CutGridOptions_Number[9].def; +} + +void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X )const +{ + double u = (double)iU / (double)(getNbU () - 1.); + double v = (double)iV / (double)(getNbV () - 1.); + X[0] = CutGridOptions_Number[0].def + + u * (CutGridOptions_Number[3].def-CutGridOptions_Number[0].def) + + v * (CutGridOptions_Number[6].def-CutGridOptions_Number[0].def) ; + X[1] = CutGridOptions_Number[1].def + + u * (CutGridOptions_Number[4].def-CutGridOptions_Number[1].def) + + v * (CutGridOptions_Number[7].def-CutGridOptions_Number[1].def) ; + X[2] = CutGridOptions_Number[2].def + + u * (CutGridOptions_Number[5].def-CutGridOptions_Number[2].def) + + v * (CutGridOptions_Number[8].def-CutGridOptions_Number[2].def) ; +} + +Post_View * GMSH_CutGridPlugin::GenerateView (Post_View * v) const +{ + Post_View * View = BeginView (1); + + double X1[3],X2[3],X3[3],X4[3]; + double *VALUES1 = new double [9*v->NbTimeStep]; + double *VALUES2 = new double [9*v->NbTimeStep]; + double *VALUES3 = new double [9*v->NbTimeStep]; + double *VALUES4 = new double [9*v->NbTimeStep]; + + OctreePost o ( v ); + + for (int i=0 ; i < getNbU ()-1 ; ++i ) + { + for (int j=0 ; j < getNbV ()-1;++j ) + { + getPoint ( i ,j ,X1 ); + getPoint ( i+1,j ,X2 ); + getPoint ( i+1,j+1,X3 ); + getPoint ( i ,j+1,X4 ); + if ( v->NbSS || v->NbSH) + { + List_Add(View->SQ, &X1[0]); + List_Add(View->SQ, &X2[0]); + List_Add(View->SQ, &X3[0]); + List_Add(View->SQ, &X4[0]); + List_Add(View->SQ, &X1[1]); + List_Add(View->SQ, &X2[1]); + List_Add(View->SQ, &X3[1]); + List_Add(View->SQ, &X4[1]); + List_Add(View->SQ, &X1[2]); + List_Add(View->SQ, &X2[2]); + List_Add(View->SQ, &X3[2]); + List_Add(View->SQ, &X4[2]); + View->NbSQ ++; + o.searchScalar ( X1[0],X1[1],X1[2] , VALUES1 ); + o.searchScalar ( X2[0],X2[1],X2[2] , VALUES2 ); + o.searchScalar ( X3[0],X3[1],X3[2] , VALUES3 ); + o.searchScalar ( X4[0],X4[1],X4[2] , VALUES4 ); + for (int k=0;k<v->NbTimeStep;++k) + { + List_Add(View->SQ, &VALUES1[k]); + List_Add(View->SQ, &VALUES2[k]); + List_Add(View->SQ, &VALUES3[k]); + List_Add(View->SQ, &VALUES4[k]); + } + } + if ( v->NbVS || v->NbVH) + { + List_Add(View->VQ, &X1[0]); + List_Add(View->VQ, &X2[0]); + List_Add(View->VQ, &X3[0]); + List_Add(View->VQ, &X4[0]); + List_Add(View->VQ, &X1[1]); + List_Add(View->VQ, &X2[1]); + List_Add(View->VQ, &X3[1]); + List_Add(View->VQ, &X4[1]); + List_Add(View->VQ, &X1[2]); + List_Add(View->VQ, &X2[2]); + List_Add(View->VQ, &X3[2]); + List_Add(View->VQ, &X4[2]); + View->NbVQ ++; + double sizeElem; + o.searchVector ( X1[0],X1[1],X1[2] , &sizeElem,VALUES1 ); + o.searchVector ( X2[0],X2[1],X2[2] , &sizeElem,VALUES2 ); + o.searchVector ( X3[0],X3[1],X3[2] , &sizeElem,VALUES3 ); + o.searchVector ( X4[0],X4[1],X4[2] , &sizeElem,VALUES4 ); + for (int k=0;k<v->NbTimeStep;++k) + { + List_Add(View->VQ, &VALUES1[3*i]); + List_Add(View->VQ, &VALUES1[3*i+1]); + List_Add(View->VQ, &VALUES1[3*i+2]); + List_Add(View->VQ, &VALUES2[3*i]); + List_Add(View->VQ, &VALUES2[3*i+1]); + List_Add(View->VQ, &VALUES2[3*i+2]); + List_Add(View->VQ, &VALUES3[3*i]); + List_Add(View->VQ, &VALUES3[3*i+1]); + List_Add(View->VQ, &VALUES3[3*i+2]); + List_Add(View->VQ, &VALUES4[3*i]); + List_Add(View->VQ, &VALUES4[3*i+1]); + List_Add(View->VQ, &VALUES4[3*i+2]); + } + } + } + } + + char name[1024], filename[1024]; + sprintf(name, "cut-%s", v->Name); + sprintf(filename, "cut-%s", v->FileName); + EndView(View, v->NbTimeStep, filename, name); + + delete [] VALUES1; + delete [] VALUES2; + delete [] VALUES3; + delete [] VALUES4; +} + +Post_View *GMSH_CutGridPlugin::execute(Post_View * v) +{ + Post_View *vv; + + int iView = (int)CutGridOptions_Number[10].def; + + if(v && iView < 0) + vv = v; + else { + if(!v && iView < 0) + iView = 0; + if(!(vv = (Post_View *) List_Pointer_Test(CTX.post.list, iView))) { + return 0; + } + } + Post_View * newView = GenerateView (vv); + + return newView; +} + +void GMSH_CutGridPlugin::Run() +{ + execute(0); +} +void GMSH_CutGridPlugin::Save() +{ +} diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h new file mode 100644 index 0000000000..e1940c5584 --- /dev/null +++ b/Plugin/CutGrid.h @@ -0,0 +1,50 @@ +#ifndef _CUTGRID_H_ +#define _CUTGRID_H + +// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + +#include "Plugin.h" + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterCutGridPlugin (); +} + +class GMSH_CutGridPlugin : public GMSH_Post_Plugin +{ +public: + GMSH_CutGridPlugin(); + void getName (char *name) const; + void getInfos (char *author, + char *copyright, + char *help_text) const; + void catchErrorMessage (char *errorMessage) const; + int getNbOptions() const; + StringXNumber *getOption (int iopt); + Post_View *execute (Post_View *); + virtual void Run(); + virtual void Save(); + virtual int getNbU () const ; + virtual int getNbV () const ; + virtual void getPoint(int iU, int iV, double *X ) const ; + virtual Post_View * GenerateView (Post_View * v) const ; +}; + +#endif diff --git a/Plugin/Makefile b/Plugin/Makefile index 2effb48212..3bfd961609 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.44 2004-04-18 03:36:07 geuzaine Exp $ +# $Id: Makefile,v 1.45 2004-04-22 09:35:01 remacle Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -30,6 +30,7 @@ SRC = Plugin.cpp\ Levelset.cpp\ CutPlane.cpp CutSphere.cpp CutMap.cpp\ Smooth.cpp\ + CutGrid.cpp OctreeSrc.cpp o_internals.cpp OctreePost.cpp StreamLines.cpp\ Transform.cpp\ Triangulate.cpp\ SphericalRaise.cpp\ @@ -85,6 +86,14 @@ CutMap.o: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \ Smooth.o: Smooth.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h Smooth.h \ ../Common/Context.h +CutGrid.o: CutGrid.cpp OctreePost.h Octree.h o_internals.h CutGrid.h \ + Plugin.h ../Common/Options.h ../Common/Message.h ../Common/Views.h \ + ../Common/ColorTable.h ../DataStr/List.h ../Common/Context.h +OctreeSrc.o: OctreeSrc.cpp o_internals.h Octree.h +o_internals.o: o_internals.cpp o_internals.h +OctreePost.o: OctreePost.cpp Octree.h o_internals.h OctreePost.h \ + ../DataStr/List.h ../Common/Views.h ../Common/ColorTable.h \ + ../Numeric/Numeric.h Transform.o: Transform.cpp Plugin.h ../Common/Options.h \ ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ ../DataStr/List.h Transform.h ../Common/Context.h diff --git a/Plugin/Octree.h b/Plugin/Octree.h new file mode 100644 index 0000000000..848f0942e0 --- /dev/null +++ b/Plugin/Octree.h @@ -0,0 +1,23 @@ +#ifndef _OCTREEH_ +#define _OCTREEH_ + +#include <list> +#include "o_internals.h" + +using std::list; + +/*class Octree; */ + +Octree* Octree_Create (int, /* max. number of elements allowed in an octant */ + double *origin, /* smallest x,y, z of model's bounding box */ + double *size, /* size in x, y, z of model bounding box */ + void (*BB)(void *, double*, double*), + void (*Centroid)(void *, double *), + int (*InEle)(void *, double *)); + +void Octree_Delete (Octree *); +void Octree_Insert (void *, Octree *); +void Octree_Arrange(Octree *); +void * Octree_Search (double *, Octree *); +void Octree_SearchAll (double *, Octree *, list<void *> * ); +#endif diff --git a/Plugin/OctreePost.cpp b/Plugin/OctreePost.cpp new file mode 100644 index 0000000000..5090ef6f17 --- /dev/null +++ b/Plugin/OctreePost.cpp @@ -0,0 +1,426 @@ +#include "Octree.h" +#include "OctreePost.h" +#include "List.h" +#include "Views.h" +#include "Numeric.h" +#include "Message.h" + +static double computeBarycentricTriangle ( double *X , double *Y, double *Z, double *P, double *U ) +{ + double mat[2][2],b[2]; + U[2] = 0.0; + mat[0][0] = X[1]-X[0]; + mat[0][1] = X[2]-X[0]; + mat[1][0] = Y[1]-Y[0]; + mat[1][1] = Y[2]-Y[0]; + b[0] = P[0] -X[0]; + b[1] = P[1] -Y[0]; + // Msg(WARNING, "louloutte %lf %lf %lf %lf %lf",P[0],P[1],X[0],Y[0]); + + sys2x2 ( mat,b,U); + return 0.5 * ( mat[0][0] * mat[1][1] - mat[1][0] *mat[0][1]); +} +static void computeBarycentricSimplex ( double *X , double *Y, double *Z, double *P, double *U ) +{ + double mat[3][3],b[3]; + + mat[0][0] = X[1]-X[0]; + mat[0][1] = X[2]-X[0]; + mat[0][2] = X[3]-X[0]; + mat[1][0] = Y[1]-Y[0]; + mat[1][1] = Y[2]-Y[0]; + mat[1][2] = Y[3]-Y[0]; + mat[2][0] = Z[1]-Z[0]; + mat[2][1] = Z[2]-Z[0]; + mat[2][2] = Z[3]-Z[0]; + b[0] = P[0] -X[0]; + b[1] = P[1] -Y[0]; + b[2] = P[2] -Z[0]; + double det; + sys3x3 ( mat,b,U,&det); +} +static void minmax ( int n , + double *X , + double *Y , + double *Z , + double *min, + double *max) +{ + min[0] = X[0]; + min[1] = Y[0]; + min[2] = Z[0]; + max[0] = X[0]; + max[1] = Y[0]; + max[2] = Z[0]; + + for (int i=1;i<n;++i) + { + min[0] = (X[i] < min[0]) ? X[i]:min[0]; + min[1] = (Y[i] < min[1]) ? Y[i]:min[1]; + min[2] = (Z[i] < min[2]) ? Z[i]:min[2]; + max[0] = (X[i] > max[0]) ? X[i]:max[0]; + max[1] = (Y[i] > max[1]) ? Y[i]:max[1]; + max[2] = (Z[i] > max[2]) ? Z[i]:max[2]; + } +} + +static void centroid ( int n , + double *X , + double *Y , + double *Z , + double *c) +{ + const double oc = 1./(double)n; + c[0] = X[0]; + c[1] = Y[0]; + c[2] = Z[0]; + for (int i=1;i<n;++i) + { + c[0] += X[i]; + c[1] += Y[i]; + c[2] += Z[i]; + } + c[0] *= oc; + c[1] *= oc; + c[2] *= oc; +} + +void PostTriangleBB ( void *a , double *min, double *max) +{ + + double *X = (double*) a; + double *Y = &X[3]; + double *Z = &X[6]; + + minmax(3,X,Y,Z,min,max); + + min[2] = -1; + max[2] = 1; +} + +int PostTriangleInEle ( void *a , double *x) +{ + const double eps = 1.e-3; + double U[3]; + double *X = (double*) a; + double *Y = &X[3]; + double *Z = &X[6]; + computeBarycentricTriangle ( X,Y,Z,x,U); + double W = 1.-U[0]-U[1]; + if (U[0] < -eps || U[0] > 1+eps || + U[1] < -eps || U[1] > 1+eps || + W < -eps || W > 1+eps ) return 0; + return 1; +} + +void PostTriangleCentroid ( void *a , double *x) +{ + double *X = (double*) a; + double *Y = &X[3]; + double *Z = &X[6]; + centroid ( 3, X,Y,Z,x); +} + +void PostSimplexBB ( void *a , double *min, double *max) +{ + double *X = (double*) a; + double *Y = &X[4]; + double *Z = &X[8]; + + minmax(4,X,Y,Z,min,max); +} + +int PostSimplexInEle ( void *a , double *x) +{ + const double eps = 1.e-5; + double U[3]; + double *X = (double*) a; + double *Y = &X[4]; + double *Z = &X[8]; + computeBarycentricSimplex ( X,Y,Z,x,U); + double W = 1.-U[0]-U[1]-U[2]; + + if (U[0] < -eps || U[0] > 1+eps || + U[1] < -eps || U[1] > 1+eps || + U[2] < -eps || U[2] > 1+eps || + W < -eps || W > 1+eps ) return 0; + return 1; +} + +void PostSimplexCentroid ( void *a , double *x) +{ + double *X = (double*) a; + double *Y = &X[4]; + double *Z = &X[8]; + centroid ( 4, X,Y,Z,x); +} + + +static void addListOfStuff ( Octree *o, + List_T *l , + int nbelm ) +{ + if (!l)return; + + for(int i = 0; i < List_Nbr(l); i += nbelm) + { + double * X = (double *)List_Pointer_Fast(l, i); + // Msg(WARNING, "Add in view : %lf %lf %lf %d %d %d", X[0],X[1],X[2],i,List_Nbr(l),nbelm); + Octree_Insert ( X , o ); + } +} + +OctreePost::~OctreePost () +{ + Octree_Delete ( ST ); + Octree_Delete ( VT ); + Octree_Delete ( TT ); + Octree_Delete ( SS ); + Octree_Delete ( VS ); +} + +OctreePost::OctreePost ( Post_View *v ) + : theView (v) +{ + double min [3] = {v->BBox[0],v->BBox[2],v->BBox[4]}; + + double size[3] = {v->BBox[1]-v->BBox[0], + v->BBox[3]-v->BBox[2], + v->BBox[5]-v->BBox[4]}; + + ST = Octree_Create ( 2 , min, size, + PostTriangleBB, + PostTriangleCentroid, + PostTriangleInEle); + + addListOfStuff ( ST , v->ST , 9 + 3* v->NbTimeStep); + VT = Octree_Create ( 1000 , min, size, + PostTriangleBB, + PostTriangleCentroid, + PostTriangleInEle); + addListOfStuff ( VT , v->VT , 9 + 9 * v->NbTimeStep); + TT = Octree_Create ( 2 , min, size, + PostTriangleBB, + PostTriangleCentroid, + PostTriangleInEle); + addListOfStuff ( TT , v->TT , 9 + 27 * v->NbTimeStep); + + + SS = Octree_Create ( 1000 , min, size, + PostSimplexBB, + PostSimplexCentroid, + PostSimplexInEle); + addListOfStuff ( SS , v->SS , 12 + 4 * v->NbTimeStep); + VS = Octree_Create ( 1000 , min, size, + PostSimplexBB, + PostSimplexCentroid, + PostSimplexInEle); + addListOfStuff ( VS , v->VS , 12 + 12 * v->NbTimeStep ); + + Octree_Arrange (ST); + Octree_Arrange (VT); + Octree_Arrange (TT); + Octree_Arrange (SS); + Octree_Arrange (VS); + +} + +bool OctreePost::searchVector ( double x , + double y , + double z, + double * values , + double * size_elem, + int timestep) +{ + double P[3] = {x,y,z}; + for (int i=0;i<3*theView->NbTimeStep;++i) + values[i] = 0.0; + + void * inVT = Octree_Search ( P , VT ); + + + // values[0] = -0.5*y; + // values[1] = 0.5*x; + // values[2] = 1; + // return true; + if (inVT) + { + double U[3]; + double *X = (double*) inVT; + double *Y = &X[3]; + double *Z = &X[6]; + double *V = &X[9]; + *size_elem = fabs(computeBarycentricTriangle ( X ,Y, Z, P, U )); + // bof + *size_elem = sqrt (*size_elem); + if (timestep < 0) + { + for (int i=0;i<theView->NbTimeStep;++i) + { + values[3*i] = + V[9*i ] * U[0] + + V[9*i+3] * U[1] + + V[9*i+6] * (1-U[0]-U[1]); + values[3*i+1] = + V[9*i+1] * U[0] + + V[9*i+4] * U[1] + + V[9*i+7] * (1-U[0]-U[1]); + values[3*i+2] = + V[9*i+2] * U[0] + + V[9*i+5] * U[1] + + V[9*i+8] * (1-U[0]-U[1]); + } + } + else + { + values[0] = + V[9*timestep ] * U[0] + + V[9*timestep+3] * U[1] + + V[9*timestep+6] * (1-U[0]-U[1]); + values[1] = + V[9*timestep+1] * U[0] + + V[9*timestep+4] * U[1] + + V[9*timestep+7] * (1-U[0]-U[1]); + values[2] = + V[9*timestep+2] * U[0] + + V[9*timestep+5] * U[1] + + V[9*timestep+8] * (1-U[0]-U[1]); + /* Msg(WARNING, "found %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", + values[0],values[1],values[2], + U[0],U[1], + X[0],X[1],X[2], + Y[0],Y[1],Y[2], + Z[0],Z[1],Z[2]);*/ + } + return true; + } + + + void * inVS = Octree_Search ( P , VS ); + + if (inVS) + { + double U[3]; + double *X = (double*) inVS; + double *Y = &X[4]; + double *Z = &X[8]; + double *V = &X[12]; + computeBarycentricSimplex ( X ,Y, Z, P, U ); + // bof + *size_elem = .1; + if (timestep < 0) + { + for (int i=0;i<theView->NbTimeStep;++i) + { + values[3*i] = + V[12*i ] * U[0] + + V[12*i+3] * U[1] + + V[12*i+6] * U[2] + + V[12*i+9] * (1-U[0]-U[1]-U[2]); + values[3*i+1] = + V[12*i+1] * U[0] + + V[12*i+4] * U[1] + + V[12*i+9] * U[2] + + V[12*i+10] * (1-U[0]-U[1]-U[2]); + values[3*i+2] = + V[12*i+2] * U[0] + + V[12*i+5] * U[1] + + V[12*i+7] * U[2] + + V[12*i+11] * (1-U[0]-U[1]-U[2]); + } + } + else + { + values[0] = + V[12*timestep ] * U[0] + + V[12*timestep+3] * U[1] + + V[12*timestep+6] * U[2] + + V[12*timestep+9] * (1-U[0]-U[1]-U[2]); + values[1] = + V[12*timestep+1] * U[0] + + V[12*timestep+4] * U[1] + + V[12*timestep+7] * U[2] + + V[12*timestep+10] * (1-U[0]-U[1]-U[2]); + values[2] = + V[12*timestep+2] * U[0] + + V[12*timestep+5] * U[1] + + V[12*timestep+8] * U[2] + + V[12*timestep+11] * (1-U[0]-U[1]-U[2]); + } + return true; + } + return false; +} + +bool OctreePost::searchScalar ( double x , + double y , + double z, + double * values , + int timestep) +{ + double P[3] = {x,y,z}; + void * inST = Octree_Search ( P , ST ); + + for (int i=0;i<theView->NbTimeStep;++i) + values[i] = 0.0; + + if (inST) + { + double U[3]; + double *X = (double*) inST; + double *Y = &X[3]; + double *Z = &X[6]; + double *V = &X[9]; + computeBarycentricTriangle ( X ,Y, Z, P, U ); + if (timestep < 0) + { + for (int i=0;i<theView->NbTimeStep;++i) + { + values[i] = V[3*i] * U[0] + + V[3*i+1] * U[1] + + V[3*i+2] * (1-U[0]-U[1]); + } + } + else + { + values[0] = V[3*timestep] * U[0] + + V[3*timestep+1] * U[1] + + V[3*timestep+2] * (1-U[0]-U[1]); + } + return true; + } + + void * inSS = Octree_Search ( P , SS ); + + if (inSS) + { + double U[3]; + double *X = (double*) inSS; + double *Y = &X[4]; + double *Z = &X[8]; + double *V = &X[12]; + computeBarycentricSimplex ( X ,Y, Z, P, U ); + if (timestep < 0) + { + for (int i=0;i<theView->NbTimeStep;++i) + { + values[i] = + V[3*i ] * U[0] + + V[3*i+1] * U[1] + + V[3*i+2] * U[2] + + V[3*i+3] * (1.-U[0]-U[1]-U[2]); + } + } + else + { + values[0] = + V[3*timestep] * U[0] + + V[3*timestep+1] * U[1] + + V[3*timestep+2] * U[2] + + V[3*timestep+3] * (1-U[0]-U[1]-U[2]); + } + return true; + } + + return false; +} diff --git a/Plugin/OctreePost.h b/Plugin/OctreePost.h new file mode 100644 index 0000000000..e7bee8833d --- /dev/null +++ b/Plugin/OctreePost.h @@ -0,0 +1,52 @@ +#ifndef _OCTREE_POST_H_ +#define _OCTREE_POST_H_ + +// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + +#include "Octree.h" +class Post_View; + +class OctreePost +{ + Octree *ST,*VT,*TT; + Octree *SS,*VS,*TS; + Post_View *theView; +public : + OctreePost ( Post_View * ); + ~OctreePost (); + /// search for the value of the View at point + /// x, y, z. Values is interpolated linearly in + /// the post element. If several time steps + /// are present, they are all interpolated unless + /// time step is set to a different value than -1. + bool searchScalar ( double x , + double y , + double z, + double * values , + int timestep = -1); + bool searchVector ( double x , + double y , + double z, + double * values , + double * size_elem , + int timestep = -1); +}; + +#endif diff --git a/Plugin/OctreeSrc.cpp b/Plugin/OctreeSrc.cpp new file mode 100644 index 0000000000..4e59ab3c0b --- /dev/null +++ b/Plugin/OctreeSrc.cpp @@ -0,0 +1,102 @@ +#include <stdlib.h> +#include <stdio.h> +#include <list> +#include "o_internals.h" +#include "Octree.h" + +using std::list; + +void free_buckets(octantBucket *); + +Octree* Octree_Create (int maxElements, double origin[3], double size[3], + void (*BB)(void *, double*, double*), + void (*Centroid)(void *, double *), + int (*InEle)(void *, double *)) +{ + Octree *myOctree = new Octree; + initializeOctantBuckets (origin, size, maxElements, + &(myOctree->root), &(myOctree->info)); + myOctree->function_BB = BB; + myOctree->function_centroid = Centroid; + myOctree->function_inElement = InEle; + return myOctree; +} + + +void Octree_Delete(Octree *myOctree) +{ + delete myOctree->info; + free_buckets(myOctree->root); + delete myOctree->root; + return; +} + +void Octree_Insert(void * element, Octree *myOctree) +{ + double minBB[3], maxBB[3], centroid[3]; + octantBucket *bucket; + (*(myOctree->function_BB))(element, minBB, maxBB); + (*(myOctree->function_centroid))(element, centroid); + +// for test +/* printf("The centroid of the insert element is %f, %f, %f\n",centroid[0], centroid[1], centroid[2]); */ +//end of test + + bucket = findElementBucket(myOctree->root, centroid); + addElement2Bucket (bucket, element, minBB, maxBB, + centroid,myOctree->info); + // printf("Ready to return from Octree_Insert\n"); + return; +} + +void Octree_Arrange(Octree *myOctree) +{ + std::list<void *>::iterator iter; + double minPt[3], maxPt[3]; + for(iter = myOctree->info->listAllElements.begin(); iter!= + myOctree->info->listAllElements.end(); iter++) { + (*(myOctree->function_BB))(*iter, minPt, maxPt); + insertOneBB(*iter, minPt, maxPt, myOctree->root); + } + myOctree->info->listAllElements.clear(); + return; +} + + + + +void * Octree_Search(double *pt, Octree *myOctree) +{ + return searchElement(myOctree->root, pt, myOctree->info, + myOctree->function_BB, myOctree->function_inElement); +} + + +void free_buckets(octantBucket * bucket) +{ + int i, numBuck = 8; + ELink ptr1, ptr2; + + if(bucket->next == NULL) { + ptr1 = bucket->lhead; + while(ptr1 != NULL) { + ptr2 = ptr1; + ptr1 = ptr1->next; + delete ptr2; + } + bucket->listBB.clear(); + return; + } + + for(i = numBuck-1; i >= 0; i--) + free_buckets((bucket->next)+i); + delete []bucket->next; + return; +} + + +void Octree_SearchAll (double * pt, Octree * myOctree, list<void *> * output) +{ + searchAllElements(myOctree->root, pt, myOctree->info, myOctree->function_BB, + myOctree->function_inElement, output); +} diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index ee27ac580b..2431e2f578 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -1,4 +1,4 @@ -// $Id: Plugin.cpp,v 1.49 2004-03-13 21:00:19 geuzaine Exp $ +// $Id: Plugin.cpp,v 1.50 2004-04-22 09:35:01 remacle Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -33,6 +33,8 @@ #include "Plugin.h" #include "PluginManager.h" #include "CutMap.h" +#include "CutGrid.h" +#include "StreamLines.h" #include "CutPlane.h" #include "CutSphere.h" #include "Skin.h" @@ -130,6 +132,10 @@ GMSH_PluginManager *GMSH_PluginManager::instance() void GMSH_PluginManager::registerDefaultPlugins() { + allPlugins.insert(std::pair < char *, GMSH_Plugin * > + ("StreamLines", GMSH_RegisterStreamLinesPlugin())); + allPlugins.insert(std::pair < char *, GMSH_Plugin * > + ("CutGrid", GMSH_RegisterCutGridPlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > ("CutMap", GMSH_RegisterCutMapPlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp new file mode 100644 index 0000000000..ae7460fc95 --- /dev/null +++ b/Plugin/StreamLines.cpp @@ -0,0 +1,217 @@ +// $Id: StreamLines.cpp,v 1.1 2004-04-22 09:35:01 remacle Exp $ +// +// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + +#include <math.h> +#include "OctreePost.h" +#include "StreamLines.h" +#include "List.h" +#include "Context.h" +#include "Views.h" +#include "Message.h" + +extern Context_T CTX; + +StringXNumber StreamLinesOptions_Number[] = { + {GMSH_FULLRC, "X0", NULL, 2.39}, + {GMSH_FULLRC, "Y0", NULL, .445}, + {GMSH_FULLRC, "Z0", NULL, 0.}, + {GMSH_FULLRC, "X1", NULL, 2.39}, + {GMSH_FULLRC, "Y1", NULL, 0.94}, + {GMSH_FULLRC, "Z1", NULL, 0.}, + {GMSH_FULLRC, "X2", NULL, 2.39}, + {GMSH_FULLRC, "Y2", NULL, .445}, + {GMSH_FULLRC, "Z2", NULL, 1.}, + {GMSH_FULLRC, "nPointsU", NULL, 20}, + {GMSH_FULLRC, "nPointsV", NULL, 1}, + {GMSH_FULLRC, "MaxIter", NULL, 100}, + {GMSH_FULLRC, "DT", NULL, .1}, + {GMSH_FULLRC, "iView", NULL, -1.} +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterStreamLinesPlugin() + { + return new GMSH_StreamLinesPlugin(); + } +} + + +GMSH_StreamLinesPlugin::GMSH_StreamLinesPlugin() +{ + ; +} + +void GMSH_StreamLinesPlugin::getName(char *name) const +{ + strcpy(name, "Stream Lines"); +} + +void GMSH_StreamLinesPlugin::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, + "Compute stream lines from a vector view. As input, give\n" + "a rectangular {X0,Y0,Z0}-{X1,Y1,Z1} grid\n" + "using nbPoints x nbPoints and propagate those points\n" + "Script name: Plugin(StreamLines)."); +} + +int GMSH_StreamLinesPlugin::getNbOptions() const +{ + return sizeof(StreamLinesOptions_Number) / sizeof(StringXNumber); +} + +StringXNumber *GMSH_StreamLinesPlugin::getOption(int iopt) +{ + return &StreamLinesOptions_Number[iopt]; +} + +void GMSH_StreamLinesPlugin::catchErrorMessage(char *errorMessage) const +{ + strcpy(errorMessage, "StreamLines failed..."); +} + +int GMSH_StreamLinesPlugin::getNbU()const +{ + return (int)StreamLinesOptions_Number[9].def; +} + +int GMSH_StreamLinesPlugin::getNbV()const +{ + return (int)StreamLinesOptions_Number[10].def; +} + +void GMSH_StreamLinesPlugin::getPoint(int iU, int iV, double *X )const +{ + double u = (double)iU / (double)(getNbU ()); + double v = (double)iV / (double)(getNbV ()); + X[0] = StreamLinesOptions_Number[0].def + + u * (StreamLinesOptions_Number[3].def-StreamLinesOptions_Number[0].def) + + v * (StreamLinesOptions_Number[6].def-StreamLinesOptions_Number[0].def) ; + X[1] = StreamLinesOptions_Number[1].def + + u * (StreamLinesOptions_Number[4].def-StreamLinesOptions_Number[1].def) + + v * (StreamLinesOptions_Number[7].def-StreamLinesOptions_Number[1].def) ; + X[2] = StreamLinesOptions_Number[2].def + + u * (StreamLinesOptions_Number[5].def-StreamLinesOptions_Number[2].def) + + v * (StreamLinesOptions_Number[8].def-StreamLinesOptions_Number[2].def) ; +} + +Post_View * GMSH_StreamLinesPlugin::GenerateView (Post_View * v) const +{ + Post_View * View = BeginView (1); + + View->NbTimeStep = (int) StreamLinesOptions_Number[11].def; + + double XINIT[3]; + double X[3],DX[3]; + double X1[3]; + double X2[3]; + double X3[3]; + double X4[3]; + double VALUES [24]; + const double b1=1./3.,b2=2./3.,b3=1./3.,b4=1./6.,a1=0.5,a2=0.5,a3=1.0,a4=1.0; + OctreePost o ( v ); + + const double DT = StreamLinesOptions_Number[12].def; + for (int i=0 ; i < getNbU () ; ++i ) + { + for (int j=0 ; j < getNbV ();++j ) + { + getPoint ( i ,j , XINIT ); + getPoint ( i ,j , X ); + + int ITER = 0; + + View->NbVP++; + + List_Add(View->VP, &X[0]); + List_Add(View->VP, &X[1]); + List_Add(View->VP, &X[2]); + + while ( ITER++ < (int) StreamLinesOptions_Number[11].def ) + { + /// dX/dt = V + /// X1 = X + a1 * DT * V ( X ) + /// X2 = X + a2 * DT * V ( X1 ) + /// X3 = X + a3 * DT * V ( X2 ) + /// X4 = X + a4 * DT * V ( X3 ) + /// X = X + b1 X1 + b2 X2 + b3 X3 + b4 x4 + double sizeElem = 0.033; + o.searchVector ( X[0],X[1],X[2] , VALUES , &sizeElem, 0 ); + // sizeElem = 0.1; + double normV = sqrt (VALUES[0]*VALUES[0]+ + VALUES[1]*VALUES[1]+ + VALUES[2]*VALUES[2]); + // if (normV==0.0) normV = 1.0; + // double DT = sizeElem / normV ; /// CFL = 1 ==> secure + for (int k=0;k<3;k++) X1[k] = X[k] + DT * VALUES[k] * a1; + o.searchVector ( X1[0],X1[1],X1[2] , VALUES , &sizeElem,0 ); + for (int k=0;k<3;k++) X2[k] = X[k] + DT * VALUES[k] * a2; + o.searchVector ( X2[0],X2[1],X2[2] , VALUES , &sizeElem,0 ); + for (int k=0;k<3;k++) X3[k] = X[k] + DT * VALUES[k] * a3; + o.searchVector ( X3[0],X3[1],X3[2] , VALUES , &sizeElem,0); + for (int k=0;k<3;k++) X4[k] = X[k] + DT * VALUES[k] * a4; + for (int k=0;k<3;k++) X[k] += (b1*(X1[k]-X[k]) + b2*(X2[k]-X[k]) + b3*(X3[k]-X[k]) + b4*(X4[k]-X[k])) ; + for (int k=0;k<3;k++) DX[k] = X[k] - XINIT[k]; + List_Add(View->VP, &DX[0]); + List_Add(View->VP, &DX[1]); + List_Add(View->VP, &DX[2]); + + } + } + } + + char name[1024], filename[1024]; + sprintf(name, "streamlines-%s", v->Name); + sprintf(filename, "streamlines-%s", v->FileName); + EndView(View, 1 , filename, name); +} + +Post_View *GMSH_StreamLinesPlugin::execute(Post_View * v) +{ + Post_View *vv; + + int iView = (int)StreamLinesOptions_Number[13].def; + + if(v && iView < 0) + vv = v; + else { + if(!v && iView < 0) + iView = 0; + if(!(vv = (Post_View *) List_Pointer_Test(CTX.post.list, iView))) { + return 0; + } + } + Post_View * newView = GenerateView (vv); + + return newView; +} + +void GMSH_StreamLinesPlugin::Run() +{ + execute(0); +} +void GMSH_StreamLinesPlugin::Save() +{ +} diff --git a/Plugin/StreamLines.h b/Plugin/StreamLines.h new file mode 100644 index 0000000000..25bf134b2f --- /dev/null +++ b/Plugin/StreamLines.h @@ -0,0 +1,50 @@ +#ifndef _STREAMLINES_H_ +#define _STREAMLINES_H + +// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + +#include "Plugin.h" + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterStreamLinesPlugin (); +} + +class GMSH_StreamLinesPlugin : public GMSH_Post_Plugin +{ +public: + GMSH_StreamLinesPlugin(); + void getName (char *name) const; + void getInfos (char *author, + char *copyright, + char *help_text) const; + void catchErrorMessage (char *errorMessage) const; + int getNbOptions() const; + StringXNumber *getOption (int iopt); + Post_View *execute (Post_View *); + virtual void Run(); + virtual void Save(); + virtual int getNbU () const ; + virtual int getNbV () const ; + virtual void getPoint(int iU, int iV, double *X ) const ; + virtual Post_View * GenerateView (Post_View * v) const ; +}; + +#endif diff --git a/doc/texinfo/opt_plugin.texi b/doc/texinfo/opt_plugin.texi index 2b05591064..31052d041b 100644 --- a/doc/texinfo/opt_plugin.texi +++ b/doc/texinfo/opt_plugin.texi @@ -215,6 +215,28 @@ Default value: 1 Default value: -1 @end table + +@item Plugin(Streamlines) +Plugin(Streamlines) computes streamlines +from a vector view 'iView' . It takes as input +a grid of points defined by 3 points XYZ0 (origin) +XYZ1 (axis of U) and XYZ2 (axis of V). The user +can choose how many points are going to be +transported along U and V. Then, we solve +the equation DX(t)/dt = V (x,y,z) with X(0) +chosen on the grid and V(x,y,z) interpolated on the +vector view. The user has to choose the timestep as +well as the maximum number of iterations. The time +stepping scheme is a RK44. + +If `iView' < 0, the plugin is +run on the current view. + +Plugin(Streamlines) creates one new view. It is +nice to choose the displacement mode to see vectors +and to animate the view ;-) + + @item Plugin(Triangulate) Plugin(Triangulate) triangulates the points in the scalar view `iView', assuming that all -- GitLab