diff --git a/Common/Makefile b/Common/Makefile index 511cfb7ee8cc5322fa2f9f72ca6dbfdc391c23dd..9cc4e242b5a89e88d7bc9c62456303f98be519c0 100644 --- a/Common/Makefile +++ b/Common/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.54 2004-04-22 09:35:01 remacle Exp $ +# $Id: Makefile,v 1.55 2004-04-24 03:51:59 geuzaine 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 Views.h Trackball.h + Options.h DefaultOptions.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 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 + ../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 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 0f4b53000c55a5bf847a2599343c7df6cb053da7..ae888f12c42c117bdf0f9734de617288dc5444f0 100644 --- a/Geo/Makefile +++ b/Geo/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.47 2004-04-22 09:35:01 remacle Exp $ +# $Id: Makefile,v 1.48 2004-04-24 03:51:59 geuzaine 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 ExtrudeParams.h \ - ../Common/Visibility.h ../Common/Context.h + ../Mesh/Interpolation.h ../Mesh/Create.h CAD.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,37 +73,34 @@ 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 \ - ExtrudeParams.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.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 \ - ExtrudeParams.h ../Parser/Parser.h ../Common/Context.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 \ - ExtrudeParams.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.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 ExtrudeParams.h StepGeomDatabase.h \ - ../Mesh/Create.h ../Common/Context.h + ../Mesh/Nurbs.h CAD.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 \ - ExtrudeParams.h + ../Geo/ExtrudeParams.h ../Mesh/STL.h ../Mesh/Metric.h ../Mesh/Matrix.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 ExtrudeParams.h ../Common/Context.h + CAD.h ../Common/Context.h diff --git a/Mesh/Makefile b/Mesh/Makefile index ce3a78bd3f6936a5567c800893b4bdee6a1fe985..1ab0b555df8b87d582cc8773a0fa32246ae8e3bc 100644 --- a/Mesh/Makefile +++ b/Mesh/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.60 2004-04-22 09:35:01 remacle Exp $ +# $Id: Makefile,v 1.61 2004-04-24 03:51:59 geuzaine 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 Mesh.h Utils.h Vertex.h Create.h \ - 2D_Mesh.h ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Utils.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.h + ../Mesh/Metric.h ../Mesh/Matrix.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 Vertex.h Mesh.h \ - 2D_Mesh.h Create.h ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.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 Mesh.h Interpolation.h Vertex.h \ - Create.h ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.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,15 +209,13 @@ 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.h ../Common/Context.h Create.h \ - Vertex.h + ../Mesh/Metric.h ../Mesh/Matrix.h ../Common/Context.h Create.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 Mesh.h ../Common/Context.h Create.h \ - Vertex.h + ../Mesh/Metric.h ../Mesh/Matrix.h ../Common/Context.h Create.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 \ @@ -243,8 +241,7 @@ 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 Mesh.h Utils.h Vertex.h \ - ../Common/Context.h Create.h + ../Mesh/Metric.h ../Mesh/Matrix.h Utils.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 \ @@ -255,26 +252,23 @@ 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 Mesh.h Create.h Vertex.h \ - ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Create.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 Mesh.h 3D_Mesh.h Create.h Vertex.h ../Geo/MinMax.h \ - ../Common/Context.h + ../Mesh/Matrix.h 3D_Mesh.h Create.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 \ - ../Mesh/Mesh.h ../Mesh/Vertex.h ../Geo/Geo.h Create.h Interpolation.h \ - ../Common/Context.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 ../Mesh/Mesh.h ../Mesh/Vertex.h ../Common/Context.h + ../Geo/CAD.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 \ @@ -285,27 +279,24 @@ 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 Mesh.h Interpolation.h Vertex.h \ - ../Common/Context.h + ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.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 Mesh.h Matrix.h Interpolation.h \ - Vertex.h + ../Mesh/Metric.h ../Mesh/Matrix.h Interpolation.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 ../Mesh/Mesh.h Create.h ../Geo/CAD.h \ - ../Mesh/Vertex.h + ../Geo/Geo.h ../Geo/GeoUtils.h Create.h ../Geo/CAD.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 \ - ../Mesh/Mesh.h ../Mesh/Vertex.h Utils.h Interpolation.h + ../Geo/ExtrudeParams.h STL.h Metric.h Matrix.h ../Geo/CAD.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/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp index f7ed5601457132c071d9e81fdbb1d685ad070da7..5d559c02a336f017dd298de88ceb5cb02d34d354 100644 --- a/Plugin/CutGrid.cpp +++ b/Plugin/CutGrid.cpp @@ -1,6 +1,6 @@ -// $Id: CutGrid.cpp,v 1.1 2004-04-22 09:35:01 remacle Exp $ +// $Id: CutGrid.cpp,v 1.2 2004-04-24 03:51:59 geuzaine Exp $ // -// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// Copyright (C) 1997-2004 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 @@ -17,7 +17,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "gmsh@geuz.org". +// Please report all bugs and problems to <gmsh@geuz.org>. #include "OctreePost.h" #include "CutGrid.h" @@ -38,7 +38,8 @@ StringXNumber CutGridOptions_Number[] = { {GMSH_FULLRC, "X2", NULL, 0.}, {GMSH_FULLRC, "Y2", NULL, -1.}, {GMSH_FULLRC, "Z2", NULL, 0.}, - {GMSH_FULLRC, "nPoints", NULL, 20}, + {GMSH_FULLRC, "nPointsU", NULL, 20}, + {GMSH_FULLRC, "nPointsV", NULL, 20}, {GMSH_FULLRC, "iView", NULL, -1.} }; @@ -50,7 +51,6 @@ extern "C" } } - GMSH_CutGridPlugin::GMSH_CutGridPlugin() { ; @@ -67,8 +67,14 @@ void GMSH_CutGridPlugin::getInfos(char *author, char *copyright, 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)."); + "Plugin(CutGrid) cuts a 3D view with a rectangular\n" + "grid defined by the 3 points {`X0',`Y0',`Z0'} (origin)\n" + "{`X1',`Y1',`Z1'} (axis of U) and {`X2',`Y2',`Z2'} (axis\n" + "of V). The number of points along U and V is set\n" + "with the options `nPointsU' and `nPointsV'. If\n" + "`iView' < 0, the plugin is run on the current view.\n" + "\n" + "Plugin(CutGrid) creates one new view.\n"); } int GMSH_CutGridPlugin::getNbOptions() const @@ -93,7 +99,7 @@ int GMSH_CutGridPlugin::getNbU()const int GMSH_CutGridPlugin::getNbV()const { - return (int)CutGridOptions_Number[9].def; + return (int)CutGridOptions_Number[10].def; } void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X )const @@ -111,9 +117,9 @@ void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X )const v * (CutGridOptions_Number[8].def-CutGridOptions_Number[2].def) ; } -Post_View * GMSH_CutGridPlugin::GenerateView (Post_View * v) const +Post_View * GMSH_CutGridPlugin::GenerateView(Post_View * v) const { - Post_View * View = BeginView (1); + Post_View * View = BeginView(1); double X1[3],X2[3],X3[3],X4[3]; double *VALUES1 = new double [9*v->NbTimeStep]; @@ -121,98 +127,94 @@ Post_View * GMSH_CutGridPlugin::GenerateView (Post_View * v) const 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]); - } - } + 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); + sprintf(name, "%s_CutGrid", v->Name); + sprintf(filename, "%s_CutGrid", v->FileName); EndView(View, v->NbTimeStep, filename, name); delete [] VALUES1; delete [] VALUES2; delete [] VALUES3; delete [] VALUES4; + + return View; } Post_View *GMSH_CutGridPlugin::execute(Post_View * v) { Post_View *vv; - int iView = (int)CutGridOptions_Number[10].def; + int iView = (int)CutGridOptions_Number[11].def; if(v && iView < 0) vv = v; @@ -223,15 +225,7 @@ Post_View *GMSH_CutGridPlugin::execute(Post_View * v) return 0; } } - Post_View * newView = GenerateView (vv); - - return newView; -} - -void GMSH_CutGridPlugin::Run() -{ - execute(0); -} -void GMSH_CutGridPlugin::Save() -{ + Post_View * newView = GenerateView (vv); + + return newView; } diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h index e1940c5584a5c0bbb22b39aad55ec55dc8fd4323..83fe47b36aa6c3c26657d17517f6e39107e611c8 100644 --- a/Plugin/CutGrid.h +++ b/Plugin/CutGrid.h @@ -1,7 +1,7 @@ -#ifndef _CUTGRID_H_ -#define _CUTGRID_H +#ifndef _CUT_GRID_H_ +#define _CUT_GRID_H -// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// Copyright (C) 1997-2004 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 @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "gmsh@geuz.org". +// Please report all bugs and problems to <gmsh@geuz.org>. #include "Plugin.h" @@ -39,8 +39,6 @@ public: 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 ; diff --git a/Plugin/Makefile b/Plugin/Makefile index 3bfd9616098eb9cfedcf33b56754def538324db1..0c35362d7a17644e2dcaea75471880b4a30b501e 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.45 2004-04-22 09:35:01 remacle Exp $ +# $Id: Makefile,v 1.46 2004-04-24 03:52:00 geuzaine Exp $ # # Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle # @@ -30,7 +30,8 @@ SRC = Plugin.cpp\ Levelset.cpp\ CutPlane.cpp CutSphere.cpp CutMap.cpp\ Smooth.cpp\ - CutGrid.cpp OctreeSrc.cpp o_internals.cpp OctreePost.cpp StreamLines.cpp\ + Octree.cpp OctreeInternals.cpp OctreePost.cpp\ + StreamLines.cpp CutGrid.cpp\ Transform.cpp\ Triangulate.cpp\ SphericalRaise.cpp\ @@ -65,9 +66,9 @@ depend: # DO NOT DELETE THIS LINE Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ - PluginManager.h CutMap.h Levelset.h CutPlane.h CutSphere.h Skin.h \ - ../DataStr/Tree.h ../DataStr/avl.h Extract.h Harmonic2Time.h \ - DecomposeInSimplex.h Smooth.h Transform.h Triangulate.h \ + PluginManager.h CutMap.h Levelset.h CutGrid.h StreamLines.h CutPlane.h \ + CutSphere.h Skin.h ../DataStr/Tree.h ../DataStr/avl.h Extract.h \ + Harmonic2Time.h DecomposeInSimplex.h Smooth.h Transform.h Triangulate.h \ SphericalRaise.h DisplacementRaise.h Levelset.o: Levelset.cpp Levelset.h Plugin.h ../Common/Options.h \ ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ @@ -86,14 +87,19 @@ 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 \ +Octree.o: Octree.cpp Octree.h OctreeInternals.h +OctreeInternals.o: OctreeInternals.cpp ../Common/Message.h \ + OctreeInternals.h +OctreePost.o: OctreePost.cpp Octree.h OctreeInternals.h OctreePost.h \ + ../DataStr/List.h ../Common/Views.h ../Common/ColorTable.h \ + ../Numeric/Numeric.h ../Common/Message.h +StreamLines.o: StreamLines.cpp OctreePost.h Octree.h OctreeInternals.h \ + StreamLines.h Plugin.h ../Common/Options.h ../Common/Message.h \ + ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ + ../Common/Context.h +CutGrid.o: CutGrid.cpp OctreePost.h Octree.h OctreeInternals.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/OctreeSrc.cpp b/Plugin/Octree.cpp similarity index 63% rename from Plugin/OctreeSrc.cpp rename to Plugin/Octree.cpp index 4e59ab3c0b26a01618f9cfa8abe073f84478a9c3..53e0480e4e8b3526fd2ab1da822df831e6647a2a 100644 --- a/Plugin/OctreeSrc.cpp +++ b/Plugin/Octree.cpp @@ -1,17 +1,37 @@ +// $Id: Octree.cpp,v 1.1 2004-04-24 03:52:00 geuzaine Exp $ +// +// Copyright (C) 1997-2004 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 <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* 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, @@ -22,13 +42,11 @@ Octree* Octree_Create (int maxElements, double origin[3], double size[3], 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) @@ -37,16 +55,9 @@ void Octree_Insert(void * element, Octree *myOctree) 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) @@ -59,19 +70,14 @@ void Octree_Arrange(Octree *myOctree) 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; @@ -94,8 +100,7 @@ void free_buckets(octantBucket * bucket) return; } - -void Octree_SearchAll (double * pt, Octree * myOctree, list<void *> * output) +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/Octree.h b/Plugin/Octree.h index 848f0942e0bb043ec773eabc8c80d06085fa10b1..2ef3e4bd3d30f0ba7ccea85b3d9647657f297cfe 100644 --- a/Plugin/Octree.h +++ b/Plugin/Octree.h @@ -1,23 +1,41 @@ -#ifndef _OCTREEH_ -#define _OCTREEH_ +#ifndef _OCTREE_H_ +#define _OCTREE_H_ + +// Copyright (C) 1997-2004 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 <list> -#include "o_internals.h" +#include "OctreeInternals.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 *)); +Octree* Octree_Create(int maxElements, // max. num of elts 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_Delete(Octree *); +void Octree_Insert(void *, Octree *); void Octree_Arrange(Octree *); -void * Octree_Search (double *, Octree *); -void Octree_SearchAll (double *, Octree *, list<void *> * ); +void * Octree_Search(double *, Octree *); +void Octree_SearchAll(double *, Octree *, list<void *> *); + #endif diff --git a/Plugin/OctreeInternals.cpp b/Plugin/OctreeInternals.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ecbfd82b8a7c3565001c1ea13a1c0b6445026db5 --- /dev/null +++ b/Plugin/OctreeInternals.cpp @@ -0,0 +1,441 @@ +// $Id: OctreeInternals.cpp,v 1.1 2004-04-24 03:52:00 geuzaine Exp $ +// +// Copyright (C) 1997-2004 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 <iostream> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <list> + +#include "Message.h" +#include "OctreeInternals.h" + +using std::list; + +int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, + octantBucket **buckets_head, globalInfo **globalPara) +// Initialize the buckets +// Given by user: orig and size -- information about the domain +// maxElem -- maximum number of elements per bucket +// Return: buckets -- pointer to the begin of buckets +// globalPara -- some info about the buckets +// At last, 1 will be returned if succeed, otherwise, return 0 +{ + int i, j, k, tmp1; + int p = 1; + int initial_buckets_num; // which is a number of 8^p form for integer p + double tmp[3], error[3]; + octantBucket *buckets; + + for (i = 0; i < 3; i++) + error[i]= _size[i]*0.01; + + initial_buckets_num = (int)pow(8, p); // it is actually 8 + + (*globalPara) = new globalInfo; + (*globalPara)->maxPrecision = 1; + (*globalPara)->maxElements = _maxElem; + (*globalPara)->ptrToPrevElement = NULL; + + for (i = 0; i < 3; i++) { + (*globalPara)->origin[i] = _orig[i]; + (*globalPara)->size[i] = _size[i]; + } + + (*globalPara)->numBuckets = initial_buckets_num; + *buckets_head = new octantBucket; + if (!(*buckets_head)) { + Msg(GERROR, "initializeOctantBuckets could not allocate enough space"); + return (0); + } // if could not allocate buckets + + buckets = new octantBucket[8]; + if (!buckets) { + Msg(GERROR, "initializeOctantBuckets could not allocate enough space"); + return (0); + } + + (*buckets_head)->next = buckets; + (*buckets_head)->parent = NULL; + (*buckets_head)->numElements = 0; + (*buckets_head)->lhead = NULL; + (*buckets_head)->precision = 0; + for (i = 0; i< 3; i++) { + (*buckets_head)->minPt[i] = _orig[i]-error[i]; + (*buckets_head)->maxPt[i] = _size[i]+_orig[i]+error[i]; + } + + for (i = 0; i < (*globalPara)->numBuckets; i++) { + buckets[i].numElements = 0; + buckets[i].lhead = NULL; + buckets[i].next = NULL; + buckets[i].parent = *buckets_head; + buckets[i].precision = 1; + } + + tmp1 = (int)(pow(2, p)); + for (i = 0; i < 3; i++) { + tmp[i] = (double)(_size[i]+2*error[i])/tmp1; + } + + for (k = 0; k < tmp1; k++) { + for (j = 0; j < tmp1; j++) { + for (i = 0; i < tmp1; i++) { + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[0] =(* buckets_head)->minPt[0] + tmp[0]*i; + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[1] =(* buckets_head)->minPt[1] + tmp[1]*j; + buckets[i+j*tmp1+k*tmp1*tmp1].minPt[2] =(* buckets_head)->minPt[2] + tmp[2]*k; + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[0] =(* buckets_head)->minPt[0] + tmp[0]*(i+1); + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[1] =(* buckets_head)->minPt[1] + tmp[1]*(j+1); + buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[2] =(* buckets_head)->minPt[2] + tmp[2]*(k+1); + } + } + } + +#if 0 + for (i = 0; i < 8; i++) { + printf(" bucket %d : min[0]=%f, min[1]=%f, min[2]=%f, max[0]= %f, max[1]=%f, max[3]=%f\n", + i,buckets[i].minPt[0],buckets[i].minPt[1], + buckets[i].minPt[2], buckets[i].maxPt[0], buckets[i].maxPt[1], + buckets[i].maxPt[2]); + printf("bucket elements link list: bucket->lhead = %d\n", buckets[i].lhead); + } +#endif + + return (1); +} + +int addElement2Bucket(octantBucket *_bucket, void * _element, + double *_minBB, double *_maxBB, + double *_ele_centroid, globalInfo *_globalPara) +// Add another element to the octant bucket's list. +// If the bucket contains too many elements after adding this element, +// refine this bucket and reallocate the elements of this bucket +// Given:- the octant bucket, - the element +// - the element's minimum and maximum x,y,z +// - the element's centroid, - global information +// Check if element has already been added - if not, return 1 +// for successfully adding, otherwise return -1 +{ + int i, flag = 1; + ELink ptr1, ptr2; + octantBucket *ptrBucket; + + // check for duplicates + if ( checkElementInBucket(_bucket, _element) == 1) return -1; + + // printf("\n addToBucket...\n"); + // ptr1 = (ELink) malloc(sizeof(Elem)); + ptr1 = new Elem; + (_globalPara->listAllElements).push_back(_element); + + ptr1-> next = _bucket->lhead; + ptr1-> region = _element; + + for (i = 0; i < 3; i++) { + ptr1->minPt[i] = _minBB[i]; + ptr1->maxPt[i] = _maxBB[i]; + ptr1->centroid[i] = _ele_centroid[i]; + // printf(" %7.2f->%-7.2f",ptr1->minPt[i], ptr1->maxPt[i]); + } + + _bucket->lhead = ptr1; + (_bucket->numElements)++; + +#if 0 + printf("bucket element list: bucket->lhead = %d", _bucket->lhead); + printf(" numElements = %d\n",_bucket->numElements); + printf("the element is add to this bucket: (%f, %f, %f) to (%f, %f, %f)\n", + _bucket->minPt[0],_bucket->minPt[1], _bucket->minPt[2], _bucket->maxPt[0], + _bucket->maxPt[1], _bucket->maxPt[2] ); +#endif + + // check whether the number of elements in the bucket > maxElements + // if true, refine the bucket and reallocate the elements + while ( flag == 1) { + flag = 0; + if (_bucket->numElements > _globalPara->maxElements) { + + // printf(" going to subdivide\n"); + + subdivideOctantBucket(_bucket, _globalPara); + + // printf("finish subdivede \n"); + + ptr1 = _bucket->lhead; + while (ptr1 != NULL) { + ptrBucket = findElementBucket(_bucket, ptr1->centroid); + ptr2 = ptr1; + ptr1 = ptr1->next; + if (ptrBucket == NULL) + Msg(GERROR, "Wrong , ptrBucket = NULL. A bug here!"); + ptr2->next = ptrBucket->lhead; + ptrBucket->lhead = ptr2; + (ptrBucket->numElements)++; + if (ptrBucket->numElements > _globalPara->maxElements) { + flag = 1; + _bucket->lhead = NULL; + _bucket = ptrBucket; + } + } + if (flag == 0) _bucket->lhead = NULL; + } + } + return 1; +} + +int checkElementInBucket (octantBucket *_bucket, void* _element) +// Given an elememt and an octant bucket, check if the element +// exists in the bucket's element list. return 1 if already exits, +// otherwise, return 0 +{ + ELink ptr; + for (ptr = _bucket->lhead; ptr != NULL; ptr = ptr->next) { + // changed ****, compare the objected pointed by the void *. + if (ptr->region == _element) return 1; + } + return 0; +} + + +octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt) +// Find the leaf bucket which contains the point _pt +// given parameter: _buckets --- the point to buckets head +// _pt --- the point to find +// Return the pointer to the bucket contains the point +// if fail, return NULL +{ + int i, j; + int num = 8; + octantBucket *prevbucket = NULL; + octantBucket *tmpbucket = _buckets_head->next; + + while (tmpbucket != NULL) { + for (i = 0; i < num; i ++) { + for (j = 0; j < 3; j++) { + if (tmpbucket[i].minPt[j] > _pt[j] || + tmpbucket[i].maxPt[j] < _pt[j]) + break; + } + if (j == 3) { + prevbucket = tmpbucket+i; + tmpbucket = tmpbucket[i].next; + break; + } + } // for loop i + if (i == num) { + // printf("Error, no bucket contains the given point! "); + return NULL; + } + } // for while loop + return prevbucket; +} + + +int subdivideOctantBucket (octantBucket *_bucket, globalInfo *_globalPara) +// To many elements are in this octant bucket, so try to refine +// Returns 1 for success, 0 for failure (no memory left). +{ + int i, j, k, tmp1; + int numBuck = 8; + double tmp[3]; + + _bucket->next = new octantBucket[8]; + // _bucket->next = (octantBucket *) calloc(numBuck,sizeof(octantBucket)); + + if (!_bucket->next) { + fprintf(stderr,"Error, subdivideOctantBucket could not allocate enough space\n"); + return 0; + } + + _globalPara->numBuckets +=8; + if (_bucket->precision == _globalPara->maxPrecision) + _globalPara->maxPrecision++; + for (i = 0; i < numBuck; i++) { + (_bucket->next[i]).numElements = 0; + (_bucket->next[i]).lhead = NULL; + (_bucket->next[i]).next = NULL; + (_bucket->next[i]).parent = _bucket; + (_bucket->next[i]).precision = _bucket->precision+1; + } + + tmp1 = 2; + for (i = 0; i < 3; i++) { + tmp[i] = ((double )(_bucket->maxPt[i]-_bucket->minPt[i]))/tmp1; + } + + for (k = 0; k < tmp1; k++) { + for (j = 0; j < tmp1; j++) { + for (i = 0; i < tmp1; i++) { + _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[0] = _bucket->minPt[0] + tmp[0]*i; + _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[1] = _bucket->minPt[1] + tmp[1]*j; + _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[2] = _bucket->minPt[2] + tmp[2]*k; + _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = _bucket->minPt[0] + tmp[0]*(i+1); + _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = _bucket->minPt[1] + tmp[1]*(j+1); + _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = _bucket->minPt[2] + tmp[2]*(k+1); + } + } + } + + return 1; +} + +void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, + BBFunction BBElement, InEleFunction xyzInElement) +{ + int flag; + octantBucket *ptrBucket; + ELink ptr1; + list<void *>::iterator iter; + void * ptrToEle = _globalPara->ptrToPrevElement; + + if (ptrToEle) { + flag = xyzInElementBB(_pt, ptrToEle, BBElement); + if (flag == 1) + flag = xyzInElement(ptrToEle, _pt); + if (flag == 1) return ptrToEle; + } + + ptrBucket = findElementBucket(_buckets_head, _pt); + if (ptrBucket == NULL) { + // printf("Error! the point is not in the domain.\n"); + return NULL; + } + + ptr1 = ptrBucket->lhead; + +#if 0 + printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", + _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], + ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); + if (ptr1 == NULL) { + printf("empty element list for centroid list!?\n, possible!"); + } +#endif + + while (ptr1 != NULL){ + flag = xyzInElementBB(_pt, ptr1->region, BBElement); + if (flag == 1) + flag = xyzInElement(ptr1->region, _pt); + if (flag == 1) { + _globalPara->ptrToPrevElement = ptr1->region; + return ptr1->region; + } + ptr1 = ptr1->next; + } + + for (iter = (ptrBucket->listBB).begin(); + iter != (ptrBucket->listBB).end(); iter++){ + flag = xyzInElementBB(_pt, *iter, BBElement); + if (flag == 1) + flag = xyzInElement(*iter, _pt); + if (flag == 1) { + _globalPara->ptrToPrevElement = *iter; + return *iter; + } + } + + // printf("This point is not found in all elements! It is not in the domain \n"); + return NULL; +} + +int xyzInElementBB(double *_xyz, void * _region, BBFunction _BBElement) +// Check if xyz is in the region's bounding box, return 1 if true, 0 otherwise +// BBElement is the function given by user to find the bounding box +{ + int i; + double minPt[3]; // corner with smallest x,y,z coords + double maxPt[3]; // corner with largest x,y,z coords + + (*_BBElement)(_region, minPt, maxPt); + + for (i = 0; i < 3; i++) { + if (_xyz[i] > maxPt[i] || _xyz[i] < minPt[i]) return 0; + } // for ith direction + + return 1; +} + +void insertOneBB(void* _region, double *_minPt, double *_maxPt, octantBucket *_bucket) +{ + int i; + ELink ptr; + for (i = 0; i < 3; i++) { + if (_bucket->minPt[i] > _maxPt[i] || _bucket->maxPt[i] < _minPt[i]) + return; + } + if (_bucket->next == NULL) { + ptr = _bucket->lhead; + while (ptr != NULL) { + if (ptr->region == _region) return; + ptr = ptr->next; + } + + _bucket->listBB.insert(_bucket->listBB.end(),_region); + return; + } + + for (i = 0; i < 8; i++) + insertOneBB(_region, _minPt, _maxPt, _bucket->next+i); + return; +} + +void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, + BBFunction BBElement, InEleFunction xyzInElement, list<void *> *_elements) +{ + int flag, flag1; + octantBucket *ptrBucket; + list<void *>::iterator iter; + + ptrBucket = findElementBucket(_buckets_head, _pt); + if (ptrBucket == NULL) { + Msg(GERROR, "The point is not in the domain"); + return NULL; + } + +#if 0 + printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", + _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], + ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); + + if (ptr1 == NULL) { + printf("empty element list for centroid list!?\n, possible!"); + } +#endif + + flag1 = 0; + for (iter = (ptrBucket->listBB).begin(); + iter != (ptrBucket->listBB).end(); iter++){ + // printf("Enter 1 \n"); + flag = xyzInElementBB(_pt, *iter, BBElement); + if (flag == 1) + flag = xyzInElement(*iter, _pt); + if (flag == 1) { + _elements->push_back(*iter); + flag1 = 1; + } + } + + if (flag1) + return (void *)(_elements); + + Msg(WARNING, "This point is not found in any element! It is not in the domain"); + return NULL; +} diff --git a/Plugin/OctreeInternals.h b/Plugin/OctreeInternals.h new file mode 100644 index 0000000000000000000000000000000000000000..9be86fb31612953b69a00d206781567bd2ad8cda --- /dev/null +++ b/Plugin/OctreeInternals.h @@ -0,0 +1,94 @@ +#ifndef _OCTREE_INTERNALS_H_ +#define _OCTREE_INTERNALS_H_ + +// Copyright (C) 1997-2004 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 <list> + +// file of function prototypes and macro constants +typedef void (*BBFunction)(void *, double*, double*); +typedef int (*InEleFunction)(void *, double *); +typedef void (*CentroidFunction)(void *, double *); + +// structure for list of elements in an octant +typedef struct elem { + void * region; // the pointer to a mesh Db region + double centroid[3]; // centroid of element bounding box inside of the octant + double minPt[3]; // corner of element bounding box nearest the origin + double maxPt[3]; // corner of elem bound box furthest from the origin + struct elem *next; // link to next item in list, NULL if end +} Elem; +typedef Elem *ELink; + +// stucture for octant buckets +struct bucket { + double minPt[3]; // the point with the smallest coordinates + double maxPt[3]; // the point with the biggest coordinates + int numElements; // number of elements contained by bucket + int precision; // the level of precision of the bucket + ELink lhead; // list of elements in bucket, if NULL -> no elements + std::list<void *> listBB; // list of elements in bucket by Bounding Box + struct bucket *next; // link to ragged digit extensions to bucket array + struct bucket *parent; // link to the parent bucket +}; +typedef struct bucket octantBucket; + +// structure for global information and requirment +struct global { + int numBuckets; // number of octant buckets in initial grid array + int maxElements; // max. number of elements allowed in an octant + int maxPrecision; // current maximum octant precision for model + double origin[3]; // smallest x,y, z of model's bounding box + double size[3]; // size in x, y, z of model bounding box + void * ptrToPrevElement; + std::list<void *> listAllElements; +}; +typedef struct global globalInfo; + +typedef struct +{ + globalInfo *info; + octantBucket *root; + BBFunction function_BB; + InEleFunction function_inElement; + CentroidFunction function_centroid; +}Octree; + +void refineOctants(octantBucket *buckets, + globalInfo *globalPara); + +int addElement2Bucket(octantBucket *bucket, void * element, + double *minBB, double *maxBB, + double *ele_centroid, globalInfo *globalPara); +int subdivideOctantBucket(octantBucket *bucket, globalInfo *globalPara); +int initializeOctantBuckets(double *orig, double *size, int maxElem, + octantBucket **buckets, globalInfo **globalPara); +int checkElementInBucket(octantBucket *bucket, void * element); +octantBucket* findElementBucket(octantBucket *buckets, double *pt); +void * searchElement(octantBucket *buckets, double *pt, + globalInfo *globalPara, BBFunction BBElement, + InEleFunction xyzInElement); +int xyzInElementBB(double *xyz, void *region, BBFunction BBElement); +void insertOneBB(void *, double *, double *, octantBucket *); +void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, + BBFunction BBElement, InEleFunction xyzInElement, + std::list<void *> *_elements); + +#endif diff --git a/Plugin/OctreePost.cpp b/Plugin/OctreePost.cpp index 470942bfa905e012aec97ff3cff3e363bc20426f..d6c5ae45659b467dfd1f3171a5712e587fc5ddf4 100644 --- a/Plugin/OctreePost.cpp +++ b/Plugin/OctreePost.cpp @@ -1,428 +1,429 @@ -#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+3] * U[0] + - V[9*i+6] * U[1] + - V[9*i+0] * (1-U[0]-U[1]); - values[3*i+1] = - V[9*i+4] * U[0] + - V[9*i+7] * U[1] + - V[9*i+1] * (1-U[0]-U[1]); - values[3*i+2] = - V[9*i+5] * U[0] + - V[9*i+8] * U[1] + - V[9*i+2] * (1-U[0]-U[1]); - } - } - else - { - values[0] = - V[9*timestep+3] * U[0] + - V[9*timestep+6] * U[1] + - V[9*timestep+0] * (1-U[0]-U[1]); - values[1] = - V[9*timestep+4] * U[0] + - V[9*timestep+7] * U[1] + - V[9*timestep+1] * (1-U[0]-U[1]); - values[2] = - V[9*timestep+5] * U[0] + - V[9*timestep+8] * U[1] + - V[9*timestep+2] * (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+3] * U[0] + - V[12*i+6] * U[1] + - V[12*i+9] * U[2] + - V[12*i+0] * (1-U[0]-U[1]-U[2]); - values[3*i+1] = - V[12*i+4] * U[0] + - V[12*i+9] * U[1] + - V[12*i+10] * U[2] + - V[12*i+1] * (1-U[0]-U[1]-U[2]); - values[3*i+2] = - V[12*i+5] * U[0] + - V[12*i+7] * U[1] + - V[12*i+11] * U[2] + - V[12*i+2] * (1-U[0]-U[1]-U[2]); - } - } - else - { - values[0] = - V[12*timestep+3] * U[0] + - V[12*timestep+6] * U[1] + - V[12*timestep+9] * U[2] + - V[12*timestep+0] * (1-U[0]-U[1]-U[2]); - values[1] = - V[12*timestep+4] * U[0] + - V[12*timestep+7] * U[1] + - V[12*timestep+10] * U[2] + - V[12*timestep+1 ] * (1-U[0]-U[1]-U[2]); - values[2] = - V[12*timestep+5 ] * U[0] + - V[12*timestep+8 ] * U[1] + - V[12*timestep+11] * U[2] + - V[12*timestep+2 ] * (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+1] * U[0] + - V[3*i+2] * U[1] + - V[3*i+0] * (1-U[0]-U[1]); - } - } - else - { - values[0] = - V[3*timestep+1] * U[0] + - V[3*timestep+2] * U[1] + - V[3*timestep+0] * (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+1] * U[0] + - V[3*i+2] * U[1] + - V[3*i+3] * U[2] + - V[3*i+0] * (1.-U[0]-U[1]-U[2]); - } - } - else - { - values[0] = - V[3*timestep+1] * U[0] + - V[3*timestep+2] * U[1] + - V[3*timestep+3] * U[2] + - V[3*timestep ] * (1-U[0]-U[1]-U[2]); - } - return true; - } - - return false; -} +// $Id: OctreePost.cpp,v 1.3 2004-04-24 03:52:00 geuzaine Exp $ +// +// Copyright (C) 1997-2004 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" +#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+3] * U[0] + + V[9*i+6] * U[1] + + V[9*i+0] * (1-U[0]-U[1]); + values[3*i+1] = + V[9*i+4] * U[0] + + V[9*i+7] * U[1] + + V[9*i+1] * (1-U[0]-U[1]); + values[3*i+2] = + V[9*i+5] * U[0] + + V[9*i+8] * U[1] + + V[9*i+2] * (1-U[0]-U[1]); + } + } + else{ + values[0] = + V[9*timestep+3] * U[0] + + V[9*timestep+6] * U[1] + + V[9*timestep+0] * (1-U[0]-U[1]); + values[1] = + V[9*timestep+4] * U[0] + + V[9*timestep+7] * U[1] + + V[9*timestep+1] * (1-U[0]-U[1]); + values[2] = + V[9*timestep+5] * U[0] + + V[9*timestep+8] * U[1] + + V[9*timestep+2] * (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+3] * U[0] + + V[12*i+6] * U[1] + + V[12*i+9] * U[2] + + V[12*i+0] * (1-U[0]-U[1]-U[2]); + values[3*i+1] = + V[12*i+4] * U[0] + + V[12*i+9] * U[1] + + V[12*i+10] * U[2] + + V[12*i+1] * (1-U[0]-U[1]-U[2]); + values[3*i+2] = + V[12*i+5] * U[0] + + V[12*i+7] * U[1] + + V[12*i+11] * U[2] + + V[12*i+2] * (1-U[0]-U[1]-U[2]); + } + } + else{ + values[0] = + V[12*timestep+3] * U[0] + + V[12*timestep+6] * U[1] + + V[12*timestep+9] * U[2] + + V[12*timestep+0] * (1-U[0]-U[1]-U[2]); + values[1] = + V[12*timestep+4] * U[0] + + V[12*timestep+7] * U[1] + + V[12*timestep+10] * U[2] + + V[12*timestep+1 ] * (1-U[0]-U[1]-U[2]); + values[2] = + V[12*timestep+5 ] * U[0] + + V[12*timestep+8 ] * U[1] + + V[12*timestep+11] * U[2] + + V[12*timestep+2 ] * (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+1] * U[0] + + V[3*i+2] * U[1] + + V[3*i+0] * (1-U[0]-U[1]); + } + } + else{ + values[0] = + V[3*timestep+1] * U[0] + + V[3*timestep+2] * U[1] + + V[3*timestep+0] * (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+1] * U[0] + + V[3*i+2] * U[1] + + V[3*i+3] * U[2] + + V[3*i+0] * (1.-U[0]-U[1]-U[2]); + } + } + else + { + values[0] = + V[3*timestep+1] * U[0] + + V[3*timestep+2] * U[1] + + V[3*timestep+3] * U[2] + + V[3*timestep ] * (1-U[0]-U[1]-U[2]); + } + return true; + } + + return false; +} diff --git a/Plugin/OctreePost.h b/Plugin/OctreePost.h index e7bee8833d631342e262a9cee1f844f1beb18d9d..0a75f78465018980d43c4105d88ee48efe46fbe8 100644 --- a/Plugin/OctreePost.h +++ b/Plugin/OctreePost.h @@ -1,52 +1,53 @@ -#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 +#ifndef _OCTREE_POST_H_ +#define _OCTREE_POST_H_ + +// Copyright (C) 1997-2004 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/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp index 9de30e5db5d0bed7df72c5a4a5dc48b23e998a9c..3d761750dc0c81a53d27ee06a498eabba5f91ef5 100644 --- a/Plugin/SphericalRaise.cpp +++ b/Plugin/SphericalRaise.cpp @@ -1,4 +1,4 @@ -// $Id: SphericalRaise.cpp,v 1.13 2004-03-13 21:00:19 geuzaine Exp $ +// $Id: SphericalRaise.cpp,v 1.14 2004-04-24 03:52:00 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -69,8 +69,8 @@ void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, "the nodes along the X, Y and Z axes as in\n" "View[`iView'].RaiseX, View[`iView'].RaiseY\n" "and View[`iView'].RaiseZ, the raise is applied\n" - " along the radius of a sphere centered at (`Xc',\n" - "`Yc', `Zc'). If `iView' < 0, the plugin is run\n" + " along the radius of a sphere centered at {`Xc',\n" + "`Yc', `Zc'}. If `iView' < 0, the plugin is run\n" "on the current view.\n" "\n" "Plugin(SphericalRaise) is executed in-place.\n"); diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp index ae7460fc95ab579126ccf507ab131585c3d9c862..32e887fe4ff5e926bd77a07b3bf6f8d469f32402 100644 --- a/Plugin/StreamLines.cpp +++ b/Plugin/StreamLines.cpp @@ -1,6 +1,6 @@ -// $Id: StreamLines.cpp,v 1.1 2004-04-22 09:35:01 remacle Exp $ +// $Id: StreamLines.cpp,v 1.2 2004-04-24 03:52:00 geuzaine Exp $ // -// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// Copyright (C) 1997-2004 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 @@ -17,7 +17,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "gmsh@geuz.org". +// Please report all bugs and problems to <gmsh@geuz.org>. #include <math.h> #include "OctreePost.h" @@ -62,19 +62,33 @@ GMSH_StreamLinesPlugin::GMSH_StreamLinesPlugin() void GMSH_StreamLinesPlugin::getName(char *name) const { - strcpy(name, "Stream Lines"); + strcpy(name, "Stream lines"); } void GMSH_StreamLinesPlugin::getInfos(char *author, char *copyright, - char *help_text) const + 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)."); + "Plugin(StreamLines) computes stream lines\n" + "from a vector view `iView'. It takes as input a\n" + "grid defined by the 3 points {`X0',`Y0',`Z0'}\n" + "(origin), {`X1',`Y1',`Z1'} (axis of U) and\n" + "{`X2',`Y2',`Z2'} (axis of V). The number of points\n" + "that are going to be transported along U and V is\n" + "set with the options `nPointsU' and `nPointsV'.\n" + "Then, we solve the equation DX(t)/dt = V(x,y,z)\n" + "with X(t=0) chosen as the grid and V(x,y,z)\n" + "interpolated on the vector view. The timestep and\n" + "the maximum number of iterations are set with\n" + "the options `MaxIter' and `DT'. The time stepping\n" + "scheme is a RK44. If `iView' < 0, the plugin is run\n" + "on the current view.\n" + "\n" + "Plugin(StreamLines) creates one new view. It is\n" + "nice to choose the displacement mode to see\n" + "vectors and to animate the view ;-)\n"); } int GMSH_StreamLinesPlugin::getNbOptions() const @@ -117,9 +131,9 @@ void GMSH_StreamLinesPlugin::getPoint(int iU, int iV, double *X )const v * (StreamLinesOptions_Number[8].def-StreamLinesOptions_Number[2].def) ; } -Post_View * GMSH_StreamLinesPlugin::GenerateView (Post_View * v) const +Post_View * GMSH_StreamLinesPlugin::GenerateView(Post_View * v) const { - Post_View * View = BeginView (1); + Post_View * View = BeginView(1); View->NbTimeStep = (int) StreamLinesOptions_Number[11].def; @@ -131,61 +145,60 @@ Post_View * GMSH_StreamLinesPlugin::GenerateView (Post_View * v) const 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 ); + 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 ); + 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]); - - } - } + 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); + sprintf(name, "%s_StreamLines", v->Name); + sprintf(filename, "%s_StreamLines", v->FileName); + EndView(View, 1, filename, name); + + return View; } Post_View *GMSH_StreamLinesPlugin::execute(Post_View * v) @@ -203,15 +216,8 @@ Post_View *GMSH_StreamLinesPlugin::execute(Post_View * v) return 0; } } - Post_View * newView = GenerateView (vv); - - return newView; -} - -void GMSH_StreamLinesPlugin::Run() -{ - execute(0); -} -void GMSH_StreamLinesPlugin::Save() -{ + + Post_View *newView = GenerateView(vv); + + return newView; } diff --git a/Plugin/StreamLines.h b/Plugin/StreamLines.h index 25bf134b2f6c9e1e299b8cb5410b8934b04aaded..cb0c65f4102a6f9d2aa7f50c2049f5c548a73a49 100644 --- a/Plugin/StreamLines.h +++ b/Plugin/StreamLines.h @@ -1,7 +1,7 @@ -#ifndef _STREAMLINES_H_ -#define _STREAMLINES_H +#ifndef _STREAM_LINES_H_ +#define _STREAM_LINES_H -// Copyright (C) 1997-2003 C. Geuzaine, J.-F. Remacle +// Copyright (C) 1997-2004 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 @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "gmsh@geuz.org". +// Please report all bugs and problems to <gmsh@geuz.org>. #include "Plugin.h" @@ -39,8 +39,6 @@ public: 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 ; diff --git a/Plugin/o_internals.cpp b/Plugin/o_internals.cpp deleted file mode 100644 index 0e94991bab15b647892143add476e27fb50992ad..0000000000000000000000000000000000000000 --- a/Plugin/o_internals.cpp +++ /dev/null @@ -1,441 +0,0 @@ -#include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <list> - -using std::list; -#include "o_internals.h" - - -int initializeOctantBuckets(double *_orig, double *_size, int _maxElem, - octantBucket **buckets_head, globalInfo **globalPara) - -/* Initialize the buckets */ -/* Given by user: orig and size -- information about the domain */ -/* maxElem -- maximum number of elements per bucket */ -/* Return: buckets -- pointer to the begin of buckets */ -/* globalPara -- some info about the buckets */ -/* At last, 1 will be returned if succeed, otherwise, return 0 */ - -{ - int i, j, k, tmp1; - int p = 1; - int initial_buckets_num; /* which is a number of 8^p form for integer p */ - double tmp[3], error[3]; - octantBucket *buckets; - - for(i = 0; i<3; i++) - error[i]= _size[i]*0.01; - - initial_buckets_num = (int)pow(8, p); /* it is actually 8 */ - - (*globalPara) = new globalInfo; //(globalInfo *)malloc(sizeof(globalInfo)); - (*globalPara)->maxPrecision = 1; - (*globalPara)->maxElements = _maxElem; - (*globalPara)->ptrToPrevElement = NULL; - - for (i=0;i<3;i++) { - (*globalPara)->origin[i] = _orig[i]; - (*globalPara)->size[i] = _size[i]; - } - - - (*globalPara)->numBuckets = initial_buckets_num; -// *buckets_head = (octantBucket *)malloc(sizeof(octantBucket)); - *buckets_head = new octantBucket; - if (!(*buckets_head)) { - printf("Error, initializeOctantBuckets could not allocate enough space\n"); - return (0); - } /* if could not allocate buckets */ - -// buckets = (octantBucket *)calloc((*globalPara)->numBuckets,sizeof(octantBucket)); - buckets = new octantBucket[8]; - if (!buckets) { - printf("Error, initializeOctantBuckets could not allocate enough space\n"); - return (0); - } /* if could not allocate buckets */ - - (*buckets_head)->next = buckets; - (*buckets_head)->parent = NULL; - (*buckets_head)->numElements = 0; - (*buckets_head)->lhead = NULL; - (*buckets_head)->precision = 0; - for(i = 0; i< 3; i++) { - (*buckets_head)->minPt[i] = _orig[i]-error[i]; - (*buckets_head)->maxPt[i] = _size[i]+_orig[i]+error[i]; - } - - for (i=0;i<(*globalPara)->numBuckets;i++) { - buckets[i].numElements = 0; - buckets[i].lhead = NULL; - buckets[i].next = NULL; - buckets[i].parent = *buckets_head; - buckets[i].precision = 1; - } - - tmp1 = (int)(pow(2, p)); - for(i = 0; i< 3; i++) { - tmp[i] = (double)(_size[i]+2*error[i])/tmp1; - } - - for(k = 0; k<tmp1; k++) { - for(j = 0; j < tmp1; j++) { - for(i = 0; i<tmp1; i++) { - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[0] =(* buckets_head)->minPt[0] + tmp[0]*i; - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[1] =(* buckets_head)->minPt[1] + tmp[1]*j; - buckets[i+j*tmp1+k*tmp1*tmp1].minPt[2] =(* buckets_head)->minPt[2] + tmp[2]*k; - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[0] =(* buckets_head)->minPt[0] + tmp[0]*(i+1); - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[1] =(* buckets_head)->minPt[1] + tmp[1]*(j+1); - buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[2] =(* buckets_head)->minPt[2] + tmp[2]*(k+1); - } - } - } - /* for test - for(i = 0; i< 8; i++) { - printf(" bucket %d : min[0]=%f, min[1]=%f, min[2]=%f, - max[0]= %f, max[1]=%f, max[3]=%f \n",i,buckets[i].minPt[0],buckets[i].minPt[1], - buckets[i].minPt[2], buckets[i].maxPt[0], buckets[i].maxPt[1], - buckets[i].maxPt[2]); - - printf("bucket elements link list: bucket->lhead = %d\n", buckets[i].lhead); - } - end for test -*/ - - return (1); -} -; - -int addElement2Bucket (octantBucket *_bucket, void * _element, - double *_minBB, double *_maxBB, - double *_ele_centroid, globalInfo *_globalPara) - -/* Add another element to the octant bucket's list. */ -/* If the bucket contains too many elements after adding this element, */ -/* refine this bucket and reallocate the elements of this bucket */ -/* Given:- the octant bucket, - the element */ -/* - the element's minimum and maximum x,y,z */ -/* - the element's centroid, - global information */ - -/* Check if element has already been added - if not, return 1 */ -/* for successfully adding, otherwise return -1 */ - -{ - int i, flag = 1; /* flag to identify whether refine is finished or not */ - ELink ptr1, ptr2; - octantBucket *ptrBucket; - - /* check for duplicates */ - if ( checkElementInBucket(_bucket, _element) == 1) return -1; - -// printf("\n addToBucket...\n"); -// ptr1 = (ELink) malloc(sizeof(Elem)); - ptr1 = new Elem; - (_globalPara->listAllElements).push_back(_element); - - ptr1-> next = _bucket->lhead; - ptr1-> region = _element; - - for (i=0;i<3;i++) { - ptr1->minPt[i] = _minBB[i]; - ptr1->maxPt[i] = _maxBB[i]; - ptr1->centroid[i] = _ele_centroid[i]; - /* printf(" %7.2f->%-7.2f",ptr1->minPt[i], ptr1->maxPt[i]); */ - } - - _bucket->lhead = ptr1; - (_bucket->numElements)++; - - /* - printf("bucket element list: bucket->lhead = %d", _bucket->lhead); - printf(" numElements = %d\n",_bucket->numElements); - printf("the element is add to this bucket: (%f, %f, %f) to (%f, %f, %f)\n", - _bucket->minPt[0],_bucket->minPt[1], _bucket->minPt[2], _bucket->maxPt[0], - _bucket->maxPt[1], _bucket->maxPt[2] ); - */ - - /* check whether the number of elements in the bucket > maxElements */ - /* if true, refine the bucket and reallocate the elements */ - while( flag == 1) { - flag = 0; - if(_bucket->numElements > _globalPara->maxElements) { - - // printf(" going to subdivide\n"); - - subdivideOctantBucket(_bucket, _globalPara); - - //printf("finish subdivede \n"); - - ptr1 = _bucket->lhead; - while(ptr1 != NULL) { - ptrBucket = findElementBucket(_bucket, ptr1->centroid); - ptr2 = ptr1; - ptr1 = ptr1->next; - if(ptrBucket == NULL) - printf("Wrong , ptrBucket = NULL. A bug here!\n"); - ptr2->next = ptrBucket->lhead; - ptrBucket->lhead = ptr2; - (ptrBucket->numElements)++; - if(ptrBucket->numElements > _globalPara->maxElements) { - flag = 1; - _bucket->lhead = NULL; - _bucket = ptrBucket; - } - } - if(flag == 0) _bucket->lhead = NULL; - } - } - return 1; -} - - - - -int checkElementInBucket (octantBucket *_bucket, void* _element) -/* Given an elememt and an octant bucket, check if the element */ -/* exists in the bucket's element list. return 1 if already exits, */ -/* otherwise, return 0 */ -{ - ELink ptr; - for (ptr = _bucket->lhead; ptr != NULL; ptr = ptr->next) { - /* changed ****, compare the objected pointed by the void *. */ - if (ptr->region == _element) return 1; - } - return 0; -} - - -octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt) -{ -/* Find the leaf bucket which contains the point _pt */ -/* given parameter: _buckets --- the point to buckets head*/ -/* _pt --- the point to find */ -/* Return the pointer to the bucket contains the point */ -/* if fail, return NULL */ - - int i, j; - int num = 8; - octantBucket *prevbucket = NULL; - octantBucket *tmpbucket = _buckets_head->next; - - while(tmpbucket != NULL) { - for(i = 0; i< num; i ++) { - for(j = 0; j < 3; j++) { - if(tmpbucket[i].minPt[j] > _pt[j] || - tmpbucket[i].maxPt[j] < _pt[j]) - break; - } - if (j == 3) { - prevbucket = tmpbucket+i; - tmpbucket = tmpbucket[i].next; - break; - } - } /* for loop i */ - if(i == num) { - // printf("Error, no bucket contains the given point! "); - return NULL; - } - } /* for while loop */ - return prevbucket; -} - - -int subdivideOctantBucket (octantBucket *_bucket, globalInfo *_globalPara) -/* To many elements are in this octant bucket, so try to refine */ -/* Returns 1 for success, 0 for failure (no memory left). */ - -{ - int i, j, k, tmp1; - int numBuck = 8; - double tmp[3]; - - _bucket->next = new octantBucket[8]; -// _bucket->next = (octantBucket *) calloc(numBuck,sizeof(octantBucket)); - - if (!_bucket->next) { - fprintf(stderr,"Error, subdivideOctantBucket could not allocate enough space\n"); - return 0; - } /* if could not allocate buckets */ - - _globalPara->numBuckets +=8; - if(_bucket->precision == _globalPara->maxPrecision) - _globalPara->maxPrecision++; - for (i=0;i<numBuck;i++) { - (_bucket->next[i]).numElements = 0; - (_bucket->next[i]).lhead = NULL; - (_bucket->next[i]).next = NULL; - (_bucket->next[i]).parent = _bucket; - (_bucket->next[i]).precision = _bucket->precision+1; - } - - tmp1 = 2; - for(i = 0; i< 3; i++) { - tmp[i] = ((double )(_bucket->maxPt[i]-_bucket->minPt[i]))/tmp1; - } - - for(k = 0; k<tmp1; k++) { - for(j = 0; j < tmp1; j++) { - for(i = 0; i<tmp1; i++) { - _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[0] = _bucket->minPt[0] + tmp[0]*i; - _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[1] = _bucket->minPt[1] + tmp[1]*j; - _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[2] = _bucket->minPt[2] + tmp[2]*k; - _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = _bucket->minPt[0] + tmp[0]*(i+1); - _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = _bucket->minPt[1] + tmp[1]*(j+1); - _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = _bucket->minPt[2] + tmp[2]*(k+1); - } - } - } - - return 1; -} - - - -void * searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement) -{ - int flag; - octantBucket *ptrBucket; - ELink ptr1; - list<void *>::iterator iter; - void * ptrToEle = _globalPara->ptrToPrevElement; - - if(ptrToEle) { - flag = xyzInElementBB(_pt, ptrToEle, BBElement); - if(flag == 1) - flag = xyzInElement(ptrToEle, _pt); - if(flag == 1) return ptrToEle; - } - - ptrBucket = findElementBucket(_buckets_head, _pt); - if(ptrBucket == NULL) { - // printf("Error! the point is not in the domain.\n"); - return NULL; - } - - ptr1 = ptrBucket->lhead; - /* - - printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", - _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], - ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); - - if(ptr1 == NULL) { - printf("empty element list for centroid list!?\n, possible!"); - } - */ - - while(ptr1 != NULL) - { - flag = xyzInElementBB(_pt, ptr1->region, BBElement); - if(flag == 1) - flag = xyzInElement(ptr1->region, _pt); - if(flag == 1) { - _globalPara->ptrToPrevElement = ptr1->region; - return ptr1->region; - } - ptr1 = ptr1->next; - } - - for(iter = (ptrBucket->listBB).begin(); iter != - (ptrBucket->listBB).end(); iter++) - { - flag = xyzInElementBB(_pt, *iter, BBElement); - if(flag == 1) - flag = xyzInElement(*iter, _pt); - if(flag == 1) { - _globalPara->ptrToPrevElement = *iter; - return *iter; - } - } - - // printf("This point is not found in all elements! It is not in the domain \n"); - return NULL; -} - -int xyzInElementBB(double *_xyz, void * _region, BBFunction _BBElement) -/* Check if xyz is in the region's bounding box, return 1 if true, 0 otherwise */ -/* BBElement is the function given by user to find the bounding box */ - -{ - int i; - double minPt[3]; /* corner with smallest x,y,z coords */ - double maxPt[3]; /* corner with largest x,y,z coords */ - - (*_BBElement)(_region, minPt, maxPt); - - for (i=0;i<3;i++) { - if (_xyz[i] > maxPt[i] || _xyz[i] < minPt[i]) return 0; - } /* for ith direciton */ - return 1; -} - -void insertOneBB(void* _region, double *_minPt, double *_maxPt, octantBucket *_bucket) -{ - int i; - ELink ptr; - for(i = 0; i< 3; i++) { - if(_bucket->minPt[i] > _maxPt[i] || _bucket->maxPt[i] < _minPt[i]) - return; - } - if(_bucket->next == NULL) { - ptr = _bucket->lhead; - while(ptr != NULL) { - if(ptr->region == _region) return; - ptr = ptr->next; - } - - _bucket->listBB.insert(_bucket->listBB.end(),_region); - return; - } - - for(i=0; i<8; i++) - insertOneBB(_region, _minPt, _maxPt, _bucket->next+i); - return; -} - - -void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement, list<void *> *_elements) -{ - int flag, flag1; - octantBucket *ptrBucket; - list<void *>::iterator iter; - - ptrBucket = findElementBucket(_buckets_head, _pt); - if(ptrBucket == NULL) { - printf("Error! the point is not in the domain.\n"); - return NULL; - } - - /* - printf("point %lf %lf %lf has been found in bucket %lf %lf %fl -> %lf %lf %lf %p\n", - _pt[0],_pt[1],_pt[2], ptrBucket->minPt[0],ptrBucket->minPt[1],ptrBucket->minPt[2], - ptrBucket->maxPt[0],ptrBucket->maxPt[1],ptrBucket->maxPt[2], ptr1); - - if(ptr1 == NULL) { - printf("empty element list for centroid list!?\n, possible!"); - } - */ - - flag1 = 0; - for(iter = (ptrBucket->listBB).begin(); iter != - (ptrBucket->listBB).end(); iter++) - { - printf("Enter 1 \n"); - flag = xyzInElementBB(_pt, *iter, BBElement); - if(flag == 1) - flag = xyzInElement(*iter, _pt); - if(flag == 1) { - _elements->push_back(*iter); - flag1 = 1; - } - } - - if(flag1) - return (void *)(_elements); - - printf("This point is not found in all elements! It is not in the domain \n"); - return NULL; -} diff --git a/Plugin/o_internals.h b/Plugin/o_internals.h deleted file mode 100644 index 35dc338d242f053d45c3bd61c6465ae5d15e75fc..0000000000000000000000000000000000000000 --- a/Plugin/o_internals.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef OCTCLASSIFY -#define OCTCLASSIFY -#include <list> - - /* file of function prototypes and macro constants */ - - typedef void (*BBFunction)(void *, double*, double*); - typedef int (*InEleFunction)(void *, double *); - typedef void (*CentroidFunction)(void *, double *); - - /* structure for list of elements in an octant */ - typedef struct elem { - void * region; /* the pointer to a mesh Db region */ - double centroid[3]; /* centroid of element bounding box inside of the octant */ - double minPt[3]; /* corner of element bounding box nearest the origin */ - double maxPt[3]; /* corner of elem bound box furthest from the origin */ - struct elem *next; /* link to next item in list, NULL if end */ - } Elem; - typedef Elem *ELink; - - /* stucture for octant buckets */ - struct bucket { - double minPt[3]; /* the point with the smallest coordinates */ - double maxPt[3]; /* the point with the biggest coordinates */ - int numElements; /* number of elements contained by bucket */ - int precision; /* the level of precision of the bucket */ - ELink lhead; /* list of elements in bucket, if NULL -> no elements */ - std::list<void *> listBB; /* list of elements in bucket by Bounding Box */ - struct bucket *next; /* link to ragged digit extensions to bucket array */ - struct bucket *parent; /* link to the parent bucket */ - }; - typedef struct bucket octantBucket; - - /* octantBucket *buckets=NULL; */ - - /* structure for global information and requirment */ - struct global { - int numBuckets; /* number of octant buckets in initial grid array */ - int maxElements; /* max. number of elements allowed in an octant */ - int maxPrecision; /* current maximum octant precision for model */ - double origin[3]; /* smallest x,y, z of model's bounding box */ - double size[3]; /* size in x, y, z of model bounding box */ - void * ptrToPrevElement; - std::list<void *> listAllElements; - }; - typedef struct global globalInfo; - - - typedef struct - { - globalInfo *info; - octantBucket *root; - BBFunction function_BB; - InEleFunction function_inElement; - CentroidFunction function_centroid; - }Octree; - - void refineOctants( octantBucket *buckets, - globalInfo *globalPara); - - int addElement2Bucket (octantBucket *bucket, void * element, - double *minBB, double *maxBB, - double *ele_centroid, globalInfo *globalPara); - int subdivideOctantBucket (octantBucket *bucket, globalInfo *globalPara); - int initializeOctantBuckets (double *orig, double *size, int maxElem, - octantBucket **buckets, globalInfo **globalPara); - int checkElementInBucket (octantBucket *bucket, void * element); - octantBucket* findElementBucket(octantBucket *buckets, double *pt); - void * searchElement(octantBucket *buckets, double *pt, - globalInfo *globalPara, BBFunction BBElement, - InEleFunction xyzInElement); - int xyzInElementBB(double *xyz, void *region, BBFunction BBElement); - void insertOneBB(void *, double *, double *, octantBucket *); - void * searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara, - BBFunction BBElement, InEleFunction xyzInElement, std::list<void *> *_elements); - -#endif - - - - - - - - - - diff --git a/doc/VERSIONS b/doc/VERSIONS index 671ed1fa63242a6953768da19cc2a56ec9c3ec2c..90913447abc24e7b910f5da2502f626331170268 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,4 @@ -$Id: VERSIONS,v 1.197 2004-04-24 02:13:07 geuzaine Exp $ +$Id: VERSIONS,v 1.198 2004-04-24 03:52:00 geuzaine Exp $ New in 1.52: new raster ("bitmap") PostScript/EPS/PDF output formats; new Plugin(Extract) to extract a given component from a @@ -6,12 +6,12 @@ post-processing view; improved mesh projection on non-planar surfaces; added support for second order tetrahedral elements; added interactive control of element order; refined mesh entity drawing selection (and renamed most of the corresponding options); enhanced log scale in -post-processing; better font selection; various bug fixes (default -postscript printing mode, drawing of 3D arrows/cylinders on Linux, -default home directory on Windows, default initial file browser -directory, extrusion of points with non-normalized axes of rotation, -computation of the scene bounding box in scripts, + the usual -documentation updates); +post-processing; better font selection; new Plugin(CutGrid) and +Plugin(StreamLines); various bug fixes (default postscript printing +mode, drawing of 3D arrows/cylinders on Linux, default home directory +on Windows, default initial file browser directory, extrusion of +points with non-normalized axes of rotation, computation of the scene +bounding box in scripts, + the usual documentation updates); New in 1.51: initial support for visualizing mesh partitions; integrated version 2.0 of the MSH mesh file format; new option to diff --git a/doc/texinfo/opt_general.texi b/doc/texinfo/opt_general.texi index 1a26461c7b6cbfde00008e638bbe3eb778062af2..2641f80dffcaaeb92822df3541e622ca76356545 100644 --- a/doc/texinfo/opt_general.texi +++ b/doc/texinfo/opt_general.texi @@ -14,6 +14,11 @@ File into which the log is saved if a fatal error occurs@* Default value: @code{".gmsh-errors"}@* Saved in: @code{General.SessionFileName} +@item General.GraphicsFont +Font used in the graphic window@* +Default value: @code{"Helvetica"}@* +Saved in: @code{General.SessionFileName} + @item General.OptionsFileName Option file created with `Tools->Options->Save'; automatically read on startup@* Default value: @code{".gmsh-options"}@* @@ -66,7 +71,7 @@ Saved in: @code{General.OptionsFileName} @item General.Axes Display the axes linked to the model@* -Default value: @code{1}@* +Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item General.Clip0 @@ -261,7 +266,7 @@ Saved in: @code{General.SessionFileName} @item General.GraphicsFontSize Size of the font in the graphic window@* -Default value: @code{11}@* +Default value: @code{14}@* Saved in: @code{General.SessionFileName} @item General.GraphicsHeight @@ -546,12 +551,12 @@ Saved in: @code{General.OptionsFileName} @item General.SmallAxesPositionX X position of small axes (use negative values for right alignment)@* -Default value: @code{-45}@* +Default value: @code{-60}@* Saved in: @code{General.OptionsFileName} @item General.SmallAxesPositionY Y position of small axes (use negative values for bottom alignment)@* -Default value: @code{-35}@* +Default value: @code{-40}@* Saved in: @code{General.OptionsFileName} @item General.SolverPositionX diff --git a/doc/texinfo/opt_geometry.texi b/doc/texinfo/opt_geometry.texi index 67a8e3a2982a34ad9b689e119b4c65083ed96c7a..0d3d580ae77d605facb1b59f177f8e066811ebec 100644 --- a/doc/texinfo/opt_geometry.texi +++ b/doc/texinfo/opt_geometry.texi @@ -39,7 +39,7 @@ Display geometry curves?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} -@item Geometry.LinesNumbers +@item Geometry.LineNumbers Display curve numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @@ -56,11 +56,11 @@ Saved in: @code{General.OptionsFileName} @item Geometry.LineWidth Display width of lines (in pixels)@* -Default value: @code{1}@* +Default value: @code{2}@* Saved in: @code{General.OptionsFileName} @item Geometry.Normals -Size of the vectors normal to the surfaces@* +Display size of normal vectors (in pixels)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @@ -79,7 +79,7 @@ Display geometry points?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} -@item Geometry.PointsNumbers +@item Geometry.PointNumbers Display points numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @@ -91,7 +91,7 @@ Saved in: @code{General.OptionsFileName} @item Geometry.PointSize Display size of points (in pixels)@* -Default value: @code{3}@* +Default value: @code{4}@* Saved in: @code{General.OptionsFileName} @item Geometry.PointType @@ -119,13 +119,13 @@ Display geometry surfaces?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Geometry.SurfacesNumbers +@item Geometry.SurfaceNumbers Display surface numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Geometry.Tangents -Size of the vectors tangent to the curves@* +Display size of tangent vectors (in pixels)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @@ -134,7 +134,7 @@ Display geometry volumes? (not implemented yet)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Geometry.VolumesNumbers +@item Geometry.VolumeNumbers Display volume numbers? (not implemented yet)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} diff --git a/doc/texinfo/opt_mesh.texi b/doc/texinfo/opt_mesh.texi index 496096198627ce047b8c1d19b95b5fc6a4f1f595..1b19c0a7de121830fb6c12707693368d0f84dcd2 100644 --- a/doc/texinfo/opt_mesh.texi +++ b/doc/texinfo/opt_mesh.texi @@ -44,6 +44,11 @@ Enable mesh cut plane@* Default value: @code{0}@* Saved in: @code{-} +@item Mesh.CutPlaneAsSurface +Draw the intersection volume layer as a surface@* +Default value: @code{0}@* +Saved in: @code{-} + @item Mesh.CutPlaneA First cut plane equation coefficient (`A' in `AX+BY+CZ+D=0')@* Default value: @code{1}@* @@ -110,22 +115,22 @@ Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.Lines -Display mesh vertices on curves?@* -Default value: @code{1}@* +Display mesh lines (1D elements)?@* +Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Mesh.LinesNumbers +@item Mesh.LineNumbers Display mesh line numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.LineType -Display lines as solid color segments (0) or 3D cylinders (1)@* +Display mesh lines as solid color segments (0) or 3D cylinders (1)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.LineWidth -Display width of lines (in pixels)@* +Display width of mesh lines (in pixels)@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} @@ -175,32 +180,32 @@ Default value: @code{0}@* Saved in: @code{-} @item Mesh.Normals -Size of the normal vectors@* +Display size of normal vectors (in pixels)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.Points -Display mesh vertices?@* +Display mesh vertices (nodes)?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} @item Mesh.PointInsertion -Point insertion method for isotropic 2D algorithm (1=center of circumscribed circle, 2=voronoi, 3=cog)@* +Point insertion method for isotropic 2D algorithm (1=center of circumscribed circle, 2=cog)@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} -@item Mesh.PointsNumbers -Display mesh vertex numbers?@* +@item Mesh.PointNumbers +Display mesh node numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.PointSize -Display size of points (in pixels)@* -Default value: @code{2}@* +Display size of mesh vertices (in pixels)@* +Default value: @code{3}@* Saved in: @code{General.OptionsFileName} @item Mesh.PointType -Display points as solid color dots (0) or 3D spheres (1)@* +Display mesh vertices as solid color dots (0) or 3D spheres (1)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @@ -239,44 +244,54 @@ Number of smoothing steps applied to the final mesh@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Mesh.Solid -Draw mesh as solid (1) or wireframe (0)?@* -Default value: @code{0}@* -Saved in: @code{General.OptionsFileName} - @item Mesh.SpeedMax Disable dubious point insertion tests@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Mesh.Surfaces -Display surface mesh?@* +@item Mesh.SurfaceEdges +Display edges of surface mesh?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} -@item Mesh.SurfacesNumbers -Display mesh surface numbers?@* +@item Mesh.SurfaceFaces +Display faces of surface mesh?@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item Mesh.SurfaceNumbers +Display surface mesh element numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.Tangents -Size of the tangent vectors@* +Display size of tangent vectors (in pixels)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Mesh.Volumes -Display volume mesh?@* +@item Mesh.VolumeEdges +Display edges of volume mesh?@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} -@item Mesh.VolumesNumbers -Display mesh elements numbers?@* +@item Mesh.VolumeFaces +Display faces of volume mesh?@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item Mesh.VolumeNumbers +Display volume mesh element numbers?@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} @item Mesh.Color.Points -Mesh vertex color@* -Default value: @code{@{0,123,59@}}@* +Mesh node color@* +Default value: @code{@{0,255,0@}}@* +Saved in: @code{General.OptionsFileName} + +@item Mesh.Color.PointsSup +Second order mesh node color@* +Default value: @code{@{255,0,255@}}@* Saved in: @code{General.OptionsFileName} @item Mesh.Color.Lines @@ -316,12 +331,12 @@ Saved in: @code{General.OptionsFileName} @item Mesh.Color.Tangents Tangent mesh vector color@* -Default value: @code{@{128,128,128@}}@* +Default value: @code{@{255,255,0@}}@* Saved in: @code{General.OptionsFileName} @item Mesh.Color.Normals Normal mesh vector color@* -Default value: @code{@{128,128,128@}}@* +Default value: @code{@{255,0,0@}}@* Saved in: @code{General.OptionsFileName} @item Mesh.Color.One diff --git a/doc/texinfo/opt_plugin.texi b/doc/texinfo/opt_plugin.texi index 31052d041b7c4b8c9b7fb30fdade7a83b88bfe04..ec77fe9daaaf28e83606148aceb8493f57182b73 100644 --- a/doc/texinfo/opt_plugin.texi +++ b/doc/texinfo/opt_plugin.texi @@ -1,4 +1,42 @@ @ftable @code +@item Plugin(CutGrid) +Plugin(CutGrid) cuts a 3D view with a rectangular +grid defined by the 3 points {`X0',`Y0',`Z0'} (origin) +{`X1',`Y1',`Z1'} (axis of U) and {`X2',`Y2',`Z2'} (axis +of V). The number of points along U and V is set +with the options `nPointsU' and `nPointsV'. If +`iView' < 0, the plugin is run on the current view. + +Plugin(CutGrid) creates one new view. + +Numeric options: +@table @code +@item X0 +Default value: -1 +@item Y0 +Default value: -1 +@item Z0 +Default value: 0 +@item X1 +Default value: -1 +@item Y1 +Default value: 0 +@item Z1 +Default value: 0 +@item X2 +Default value: 0 +@item Y2 +Default value: -1 +@item Z2 +Default value: 0 +@item nPointsU +Default value: 20 +@item nPointsV +Default value: 20 +@item iView +Default value: -1 +@end table + @item Plugin(CutMap) Plugin(CutMap) extracts the isovalue surface of value `A' from the view `iView' and draws the @@ -158,8 +196,8 @@ using the values associated with the the nodes along the X, Y and Z axes as in View[`iView'].RaiseX, View[`iView'].RaiseY and View[`iView'].RaiseZ, the raise is applied - along the radius of a sphere centered at (`Xc', -`Yc', `Zc'). If `iView' < 0, the plugin is run + along the radius of a sphere centered at {`Xc', +`Yc', `Zc'}. If `iView' < 0, the plugin is run on the current view. Plugin(SphericalRaise) is executed in-place. @@ -180,6 +218,58 @@ Default value: 0 Default value: -1 @end table +@item Plugin(StreamLines) +Plugin(StreamLines) computes stream lines +from a vector view `iView'. It takes as input a +grid defined by the 3 points {`X0',`Y0',`Z0'} +(origin), {`X1',`Y1',`Z1'} (axis of U) and +{`X2',`Y2',`Z2'} (axis of V). The number of points +that are going to be transported along U and V is +set with the options `nPointsU' and `nPointsV'. +Then, we solve the equation DX(t)/dt = V(x,y,z) +with X(t=0) chosen as the grid and V(x,y,z) +interpolated on the vector view. The timestep and +the maximum number of iterations are set with +the options `MaxIter' and `DT'. 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 ;-) + +Numeric options: +@table @code +@item X0 +Default value: 2.39 +@item Y0 +Default value: 0.445 +@item Z0 +Default value: 0 +@item X1 +Default value: 2.39 +@item Y1 +Default value: 0.94 +@item Z1 +Default value: 0 +@item X2 +Default value: 2.39 +@item Y2 +Default value: 0.445 +@item Z2 +Default value: 1 +@item nPointsU +Default value: 20 +@item nPointsV +Default value: 1 +@item MaxIter +Default value: 100 +@item DT +Default value: 0.1 +@item iView +Default value: -1 +@end table + @item Plugin(Transform) Plugin(Transform) transforms the coordinates of the nodes of the view `iView' by the matrix @@ -215,28 +305,6 @@ 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 diff --git a/doc/texinfo/opt_print.texi b/doc/texinfo/opt_print.texi index db00a5dfd34c5c335ddc9fbc88a498d9ede1dcab..cd789448d7b19746b5dd2c1fcb2fb44df915930e 100644 --- a/doc/texinfo/opt_print.texi +++ b/doc/texinfo/opt_print.texi @@ -1,9 +1,4 @@ @ftable @code -@item Print.EpsFont -Font used in PostScript/PDF output@* -Default value: @code{"Courier"}@* -Saved in: @code{General.OptionsFileName} - @item Print.EpsBackground Save image background in PostScript/PDF output@* Default value: @code{1}@* @@ -19,11 +14,6 @@ Compress PostScript/PDF output using zlib@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} -@item Print.EpsFontSize -Font size used in PostScript/PDF output@* -Default value: @code{12}@* -Saved in: @code{General.OptionsFileName} - @item Print.EpsLineWidthFactor Width factor for lines in PostScript/PDF output@* Default value: @code{0.5}@* @@ -39,6 +29,11 @@ Size factor for points in PostScript/PDF output@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} +@item Print.EpsPS3Shading +Enable PostScript Level 3 shading@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + @item Print.EpsQuality PostScript/PDF quality (1=simple sort, 2=BSP tree sort)@* Default value: @code{1}@* diff --git a/doc/texinfo/opt_view.texi b/doc/texinfo/opt_view.texi index 7d5c393aca47ec3774b7cb2245849ec930957993..fb6ed03c13be8a9b08ebdba444f26a7b53f33af2 100644 --- a/doc/texinfo/opt_view.texi +++ b/doc/texinfo/opt_view.texi @@ -40,13 +40,13 @@ Default value: @code{0.12}@* Saved in: @code{General.OptionsFileName} @item View.ArrowLocation -Arrow location (1=cog, 2=vertex)@* +Arrow location (1=cog, 2=node)@* Default value: @code{1}@* Saved in: @code{General.OptionsFileName} @item View.ArrowSize -Size of vectors arrows (in pixels)@* -Default value: @code{50}@* +Display size of arrows (in pixels)@* +Default value: @code{60}@* Saved in: @code{General.OptionsFileName} @item View.ArrowStemLength @@ -221,7 +221,7 @@ Saved in: @code{-} @item View.PointSize Display size of points (in pixels)@* -Default value: @code{2}@* +Default value: @code{3}@* Saved in: @code{General.OptionsFileName} @item View.PointType