From ba88df5db34ec9129c8cbda82d6c9245ec156832 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 19 Aug 2006 19:46:07 +0000 Subject: [PATCH] only compute mesh quality measures on demand: it's too slow for large meshes --- Fltk/Callbacks.cpp | 4 +- Fltk/GUI.cpp | 53 ++++++++++---- Fltk/GUI.h | 177 +++++++++++++++++++++++---------------------- Geo/GModelIO.cpp | 36 ++++----- 4 files changed, 147 insertions(+), 123 deletions(-) diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 61043149c6..ad562b6ff7 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.443 2006-08-19 04:24:03 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.444 2006-08-19 19:46:07 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -1257,7 +1257,7 @@ void statistics_cb(CALLBACK_ARGS) void statistics_update_cb(CALLBACK_ARGS) { - WID->set_statistics(); + WID->set_statistics(true); } void statistics_histogram_cb(CALLBACK_ARGS) diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 3b068dc7b6..da09ea2ef3 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.532 2006-08-18 21:11:42 geuzaine Exp $ +// $Id: GUI.cpp,v 1.533 2006-08-19 19:46:07 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -3451,7 +3451,7 @@ void GUI::create_statistics_window() if(stat_window) { if(!stat_window->shown()) - set_statistics(); + set_statistics(false); for(i = 0; i < 3; i++) g[i]->hide(); switch(get_context()){ @@ -3501,12 +3501,12 @@ void GUI::create_statistics_window() stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 15 * BH, IW, BH, "Eta"); stat_value[num++] = new Fl_Output(2 * WB, 2 * WB + 16 * BH, IW, BH, "Rho"); - Fl_Button *b0 = new Fl_Button(width - BB - 5 * WB, 2 * WB + 14 * BH, BB, BH, "Graph"); - b0->callback(statistics_histogram_cb, (void *)"Gamma"); - Fl_Button *b1 = new Fl_Button(width - BB - 5 * WB, 2 * WB + 15 * BH, BB, BH, "Graph"); - b1->callback(statistics_histogram_cb, (void *)"Eta"); - Fl_Button *b2 = new Fl_Button(width - BB - 5 * WB, 2 * WB + 16 * BH, BB, BH, "Graph"); - b2->callback(statistics_histogram_cb, (void *)"Rho"); + stat_butt[0] = new Fl_Button(width - BB - 5 * WB, 2 * WB + 14 * BH, BB, BH, "Graph"); + stat_butt[0]->callback(statistics_histogram_cb, (void *)"Gamma"); + stat_butt[1] = new Fl_Button(width - BB - 5 * WB, 2 * WB + 15 * BH, BB, BH, "Graph"); + stat_butt[1]->callback(statistics_histogram_cb, (void *)"Eta"); + stat_butt[2] = new Fl_Button(width - BB - 5 * WB, 2 * WB + 16 * BH, BB, BH, "Graph"); + stat_butt[2]->callback(statistics_histogram_cb, (void *)"Rho"); g[1]->end(); } @@ -3548,13 +3548,16 @@ void GUI::create_statistics_window() extern void GetStatistics(double s[50], double quality[3][100]=0); -void GUI::set_statistics() +void GUI::set_statistics(bool compute_quality) { int num = 0; static double s[50]; static char label[50][256]; - GetStatistics(s, quality); + if(compute_quality) + GetStatistics(s, quality); + else + GetStatistics(s); // geom sprintf(label[num], "%g", s[0]); stat_value[num]->value(label[num]); num++; @@ -3579,12 +3582,30 @@ void GUI::set_statistics() sprintf(label[num], "%g", s[14]); stat_value[num]->value(label[num]); num++; sprintf(label[num], "%g", s[15]); stat_value[num]->value(label[num]); num++; - sprintf(label[num], "%.4g (%.4g->%.4g)", s[17], s[18], s[19]); - stat_value[num]->value(label[num]); num++; - sprintf(label[num], "%.4g (%.4g->%.4g)", s[20], s[21], s[22]); - stat_value[num]->value(label[num]); num++; - sprintf(label[num], "%.4g (%.4g->%.4g)", s[23], s[24], s[25]); - stat_value[num]->value(label[num]); num++; + if(!compute_quality){ + for(int i = 0; i < 3; i++) stat_butt[i]->deactivate(); + sprintf(label[num], "Press Update"); + stat_value[num]->deactivate(); + stat_value[num]->value(label[num]); num++; + sprintf(label[num], "Press Update"); + stat_value[num]->deactivate(); + stat_value[num]->value(label[num]); num++; + sprintf(label[num], "Press Update"); + stat_value[num]->deactivate(); + stat_value[num]->value(label[num]); num++; + } + else{ + for(int i = 0; i < 3; i++) stat_butt[i]->activate(); + sprintf(label[num], "%.4g (%.4g->%.4g)", s[17], s[18], s[19]); + stat_value[num]->activate(); + stat_value[num]->value(label[num]); num++; + sprintf(label[num], "%.4g (%.4g->%.4g)", s[20], s[21], s[22]); + stat_value[num]->activate(); + stat_value[num]->value(label[num]); num++; + sprintf(label[num], "%.4g (%.4g->%.4g)", s[23], s[24], s[25]); + stat_value[num]->activate(); + stat_value[num]->value(label[num]); num++; + } // post sprintf(label[num], "%g", s[26]); stat_value[num]->value(label[num]); num++; diff --git a/Fltk/GUI.h b/Fltk/GUI.h index 0d35b61913..91ddc8ce7e 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -107,7 +107,7 @@ struct PluginDialogBox Fl_Window *main_window; Fl_Return_Button *run_button; Fl_Value_Input *value[MAX_PLUGIN_OPTIONS]; - Fl_Input *input[MAX_PLUGIN_OPTIONS] ; + Fl_Input *input[MAX_PLUGIN_OPTIONS]; }; // The dialog for solvers @@ -115,148 +115,149 @@ struct PluginDialogBox struct SolverDialogBox { Fl_Window *window; - Fl_Input *input[50] ; - Fl_Choice *choice[10] ; - Fl_Check_Button *butt[10] ; - Fl_Button *command[10] ; + Fl_Input *input[50]; + Fl_Choice *choice[10]; + Fl_Check_Button *butt[10]; + Fl_Button *command[10]; }; // The GUI class contains only the important widgets (which can be set/queried). class GUI{ - int MH, fontsize ; + int MH, fontsize; Fl_Scroll *m_scroll; // Bitmaps - Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *rotate_bmp, *ortho_bmp ; + Fl_Bitmap *abort_bmp, *start_bmp, *stop_bmp, *rewind_bmp, *rotate_bmp, *ortho_bmp; void add_post_plugins(Popup_Button *button , int iView); void add_multiline_in_browser(Fl_Browser *o, char* prefix, char *str); public: // menu window - Fl_Window *m_window ; + Fl_Window *m_window; #if defined(__APPLE__) && defined(HAVE_FLTK_1_1_5_OR_ABOVE) - Fl_Sys_Menu_Bar *m_sys_menu_bar ; + Fl_Sys_Menu_Bar *m_sys_menu_bar; #endif - Fl_Menu_Bar *m_menu_bar ; - Fl_Choice *m_module_butt ; - Fl_Button *m_navig_butt [2] ; - std::vector<Fl_Button*> m_push_butt ; - std::vector<Fl_Light_Button*> m_toggle_butt ; - std::vector<Fl_Button*> m_toggle2_butt ; - std::vector<Popup_Button*> m_popup_butt ; - std::vector<Popup_Button*> m_popup2_butt ; - std::vector<char*> m_pop_label ; + Fl_Menu_Bar *m_menu_bar; + Fl_Choice *m_module_butt; + Fl_Button *m_navig_butt[2]; + std::vector<Fl_Button*> m_push_butt; + std::vector<Fl_Light_Button*> m_toggle_butt; + std::vector<Fl_Button*> m_toggle2_butt; + std::vector<Popup_Button*> m_popup_butt; + std::vector<Popup_Button*> m_popup2_butt; + std::vector<char*> m_pop_label; std::vector<std::pair<int, GMSH_Plugin*>*> m_pop_plugin; // graphic window - Fl_Window *g_window ; - Opengl_Window *g_opengl_window ; - Fl_Button *g_status_butt[10] ; - Fl_Box *g_status_label[2] ; + Fl_Window *g_window; + Opengl_Window *g_opengl_window; + Fl_Button *g_status_butt[10]; + Fl_Box *g_status_label[2]; // Option window - Fl_Window *opt_window ; - Fl_Hold_Browser *opt_browser ; + Fl_Window *opt_window; + Fl_Hold_Browser *opt_browser; // general options - Fl_Group *gen_group ; - Fl_Check_Button *gen_butt[20] ; - Fl_Button *gen_push_butt[20] ; - Fl_Value_Input *gen_value[50] ; - Fl_Button *gen_col[50] ; - Fl_Input *gen_input[20] ; - Fl_Choice *gen_choice[20] ; + Fl_Group *gen_group; + Fl_Check_Button *gen_butt[20]; + Fl_Button *gen_push_butt[20]; + Fl_Value_Input *gen_value[50]; + Fl_Button *gen_col[50]; + Fl_Input *gen_input[20]; + Fl_Choice *gen_choice[20]; // geometry options - Fl_Group *geo_group ; - Fl_Check_Button *geo_butt[20] ; - Fl_Value_Input *geo_value[20] ; - Fl_Button *geo_col[50] ; - Fl_Choice *geo_choice[20] ; + Fl_Group *geo_group; + Fl_Check_Button *geo_butt[20]; + Fl_Value_Input *geo_value[20]; + Fl_Button *geo_col[50]; + Fl_Choice *geo_choice[20]; // mesh options - Fl_Group *mesh_group ; - Fl_Group *mesh_cut_plane ; - Fl_Check_Button *mesh_butt[50] ; - Fl_Return_Button *mesh_retbutt[50] ; - Fl_Input *mesh_input[20] ; - Fl_Value_Input *mesh_value[50] ; - Fl_Button *mesh_col[50] ; - Fl_Choice *mesh_choice[20] ; + Fl_Group *mesh_group; + Fl_Group *mesh_cut_plane; + Fl_Check_Button *mesh_butt[50]; + Fl_Return_Button *mesh_retbutt[50]; + Fl_Input *mesh_input[20]; + Fl_Value_Input *mesh_value[50]; + Fl_Button *mesh_col[50]; + Fl_Choice *mesh_choice[20]; Fl_Menu_Button *mesh_menu_butt; // solver options - Fl_Group *solver_group ; - Fl_Check_Button *solver_butt[20] ; - Fl_Value_Input *solver_value[20] ; - Fl_Input *solver_input[20] ; + Fl_Group *solver_group; + Fl_Check_Button *solver_butt[20]; + Fl_Value_Input *solver_value[20]; + Fl_Input *solver_input[20]; // post-processing options - Fl_Group *post_group ; - Fl_Check_Button *post_butt[20] ; - Fl_Value_Input *post_value[20] ; - Fl_Choice *post_choice[20] ; + Fl_Group *post_group; + Fl_Check_Button *post_butt[20]; + Fl_Value_Input *post_value[20]; + Fl_Choice *post_choice[20]; // view options - int view_number ; - Fl_Group *view_group ; - Fl_Group *view_range, *view_vector ; - Fl_Check_Button *view_butt[100] ; - Fl_Value_Input *view_value[100] ; - Fl_Input *view_input[100] ; - Fl_Repeat_Button *view_butt_rep[100] ; - Fl_Button *view_push_butt[100] ; - Fl_Choice *view_choice[100] ; - Fl_Button *view_col[50] ; - Colorbar_Window *view_colorbar_window ; - Fl_Return_Button *view_ok ; + int view_number; + Fl_Group *view_group; + Fl_Group *view_range, *view_vector; + Fl_Check_Button *view_butt[100]; + Fl_Value_Input *view_value[100]; + Fl_Input *view_input[100]; + Fl_Repeat_Button *view_butt_rep[100]; + Fl_Button *view_push_butt[100]; + Fl_Choice *view_choice[100]; + Fl_Button *view_col[50]; + Colorbar_Window *view_colorbar_window; + Fl_Return_Button *view_ok; Fl_Menu_Button *view_menu_butt[2]; // statistics window - Fl_Window *stat_window ; - Fl_Output *stat_value[50] ; - double quality[3][100]; + Fl_Window *stat_window; + Fl_Output *stat_value[50]; + Fl_Button *stat_butt[3]; + double quality[3][100]; // message window - Fl_Window *msg_window ; - Fl_Browser *msg_browser ; + Fl_Window *msg_window; + Fl_Browser *msg_browser; // visibility window - Fl_Window *vis_window ; - Fl_Choice *vis_type ; - Fl_Browser *vis_browser ; - Fl_Check_Button *vis_butt[2] ; - Fl_Button *vis_push_butt[2] ; + Fl_Window *vis_window; + Fl_Choice *vis_type; + Fl_Browser *vis_browser; + Fl_Check_Button *vis_butt[2]; + Fl_Button *vis_push_butt[2]; Fl_Input *vis_input[10]; // clipping planes window - Fl_Window *clip_window ; - Fl_Choice *clip_choice ; - Fl_Multi_Browser *clip_browser ; + Fl_Window *clip_window; + Fl_Choice *clip_choice; + Fl_Multi_Browser *clip_browser; Fl_Value_Input *clip_value[4]; // manipulator window - Fl_Window *manip_window ; - Fl_Value_Input *manip_value[9] ; + Fl_Window *manip_window; + Fl_Value_Input *manip_value[9]; // about window - Fl_Window *about_window ; + Fl_Window *about_window; // geometry context window - Fl_Window *context_geometry_window ; - Fl_Input *context_geometry_input[30] ; - Fl_Value_Input *context_geometry_value[10] ; + Fl_Window *context_geometry_window; + Fl_Input *context_geometry_input[30]; + Fl_Value_Input *context_geometry_value[10]; // mesh context window - Fl_Window *context_mesh_window ; - Fl_Input *context_mesh_input[20] ; - Fl_Choice *context_mesh_choice[20] ; + Fl_Window *context_mesh_window; + Fl_Input *context_mesh_input[20]; + Fl_Choice *context_mesh_choice[20]; // solver windows - SolverDialogBox solver[5] ; + SolverDialogBox solver[5]; // on-screen persistent messages char onscreen_buffer[2][256]; @@ -303,7 +304,7 @@ public: void add_message(char *msg); void save_message(char *filename); void fatal_error(char *filename); - void set_statistics(); + void set_statistics(bool compute_quality); void update_view_window(int numview); void set_title(char *str); void add_handler(); diff --git a/Geo/GModelIO.cpp b/Geo/GModelIO.cpp index c0614545e0..9de79ab416 100644 --- a/Geo/GModelIO.cpp +++ b/Geo/GModelIO.cpp @@ -1,4 +1,4 @@ -// $Id: GModelIO.cpp,v 1.27 2006-08-19 18:48:06 geuzaine Exp $ +// $Id: GModelIO.cpp,v 1.28 2006-08-19 19:46:07 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -342,12 +342,12 @@ int GModel::readMSH(const std::string &name) if(format){ binary = true; - Msg(INFO, "Reading binary MSH file"); + Msg(INFO, "Mesh is in binary format"); int one; if(fread(&one, sizeof(int), 1, fp) != 1) return 0; if(one != 1){ swap = true; - Msg(INFO, "Swapping bytes in binary file"); + Msg(INFO, "Swapping bytes from binary file"); } } @@ -433,11 +433,11 @@ int GModel::readMSH(const std::string &name) int indices[30]; for(int j = 0; j < numVertices; j++) fscanf(fp, "%d", &indices[j]); if(vertexVector.size()) - createElementMSH(this, num, type, physical, elementary, partition, indices, - vertexVector, points, elements, physicals); + createElementMSH(this, num, type, physical, elementary, partition, + indices, vertexVector, points, elements, physicals); else - createElementMSH(this, num, type, physical, elementary, partition, indices, - vertexMap, points, elements, physicals); + createElementMSH(this, num, type, physical, elementary, partition, + indices, vertexMap, points, elements, physicals); if(progress && (i % progress == progress - 1)) Msg(PROGRESS, "Read %d elements", i + 1); } @@ -445,13 +445,14 @@ int GModel::readMSH(const std::string &name) else{ int numElementsPartial = 0; while(numElementsPartial < numElements){ - int tags[3]; - if(fread(tags, sizeof(int), 3, fp) != 3) return 0; - if(swap) swapBytes((char*)&tags, sizeof(int), 3); - int type = tags[0]; - int numElms = tags[1]; - int numTags = tags[2]; - unsigned int n = 1 + numTags + getNumVerticesForElementTypeMSH(type); + int header[3]; + if(fread(header, sizeof(int), 3, fp) != 3) return 0; + if(swap) swapBytes((char*)&header, sizeof(int), 3); + int type = header[0]; + int numElms = header[1]; + int numTags = header[2]; + int numVertices = getNumVerticesForElementTypeMSH(type); + unsigned int n = 1 + numTags + numVertices; int *data = new int[n]; for(int i = 0; i < numElms; i++) { if(fread(data, sizeof(int), n, fp) != n) return 0; @@ -460,13 +461,13 @@ int GModel::readMSH(const std::string &name) int physical = (numTags > 0) ? data[4 - numTags] : 0; int elementary = (numTags > 1) ? data[4 - numTags + 1] : 0; int partition = (numTags > 2) ? data[4 - numTags + 2] : 0; - int *verts = &data[numTags + 1]; + int *indices = &data[numTags + 1]; if(vertexVector.size()) createElementMSH(this, num, type, physical, elementary, partition, - verts, vertexVector, points, elements, physicals); + indices, vertexVector, points, elements, physicals); else createElementMSH(this, num, type, physical, elementary, partition, - verts, vertexMap, points, elements, physicals); + indices, vertexMap, points, elements, physicals); if(progress && ((numElementsPartial + i) % progress == progress - 1)) Msg(PROGRESS, "Read %d elements", i + 1); } @@ -800,6 +801,7 @@ int GModel::readSTL(const std::string &name, double tolerance) } else{ // Binary STL + Msg(INFO, "Mesh is in binary format"); rewind(fp); char header[80]; if(fread(header, sizeof(char), 80, fp)){ -- GitLab