From 26909b4d8a0a77c634db26b8fdbe8908a26d97cb Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 8 May 2004 00:19:47 +0000 Subject: [PATCH] - add GUI for exporting characteristic length fields - error->warning if lc <= 0 - don't enable POLYGON_OFFSET_FILL for 3D isos --- Fltk/Callbacks.cpp | 12 +++++++++++- Graphics/CreateFile.cpp | 15 +++++++++++++-- Graphics/Draw.h | 4 ++-- Graphics/Entity.cpp | 14 +++++++------- Graphics/Iso.cpp | 6 +++--- Mesh/3D_BGMesh.cpp | 20 ++++++++++---------- Mesh/Mesh.h | 4 ++++ 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index d42c309826..46520979bd 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.222 2004-04-24 06:13:45 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.223 2004-05-08 00:19:47 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -515,6 +515,14 @@ void _save_msh_all_v2(char *name) CTX.mesh.save_all = all; CTX.mesh.msh_file_version = ver; } +void _save_lc_sur(char *name) +{ + CreateOutputFile(name, FORMAT_LC_SUR); +} +void _save_lc_vol(char *name) +{ + CreateOutputFile(name, FORMAT_LC_VOL); +} void _save_gref(char *name) { CreateOutputFile(name, CTX.mesh.format = FORMAT_GREF); @@ -694,6 +702,8 @@ void file_save_as_cb(CALLBACK_ARGS) {"Gmsh mesh v1.0 without physicals (*.msh)", _save_msh_all}, {"Gmsh mesh v2.0 (*.msh)", _save_msh_v2}, {"Gmsh mesh v2.0 without physicals (*.msh)", _save_msh_all_v2}, + {"Gmsh Surface LC field (*.pos)", _save_lc_sur}, + {"Gmsh Volume LC field (*.pos)", _save_lc_vol}, {"GREF mesh (*.gref)", _save_gref}, {"I-DEAS universal mesh format (*.unv)", _save_unv}, {"VRML surface mesh (*.wrl)", _save_vrml}, diff --git a/Graphics/CreateFile.cpp b/Graphics/CreateFile.cpp index 669790bcb4..d2ae3bee0f 100644 --- a/Graphics/CreateFile.cpp +++ b/Graphics/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.57 2004-04-08 19:26:49 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.58 2004-05-08 00:19:47 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -82,6 +82,8 @@ void CreateOutputFile(char *name, int format) CreateOutputFile(name, FORMAT_MSH); else if(!strcmp(ext, ".unv")) CreateOutputFile(name, FORMAT_UNV); + else if(!strcmp(ext, ".pos")) + CreateOutputFile(name, FORMAT_LC_SUR); else if(!strcmp(ext, ".gif")) CreateOutputFile(name, FORMAT_GIF); else if(!strcmp(ext, ".jpg")) @@ -134,6 +136,16 @@ void CreateOutputFile(char *name, int format) Print_Mesh(&M, name, format); break; + case FORMAT_LC_SUR: + ExportLcFieldOnSurfaces(&M, name); + Msg(STATUS2N, "Wrote '%s'", name); + break; + + case FORMAT_LC_VOL: + ExportLcFieldOnVolume(&M, name); + Msg(STATUS2N, "Wrote '%s'", name); + break; + case FORMAT_JPEG: case FORMAT_JPEGTEX: case FORMAT_PNG: @@ -308,5 +320,4 @@ void CreateOutputFile(char *name, int format) } CTX.print.format = oldformat; - } diff --git a/Graphics/Draw.h b/Graphics/Draw.h index f0506ae03d..f316541886 100644 --- a/Graphics/Draw.h +++ b/Graphics/Draw.h @@ -76,9 +76,9 @@ void Draw_Point(int type, double size, double *x, double *y, double *z, void Draw_Line(int type, double width, double *x, double *y, double *z, double Raise[3][8], int light); void Draw_Triangle(double *x, double *y, double *z,double *n, - double Raise[3][8], int light); + double Raise[3][8], int light, bool polygon_offset); void Draw_Quadrangle(double *x, double *y, double *z, double *n, - double Raise[3][8], int light); + double Raise[3][8], int light, bool polygon_offset); void Draw_Vector(int Type, int Fill, double relHeadRadius, double relStemLength, double relStemRadius, double x, double y, double z, double dx, double dy, double dz, diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index 12bbfd672a..f87398876e 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.37 2004-04-23 18:31:01 geuzaine Exp $ +// $Id: Entity.cpp,v 1.38 2004-05-08 00:19:47 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -126,12 +126,12 @@ void Draw_Line(int type, double width, double *x, double *y, double *z, } void Draw_Triangle(double *x, double *y, double *z, double *n, - double Raise[3][8], int light) + double Raise[3][8], int light, bool polygon_offset) { double x1x0, y1y0, z1z0, x2x0, y2y0, z2z0, nn[3]; if(light) glEnable(GL_LIGHTING); - glEnable(GL_POLYGON_OFFSET_FILL); + if(polygon_offset) glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_TRIANGLES); if(light) { @@ -170,13 +170,13 @@ void Draw_Triangle(double *x, double *y, double *z, double *n, } void Draw_Quadrangle(double *x, double *y, double *z, double *n, - double Raise[3][8], int light) + double Raise[3][8], int light, bool polygon_offset) { double x2[3] = { x[2], x[3], x[0] }; double y2[3] = { y[2], y[3], y[0] }; double z2[3] = { z[2], z[3], z[0] }; - Draw_Triangle(x, y, z, n, Raise, light); + Draw_Triangle(x, y, z, n, Raise, light, polygon_offset); if(n) { double n2[9]; n2[0] = n[6]; @@ -188,10 +188,10 @@ void Draw_Quadrangle(double *x, double *y, double *z, double *n, n2[6] = n[0]; n2[7] = n[1]; n2[8] = n[2]; - Draw_Triangle(x2, y2, z2, n2, Raise, light); + Draw_Triangle(x2, y2, z2, n2, Raise, light, polygon_offset); } else - Draw_Triangle(x2, y2, z2, n, Raise, light); + Draw_Triangle(x2, y2, z2, n, Raise, light, polygon_offset); } void Draw_SimpleVector(int arrow, int fill, diff --git a/Graphics/Iso.cpp b/Graphics/Iso.cpp index 21a307b765..8bde4007cb 100644 --- a/Graphics/Iso.cpp +++ b/Graphics/Iso.cpp @@ -1,4 +1,4 @@ -// $Id: Iso.cpp,v 1.22 2004-04-27 00:11:55 geuzaine Exp $ +// $Id: Iso.cpp,v 1.23 2004-05-08 00:19:47 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -440,7 +440,7 @@ void IsoSimplex(Post_View * View, Raise[i][k] = View->Raise[i] * V; if(nb == 3) - Draw_Triangle(Xp, Yp, Zp, norms, Raise, View->Light); + Draw_Triangle(Xp, Yp, Zp, norms, Raise, View->Light, false); else if(nb == 4) - Draw_Quadrangle(Xp, Yp, Zp, norms, Raise, View->Light); + Draw_Quadrangle(Xp, Yp, Zp, norms, Raise, View->Light, false); } diff --git a/Mesh/3D_BGMesh.cpp b/Mesh/3D_BGMesh.cpp index 5f045fc845..086daef69f 100644 --- a/Mesh/3D_BGMesh.cpp +++ b/Mesh/3D_BGMesh.cpp @@ -1,4 +1,4 @@ -// $Id: 3D_BGMesh.cpp,v 1.28 2004-05-07 22:51:11 geuzaine Exp $ +// $Id: 3D_BGMesh.cpp,v 1.29 2004-05-08 00:19:47 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -30,19 +30,19 @@ extern Mesh *THEM; extern Context_T CTX; -void ExportLcFieldOnVolume(Mesh * M) +void ExportLcFieldOnVolume(Mesh * M, char *filename) { List_T *l = Tree2List(M->Volumes); Volume *vol; Simplex *simp; - FILE *f = fopen("OutFile.pos", "w"); + FILE *f = fopen(filename, "w"); if(!f) { - Msg(GERROR, "Unable to open file"); + Msg(GERROR, "Unable to open file '%s'", filename); return; } - fprintf(f, "View \"LC_FIELD\" Offset{0,0,0} {\n"); + fprintf(f, "View \"LC_FIELD\" {\n"); for(int i = 0; i < List_Nbr(l); i++) { List_Read(l, i, &vol); List_T *ll = Tree2List(vol->Simplexes); @@ -57,19 +57,19 @@ void ExportLcFieldOnVolume(Mesh * M) fclose(f); } -void ExportLcFieldOnSurfaces(Mesh * M) +void ExportLcFieldOnSurfaces(Mesh * M, char *filename) { List_T *l = Tree2List(M->Surfaces); Surface *surf; Simplex *simp; - FILE *f = fopen("OutFileS.pos", "w"); + FILE *f = fopen(filename, "w"); if(!f) { - Msg(GERROR, "Unable to open file"); + Msg(GERROR, "Unable to open file '%s'", filename); return; } - fprintf(f, "View \"LC_FIELD\" Offset{0,0,0} {\n"); + fprintf(f, "View \"LC_FIELD\" {\n"); for(int i = 0; i < List_Nbr(l); i++) { List_Read(l, i, &surf); List_T *ll = Tree2List(surf->Simplexes); @@ -134,7 +134,7 @@ double Lc_XYZ(double X, double Y, double Z, Mesh * m) } if(l <= 0.){ - Msg(GERROR, "Characteristic length <= 0: setting to 1.0"); + Msg(WARNING, "Characteristic length <= 0: setting to 1.0"); l = 1.0; } diff --git a/Mesh/Mesh.h b/Mesh/Mesh.h index c733fe9add..c5690c726c 100644 --- a/Mesh/Mesh.h +++ b/Mesh/Mesh.h @@ -57,6 +57,8 @@ #define FORMAT_PDF_RASTER 28 #define FORMAT_EPSTEX_RASTER 29 #define FORMAT_PDFTEX_RASTER 30 +#define FORMAT_LC_SUR 31 +#define FORMAT_LC_VOL 32 #define CONV_VALUE 0.8 @@ -504,6 +506,8 @@ void ActionLiss (void *data, void *dummy); void ActionLissSurf (void *data, void *dummy); int Recombine (Tree_T *TreeAllVert, Tree_T *TreeAllElg, double a); void ApplyLcFactor(Mesh *M); +void ExportLcFieldOnVolume(Mesh * M, char *filename); +void ExportLcFieldOnSurfaces(Mesh * M, char *filename); void Gamma_Maillage (Mesh * m, double *gamma, double *gammamax, double *gammamin); void Eta_Maillage (Mesh * m, double *gamma, double *gammamax, double *gammamin); -- GitLab