diff --git a/Common/Context.h b/Common/Context.h index f0afffaf0d362ac7fbf17fa2dfd48c8924197f9b..d2835522286ecd7a9cfac056fa99d96b4c8d825b 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -181,7 +181,7 @@ public : double quality_inf, quality_sup, radius_inf, radius_sup; double scaling_factor, lc_factor, rand_factor; int dual, interactive; - int light, light_two_side; + int light, light_two_side, light_lines; int format, nbPartitions,nb_smoothing, algo2d, algo3d, order,algo_recombine; int point_insertion, speed_max, min_circ_points, constrained_bgmesh; int histogram, initial_only; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 8537c09bc6da37e7e6f9838aea83346c4546892f..cea0ec45a4d9ada62822cbaabbfcf0a61ae1550d 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -881,6 +881,8 @@ StringXNumber MeshOptions_Number[] = { "Type of element label (0=element number, 1=elementary entity number, 2=physical entity number, 3=partition number)" }, { F|O, "Light" , opt_mesh_light , 0. , "Enable lighting for the mesh" }, + { F|O, "LightLines" , opt_mesh_light_lines , 1. , + "Enable lighting for mesh lines (element edges)" }, { F|O, "LightTwoSide" , opt_mesh_light_two_side , 1. , "Light both sides of mesh elements (leads to slower rendering)" }, { F|O, "Lines" , opt_mesh_lines , 0. , @@ -1196,6 +1198,8 @@ StringXNumber ViewOptions_Number[] = { { F|O, "Light" , opt_view_light , 1. , "Enable lighting for the view" }, + { F|O, "LightLines" , opt_view_light_lines , 0. , + "Light element edges" }, { F|O, "LightTwoSide" , opt_view_light_two_side , 1. , "Light both sides of view elements (leads to slower rendering)" }, { F|O, "LineType" , opt_view_line_type , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 91117fed6422baaffa1b54c615cba4db2e996858..9ee439c2064b703eebfeddf2142fdd8c47a82448 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.262 2005-11-19 04:01:13 geuzaine Exp $ +// $Id: Options.cpp,v 1.263 2005-11-20 03:58:27 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -4347,6 +4347,17 @@ double opt_mesh_light(OPT_ARGS_NUM) return CTX.mesh.light; } +double opt_mesh_light_lines(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.mesh.light_lines = (int)val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->mesh_butt[20]->value(CTX.mesh.light_lines); +#endif + return CTX.mesh.light_lines; +} + double opt_mesh_light_two_side(OPT_ARGS_NUM) { if(action & GMSH_SET) @@ -5900,6 +5911,19 @@ double opt_view_light_two_side(OPT_ARGS_NUM) return v->LightTwoSide; } +double opt_view_light_lines(OPT_ARGS_NUM) +{ + GET_VIEW(0.); + if(action & GMSH_SET) { + v->LightLines = (int)val; + } +#if defined(HAVE_FLTK) + if(_gui_action_valid(action, num)) + WID->view_butt[8]->value(v->LightLines); +#endif + return v->LightLines; +} + double opt_view_smooth_normals(OPT_ARGS_NUM) { GET_VIEW(0.); diff --git a/Common/Options.h b/Common/Options.h index 4f66ecd25dfe42583b291fa084e2af18d4215cdb..898bbc56ce7f965df0f80f7dd30989a92ced8e1e 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -433,6 +433,7 @@ double opt_mesh_vertex_arrays(OPT_ARGS_NUM); double opt_mesh_smooth_normals(OPT_ARGS_NUM); double opt_mesh_angle_smooth_normals(OPT_ARGS_NUM); double opt_mesh_light(OPT_ARGS_NUM); +double opt_mesh_light_lines(OPT_ARGS_NUM); double opt_mesh_light_two_side(OPT_ARGS_NUM); double opt_mesh_format(OPT_ARGS_NUM); double opt_mesh_msh_file_version(OPT_ARGS_NUM); @@ -580,6 +581,7 @@ double opt_view_nb_iso(OPT_ARGS_NUM); double opt_view_boundary(OPT_ARGS_NUM); double opt_view_light(OPT_ARGS_NUM); double opt_view_light_two_side(OPT_ARGS_NUM); +double opt_view_light_lines(OPT_ARGS_NUM); double opt_view_smooth_normals(OPT_ARGS_NUM); double opt_view_angle_smooth_normals(OPT_ARGS_NUM); double opt_view_show_element(OPT_ARGS_NUM); diff --git a/Common/Views.cpp b/Common/Views.cpp index 767e71fbac5d5baf34892d21b0ee2c3de59f020d..0589091a135516d6bb941e83cdb033308a8680db 100644 --- a/Common/Views.cpp +++ b/Common/Views.cpp @@ -1,4 +1,4 @@ -// $Id: Views.cpp,v 1.177 2005-10-14 19:26:06 geuzaine Exp $ +// $Id: Views.cpp,v 1.178 2005-11-20 03:58:28 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -633,6 +633,7 @@ void CopyViewOptions(Post_View * src, Post_View * dest) dest->NbIso = src->NbIso; dest->Light = src->Light; dest->LightTwoSide = src->LightTwoSide; + dest->LightLines = src->LightLines; dest->SmoothNormals = src->SmoothNormals; dest->AngleSmoothNormals = src->AngleSmoothNormals; dest->ShowElement = src->ShowElement; diff --git a/Common/Views.h b/Common/Views.h index c3e3825e2ec05802b7e3b872aad5fd575592570d..8428f4946c93051be261116ef04d1caeb796ed0c 100644 --- a/Common/Views.h +++ b/Common/Views.h @@ -84,7 +84,7 @@ class Post_View{ double ArrowSize, ArrowRelHeadRadius, ArrowRelStemRadius, ArrowRelStemLength; double Normals, Tangents; int Visible, IntervalsType, NbIso, ArrowSizeProportional; - int Light, LightTwoSide, SmoothNormals; + int Light, LightTwoSide, LightLines, SmoothNormals; double AngleSmoothNormals; int SaturateValues, FakeTransparency; int ShowElement, ShowTime, ShowScale; diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index a147301a31a2279f2a80ca3a5c93ef4c069a161f..3f8a0ee1f3a3a553ff268b66ee5199cdd464d234 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.375 2005-11-01 16:37:12 remacle Exp $ +// $Id: Callbacks.cpp,v 1.376 2005-11-20 03:58:28 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -297,21 +297,25 @@ void activate_cb(CALLBACK_ARGS) if(WID->mesh_butt[17]->value()){ WID->mesh_butt[18]->activate(); WID->mesh_butt[19]->activate(); + WID->mesh_butt[20]->activate(); WID->mesh_value[18]->activate(); } else{ WID->mesh_butt[18]->deactivate(); WID->mesh_butt[19]->deactivate(); + WID->mesh_butt[20]->deactivate(); WID->mesh_value[18]->deactivate(); } } else if(!strcmp(str, "view_light")){ if(WID->view_butt[11]->value()){ + WID->view_butt[8]->activate(); WID->view_butt[9]->activate(); WID->view_butt[12]->activate(); WID->view_value[10]->activate(); } else{ + WID->view_butt[8]->deactivate(); WID->view_butt[9]->deactivate(); WID->view_butt[12]->deactivate(); WID->view_value[10]->deactivate(); @@ -1043,6 +1047,7 @@ void mesh_options_ok_cb(CALLBACK_ARGS) opt_mesh_light(0, GMSH_SET, WID->mesh_butt[17]->value()); opt_mesh_light_two_side(0, GMSH_SET, WID->mesh_butt[18]->value()); opt_mesh_smooth_normals(0, GMSH_SET, WID->mesh_butt[19]->value()); + opt_mesh_light_lines(0, GMSH_SET, WID->mesh_butt[20]->value()); opt_mesh_nb_smoothing(0, GMSH_SET, WID->mesh_value[0]->value()); opt_mesh_scaling_factor(0, GMSH_SET, WID->mesh_value[1]->value()); @@ -3659,6 +3664,7 @@ void view_options_ok_cb(CALLBACK_ARGS) double draw_strings = opt_view_draw_strings(current, GMSH_GET, 0); double light = opt_view_light(current, GMSH_GET, 0); double light_two_side = opt_view_light_two_side(current, GMSH_GET, 0); + double light_lines = opt_view_light_lines(current, GMSH_GET, 0); double smooth_normals = opt_view_smooth_normals(current, GMSH_GET, 0); double draw_points = opt_view_draw_points(current, GMSH_GET, 0); double draw_lines = opt_view_draw_lines(current, GMSH_GET, 0); @@ -3908,6 +3914,10 @@ void view_options_ok_cb(CALLBACK_ARGS) if(force || (val != light)) opt_view_light(i, GMSH_SET, val); + val = WID->view_butt[8]->value(); + if(force || (val != light_lines)) + opt_view_light_lines(i, GMSH_SET, val); + val = WID->view_butt[9]->value(); if(force || (val != light_two_side)) opt_view_light_two_side(i, GMSH_SET, val); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 1880fe632de41e010cdb66218a48c4ff911b84c4..6c2c7d0189058f5e4c006af2ac625be4a642902e 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.467 2005-11-05 03:12:50 geuzaine Exp $ +// $Id: GUI.cpp,v 1.468 2005-11-20 03:58:28 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -2510,17 +2510,22 @@ void GUI::create_option_window() mesh_butt[17]->selection_color(GMSH_TOGGLE_COLOR); mesh_butt[17]->callback(activate_cb, (void*)"mesh_light"); - mesh_butt[18] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Use two-side lighting"); + mesh_butt[20] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines"); + mesh_butt[20]->type(FL_TOGGLE_BUTTON); + mesh_butt[20]->down_box(GMSH_TOGGLE_BOX); + mesh_butt[20]->selection_color(GMSH_TOGGLE_COLOR); + + mesh_butt[18] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting"); mesh_butt[18]->type(FL_TOGGLE_BUTTON); mesh_butt[18]->down_box(GMSH_TOGGLE_BOX); mesh_butt[18]->selection_color(GMSH_TOGGLE_COLOR); - mesh_butt[19] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Smooth normals"); + mesh_butt[19] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Smooth normals"); mesh_butt[19]->type(FL_TOGGLE_BUTTON); mesh_butt[19]->down_box(GMSH_TOGGLE_BOX); mesh_butt[19]->selection_color(GMSH_TOGGLE_COLOR); - mesh_value[18] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Smoothing threshold angle"); + mesh_value[18] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Smoothing threshold angle"); mesh_value[18]->minimum(0.); mesh_value[18]->maximum(180.); mesh_value[18]->step(1.); @@ -3109,17 +3114,22 @@ void GUI::create_option_window() view_butt[11]->selection_color(GMSH_TOGGLE_COLOR); view_butt[11]->callback(activate_cb, (void*)"view_light"); - view_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Use two-side lighting"); + view_butt[8] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 2 * BH, BW, BH, "Enable lighting of lines"); + view_butt[8]->type(FL_TOGGLE_BUTTON); + view_butt[8]->down_box(GMSH_TOGGLE_BOX); + view_butt[8]->selection_color(GMSH_TOGGLE_COLOR); + + view_butt[9] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Use two-side lighting"); view_butt[9]->type(FL_TOGGLE_BUTTON); view_butt[9]->down_box(GMSH_TOGGLE_BOX); view_butt[9]->selection_color(GMSH_TOGGLE_COLOR); - view_butt[12] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 3 * BH, BW, BH, "Smooth normals"); + view_butt[12] = new Fl_Check_Button(L + 2 * WB, 2 * WB + 4 * BH, BW, BH, "Smooth normals"); view_butt[12]->type(FL_TOGGLE_BUTTON); view_butt[12]->down_box(GMSH_TOGGLE_BOX); view_butt[12]->selection_color(GMSH_TOGGLE_COLOR); - view_value[10] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Smoothing threshold angle"); + view_value[10] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Smoothing threshold angle"); view_value[10]->minimum(0.); view_value[10]->step(1.); view_value[10]->maximum(180.); @@ -3248,6 +3258,7 @@ void GUI::update_view_window(int num) opt_view_show_element(num, GMSH_GUI, 0); opt_view_light(num, GMSH_GUI, 0); opt_view_light_two_side(num, GMSH_GUI, 0); + opt_view_light_lines(num, GMSH_GUI, 0); opt_view_smooth_normals(num, GMSH_GUI, 0); opt_view_angle_smooth_normals(num, GMSH_GUI, 0); opt_view_boundary(num, GMSH_GUI, 0); diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index 5f2577b97074c6e05997f96b7e2e2b9e2da59020..e6fda2169aec3afdb79a27094584ad829a5ba1a3 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.141 2005-10-10 16:16:50 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.142 2005-11-20 03:58:29 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -881,10 +881,14 @@ void Draw_Mesh_Array(VertexArray *va, int faces, int edges) glDisableClientState(GL_COLOR_ARRAY); glColor4ubv((GLubyte *) & CTX.color.mesh.line); } - glDisableClientState(GL_NORMAL_ARRAY); + if(CTX.mesh.light && CTX.mesh.light_lines) + glEnable(GL_LIGHTING); + else + glDisableClientState(GL_NORMAL_ARRAY); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDrawArrays((va->type == 3) ? GL_TRIANGLES : GL_QUADS, 0, va->type * va->num); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDisable(GL_LIGHTING); } } @@ -999,12 +1003,19 @@ void Draw_Mesh_Triangle(void *a, void *b) glColor4ubv((GLubyte *) & CTX.color.mesh.line); else glColor4ubv((GLubyte *) & col); + if(CTX.mesh.light && CTX.mesh.light_lines){ + // FIXME: very crude (not smooth, only 1st order) + glEnable(GL_LIGHTING); + normal3points(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], n); + glNormal3dv(n); + } glBegin(GL_LINE_LOOP); for(int i = 0; i < 3; i++){ glVertex3d(X[i], Y[i], Z[i]); if(s->VSUP) glVertex3d(X2[i], Y2[i], Z2[i]); } glEnd(); + glDisable(GL_LIGHTING); } if(CTX.mesh.surfaces_faces) { @@ -1182,12 +1193,19 @@ void Draw_Mesh_Quadrangle(void *a, void *b) glColor4ubv((GLubyte *) & CTX.color.mesh.line); else glColor4ubv((GLubyte *) & col); + if(CTX.mesh.light && CTX.mesh.light_lines){ + // FIXME: very crude (not smooth, only 1st order) + glEnable(GL_LIGHTING); + normal3points(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], n); + glNormal3dv(n); + } glBegin(GL_LINE_LOOP); for(int i = 0; i < 4; i++){ glVertex3d(X[i], Y[i], Z[i]); if(q->VSUP) glVertex3d(X2[i], Y2[i], Z2[i]); } glEnd(); + glDisable(GL_LIGHTING); } if(CTX.mesh.surfaces_faces) { diff --git a/Graphics/PostElement.cpp b/Graphics/PostElement.cpp index e5cf53da6a3296f184ff1abae1967241edeb8138..369d8e1708c8bb99beef93bc530625e4094af75a 100644 --- a/Graphics/PostElement.cpp +++ b/Graphics/PostElement.cpp @@ -1,4 +1,4 @@ -// $Id: PostElement.cpp,v 1.68 2005-11-18 23:21:56 geuzaine Exp $ +// $Id: PostElement.cpp,v 1.69 2005-11-20 03:58:29 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -35,8 +35,13 @@ extern Context_T CTX; void Draw_ElementBoundary(int type, Post_View * View, - double *X, double *Y, double *Z) + double *X, double *Y, double *Z, double *n = 0) { + if(n && View->Light && View->LightLines){ + glEnable(GL_LIGHTING); + glNormal3dv(n); + } + switch (type) { case POST_POINT: glColor4ubv((GLubyte *) & View->color.point); @@ -151,6 +156,8 @@ void Draw_ElementBoundary(int type, Post_View * View, glEnd(); break; } + + glDisable(GL_LIGHTING); } void SaturateValues(int saturate, double min, double max, @@ -382,8 +389,16 @@ void Draw_ScalarTriangle(Post_View * View, int preproNormals, normal3points(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], nn); } - if(!preproNormals && View->ShowElement) - Draw_ElementBoundary(POST_TRIANGLE, View, X, Y, Z); + if(!preproNormals && View->ShowElement){ + if(View->Light && View->LightLines){ + // FIXME: very crude (not smooth) and inefficient + double n[3]; + normal3points(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], n); + Draw_ElementBoundary(POST_TRIANGLE, View, X, Y, Z, n); + } + else + Draw_ElementBoundary(POST_TRIANGLE, View, X, Y, Z); + } if(!preproNormals && View->Normals){ double t[3] = { nn[0], nn[1], nn[2] }; @@ -692,7 +707,14 @@ void Draw_ScalarQuadrangle(Post_View * View, int preproNormals, if(!preproNormals && show) { SaturateValues(View->SaturateValues, ValMin, ValMax, vv, Val, 4); - Draw_ElementBoundary(POST_QUADRANGLE, View, X, Y, Z); + if(View->Light && View->LightLines){ + // FIXME: very crude (not smooth) and inefficient + double n[3]; + normal3points(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], n); + Draw_ElementBoundary(POST_QUADRANGLE, View, X, Y, Z, n); + } + else + Draw_ElementBoundary(POST_QUADRANGLE, View, X, Y, Z); } Draw_ScalarTriangle(View, preproNormals, ValMin, ValMax, X, Y, Z, vv); // 012 diff --git a/TODO b/TODO index 165eb9a1091149775cc5314c8685fa96ffcd29ba..73fa517463025ef5d96391972283f9a552b55007 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.107 2005-11-16 18:15:35 geuzaine Exp $ +$Id: TODO,v 1.108 2005-11-20 03:58:27 geuzaine Exp $ ******************************************************************** @@ -131,10 +131,6 @@ simple while(1) loop ******************************************************************** -add an option to enable lighting of wireframe meshes & post-pro plots. - -******************************************************************** - keep a table (stack) with the N last file positions when add_infile() is called; we could then easily implement a simple (but real) UNDO strategy diff --git a/doc/VERSIONS b/doc/VERSIONS index f93c57587c93347ad417d9810d2bb64e52138267..71af020ea1929c0d5aa1ebb02d61279f09ad2add 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,4 +1,4 @@ -$Id: VERSIONS,v 1.343 2005-10-14 20:10:44 geuzaine Exp $ +$Id: VERSIONS,v 1.344 2005-11-20 03:58:29 geuzaine Exp $ New since 1.60: added support for second order (curved) elements in post-processor; new version (1.4) of post-processing file formats; new @@ -11,12 +11,13 @@ handling of meshes with large number of physical entities; optimized vertex array creation for large post-processing views on Windows/Cygwin; removed Discrete Line and Discrete Surface commands (the same functionality can now be obtained by simply loading a mesh -in .msh format); fixed coloring by mesh partition; new "mesh -statistics" export format; new full-quad recombine option; new -Plugin(ModulusPhase); hexas and prisms are now always saved with -positive volume; improved interactive entity selection; new -experimental Tetgen integration; new experimental STL remeshing -algorithm; various small bug fixes and improvements. +in .msh format); fixed coloring by mesh partition; added option to +light wireframe meshes and views; new "mesh statistics" export format; +new full-quad recombine option; new Plugin(ModulusPhase); hexas and +prisms are now always saved with positive volume; improved interactive +entity selection; new experimental Tetgen integration; new +experimental STL remeshing algorithm; various small bug fixes and +improvements. New in 1.60: added support for discrete curves; new Window menu on Mac OS X; generalized all octree-based plugins (CutGrid, StreamLines,