diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index 54076d360fb170ea1d63b86053f450e1e66f3815..c6ffc2c2298378fcc04ea8b0e4833bb7e9b271e1 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -1,4 +1,4 @@ -// $Id: Triangulate.cpp,v 1.22 2004-05-17 21:28:02 geuzaine Exp $ +// $Id: Triangulate.cpp,v 1.23 2004-06-24 07:13:18 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -63,8 +63,8 @@ void GMSH_TriangulatePlugin::getInfos(char *author, char *copyright, strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(help_text, "Plugin(Triangulate) triangulates the points\n" - "in the scalar view `iView', assuming that all\n" - "the points belong to a surface that can be\n" + "in the view `iView', assuming that all the\n" + "points belong to a surface that can be\n" "univoquely projected into a plane. If `iView'\n" "< 0, the plugin is run on the current view.\n" "\n" @@ -88,7 +88,8 @@ void GMSH_TriangulatePlugin::catchErrorMessage(char *errorMessage) const #if !defined(HAVE_TRIANGLE) -void Triangulate(Post_View * vin, Post_View * vout) +void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList, + int nbTimeStep, int nbComp) { Msg(GERROR, "Triangle is not compiled in this version of Gmsh"); } @@ -103,34 +104,35 @@ extern "C" #include "triangle.h" } -void Triangulate(Post_View * vin, Post_View * vout) +void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList, + int nbTimeStep, int nbComp) { - int nb, i, j = 0, j0, j1, j2; - Surface *s; - Vertex *v; - struct triangulateio in, out; - - List_T *points = List_Create(vin->NbSP, 1, sizeof(Vertex *)); - nb = List_Nbr(vin->SP) / vin->NbSP; - - for(i = 0; i < List_Nbr(vin->SP); i += nb) { - v = Create_Vertex(j++, - *(double *)List_Pointer_Fast(vin->SP, i), - *(double *)List_Pointer_Fast(vin->SP, i + 1), - *(double *)List_Pointer_Fast(vin->SP, i + 2), 1., 0.); + if(!nbIn) + return; + + List_T *points = List_Create(nbIn, 1, sizeof(Vertex *)); + int nb = List_Nbr(inList) / nbIn; + int j = 0; + for(int i = 0; i < List_Nbr(inList); i += nb) { + Vertex *v = Create_Vertex(j++, + *(double *)List_Pointer_Fast(inList, i), + *(double *)List_Pointer_Fast(inList, i + 1), + *(double *)List_Pointer_Fast(inList, i + 2), 1., 0.); List_Add(points, &v); } - s = Create_Surface(1, MSH_SURF_PLAN); + Surface *s = Create_Surface(1, MSH_SURF_PLAN); MeanPlane(points, s); - for(i = 0; i < List_Nbr(points); i++) { + for(int i = 0; i < List_Nbr(points); i++) { + Vertex *v; List_Read(points, i, &v); Projette(v, s->plan); } Free_Surface(&s, NULL); + struct triangulateio in; in.numberofpoints = List_Nbr(points); in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL)); in.numberofpointattributes = 0; @@ -145,19 +147,22 @@ void Triangulate(Post_View * vin, Post_View * vout) in.holelist = NULL; j = 0; - for(i = 0; i < List_Nbr(points); i++) { + for(int i = 0; i < List_Nbr(points); i++) { + Vertex *v; List_Read(points, i, &v); in.pointlist[j] = v->Pos.X; in.pointlist[j + 1] = v->Pos.Y; j += 2; } - for(i = 0; i < List_Nbr(points); i++) { + for(int i = 0; i < List_Nbr(points); i++) { + Vertex *v; List_Read(points, i, &v); Free_Vertex(&v, NULL); } List_Delete(points); + struct triangulateio out; out.pointlist = NULL; out.pointattributelist = NULL; out.pointmarkerlist = NULL; @@ -177,25 +182,27 @@ void Triangulate(Post_View * vin, Post_View * vout) Free(in.pointlist); Free(out.pointlist); - for(i = 0; i < out.numberoftriangles; i++) { - j0 = out.trianglelist[i * out.numberofcorners + 0]; - j1 = out.trianglelist[i * out.numberofcorners + 1]; - j2 = out.trianglelist[i * out.numberofcorners + 2]; - for(j = 0; j < 3; j++) { - List_Add(vout->ST, List_Pointer(vin->SP, (j0 * nb) + j)); - List_Add(vout->ST, List_Pointer(vin->SP, (j1 * nb) + j)); - List_Add(vout->ST, List_Pointer(vin->SP, (j2 * nb) + j)); + for(int i = 0; i < out.numberoftriangles; i++) { + int j0 = out.trianglelist[i * out.numberofcorners + 0]; + int j1 = out.trianglelist[i * out.numberofcorners + 1]; + int j2 = out.trianglelist[i * out.numberofcorners + 2]; + for(int j = 0; j < 3; j++) { + List_Add(outList, List_Pointer(inList, (j0 * nb) + j)); + List_Add(outList, List_Pointer(inList, (j1 * nb) + j)); + List_Add(outList, List_Pointer(inList, (j2 * nb) + j)); } - for(j = 0; j < vin->NbTimeStep; j++) { - List_Add(vout->ST, List_Pointer(vin->SP, (j0 * nb) + 3 + j)); - List_Add(vout->ST, List_Pointer(vin->SP, (j1 * nb) + 3 + j)); - List_Add(vout->ST, List_Pointer(vin->SP, (j2 * nb) + 3 + j)); + for(int j = 0; j < nbTimeStep; j++) { + for(int k = 0; k < nbComp; k++) + List_Add(outList, List_Pointer(inList, (j0 * nb) + 3 + j*nbComp + k)); + for(int k = 0; k < nbComp; k++) + List_Add(outList, List_Pointer(inList, (j1 * nb) + 3 + j*nbComp + k)); + for(int k = 0; k < nbComp; k++) + List_Add(outList, List_Pointer(inList, (j2 * nb) + 3 + j*nbComp + k)); } - vout->NbST++; + (*nbOut)++; } Free(out.trianglelist); - } #endif // !HAVE_TRIANGLE @@ -212,24 +219,24 @@ Post_View *GMSH_TriangulatePlugin::execute(Post_View * v) return v; } + if(v->NbSP < 2 && v->NbVP < 2 && v->NbTP < 2) + return v; + + Post_View *v2 = BeginView(1); Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView); - - if(v1->NbSP > 2) { - // FIXME: this is not secure: if BeginView forces a post.list - // reallocation, v1 could be wrong - Post_View *v2 = BeginView(1); - Triangulate(v1, v2); - // copy time data - for(int i = 0; i < List_Nbr(v1->Time); i++) - List_Add(v2->Time, List_Pointer(v1->Time, i)); - // finalize - char name[1024], filename[1024]; - sprintf(name, "%s_Triangulate", v1->Name); - sprintf(filename, "%s_Triangulate.pos", v1->Name); - EndView(v2, 1, filename, name); - return v2; - } - return v1; -} + Triangulate(v1->NbSP, v1->SP, &v2->NbST, v2->ST, v1->NbTimeStep, 1); + Triangulate(v1->NbVP, v1->VP, &v2->NbVT, v2->VT, v1->NbTimeStep, 3); + Triangulate(v1->NbTP, v1->TP, &v2->NbTT, v2->TT, v1->NbTimeStep, 9); + // copy time data + for(int i = 0; i < List_Nbr(v1->Time); i++) + List_Add(v2->Time, List_Pointer(v1->Time, i)); + + // finalize + char name[1024], filename[1024]; + sprintf(name, "%s_Triangulate", v1->Name); + sprintf(filename, "%s_Triangulate.pos", v1->Name); + EndView(v2, 1, filename, name); + return v2; +} diff --git a/TODO b/TODO index 1bb5a9d8cb014b09c4bed434596e87d457a106c5..8f3392332eb28476e2c8ae1388f5ff9e610e0f37 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,9 @@ -$Id: TODO,v 1.51 2004-06-23 19:53:52 geuzaine Exp $ +$Id: TODO,v 1.52 2004-06-24 07:13:18 geuzaine Exp $ add ternary operator and <,>,<=,>=,== tests in MathEval ******************************************************************** -generalize Plugin(Triangulate) to vector and tensor points - -******************************************************************** - gerard.fleury@inrs.fr: add the capability to mesh some entities using 1st order and some other using 2nd order elements (in the same geometry)? diff --git a/doc/VERSIONS b/doc/VERSIONS index 8552079b24a3988f429003bba271838d69646148..489984a0bc9436610f44c6146f88286b48431bc4 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,4 @@ -$Id: VERSIONS,v 1.227 2004-06-23 18:52:45 geuzaine Exp $ +$Id: VERSIONS,v 1.228 2004-06-24 07:13:18 geuzaine Exp $ New since 1.53: fixed UNV output; make Layers' region numbering consistent between lines/surfaces/volumes; fixed home directory @@ -6,7 +6,8 @@ problem on Win98; new Plugin(CutParametric); the default project file is now created in the home directory if no current directory is defined (e.g. when double-clicking on the icon on Windows/MacOS); fixed the discrepancy between the orientation of geometrical surfaces -and the associated surface meshes; small bug fixes and cleanups. +and the associated surface meshes; generalized Plugin(Triangulate) to +handle vector and tensor views; small bug fixes and cleanups. New in 1.53: completed support for second order elements in the mesh module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms diff --git a/doc/texinfo/opt_plugin.texi b/doc/texinfo/opt_plugin.texi index 8273b82d4aa3c853aeed92cc3acb8861854243d6..79bee321d543820c7229ec0a7243faa4bc7fd15d 100644 --- a/doc/texinfo/opt_plugin.texi +++ b/doc/texinfo/opt_plugin.texi @@ -387,8 +387,8 @@ Default value: @code{-1} @item Plugin(Triangulate) Plugin(Triangulate) triangulates the points -in the scalar view `iView', assuming that all -the points belong to a surface that can be +in the view `iView', assuming that all the +points belong to a surface that can be univoquely projected into a plane. If `iView' < 0, the plugin is run on the current view.