diff --git a/Common/Context.h b/Common/Context.h index f5182934e4c6dc855b9f1d4368ed1dea6d57f441..1be0f9e5b1b439a4977d283fdd42439cf0d50efa 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -132,6 +132,7 @@ public : int render_mode; // GMSH_RENDER, GMSH_SELECT, GMSH_FEEDBACK int clip[6]; // status of clip planes (bit arrays) double clip_plane[6][4]; // clip planes + double polygon_offset_factor, polygon_offset_units; // params for glPolygonOffset double pixel_equiv_x, pixel_equiv_y ; // approximative equivalent model length of a pixel int color_scheme ; // general color scheme diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 46ec58a7269f39c50d1f91d3e5d442c66cd0ab8d..65bed6af2e1fba80f9d743a5ad5c2060aca966bd 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -594,6 +594,10 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "PointSize" , opt_general_point_size , 3. , "Display size of points (in pixels)" }, + { F|O, "PolygonOffsetFactor" , opt_general_polygon_offset_factor , 1. , + "Polygon offset factor (offset = factor * DZ + r * units)" }, + { F|O, "PolygonOffsetUnits" , opt_general_polygon_offset_units , 1. , + "Polygon offset units (offset = factor * DZ + r * units)" }, { F|O, "QuadricSubdivisions" , opt_general_quadric_subdivisions, 8. , "Number of subdivisions used to draw points or lines as spheres or cylinders" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 9ef0d668835ca53a6d5cca61596236c92b88416b..7fb46e30e400c54ec6e11777e9177ee8e823f459 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.220 2004-12-30 22:43:21 geuzaine Exp $ +// $Id: Options.cpp,v 1.221 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1954,6 +1954,28 @@ double opt_general_viewport3(OPT_ARGS_NUM) return CTX.viewport[3]; } +double opt_general_polygon_offset_factor(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.polygon_offset_factor = val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->gen_value[15]->value(CTX.polygon_offset_factor); +#endif + return CTX.polygon_offset_factor; +} + +double opt_general_polygon_offset_units(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.polygon_offset_units = val; +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->gen_value[16]->value(CTX.polygon_offset_units); +#endif + return CTX.polygon_offset_units; +} + double opt_general_graphics_position0(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 17f2c3b5075fd113fe7d5d1d2220f226361316ea..13b430a93b5543245369c62f235be11f9b6749b1 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -216,6 +216,8 @@ double opt_general_file_chooser_position0(OPT_ARGS_NUM); double opt_general_file_chooser_position1(OPT_ARGS_NUM); double opt_general_viewport2(OPT_ARGS_NUM); double opt_general_viewport3(OPT_ARGS_NUM); +double opt_general_polygon_offset_factor(OPT_ARGS_NUM); +double opt_general_polygon_offset_units(OPT_ARGS_NUM); double opt_general_menu_position0(OPT_ARGS_NUM); double opt_general_menu_position1(OPT_ARGS_NUM); double opt_general_system_menu_bar(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 2942726149d3525aa3c25561ca3864ee0d851606..576114c6f0d0341ec91669f0c18d73b25d3c0fe0 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.322 2004-12-31 17:50:34 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.323 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -667,6 +667,8 @@ void general_options_ok_cb(CALLBACK_ARGS) opt_general_quadric_subdivisions(0, GMSH_SET, WID->gen_value[11]->value()); opt_general_graphics_fontsize(0, GMSH_SET, WID->gen_value[12]->value()); opt_general_clip_factor(0, GMSH_SET, WID->gen_value[14]->value()); + opt_general_polygon_offset_factor(0, GMSH_SET, WID->gen_value[15]->value()); + opt_general_polygon_offset_units(0, GMSH_SET, WID->gen_value[16]->value()); opt_general_default_filename(0, GMSH_SET, (char *)WID->gen_input[0]->value()); opt_general_editor(0, GMSH_SET, (char *)WID->gen_input[1]->value()); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 04c2a95b1bbe9755b827ac661e43bba243824ff8..180d5cd92eb9b7f3321e2e0786c34fade81a99a1 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.405 2004-12-31 16:19:20 geuzaine Exp $ +// $Id: GUI.cpp,v 1.406 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1743,19 +1743,31 @@ void GUI::create_option_window() gen_value[14]->step(0.1); gen_value[14]->align(FL_ALIGN_RIGHT); - gen_value[11] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW, BH, "Number of quadric subdivisions"); + gen_value[15] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 3 * BH, IW/2, BH); + gen_value[15]->minimum(0.); + gen_value[15]->maximum(10.); + gen_value[15]->step(0.01); + gen_value[15]->align(FL_ALIGN_RIGHT); + + gen_value[16] = new Fl_Value_Input(L + 2 * WB + IW/2, 2 * WB + 3 * BH, IW/2, BH, "Polygon offset factor and units"); + gen_value[16]->minimum(0.); + gen_value[16]->maximum(10.); + gen_value[16]->step(0.01); + gen_value[16]->align(FL_ALIGN_RIGHT); + + gen_value[11] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Number of quadric subdivisions"); gen_value[11]->minimum(3); gen_value[11]->maximum(30); gen_value[11]->step(1); gen_value[11]->align(FL_ALIGN_RIGHT); - gen_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 4 * BH, IW, BH, "Point size"); + gen_value[6] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Point size"); gen_value[6]->minimum(0.1); gen_value[6]->maximum(50); gen_value[6]->step(0.1); gen_value[6]->align(FL_ALIGN_RIGHT); - gen_value[7] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width"); + gen_value[7] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Line width"); gen_value[7]->minimum(0.1); gen_value[7]->maximum(50); gen_value[7]->step(0.1); @@ -1768,18 +1780,18 @@ void GUI::create_option_window() {"3D arrow", 0, 0, 0}, {0} }; - gen_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 6 * BH, IW, BH, "Vector display"); + gen_choice[0] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Vector display"); gen_choice[0]->menu(menu_genvectype); gen_choice[0]->align(FL_ALIGN_RIGHT); - Fl_Button *b = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 6 * BH, (int)(1.5*BB), BH, "Edit arrow shape"); + Fl_Button *b = new Fl_Button(L + 2 * IW - 2 * WB, 2 * WB + 7 * BH, (int)(1.5*BB), BH, "Edit arrow shape"); b->callback(general_arrow_param_cb); - gen_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 7 * BH, IW, BH, "Font"); + gen_choice[1] = new Fl_Choice(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Font"); gen_choice[1]->menu(menu_font_names); gen_choice[1]->align(FL_ALIGN_RIGHT); - gen_value[12] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW, BH, "Font size"); + gen_value[12] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Font size"); gen_value[12]->minimum(5); gen_value[12]->maximum(40); gen_value[12]->step(1); diff --git a/Graphics/CreateFile.cpp b/Graphics/CreateFile.cpp index 7c8bf33f9734636ace44f7e1ca2a935be46a64de..f7af8a7915832a21074bb44164ebf5ed35a89cfc 100644 --- a/Graphics/CreateFile.cpp +++ b/Graphics/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.63 2004-12-31 17:50:34 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.64 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -105,7 +105,7 @@ void CreateOutputFile(char *name, int format) break; case FORMAT_OPT: - Print_Options(0, GMSH_FULLRC, false, name); + Print_Options(0, GMSH_FULLRC, true, name); break; case FORMAT_MSH: diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp index 8e174a67592cafbaa02fe86f5a5774fce7567364..44a4ed553f36051f04db74219ab57ae585e486ca 100644 --- a/Graphics/Draw.cpp +++ b/Graphics/Draw.cpp @@ -1,4 +1,4 @@ -// $Id: Draw.cpp,v 1.69 2004-12-29 22:30:09 geuzaine Exp $ +// $Id: Draw.cpp,v 1.70 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -36,7 +36,12 @@ extern Mesh M; void Draw3d(void) { - glPolygonOffset(1.0, 1.0); + // offset = factor*DZ+r*units, where DZ is a measurement of the + // change in depth relative to the screen area of the polygon, and r + // is the smallest value that is guaranteed to produce a resolvable + // offset for a given implementation: + glPolygonOffset(CTX.polygon_offset_factor, CTX.polygon_offset_units); + glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 404f35d48847f75058aaa2aad798ff77a2f99b2d..f220852536cf786e2801c845a522df1f930d0d3c 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.76 2004-12-21 04:51:37 geuzaine Exp $ +// $Id: Geom.cpp,v 1.77 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -324,8 +324,10 @@ void Draw_Triangulated_Surface(Surface * s) double *points, *p1, *p2, *p3; if(CTX.geom.surfaces) { - if(CTX.geom.light) glEnable(GL_LIGHTING); - glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.geom.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_TRIANGLES); while (k < List_Nbr(s->thePolyRep->polygons)){ points = (double*)List_Pointer(s->thePolyRep->polygons,k); @@ -512,8 +514,10 @@ void Draw_NonPlane_Surface(Surface * s) { if(CTX.geom.surfaces) { if(s->Typ == MSH_SURF_NURBS) { - if(CTX.geom.light) glEnable(GL_LIGHTING); - glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.geom.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); GLUnurbsObj *nurb; nurb = gluNewNurbsRenderer(); #if defined(GLU_VERSION_1_3) diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index b700803ba2caa5e989b5e5de78ca8ad57f37a5e4..168ef035c0c07d683ecaaedf8c5985ca1bf767df 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.115 2004-12-28 17:24:25 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.116 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -703,12 +703,12 @@ void Draw_Mesh_Array(VertexArray *va, int faces, int edges) glEnableClientState(GL_NORMAL_ARRAY); if(faces){ - if(edges) - glEnable(GL_POLYGON_OFFSET_FILL); if(CTX.mesh.light) glEnable(GL_LIGHTING); else glDisableClientState(GL_NORMAL_ARRAY); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glDrawArrays((va->type == 3) ? GL_TRIANGLES : GL_QUADS, 0, va->type * va->num); glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_LIGHTING); @@ -835,8 +835,10 @@ void Draw_Mesh_Triangle(void *a, void *b) if(CTX.mesh.surfaces_faces) { glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!s->VSUP) { glBegin(GL_TRIANGLES); _triFace(X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2]); @@ -997,8 +999,10 @@ void Draw_Mesh_Quadrangle(void *a, void *b) if(CTX.mesh.surfaces_faces) { glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!q->VSUP) { glBegin(GL_QUADS); _quadFace(X, Y, Z, 0, 1, 2, 3); @@ -1169,8 +1173,10 @@ void Draw_Mesh_Tetrahedron(void *a, void *b) if(faces){ glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges || edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!s->VSUP){ glBegin(GL_TRIANGLES); _triFace(X[0], Y[0], Z[0], X[2], Y[2], Z[2], X[1], Y[1], Z[1]); @@ -1340,8 +1346,10 @@ void Draw_Mesh_Hexahedron(void *a, void *b) if(faces){ glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges || edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!h->VSUP){ glBegin(GL_QUADS); _quadFace(X, Y, Z, 0, 3, 2, 1); @@ -1539,8 +1547,10 @@ void Draw_Mesh_Prism(void *a, void *b) if(faces){ glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges || edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!p->VSUP){ glBegin(GL_TRIANGLES); _triFace(X[0], Y[0], Z[0], X[2], Y[2], Z[2], X[1], Y[1], Z[1]); @@ -1733,8 +1743,10 @@ void Draw_Mesh_Pyramid(void *a, void *b) if(faces){ glColor4ubv((GLubyte *) & col); - if(CTX.mesh.light) glEnable(GL_LIGHTING); - if(CTX.mesh.surfaces_edges || edges) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.mesh.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); if(!p->VSUP){ glBegin(GL_QUADS); _quadFace(X, Y, Z, 0, 3, 2, 1); diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp index 8d7594652e6900e8091c82d4e8b65500221a92ff..d3343f64a41dd092a29bcec08585dc9525761e73 100644 --- a/Graphics/Post.cpp +++ b/Graphics/Post.cpp @@ -1,4 +1,4 @@ -// $Id: Post.cpp,v 1.88 2004-12-28 20:37:19 geuzaine Exp $ +// $Id: Post.cpp,v 1.89 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -717,7 +717,8 @@ void Draw_Post(void) glEnable(GL_LIGHTING); else glDisableClientState(GL_NORMAL_ARRAY); - if(v->ShowElement) glEnable(GL_POLYGON_OFFSET_FILL); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glDrawArrays(GL_TRIANGLES, 0, 3 * v->TriVertexArray->num); glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_LIGHTING); diff --git a/Graphics/PostElement.cpp b/Graphics/PostElement.cpp index abfc5c19de0146b3a517745278f5ff5b7293e3f8..976e45d2e2996b5e9d603fa6a17c0ab8a6b582c0 100644 --- a/Graphics/PostElement.cpp +++ b/Graphics/PostElement.cpp @@ -1,4 +1,4 @@ -// $Id: PostElement.cpp,v 1.57 2004-12-24 23:10:27 geuzaine Exp $ +// $Id: PostElement.cpp,v 1.58 2004-12-31 21:12:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -440,8 +440,10 @@ void Draw_ScalarTriangle(Post_View * View, int preproNormals, View->TriVertexArray->num++; } else{ - if(View->Light) glEnable(GL_LIGHTING); - if(View->ShowElement) glEnable(GL_POLYGON_OFFSET_FILL); + if(View->Light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_TRIANGLES); for(int i = 0; i < 3; i++){ PaletteContinuous(View, ValMin, ValMax, Val[i]); @@ -487,8 +489,10 @@ void Draw_ScalarTriangle(Post_View * View, int preproNormals, } } else{ - if(View->Light) glEnable(GL_LIGHTING); - if(View->ShowElement) glEnable(GL_POLYGON_OFFSET_FILL); + if(View->Light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_POLYGON); for(int i = 0; i < nb; i++) { PaletteContinuous(View, ValMin, ValMax, Vp[i]); @@ -542,8 +546,10 @@ void Draw_ScalarTriangle(Post_View * View, int preproNormals, } } else{ - if(View->Light) glEnable(GL_LIGHTING); - if(View->ShowElement) glEnable(GL_POLYGON_OFFSET_FILL); + if(View->Light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glBegin(GL_POLYGON); for(int i = 0; i < nb; i++){ if(View->Light) glNormal3dv(&norms[3*i]); diff --git a/Plugin/StructuralSolver.cpp b/Plugin/StructuralSolver.cpp index 92b976139b77fe41ad6b6bb848e997a0bcfb336c..b34af7355f4c187cc319110880dd205dbbd3ca38 100644 --- a/Plugin/StructuralSolver.cpp +++ b/Plugin/StructuralSolver.cpp @@ -184,8 +184,10 @@ void Structural_BeamSection :: GL_DrawBeam (double pinit[3], double dir[3], con List_T *surfaces = Tree2List (m.Surfaces); List_T *curves = Tree2List (m.Curves); List_T *points = Tree2List (m.Points); - glEnable(GL_POLYGON_OFFSET_FILL); - if(CTX.geom.light) glEnable(GL_LIGHTING); + if(CTX.geom.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable( GL_TEXTURE_2D ); @@ -773,10 +775,11 @@ void Draw_Kinematic_Constraint ( const int type [3], return; } - if(CTX.geom.light) glEnable(GL_LIGHTING); + if(CTX.geom.light) + glEnable(GL_LIGHTING); + if(CTX.polygon_offset_factor || CTX.polygon_offset_units) + glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glEnable(GL_POLYGON_OFFSET_FILL); glColor3f (0.8,0.8,0.8); glBegin(GL_QUADS);