Skip to content
Snippets Groups Projects
Commit e399296e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Generalized Plugin(Triangulate) to handle vector and tensor views
parent 0ee2236b
Branches
Tags
No related merge requests found
// $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 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -63,8 +63,8 @@ void GMSH_TriangulatePlugin::getInfos(char *author, char *copyright, ...@@ -63,8 +63,8 @@ void GMSH_TriangulatePlugin::getInfos(char *author, char *copyright,
strcpy(copyright, "DGR (www.multiphysics.com)"); strcpy(copyright, "DGR (www.multiphysics.com)");
strcpy(help_text, strcpy(help_text,
"Plugin(Triangulate) triangulates the points\n" "Plugin(Triangulate) triangulates the points\n"
"in the scalar view `iView', assuming that all\n" "in the view `iView', assuming that all the\n"
"the points belong to a surface that can be\n" "points belong to a surface that can be\n"
"univoquely projected into a plane. If `iView'\n" "univoquely projected into a plane. If `iView'\n"
"< 0, the plugin is run on the current view.\n" "< 0, the plugin is run on the current view.\n"
"\n" "\n"
...@@ -88,7 +88,8 @@ void GMSH_TriangulatePlugin::catchErrorMessage(char *errorMessage) const ...@@ -88,7 +88,8 @@ void GMSH_TriangulatePlugin::catchErrorMessage(char *errorMessage) const
#if !defined(HAVE_TRIANGLE) #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"); Msg(GERROR, "Triangle is not compiled in this version of Gmsh");
} }
...@@ -103,34 +104,35 @@ extern "C" ...@@ -103,34 +104,35 @@ extern "C"
#include "triangle.h" #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; if(!nbIn)
Surface *s; return;
Vertex *v;
struct triangulateio in, out; List_T *points = List_Create(nbIn, 1, sizeof(Vertex *));
int nb = List_Nbr(inList) / nbIn;
List_T *points = List_Create(vin->NbSP, 1, sizeof(Vertex *)); int j = 0;
nb = List_Nbr(vin->SP) / vin->NbSP; for(int i = 0; i < List_Nbr(inList); i += nb) {
Vertex *v = Create_Vertex(j++,
for(i = 0; i < List_Nbr(vin->SP); i += nb) { *(double *)List_Pointer_Fast(inList, i),
v = Create_Vertex(j++, *(double *)List_Pointer_Fast(inList, i + 1),
*(double *)List_Pointer_Fast(vin->SP, i), *(double *)List_Pointer_Fast(inList, i + 2), 1., 0.);
*(double *)List_Pointer_Fast(vin->SP, i + 1),
*(double *)List_Pointer_Fast(vin->SP, i + 2), 1., 0.);
List_Add(points, &v); List_Add(points, &v);
} }
s = Create_Surface(1, MSH_SURF_PLAN); Surface *s = Create_Surface(1, MSH_SURF_PLAN);
MeanPlane(points, s); 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); List_Read(points, i, &v);
Projette(v, s->plan); Projette(v, s->plan);
} }
Free_Surface(&s, NULL); Free_Surface(&s, NULL);
struct triangulateio in;
in.numberofpoints = List_Nbr(points); in.numberofpoints = List_Nbr(points);
in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL)); in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL));
in.numberofpointattributes = 0; in.numberofpointattributes = 0;
...@@ -145,19 +147,22 @@ void Triangulate(Post_View * vin, Post_View * vout) ...@@ -145,19 +147,22 @@ void Triangulate(Post_View * vin, Post_View * vout)
in.holelist = NULL; in.holelist = NULL;
j = 0; 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); List_Read(points, i, &v);
in.pointlist[j] = v->Pos.X; in.pointlist[j] = v->Pos.X;
in.pointlist[j + 1] = v->Pos.Y; in.pointlist[j + 1] = v->Pos.Y;
j += 2; 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); List_Read(points, i, &v);
Free_Vertex(&v, NULL); Free_Vertex(&v, NULL);
} }
List_Delete(points); List_Delete(points);
struct triangulateio out;
out.pointlist = NULL; out.pointlist = NULL;
out.pointattributelist = NULL; out.pointattributelist = NULL;
out.pointmarkerlist = NULL; out.pointmarkerlist = NULL;
...@@ -177,25 +182,27 @@ void Triangulate(Post_View * vin, Post_View * vout) ...@@ -177,25 +182,27 @@ void Triangulate(Post_View * vin, Post_View * vout)
Free(in.pointlist); Free(in.pointlist);
Free(out.pointlist); Free(out.pointlist);
for(i = 0; i < out.numberoftriangles; i++) { for(int i = 0; i < out.numberoftriangles; i++) {
j0 = out.trianglelist[i * out.numberofcorners + 0]; int j0 = out.trianglelist[i * out.numberofcorners + 0];
j1 = out.trianglelist[i * out.numberofcorners + 1]; int j1 = out.trianglelist[i * out.numberofcorners + 1];
j2 = out.trianglelist[i * out.numberofcorners + 2]; int j2 = out.trianglelist[i * out.numberofcorners + 2];
for(j = 0; j < 3; j++) { for(int j = 0; j < 3; j++) {
List_Add(vout->ST, List_Pointer(vin->SP, (j0 * nb) + j)); List_Add(outList, List_Pointer(inList, (j0 * nb) + j));
List_Add(vout->ST, List_Pointer(vin->SP, (j1 * nb) + j)); List_Add(outList, List_Pointer(inList, (j1 * nb) + j));
List_Add(vout->ST, List_Pointer(vin->SP, (j2 * nb) + j)); List_Add(outList, List_Pointer(inList, (j2 * nb) + j));
} }
for(j = 0; j < vin->NbTimeStep; j++) { for(int j = 0; j < nbTimeStep; j++) {
List_Add(vout->ST, List_Pointer(vin->SP, (j0 * nb) + 3 + j)); for(int k = 0; k < nbComp; k++)
List_Add(vout->ST, List_Pointer(vin->SP, (j1 * nb) + 3 + j)); List_Add(outList, List_Pointer(inList, (j0 * nb) + 3 + j*nbComp + k));
List_Add(vout->ST, List_Pointer(vin->SP, (j2 * nb) + 3 + j)); 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); Free(out.trianglelist);
} }
#endif // !HAVE_TRIANGLE #endif // !HAVE_TRIANGLE
...@@ -212,24 +219,24 @@ Post_View *GMSH_TriangulatePlugin::execute(Post_View * v) ...@@ -212,24 +219,24 @@ Post_View *GMSH_TriangulatePlugin::execute(Post_View * v)
return 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); 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;
}
$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 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 gerard.fleury@inrs.fr: add the capability to mesh some entities using
1st order and some other using 2nd order elements (in the same 1st order and some other using 2nd order elements (in the same
geometry)? geometry)?
......
$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 New since 1.53: fixed UNV output; make Layers' region numbering
consistent between lines/surfaces/volumes; fixed home directory consistent between lines/surfaces/volumes; fixed home directory
...@@ -6,7 +6,8 @@ problem on Win98; new Plugin(CutParametric); the default project file ...@@ -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 is now created in the home directory if no current directory is
defined (e.g. when double-clicking on the icon on Windows/MacOS); defined (e.g. when double-clicking on the icon on Windows/MacOS);
fixed the discrepancy between the orientation of geometrical surfaces 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 New in 1.53: completed support for second order elements in the mesh
module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms
......
...@@ -387,8 +387,8 @@ Default value: @code{-1} ...@@ -387,8 +387,8 @@ Default value: @code{-1}
@item Plugin(Triangulate) @item Plugin(Triangulate)
Plugin(Triangulate) triangulates the points Plugin(Triangulate) triangulates the points
in the scalar view `iView', assuming that all in the view `iView', assuming that all the
the points belong to a surface that can be points belong to a surface that can be
univoquely projected into a plane. If `iView' univoquely projected into a plane. If `iView'
< 0, the plugin is run on the current view. < 0, the plugin is run on the current view.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment