diff --git a/Common/Context.h b/Common/Context.h index 115fc94b21d16136d2f48fa94188fd9764393e54..6dcb7ff5844d6d051587d32ea1e300da9f70b973 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -221,6 +221,7 @@ public : int jpeg_quality, jpeg_smoothing; int gif_dither, gif_sort, gif_interlace, gif_transparent; int geo_labels; + int pos_elementary, pos_element, pos_gamma, pos_eta, pos_rho; int text, tex_as_equation; } print; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 98165d62132653f4a18ff01d13a525f6aa64173c..21571b2c14d5564688b945f88e4de670fddd8f28 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1406,6 +1406,17 @@ StringXNumber PrintOptions_Number[] = { { F|O, "JpegSmoothing" , opt_print_jpeg_smoothing , 0. , "JPEG smoothing (between 0 and 100)" }, + { F|O, "PostElementary" , opt_print_pos_elementary , 1. , + "Save elementary region tags in mesh statistics exported as post-processing views" }, + { F|O, "PostElement" , opt_print_pos_element , 0. , + "Save element numbers in mesh statistics exported as post-processing views" }, + { F|O, "PostGamma" , opt_print_pos_gamma , 0. , + "Save Gamma quality measure in mesh statistics exported as post-processing views" }, + { F|O, "PostEta" , opt_print_pos_eta , 0. , + "Save Eta quality measure in mesh statistics exported as post-processing views" }, + { F|O, "PostRho" , opt_print_pos_rho , 0. , + "Save Rho quality measure in mesh statistics exported as post-processing views" }, + { F|O, "TexAsEquation" , opt_print_tex_as_equation , 0. , "Print all TeX strings as equations" }, { F|O, "Text" , opt_print_text , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 37405944c590abf255ccf28dbd3775e26950d9c1..8fe9d671d17b79112b9ac2b98ac6cd306b4a8889 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.363 2007-10-02 20:07:29 geuzaine Exp $ +// $Id: Options.cpp,v 1.364 2007-10-03 19:40:40 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -7006,6 +7006,41 @@ double opt_print_geo_labels(OPT_ARGS_NUM) return CTX.print.geo_labels; } +double opt_print_pos_elementary(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.pos_elementary = (int)val; + return CTX.print.pos_elementary; +} + +double opt_print_pos_element(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.pos_element = (int)val; + return CTX.print.pos_element; +} + +double opt_print_pos_gamma(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.pos_gamma = (int)val; + return CTX.print.pos_gamma; +} + +double opt_print_pos_eta(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.pos_eta = (int)val; + return CTX.print.pos_eta; +} + +double opt_print_pos_rho(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.pos_rho = (int)val; + return CTX.print.pos_rho; +} + double opt_print_gif_dither(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 18ce4f9d1bd6e812de8a05f4446fc5f905022ab6..e99a647f6027ca2b15435fe8661bddee3979cd22 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -650,6 +650,11 @@ double opt_print_eps_point_size_factor(OPT_ARGS_NUM); double opt_print_jpeg_quality(OPT_ARGS_NUM); double opt_print_jpeg_smoothing(OPT_ARGS_NUM); double opt_print_geo_labels(OPT_ARGS_NUM); +double opt_print_pos_elementary(OPT_ARGS_NUM); +double opt_print_pos_element(OPT_ARGS_NUM); +double opt_print_pos_gamma(OPT_ARGS_NUM); +double opt_print_pos_eta(OPT_ARGS_NUM); +double opt_print_pos_rho(OPT_ARGS_NUM); double opt_print_gif_dither(OPT_ARGS_NUM); double opt_print_gif_sort(OPT_ARGS_NUM); double opt_print_gif_interlace(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index ff37f78343c2effdb28f897ece3460e24c420cc4..2bc63a6bf1264e07d97077dab3c02d12e093031f 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.551 2007-10-01 08:45:15 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.552 2007-10-03 19:40:40 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -638,7 +638,7 @@ void file_merge_cb(CALLBACK_ARGS) } int _save_msh(char *name){ return msh_dialog(name); } -int _save_pos(char *name){ return generic_mesh_dialog(name, "POS Options", FORMAT_POS); } +int _save_pos(char *name){ return pos_dialog(name); } int _save_options(char *name){ return options_dialog(name); } int _save_geo(char *name){ return geo_dialog(name); } int _save_cgns(char *name){ CreateOutputFile(name, FORMAT_CGNS); return 1; } diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp index 08f7557a9bb0dc07db7544bf972cb744cd1cefec..facbf2aa4402e6915fa817331602113275366b4d 100644 --- a/Fltk/GUI_Extras.cpp +++ b/Fltk/GUI_Extras.cpp @@ -1,4 +1,4 @@ -// $Id: GUI_Extras.cpp,v 1.36 2007-06-22 08:07:46 geuzaine Exp $ +// $Id: GUI_Extras.cpp,v 1.37 2007-10-03 19:40:40 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -697,6 +697,73 @@ int geo_dialog(char *name) return 0; } +int pos_dialog(char *name) +{ + struct _pos_dialog{ + Fl_Window *window; + Fl_Check_Button *b[6]; + Fl_Button *ok, *cancel; + }; + static _pos_dialog *dialog = NULL; + + const int BH = 2 * GetFontSize() + 1; + const int BB = 7 * GetFontSize() + 9; + const int WB = 7; + + if(!dialog){ + dialog = new _pos_dialog; + int h = 3 * WB + 7 * BH, w = 2 * BB + 3 * WB, y = WB; + // not a "Dialog_Window" since it is modal + dialog->window = new Fl_Double_Window(w, h, "POS Options"); + dialog->window->box(GMSH_WINDOW_BOX); + dialog->b[0] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Save all (ignore physical groups)"); y += BH; + dialog->b[1] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print elementary tags"); y += BH; + dialog->b[2] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print element numbers"); y += BH; + dialog->b[3] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Gamma quality measure"); y += BH; + dialog->b[4] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Eta quality measure"); y += BH; + dialog->b[5] = new Fl_Check_Button(WB, y, 2 * BB + WB, BH, "Print Rho quality measure"); y += BH; + for(int i = 0; i < 5; i++) + dialog->b[i]->type(FL_TOGGLE_BUTTON); + dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK"); + dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel"); + dialog->window->set_modal(); + dialog->window->end(); + dialog->window->hotspot(dialog->window); + } + + dialog->b[0]->value(CTX.mesh.save_all ? 1 : 0); + dialog->b[1]->value(CTX.print.pos_elementary ? 1 : 0); + dialog->b[2]->value(CTX.print.pos_element ? 1 : 0); + dialog->b[3]->value(CTX.print.pos_gamma ? 1 : 0); + dialog->b[4]->value(CTX.print.pos_eta ? 1 : 0); + dialog->b[5]->value(CTX.print.pos_rho ? 1 : 0); + dialog->window->show(); + + while(dialog->window->shown()){ + Fl::wait(); + for (;;) { + Fl_Widget* o = Fl::readqueue(); + if (!o) break; + if (o == dialog->ok) { + opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); + opt_print_pos_elementary(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); + opt_print_pos_element(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value() ? 1 : 0); + opt_print_pos_gamma(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value() ? 1 : 0); + opt_print_pos_eta(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value() ? 1 : 0); + opt_print_pos_rho(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value() ? 1 : 0); + CreateOutputFile(name, FORMAT_POS); + dialog->window->hide(); + return 1; + } + if (o == dialog->window || o == dialog->cancel){ + dialog->window->hide(); + return 0; + } + } + } + return 0; +} + // Generic save mesh dialog int generic_mesh_dialog(char *name, char *title, int format) diff --git a/Fltk/GUI_Extras.h b/Fltk/GUI_Extras.h index 721e63cf2db11832c507236824313fa763f665be..9e7619f14a14550c281e2dce4bf199aa3a755c5e 100644 --- a/Fltk/GUI_Extras.h +++ b/Fltk/GUI_Extras.h @@ -36,6 +36,7 @@ int generic_bitmap_dialog(char *filename, char *title, int format); int generic_mesh_dialog(char *filename, char *title, int format); int gl2ps_dialog(char *filename, char *title, int format); int options_dialog(char *filename); +int pos_dialog(char *filename); int msh_dialog(char *filename); int unv_dialog(char *filename); int bdf_dialog(char *filename); diff --git a/Geo/GModel.h b/Geo/GModel.h index e46154091b2c07225e74224e8e4355c484dc061f..bf39532bf93f5a5b7436f0a7385621f5cf19d5d7 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -196,7 +196,8 @@ class GModel bool saveAll=false, double scalingFactor=1.0); // Mesh statistics (as Gmsh post-processing views) - int writePOS(const std::string &name, + int writePOS(const std::string &name, bool printElementary, + bool printElementNumber, bool printGamma, bool printEta, bool printRho, bool saveAll=false, double scalingFactor=1.0); // Stereo lithography format diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index 9ab00dd65fee53d0f3ea6c819f9dd20275118f1e..3299ace23fe74ac69d480caf724fdb68c9d45579 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO_Mesh.cpp,v 1.22 2007-08-14 18:11:19 anand Exp $ +// $Id: GModelIO_Mesh.cpp,v 1.23 2007-10-03 19:40:41 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -731,7 +731,9 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, return 1; } -int GModel::writePOS(const std::string &name, bool saveAll, double scalingFactor) +int GModel::writePOS(const std::string &name, bool printElementary, + bool printElementNumber, bool printGamma, bool printEta, + bool printRho, bool saveAll, double scalingFactor) { FILE *fp = fopen(name.c_str(), "w"); if(!fp){ @@ -739,57 +741,76 @@ int GModel::writePOS(const std::string &name, bool saveAll, double scalingFactor return 0; } + bool f[5] = {printElementary, printElementNumber, printGamma, printEta, printRho}; + + bool first = true; + std::string names; + if(f[0]){ + if(first) first = false; else names += ","; + names += "\"Elementary Entity\""; + } + if(f[1]){ + if(first) first = false; else names += ","; + names += "\"Element Number\""; + } + if(f[2]){ + if(first) first = false; else names += ","; + names += "\"Gamma\""; + } + if(f[3]){ + if(first) first = false; else names += ","; + names += "\"Eta\""; + } + if(f[4]){ + if(first) first = false; else names += ","; + names += "\"Rho\""; + } + + if(names.empty()) return 0; + if(noPhysicalGroups()) saveAll = true; - int status = getMeshStatus(); + fprintf(fp, "View \"Statistics\" {\n"); + fprintf(fp, "T2(1.e5,30,%d){%s};\n", (1<<16)|(4<<8), names.c_str()); - if(status >= 3){ - fprintf(fp, "View \"Volumes\" {\n"); - fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", " - "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8)); - for(riter it = firstRegion(); it != lastRegion(); ++it) { - if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) - (*it)->tetrahedra[i]->writePOS(fp, scalingFactor, (*it)->tag()); - for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) - (*it)->hexahedra[i]->writePOS(fp, scalingFactor, (*it)->tag()); - for(unsigned int i = 0; i < (*it)->prisms.size(); i++) - (*it)->prisms[i]->writePOS(fp, scalingFactor, (*it)->tag()); - for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) - (*it)->pyramids[i]->writePOS(fp, scalingFactor, (*it)->tag()); - } + for(eiter it = firstEdge(); it != lastEdge(); ++it) { + if(saveAll || (*it)->physicals.size()){ + for(unsigned int i = 0; i < (*it)->lines.size(); i++) + (*it)->lines[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } - fprintf(fp, "};\n"); } - - if(status >= 2){ - fprintf(fp, "View \"Surfaces\" {\n"); - fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", " - "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8)); - for(fiter it = firstFace(); it != lastFace(); ++it) { - if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->triangles.size(); i++) - (*it)->triangles[i]->writePOS(fp, scalingFactor, (*it)->tag()); - for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) - (*it)->quadrangles[i]->writePOS(fp, scalingFactor, (*it)->tag()); - } + + for(fiter it = firstFace(); it != lastFace(); ++it) { + if(saveAll || (*it)->physicals.size()){ + for(unsigned int i = 0; i < (*it)->triangles.size(); i++) + (*it)->triangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++) + (*it)->quadrangles[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } - fprintf(fp, "};\n"); } - if(status >= 1){ - fprintf(fp, "View \"Lines\" {\n"); - fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", " - "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8)); - for(eiter it = firstEdge(); it != lastEdge(); ++it) { - if(saveAll || (*it)->physicals.size()){ - for(unsigned int i = 0; i < (*it)->lines.size(); i++) - (*it)->lines[i]->writePOS(fp, scalingFactor, (*it)->tag()); - } + for(riter it = firstRegion(); it != lastRegion(); ++it) { + if(saveAll || (*it)->physicals.size()){ + for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++) + (*it)->tetrahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++) + (*it)->hexahedra[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->prisms.size(); i++) + (*it)->prisms[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); + for(unsigned int i = 0; i < (*it)->pyramids.size(); i++) + (*it)->pyramids[i]->writePOS(fp, f[0], f[1], f[2], f[3], f[4], + scalingFactor, (*it)->tag()); } - fprintf(fp, "};\n"); } + fprintf(fp, "};\n"); + fclose(fp); return 1; } diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index b3b7df4b3768e0d089c9b0dce81e9fa4fe241806..442984294ded35f32e96313dd54f361e8607844c 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -1,4 +1,4 @@ -// $Id: MElement.cpp,v 1.43 2007-09-19 23:42:10 geuzaine Exp $ +// $Id: MElement.cpp,v 1.44 2007-10-03 19:40:41 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -188,15 +188,14 @@ void MElement::writeMSH(FILE *fp, double version, bool binary, int num, if(physical < 0) revert(); } -void MElement::writePOS(FILE *fp, double scalingFactor, int elementary) +void MElement::writePOS(FILE *fp, bool printElementary, bool printElementNumber, + bool printGamma, bool printEta, bool printRho, + double scalingFactor, int elementary) { const char *str = getStringForPOS(); if(!str) return; int n = getNumVertices(); - double gamma = gammaShapeMeasure(); - double eta = etaShapeMeasure(); - double rho = rhoShapeMeasure(); fprintf(fp, "%s(", str); for(int i = 0; i < n; i++){ if(i) fprintf(fp, ","); @@ -204,19 +203,39 @@ void MElement::writePOS(FILE *fp, double scalingFactor, int elementary) getVertex(i)->y() * scalingFactor, getVertex(i)->z() * scalingFactor); } fprintf(fp, "){"); - for(int i = 0; i < n; i++) - fprintf(fp, "%d,", elementary); - for(int i = 0; i < n; i++) - fprintf(fp, "%d,", getNum()); - for(int i = 0; i < n; i++) - fprintf(fp, "%g,", gamma); - for(int i = 0; i < n; i++) - fprintf(fp, "%g,", eta); - for(int i = 0; i < n; i++){ - if(i == n - 1) + bool first = true; + if(printElementary){ + for(int i = 0; i < n; i++){ + if(first) first = false; else fprintf(fp, ","); + fprintf(fp, "%d", elementary); + } + } + if(printElementNumber){ + for(int i = 0; i < n; i++){ + if(first) first = false; else fprintf(fp, ","); + fprintf(fp, "%d", getNum()); + } + } + if(printGamma){ + double gamma = gammaShapeMeasure(); + for(int i = 0; i < n; i++){ + if(first) first = false; else fprintf(fp, ","); + fprintf(fp, "%g", gamma); + } + } + if(printEta){ + double eta = etaShapeMeasure(); + for(int i = 0; i < n; i++){ + if(first) first = false; else fprintf(fp, ","); + fprintf(fp, "%g", eta); + } + } + if(printRho){ + double rho = rhoShapeMeasure(); + for(int i = 0; i < n; i++){ + if(first) first = false; else fprintf(fp, ","); fprintf(fp, "%g", rho); - else - fprintf(fp, "%g,", rho); + } } fprintf(fp, "};\n"); } diff --git a/Geo/MElement.h b/Geo/MElement.h index 0712f51a99c14eb8e26409f01968c873dc1864e9..79c9e77e0cfb1e32075a89bf098b4501abaf4a23 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -146,7 +146,9 @@ class MElement // IO routines virtual void writeMSH(FILE *fp, double version=1.0, bool binary=false, int num=0, int elementary=1, int physical=1); - virtual void writePOS(FILE *fp, double scalingFactor=1.0, int elementary=1); + virtual void writePOS(FILE *fp, bool printElementary, bool printElementNumber, + bool printGamma, bool printEta, bool printRho, + double scalingFactor=1.0, int elementary=1); virtual void writeSTL(FILE *fp, bool binary=false, double scalingFactor=1.0); virtual void writeVRML(FILE *fp); virtual void writeUNV(FILE *fp, int num=0, int elementary=1, int physical=1); diff --git a/Parser/CreateFile.cpp b/Parser/CreateFile.cpp index 9a07773a6062d2e4be5c8510603dda4f5efeb936..4bde77d4d7049b69fe27050b0f1e08b03a238a50 100644 --- a/Parser/CreateFile.cpp +++ b/Parser/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.20 2007-09-26 20:51:58 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.21 2007-10-03 19:40:41 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -188,7 +188,9 @@ void CreateOutputFile(char *filename, int format) break; case FORMAT_POS: - GModel::current()->writePOS(name, CTX.mesh.save_all, CTX.mesh.scaling_factor); + GModel::current()->writePOS(name, CTX.print.pos_elementary, CTX.print.pos_element, + CTX.print.pos_gamma, CTX.print.pos_eta, CTX.print.pos_rho, + CTX.mesh.save_all, CTX.mesh.scaling_factor); break; case FORMAT_GEO: diff --git a/doc/texinfo/opt_print.texi b/doc/texinfo/opt_print.texi index e6824f52f2d0156bcd24fcd60703175829180e1d..0811ee07afc3fc3b0c5330a3f41fbb28a05fba1b 100644 --- a/doc/texinfo/opt_print.texi +++ b/doc/texinfo/opt_print.texi @@ -84,6 +84,31 @@ JPEG smoothing (between 0 and 100)@* Default value: @code{0}@* Saved in: @code{General.OptionsFileName} +@item Print.PostElementary +Save elementary region tags in mesh statistics exported as post-processing views@* +Default value: @code{1}@* +Saved in: @code{General.OptionsFileName} + +@item Print.PostElement +Save element numbers in mesh statistics exported as post-processing views@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item Print.PostGamma +Save Gamma quality measure in mesh statistics exported as post-processing views@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item Print.PostEta +Save Eta quality measure in mesh statistics exported as post-processing views@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + +@item Print.PostRho +Save Rho quality measure in mesh statistics exported as post-processing views@* +Default value: @code{0}@* +Saved in: @code{General.OptionsFileName} + @item Print.TexAsEquation Print all TeX strings as equations@* Default value: @code{0}@*