diff --git a/Common/Context.h b/Common/Context.h index a7e147faaa46c8d5402b449adefbaa077596ba7b..047e3b64fad23777771a2cd8dcd8d75b31e4ed95 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -195,6 +195,7 @@ public : int force_num, compute_bb, vertex_arrays; int draw, scales, link, horizontal_scales ; int smooth, anim_cycle, combine_time, combine_remove_orig ; + int file_format; double anim_delay ; }post; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 61f7ffe3f77697437cc6afb6a5c3cdf3453c320d..5799cd03c8fdae589222ce816d62d4dacff7b269 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -917,6 +917,9 @@ StringXNumber PostProcessingOptions_Number[] = { { F|O, "CombineRemoveOriginal" , opt_post_combine_remove_orig , 1. , "Remove original views after a Combine operation" }, + { F|0, "Format" , opt_post_file_format , 0. , + "Default file format for post-processing views" }, + { F|O, "HorizontalScales" , opt_post_horizontal_scales , 0. , "Display value scales horizontally" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 594ebc10c1950c2c3924dda632078cd9a95fc712..28369836cfdcf79b04bed3ff196e834e0ad44f6b 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.188 2004-10-14 22:56:39 geuzaine Exp $ +// $Id: Options.cpp,v 1.189 2004-10-15 02:30:50 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -4226,6 +4226,13 @@ double opt_post_nb_views(OPT_ARGS_NUM) return List_Nbr(CTX.post.list); } +double opt_post_file_format(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.post.file_format = (int)val; + return CTX.post.file_format; +} + double opt_view_nb_timestep(OPT_ARGS_NUM) { GET_VIEW(0.); diff --git a/Common/Options.h b/Common/Options.h index a9af15751285e8492ea23c5322b0a59ac9541851..6ad335743e8c9c27ebf32866e5cc9b6c2d7f56ad 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -436,6 +436,7 @@ double opt_post_anim_delay(OPT_ARGS_NUM); double opt_post_anim_cycle(OPT_ARGS_NUM); double opt_post_combine_remove_orig(OPT_ARGS_NUM); double opt_post_nb_views(OPT_ARGS_NUM); +double opt_post_file_format(OPT_ARGS_NUM); double opt_view_nb_timestep(OPT_ARGS_NUM); double opt_view_timestep(OPT_ARGS_NUM); double opt_view_min(OPT_ARGS_NUM); diff --git a/Common/Views.cpp b/Common/Views.cpp index 7846ff827e68e9bf449ec29bbc1a71a908a79864..5f088a6804d4e3f082dc496364e658a5df66f6e7 100644 --- a/Common/Views.cpp +++ b/Common/Views.cpp @@ -1,4 +1,4 @@ -// $Id: Views.cpp,v 1.135 2004-10-11 17:22:56 geuzaine Exp $ +// $Id: Views.cpp,v 1.136 2004-10-15 02:30:50 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -954,15 +954,40 @@ void ReadView(FILE *file, char *filename) Msg(STATUS2N, "Read '%s'", filename); } -// FIXME: add an integer per simplex (region num) -// FIXME: add a format similar to the msh format (node list + simplex list) -// FIXME: add a structured format +// FIXME: add an integer per simplex (region num)? +// FIXME: add a format similar to the msh format (node list + simplex list)? +// FIXME: add a structured format? -void WriteView(Post_View *v, char *filename, int binary, int append) +static void write_parsed_line(char *str, int nbnod, int nb, List_T *list, FILE *fp) +{ + if(nb) { + int n = List_Nbr(list) / nb; + for(int i = 0; i < List_Nbr(list); i += n) { + double *x = (double *)List_Pointer(list, i); + double *y = (double *)List_Pointer(list, i + nbnod); + double *z = (double *)List_Pointer(list, i + 2 * nbnod); + fprintf(fp, "%s(", str); + for(int j = 0; j < nbnod; j++) { + if(j) fprintf(fp, ","); + fprintf(fp, "%.16g,%.16g,%.16g", x[j], y[j], z[j]); + } + fprintf(fp, "){", str); + for(int j = 3 * nbnod; j < n; j++) { + if(j - 3 * nbnod) fprintf(fp, ","); + fprintf(fp, "%.16g", *(double *)List_Pointer(list, i + j)); + } + fprintf(fp, "};\n", str); + } + } +} + +void WriteView(Post_View *v, char *filename, int format, int append) { FILE *file; char name[256]; int i, f, One = 1; + int binary = (format == 1) ? 1 : 0; + int parsed = (format == 2); if(filename) { file = fopen(filename, append ? (binary ? "ab" : "a") : (binary ? "wb" : "w")); @@ -976,7 +1001,7 @@ void WriteView(Post_View *v, char *filename, int binary, int append) else file = stdout; - if(!append){ + if(!parsed && !append){ fprintf(file, "$PostFormat /* Gmsh 1.2, %s */\n", binary ? "binary" : "ascii"); fprintf(file, "1.2 %d %d\n", binary, (int)sizeof(double)); @@ -991,53 +1016,84 @@ void WriteView(Post_View *v, char *filename, int binary, int append) } name[i] = '\0'; - fprintf(file, "$View /* %s */\n", v->Name); - fprintf(file, "%s ", name); - fprintf(file, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d %d %d %d %d %d\n", - List_Nbr(v->Time), - v->NbSP, v->NbVP, v->NbTP, v->NbSL, v->NbVL, v->NbTL, - v->NbST, v->NbVT, v->NbTT, v->NbSQ, v->NbVQ, v->NbTQ, - v->NbSS, v->NbVS, v->NbTS, v->NbSH, v->NbVH, v->NbTH, - v->NbSI, v->NbVI, v->NbTI, v->NbSY, v->NbVY, v->NbTY, - v->NbT2, List_Nbr(v->T2C), v->NbT3, List_Nbr(v->T3C)); - if(binary) { - f = LIST_FORMAT_BINARY; - fwrite(&One, sizeof(int), 1, file); + if(!parsed){ + fprintf(file, "$View /* %s */\n", v->Name); + fprintf(file, "%s ", name); + fprintf(file, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + List_Nbr(v->Time), + v->NbSP, v->NbVP, v->NbTP, v->NbSL, v->NbVL, v->NbTL, + v->NbST, v->NbVT, v->NbTT, v->NbSQ, v->NbVQ, v->NbTQ, + v->NbSS, v->NbVS, v->NbTS, v->NbSH, v->NbVH, v->NbTH, + v->NbSI, v->NbVI, v->NbTI, v->NbSY, v->NbVY, v->NbTY, + v->NbT2, List_Nbr(v->T2C), v->NbT3, List_Nbr(v->T3C)); + if(binary) { + f = LIST_FORMAT_BINARY; + fwrite(&One, sizeof(int), 1, file); + } + else + f = LIST_FORMAT_ASCII; + List_WriteToFile(v->Time, file, f); + List_WriteToFile(v->SP, file, f); + List_WriteToFile(v->VP, file, f); + List_WriteToFile(v->TP, file, f); + List_WriteToFile(v->SL, file, f); + List_WriteToFile(v->VL, file, f); + List_WriteToFile(v->TL, file, f); + List_WriteToFile(v->ST, file, f); + List_WriteToFile(v->VT, file, f); + List_WriteToFile(v->TT, file, f); + List_WriteToFile(v->SQ, file, f); + List_WriteToFile(v->VQ, file, f); + List_WriteToFile(v->TQ, file, f); + List_WriteToFile(v->SS, file, f); + List_WriteToFile(v->VS, file, f); + List_WriteToFile(v->TS, file, f); + List_WriteToFile(v->SH, file, f); + List_WriteToFile(v->VH, file, f); + List_WriteToFile(v->TH, file, f); + List_WriteToFile(v->SI, file, f); + List_WriteToFile(v->VI, file, f); + List_WriteToFile(v->TI, file, f); + List_WriteToFile(v->SY, file, f); + List_WriteToFile(v->VY, file, f); + List_WriteToFile(v->TY, file, f); + List_WriteToFile(v->T2D, file, f); + List_WriteToFile(v->T2C, file, f); + List_WriteToFile(v->T3D, file, f); + List_WriteToFile(v->T3C, file, f); + fprintf(file, "\n"); + fprintf(file, "$EndView\n"); + } + else{ + fprintf(file, "View \"%s\" {\n", v->Name); + write_parsed_line("SP", 1, v->NbSP, v->SP, file); + write_parsed_line("VP", 1, v->NbVP, v->VP, file); + write_parsed_line("TP", 1, v->NbTP, v->TP, file); + write_parsed_line("SL", 2, v->NbSL, v->SL, file); + write_parsed_line("VL", 2, v->NbVL, v->VL, file); + write_parsed_line("TL", 2, v->NbTL, v->TL, file); + write_parsed_line("ST", 3, v->NbST, v->ST, file); + write_parsed_line("VT", 3, v->NbVT, v->VT, file); + write_parsed_line("TT", 3, v->NbTT, v->TT, file); + write_parsed_line("SQ", 4, v->NbSQ, v->SQ, file); + write_parsed_line("VQ", 4, v->NbVQ, v->VQ, file); + write_parsed_line("TQ", 4, v->NbTQ, v->TQ, file); + write_parsed_line("SS", 4, v->NbSS, v->SS, file); + write_parsed_line("VS", 4, v->NbVS, v->VS, file); + write_parsed_line("TS", 4, v->NbTS, v->TS, file); + write_parsed_line("SH", 8, v->NbSH, v->SH, file); + write_parsed_line("VH", 8, v->NbVH, v->VH, file); + write_parsed_line("TH", 8, v->NbTH, v->TH, file); + write_parsed_line("SI", 6, v->NbSI, v->SI, file); + write_parsed_line("VI", 6, v->NbVI, v->VI, file); + write_parsed_line("TI", 6, v->NbTI, v->TI, file); + write_parsed_line("SY", 5, v->NbSY, v->SY, file); + write_parsed_line("VY", 5, v->NbVY, v->VY, file); + write_parsed_line("TY", 5, v->NbTY, v->TY, file); + // FIXME: do strings! + fprintf(file, "};\n"); } - else - f = LIST_FORMAT_ASCII; - List_WriteToFile(v->Time, file, f); - List_WriteToFile(v->SP, file, f); - List_WriteToFile(v->VP, file, f); - List_WriteToFile(v->TP, file, f); - List_WriteToFile(v->SL, file, f); - List_WriteToFile(v->VL, file, f); - List_WriteToFile(v->TL, file, f); - List_WriteToFile(v->ST, file, f); - List_WriteToFile(v->VT, file, f); - List_WriteToFile(v->TT, file, f); - List_WriteToFile(v->SQ, file, f); - List_WriteToFile(v->VQ, file, f); - List_WriteToFile(v->TQ, file, f); - List_WriteToFile(v->SS, file, f); - List_WriteToFile(v->VS, file, f); - List_WriteToFile(v->TS, file, f); - List_WriteToFile(v->SH, file, f); - List_WriteToFile(v->VH, file, f); - List_WriteToFile(v->TH, file, f); - List_WriteToFile(v->SI, file, f); - List_WriteToFile(v->VI, file, f); - List_WriteToFile(v->TI, file, f); - List_WriteToFile(v->SY, file, f); - List_WriteToFile(v->VY, file, f); - List_WriteToFile(v->TY, file, f); - List_WriteToFile(v->T2D, file, f); - List_WriteToFile(v->T2C, file, f); - List_WriteToFile(v->T3D, file, f); - List_WriteToFile(v->T3C, file, f); - fprintf(file, "\n"); - fprintf(file, "$EndView\n"); if(filename) { fclose(file); diff --git a/Common/Views.h b/Common/Views.h index 1da08287cc8442508e862237a41d1121c5631ef3..19dfeeab8d8c114276d1638a6e834edd4e26d3b3 100644 --- a/Common/Views.h +++ b/Common/Views.h @@ -157,7 +157,7 @@ void FreeView(Post_View *v); bool RemoveViewByIndex(int index); bool RemoveViewByNumber(int num); void ReadView(FILE *file, char *filename); -void WriteView(Post_View *v, char *filename, int binary, int append); +void WriteView(Post_View *v, char *filename, int format, int append); void CopyViewOptions(Post_View *src, Post_View *dest); void CombineViews(int time, int how, int remove); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index dc7bca7c535c2f2654680c050c096c47bf6ece5b..71482d576c79135fdbbe8ad8efd014eeb47d9c19 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.281 2004-10-14 22:56:39 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.282 2004-10-15 02:30:50 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -3166,6 +3166,27 @@ test: } } +void view_save_parsed_cb(CALLBACK_ARGS) +{ + Post_View *v = (Post_View *) List_Pointer(CTX.post.list, (long int)data); + if(!v) return; + +test: + if(file_chooser(0, 1, "Save view in parsed format", "*", 0, v->FileName)) { + char *name = file_chooser_get_name(1); + if(CTX.confirm_overwrite) { + struct stat buf; + if(!stat(name, &buf)) + if(fl_ask("%s already exists.\nDo you want to replace it?", name)) + goto save; + else + goto test; + } + save: + WriteView(v, name, 2, 0); + } +} + void view_duplicate_cb(CALLBACK_ARGS) { DuplicateView((long int)data, 0); diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h index ab6290b1327d41262b0ae556fdbb40867fa86680..8a8d63c6d219b15835a896ca50e4bd0f75798ec5 100644 --- a/Fltk/Callbacks.h +++ b/Fltk/Callbacks.h @@ -110,6 +110,7 @@ void view_remove_invisible_cb(CALLBACK_ARGS) ; void view_remove_empty_cb(CALLBACK_ARGS) ; void view_save_ascii_cb(CALLBACK_ARGS) ; void view_save_binary_cb(CALLBACK_ARGS) ; +void view_save_parsed_cb(CALLBACK_ARGS) ; void view_duplicate_cb(CALLBACK_ARGS) ; void view_duplicate_with_options_cb(CALLBACK_ARGS) ; void view_combine_space_all_cb(CALLBACK_ARGS) ; diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 8a375663af327d5ee8b6355ae746e21c7a41f591..47c3f4cd06e2fe150b6f75e7dd0b2ba9589a30b1 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.360 2004-10-14 22:56:40 geuzaine Exp $ +// $Id: GUI.cpp,v 1.361 2004-10-15 02:30:50 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1103,6 +1103,8 @@ void GUI::set_context(Context_Item * menu_asked, int flag) (Fl_Callback *) view_all_visible_cb, (void *)1, 0); p[j]->add("Set visibility/All off", 0, (Fl_Callback *) view_all_visible_cb, (void *)0, 0); + p[j]->add("Save as/Parsed view...", 0, + (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0); p[j]->add("Save as/ASCII view...", 0, (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0); p[j]->add("Save as/Binary view...", 0, diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index e2a73f6303f816887a7d9ed7863170df4b2cc4b6..10d97acb326c73a6492346900e850dcde61aabfd 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.109 2004-10-14 22:56:40 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.110 2004-10-15 02:30:51 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -382,8 +382,7 @@ void Draw_Mesh_Surface(void *a, void *b) void Draw_Mesh_Extruded_Surfaces(void *a, void *b) { - Volume *v; - v = *(Volume **) a; + Volume *v = *(Volume **) a; if(!(v->Visible & VIS_MESH)) return; Tree_Action(v->Simp_Surf, Draw_Mesh_Triangle); @@ -447,11 +446,10 @@ void Draw_Mesh_Point(void *a, void *b) void Draw_Mesh_Line(void *a, void *b) { - Simplex *s; double Xc = 0.0, Yc = 0.0, Zc = 0.0, m[3]; char Num[100]; - s = *(Simplex **) a; + Simplex *s = *(Simplex **) a; if(!(s->Visible & VIS_MESH)) return; @@ -1026,11 +1024,10 @@ void Draw_Mesh_Quadrangle(void *a, void *b) void Draw_Mesh_Tetrahedron(void *a, void *b) { - Simplex *s; char Num[100]; double tmp, X[4], Y[4], Z[4], X2[6], Y2[6], Z2[6]; - s = *(Simplex **) a; + Simplex *s = *(Simplex **) a; if(!s->V[3] || !(s->Visible & VIS_MESH)) return; diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 7d7e6b6e3ee9e6fabb8c4db67c6677d0a661deae..fc7c584cce861990cf38d74a9c5c450af066742b 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1,5 +1,5 @@ %{ -// $Id: Gmsh.y,v 1.178 2004-09-18 01:51:56 geuzaine Exp $ +// $Id: Gmsh.y,v 1.179 2004-10-15 02:30:51 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -2500,7 +2500,7 @@ Command : if(v){ char tmpstring[1024]; FixRelativePath($6, tmpstring); - WriteView(v, tmpstring, 0, 0); + WriteView(v, tmpstring, CTX.post.file_format, 0); } } else{ diff --git a/doc/VERSIONS b/doc/VERSIONS index 7ac5b45ce97b8961e1cc5d373fd4988787ba3ae9..3aee4dacfb7ab0bf14ffcc848cfd9124fa3efd2d 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,4 @@ -$Id: VERSIONS,v 1.251 2004-10-14 22:57:07 geuzaine Exp $ +$Id: VERSIONS,v 1.252 2004-10-15 02:30:51 geuzaine Exp $ New since 1.55: new post-processing option to draw a scalar view raised by a displacement view without using Plugin(DisplacementRaise) @@ -6,7 +6,8 @@ raised by a displacement view without using Plugin(DisplacementRaise) easier); better post-processing menu (arbitrary number of views+scrollable+show view number); improved view->combine; new horizontal post-processing scales; new option to draw the nodes per -element; small bug fixes. +element; views can now also be saved in "parsed" format; small bug +fixes. New in 1.55: added background mesh support for Triangle; meshes can now be displayed using "smoothed" normals (like post-processing