diff --git a/Common/Context.h b/Common/Context.h index 24a67fcfa1cfd46a2c9f8f29020c39d5098f1f2e..a7e147faaa46c8d5402b449adefbaa077596ba7b 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -164,6 +164,7 @@ public : int points_num, lines_num, surfaces_num, volumes_num; int point_type, line_type; // flat or 3D double point_size, line_width; + int points_per_element; int optimize; double quality; double gamma_inf, gamma_sup, radius_inf, radius_sup; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 503937d1a8e93713200d014521be5f8f58c58274..61f7ffe3f77697437cc6afb6a5c3cdf3453c320d 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -811,6 +811,8 @@ StringXNumber MeshOptions_Number[] = { { F|O, "Points" , opt_mesh_points , 1. , "Display mesh vertices (nodes)?" }, + { F|O, "PointsPerElement" , opt_mesh_points_per_element , 0. , + "Display mesh nodes per element (slower, but permits to visualize only a subset of the nodes)" }, { F|O, "PointInsertion" , opt_mesh_point_insertion, CENTER_CIRCCIRC , "Point insertion method for isotropic 2D algorithm (1=center of circumscribed circle, 2=cog)" }, { F|O, "PointNumbers" , opt_mesh_points_num , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 78710b201d34f874f3c13de77374ed1015901ca1..594ebc10c1950c2c3924dda632078cd9a95fc712 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.187 2004-10-11 17:22:56 geuzaine Exp $ +// $Id: Options.cpp,v 1.188 2004-10-14 22:56:39 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -3575,6 +3575,18 @@ double opt_mesh_volumes_num(OPT_ARGS_NUM) return CTX.mesh.volumes_num; } +double opt_mesh_points_per_element(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) { + CTX.mesh.points_per_element = (int)val; + } +#if defined(HAVE_FLTK) + if(WID && (action & GMSH_GUI)) + WID->mesh_butt[0]->value(CTX.mesh.points_per_element); +#endif + return CTX.mesh.points_per_element; +} + double opt_mesh_point_size(OPT_ARGS_NUM) { if(action & GMSH_SET) { diff --git a/Common/Options.h b/Common/Options.h index b2ae315f05c40a9e2ed97fac68b5366e0d27f0b7..a9af15751285e8492ea23c5322b0a59ac9541851 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -332,6 +332,7 @@ double opt_geometry_points_num(OPT_ARGS_NUM); double opt_geometry_lines_num(OPT_ARGS_NUM); double opt_geometry_surfaces_num(OPT_ARGS_NUM); double opt_geometry_volumes_num(OPT_ARGS_NUM); +double opt_mesh_points_per_element(OPT_ARGS_NUM); double opt_geometry_point_size(OPT_ARGS_NUM); double opt_geometry_point_sel_size(OPT_ARGS_NUM); double opt_geometry_point_type(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index f734c4a9142311543a6d1b8464f986ba719d1e47..dc7bca7c535c2f2654680c050c096c47bf6ece5b 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.280 2004-10-11 17:22:57 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.281 2004-10-14 22:56:39 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -960,6 +960,7 @@ void mesh_options_cb(CALLBACK_ARGS) void mesh_options_ok_cb(CALLBACK_ARGS) { + opt_mesh_points_per_element(0, GMSH_SET, WID->mesh_butt[0]->value()); opt_mesh_optimize(0, GMSH_SET, WID->mesh_butt[2]->value()); opt_mesh_order(0, GMSH_SET, WID->mesh_butt[3]->value()? 2 : 1); opt_mesh_interactive(0, GMSH_SET, WID->mesh_butt[4]->value()); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index d8bf4982b795f4444ea0bfd1b28a72f8c80ecb90..8a375663af327d5ee8b6355ae746e21c7a41f591 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.359 2004-10-11 19:27:51 geuzaine Exp $ +// $Id: GUI.cpp,v 1.360 2004-10-14 22:56:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -2141,22 +2141,27 @@ void GUI::create_option_window() mesh_value[9]->step(0.01); mesh_value[9]->align(FL_ALIGN_RIGHT); - mesh_choice[0] = new Fl_Choice(2 * WB, 2 * WB + 2 * BH, IW, BH, "Point display"); + mesh_butt[0] = new Fl_Check_Button(2 * WB, 2 * WB + 2 * BH, BW, BH, "Draw nodes per element"); + mesh_butt[0]->type(FL_TOGGLE_BUTTON); + mesh_butt[0]->down_box(TOGGLE_BOX); + mesh_butt[0]->selection_color(TOGGLE_COLOR); + + mesh_choice[0] = new Fl_Choice(2 * WB, 2 * WB + 3 * BH, IW, BH, "Point display"); mesh_choice[0]->menu(menu_point_display); mesh_choice[0]->align(FL_ALIGN_RIGHT); - mesh_value[10] = new Fl_Value_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Point size"); + mesh_value[10] = new Fl_Value_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Point size"); mesh_value[10]->minimum(0.1); mesh_value[10]->maximum(50); mesh_value[10]->step(0.1); mesh_value[10]->align(FL_ALIGN_RIGHT); - mesh_choice[1] = new Fl_Choice(2 * WB, 2 * WB + 4 * BH, IW, BH, "Line display"); + mesh_choice[1] = new Fl_Choice(2 * WB, 2 * WB + 5 * BH, IW, BH, "Line display"); mesh_choice[1]->menu(menu_line_display); mesh_choice[1]->align(FL_ALIGN_RIGHT); mesh_choice[1]->deactivate(); // don't give false hopes, as it's not used anywhere right now - mesh_value[11] = new Fl_Value_Input(2 * WB, 2 * WB + 5 * BH, IW, BH, "Line width"); + mesh_value[11] = new Fl_Value_Input(2 * WB, 2 * WB + 6 * BH, IW, BH, "Line width"); mesh_value[11]->minimum(0.1); mesh_value[11]->maximum(50); mesh_value[11]->step(0.1); diff --git a/Graphics/Mesh.cpp b/Graphics/Mesh.cpp index 602f9d28bb4c12aa83bc33d21ca7cec678c70cb6..e2a73f6303f816887a7d9ed7863170df4b2cc4b6 100644 --- a/Graphics/Mesh.cpp +++ b/Graphics/Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Mesh.cpp,v 1.108 2004-08-13 21:23:23 geuzaine Exp $ +// $Id: Mesh.cpp,v 1.109 2004-10-14 22:56:40 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -215,25 +215,27 @@ void Draw_Mesh(Mesh * M) glDisable((GLenum)(GL_CLIP_PLANE0 + i)); if(M->status >= 3 && (CTX.mesh.volumes_faces || CTX.mesh.volumes_edges || - CTX.mesh.volumes_num || + CTX.mesh.volumes_num || CTX.mesh.points_per_element || (CTX.mesh.use_cut_plane && CTX.mesh.cut_plane_as_surface && (CTX.mesh.surfaces_edges || CTX.mesh.surfaces_faces)))) { Tree_Action(M->Volumes, Draw_Mesh_Volume); } if(M->status >= 2 && (CTX.mesh.surfaces_faces || CTX.mesh.surfaces_edges || - CTX.mesh.surfaces_num || CTX.mesh.normals)) { + CTX.mesh.surfaces_num || CTX.mesh.points_per_element || + CTX.mesh.normals)) { Tree_Action(M->Surfaces, Draw_Mesh_Surface); if(CTX.mesh.oldxtrude) //old extrusion algo Tree_Action(M->Volumes, Draw_Mesh_Extruded_Surfaces); } if(M->status >= 1 && (CTX.mesh.lines || CTX.mesh.lines_num || - CTX.mesh.tangents)) { + CTX.mesh.points_per_element || CTX.mesh.tangents)) { Tree_Action(M->Curves, Draw_Mesh_Curve); } - if(M->status >= 0 && (CTX.mesh.points || CTX.mesh.points_num)) { + if(M->status >= 0 && !CTX.mesh.points_per_element && + (CTX.mesh.points || CTX.mesh.points_num)) { Tree_Action(M->Vertices, Draw_Mesh_Point); } CTX.mesh.changed = 0; @@ -301,7 +303,8 @@ void Draw_Mesh_Volume(void *a, void *b) if(!CTX.mesh.use_cut_plane || !CTX.mesh.cut_plane_as_surface || !v->TriVertexArray || !v->QuadVertexArray || CTX.mesh.volumes_faces || CTX.mesh.volumes_edges || - CTX.mesh.dual || CTX.mesh.volumes_num || CTX.mesh.normals){ + CTX.mesh.dual || CTX.mesh.volumes_num || CTX.mesh.points_per_element || + CTX.mesh.normals){ Msg(DEBUG, "classic volume data path"); Tree_Action(v->Simplexes, Draw_Mesh_Tetrahedron); Tree_Action(v->Hexahedra, Draw_Mesh_Hexahedron); @@ -362,12 +365,14 @@ void Draw_Mesh_Surface(void *a, void *b) CTX.mesh.surfaces_faces, CTX.mesh.surfaces_edges); } - if(!s->TriVertexArray || CTX.mesh.dual || CTX.mesh.surfaces_num || CTX.mesh.normals){ + if(!s->TriVertexArray || CTX.mesh.dual || CTX.mesh.surfaces_num || + CTX.mesh.points_per_element || CTX.mesh.normals){ Msg(DEBUG, "classic triangle data path"); Tree_Action(s->Simplexes, Draw_Mesh_Triangle); } - if(!s->QuadVertexArray || CTX.mesh.dual || CTX.mesh.surfaces_num || CTX.mesh.normals){ + if(!s->QuadVertexArray || CTX.mesh.dual || CTX.mesh.surfaces_num || + CTX.mesh.points_per_element || CTX.mesh.normals){ Msg(DEBUG, "classic quadrangle data path"); Tree_Action(s->Quadrangles, Draw_Mesh_Quadrangle); } @@ -394,49 +399,52 @@ void Draw_Mesh_Curve(void *a, void *b) return; theColor = c->Color; thePhysical = getFirstPhysical(MSH_PHYSICAL_LINE, c->Num); + Tree_Action(c->Simplexes, Draw_Mesh_Line); } -void Draw_Mesh_Point(void *a, void *b) +void Draw_Mesh_Point(int num, double x, double y, double z, int degree, int visible) { - Vertex *v; - char Num[100]; - - v = *(Vertex **) a; - - if(!(v->Visible & VIS_MESH)) + if(!(visible & VIS_MESH)) return; - if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(1, &v) < 0) - return; - - if(v->Degree == 2) + if(degree == 2) glColor4ubv((GLubyte *) & CTX.color.mesh.vertex_deg2); else glColor4ubv((GLubyte *) & CTX.color.mesh.vertex); if(CTX.mesh.points) { if(CTX.mesh.point_type) { - Draw_Sphere(CTX.mesh.point_size, v->Pos.X, v->Pos.Y, v->Pos.Z, - CTX.mesh.light); + Draw_Sphere(CTX.mesh.point_size, x, y, z, CTX.mesh.light); } else { glBegin(GL_POINTS); - glVertex3d(v->Pos.X, v->Pos.Y, v->Pos.Z); + glVertex3d(x, y, z); glEnd(); } } if(CTX.mesh.points_num) { - sprintf(Num, "%d", v->Num); + char Num[100]; + sprintf(Num, "%d", num); double offset = 0.5 * (CTX.mesh.point_size + CTX.gl_fontsize) * CTX.pixel_equiv_x; - glRasterPos3d(v->Pos.X + offset / CTX.s[0], - v->Pos.Y + offset / CTX.s[1], - v->Pos.Z + offset / CTX.s[2]); + glRasterPos3d(x + offset / CTX.s[0], + y + offset / CTX.s[1], + z + offset / CTX.s[2]); Draw_String(Num); } } +void Draw_Mesh_Point(void *a, void *b) +{ + Vertex *v = *(Vertex **) a; + + if(!CTX.mesh.cut_plane_only_volume && intersectCutPlane(1, &v) < 0) + return; + + Draw_Mesh_Point(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->Degree, v->Visible); +} + void Draw_Mesh_Line(void *a, void *b) { Simplex *s; @@ -466,6 +474,9 @@ void Draw_Mesh_Line(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->V[i]->Num, X[i], Y[i], Z[i], + s->V[i]->Degree, s->V[i]->Visible); } if(N == 3){ @@ -475,6 +486,9 @@ void Draw_Mesh_Line(void *a, void *b) X[1] = Xc + CTX.mesh.explode * (s->VSUP[0]->Pos.X - Xc); Y[1] = Yc + CTX.mesh.explode * (s->VSUP[0]->Pos.Y - Yc); Z[1] = Zc + CTX.mesh.explode * (s->VSUP[0]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->VSUP[0]->Num, X[1], Y[1], Z[1], + s->VSUP[0]->Degree, s->VSUP[0]->Visible); } if(theColor.type) @@ -739,7 +753,11 @@ void Draw_Mesh_Triangle(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->V[i]->Num, X[i], Y[i], Z[i], + s->V[i]->Degree, s->V[i]->Visible); } + if(s->VSUP){ if(theSurface && theSurface->TriVertexArray){ // vertex arrays not implemented for second order elements @@ -750,6 +768,9 @@ void Draw_Mesh_Triangle(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (s->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (s->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (s->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + s->VSUP[i]->Degree, s->VSUP[i]->Visible); } } @@ -888,7 +909,11 @@ void Draw_Mesh_Quadrangle(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (q->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (q->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (q->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(q->V[i]->Num, X[i], Y[i], Z[i], + q->V[i]->Degree, q->V[i]->Visible); } + if(q->VSUP){ if(theSurface && theSurface->QuadVertexArray){ // vertex arrays not implemented for second order elements @@ -899,6 +924,9 @@ void Draw_Mesh_Quadrangle(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (q->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (q->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (q->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(q->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + q->VSUP[i]->Degree, q->VSUP[i]->Visible); } } @@ -1051,7 +1079,11 @@ void Draw_Mesh_Tetrahedron(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (s->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (s->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (s->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->V[i]->Num, X[i], Y[i], Z[i], + s->V[i]->Degree, s->V[i]->Visible); } + if(s->VSUP){ if(theVolume && theVolume->TriVertexArray){ // vertex arrays not implemented for second order elements @@ -1062,6 +1094,9 @@ void Draw_Mesh_Tetrahedron(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (s->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (s->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (s->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(s->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + s->VSUP[i]->Degree, s->VSUP[i]->Visible); } } @@ -1207,7 +1242,11 @@ void Draw_Mesh_Hexahedron(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (h->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (h->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (h->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(h->V[i]->Num, X[i], Y[i], Z[i], + h->V[i]->Degree, h->V[i]->Visible); } + if(h->VSUP){ if(theVolume && theVolume->QuadVertexArray){ // vertex arrays not implemented for second order elements @@ -1218,6 +1257,9 @@ void Draw_Mesh_Hexahedron(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (h->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (h->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (h->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(h->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + h->VSUP[i]->Degree, h->VSUP[i]->Visible); } } @@ -1375,7 +1417,11 @@ void Draw_Mesh_Prism(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (p->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (p->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (p->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(p->V[i]->Num, X[i], Y[i], Z[i], + p->V[i]->Degree, p->V[i]->Visible); } + if(p->VSUP){ if(theVolume && theVolume->TriVertexArray){ // vertex arrays not implemented for second order elements @@ -1391,6 +1437,9 @@ void Draw_Mesh_Prism(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (p->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (p->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (p->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(p->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + p->VSUP[i]->Degree, p->VSUP[i]->Visible); } } @@ -1558,7 +1607,11 @@ void Draw_Mesh_Pyramid(void *a, void *b) X[i] = Xc + CTX.mesh.explode * (p->V[i]->Pos.X - Xc); Y[i] = Yc + CTX.mesh.explode * (p->V[i]->Pos.Y - Yc); Z[i] = Zc + CTX.mesh.explode * (p->V[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(p->V[i]->Num, X[i], Y[i], Z[i], + p->V[i]->Degree, p->V[i]->Visible); } + if(p->VSUP){ if(theVolume && theVolume->TriVertexArray){ // vertex arrays not implemented for second order elements @@ -1574,6 +1627,9 @@ void Draw_Mesh_Pyramid(void *a, void *b) X2[i] = Xc + CTX.mesh.explode * (p->VSUP[i]->Pos.X - Xc); Y2[i] = Yc + CTX.mesh.explode * (p->VSUP[i]->Pos.Y - Yc); Z2[i] = Zc + CTX.mesh.explode * (p->VSUP[i]->Pos.Z - Zc); + if(CTX.mesh.points_per_element) + Draw_Mesh_Point(p->VSUP[i]->Num, X2[i], Y2[i], Z2[i], + p->VSUP[i]->Degree, p->VSUP[i]->Visible); } }