From 864a124efec06a3f022b97fda9058ee61fe6270c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 22 May 2004 01:29:46 +0000 Subject: [PATCH] Small changes inspired by Wednesday's discussions: - added FL::check in redraw_opengl() (and thus removed DrawUI()): this should (?) fix the missing redraws - protected the orientation calculation with a lock - made the mode selection widget do its callback even if we don't change the selection (so that we always go back to the top-level menu) --- Fltk/GUI.cpp | 10 ++++++++-- Fltk/Opengl.cpp | 8 +------- Graphics/Draw.h | 1 - Graphics/Geom.cpp | 20 ++++++++++++-------- Mesh/2D_Mesh.cpp | 8 ++++---- Mesh/2D_Mesh_Triangle.cpp | 32 ++++++++++++++++++++++++-------- Mesh/Create.cpp | 6 +++--- Mesh/Create.h | 2 +- Parser/Gmsh.y | 6 ++---- 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 1528539b57..0f587700f0 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.304 2004-05-22 01:24:17 geuzaine Exp $ +// $Id: GUI.cpp,v 1.305 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -874,7 +874,11 @@ void GUI::create_menu_window(int argc, char **argv) m_module_butt = new Fl_Choice(19, y, width - 24, BH); m_module_butt->menu(m_module_table); m_module_butt->box(FL_THIN_DOWN_BOX); - + // force the executation of the callback even if we didn't change + // the selection (we want to go back to the top-level menu every + // time we select one of the categories, even if the category is not + // changed): + m_module_butt->when(FL_WHEN_RELEASE_ALWAYS); y = MH; for(i = 0; i < NB_BUTT_MAX; i++) { @@ -1265,7 +1269,9 @@ void GUI::make_opengl_current() void GUI::redraw_opengl() { + g_opengl_window->make_current(); g_opengl_window->redraw(); + check(); } // Create the option window diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index d9c8ab7bc3..20bda3753e 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.41 2004-05-19 07:44:51 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.42 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -66,14 +66,8 @@ void Draw(void) WID->redraw_opengl(); } -void DrawUI(void) -{ - WID->check(); -} - void Draw_String(char *s) { - if(CTX.print.gl_fonts) { gl_font(CTX.gl_font_enum, CTX.gl_fontsize); gl_draw(s); diff --git a/Graphics/Draw.h b/Graphics/Draw.h index 1bbb2b957b..80aac8ae6b 100644 --- a/Graphics/Draw.h +++ b/Graphics/Draw.h @@ -55,7 +55,6 @@ void ZeroHighlightEntityNum(int v, int c, int s); void Draw3d(void); void Draw2d(void); -void DrawUI(void); void Draw(void); void Draw_String(char *s); diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 844b991839..7f0cda03e9 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.61 2004-05-19 18:43:15 geuzaine Exp $ +// $Id: Geom.cpp,v 1.62 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -256,9 +256,9 @@ int isPointOnPlanarSurface(Surface * S, double X, double Y, double Z, } - //printf(" %d -> angle %g\n", S->Num, fabs(Angle)); + // if Angle == 2*pi, we're inside - if(fabs(Angle) > 6.0 && fabs(Angle) < 7.0) // Should be 2 * Pi or 0 + if(fabs(Angle) > 2*M_PI-0.5 && fabs(Angle) < 2*M_PI+0.5) return 1; return 0; } @@ -300,13 +300,15 @@ void Draw_Plane_Surface(Surface * s) double minx = 0., miny = 0., maxx = 0., maxy = 0., t, n[3]; Vertex P1, P2, P3, V[4], vv, vv1, vv2; char Num[100]; + const int numPoints = 100; if (s->thePolyRep) { Draw_Triangulated_Surface(s); return; } - if(List_Nbr(s->Orientations) < 1) { + if(!CTX.threads_lock && List_Nbr(s->Orientations) < 1) { + CTX.threads_lock = 1; List_T *points = List_Create(10, 10, sizeof(Vertex *)); for(i = 0; i < List_Nbr(s->Generatrices); i++) { @@ -359,8 +361,8 @@ void Draw_Plane_Surface(Surface * s) norme(n); k = 0; - for(i = 0; i < 100; i++) { - t = (double)i / (double)(100); + for(i = 0; i < numPoints; i++) { + t = (double)i / (double)(numPoints-1); vv.Pos.X = t * 0.5 * (V[0].Pos.X + V[1].Pos.X) + (1. - t) * 0.5 * (V[2].Pos.X + V[3].Pos.X); vv.Pos.Y = t * 0.5 * (V[0].Pos.Y + V[1].Pos.Y) + (1. - t) * @@ -385,8 +387,8 @@ void Draw_Plane_Surface(Surface * s) List_Add(s->Orientations, &vv); k = 0; - for(i = 0; i < 100; i++) { - t = (double)i / (double)(100); + for(i = 0; i < numPoints; i++) { + t = (double)i / (double)(numPoints-1); vv.Pos.X = t * .5 * (V[0].Pos.X + V[3].Pos.X) + (1. - t) * .5 * (V[2].Pos.X + V[1].Pos.X); vv.Pos.Y = t * .5 * (V[0].Pos.Y + V[3].Pos.Y) + @@ -413,6 +415,8 @@ void Draw_Plane_Surface(Surface * s) if(!List_Nbr(s->Orientations)) // add dummy List_Add(s->Orientations, &vv); + + CTX.threads_lock = 0; } if(List_Nbr(s->Orientations) > 1) { diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp index 3d67ffbbd1..180ccc867f 100644 --- a/Mesh/2D_Mesh.cpp +++ b/Mesh/2D_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: 2D_Mesh.cpp,v 1.55 2004-05-07 18:42:48 geuzaine Exp $ +// $Id: 2D_Mesh.cpp,v 1.56 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -833,7 +833,7 @@ void Maillage_Surface(void *data, void *dum) Tree_Action(s->Vertices, Projette_Plan_Moyen); Tree_Action(THEM->Curves, ActionEndTheCurve); s->Typ = MSH_SURF_PLAN; - End_Surface(s); + End_Surface(s, 0); ori = Calcule_Contours(s); @@ -880,8 +880,8 @@ void Maillage_Surface(void *data, void *dum) Tree_Action(s->Vertices, Add_In_Mesh); Tree_Action(THEM->Curves, ActionEndTheCurve); - End_Surface(s->Support); - End_Surface(s); + End_Surface(s->Support, 0); + End_Surface(s, 0); THEM->Statistics[5] += Tree_Nbr(THESURFACE->Vertices); THEM->Statistics[7] += Tree_Nbr(THESURFACE->Simplexes); // tri+qua diff --git a/Mesh/2D_Mesh_Triangle.cpp b/Mesh/2D_Mesh_Triangle.cpp index bc54935716..76616dd70a 100644 --- a/Mesh/2D_Mesh_Triangle.cpp +++ b/Mesh/2D_Mesh_Triangle.cpp @@ -1,4 +1,4 @@ -// $Id: 2D_Mesh_Triangle.cpp,v 1.8 2004-05-22 01:24:17 geuzaine Exp $ +// $Id: 2D_Mesh_Triangle.cpp,v 1.9 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -200,17 +200,33 @@ int Mesh_Shewchuk(Surface * s) return 0; } - // generalize this if we have a bgmesh! mid.trianglearealist = (REAL *) Malloc(mid.numberoftriangles * sizeof(REAL)); for(i = 0; i < mid.numberoftriangles; i++) { - val = 0; - for(j = 0; j < mid.numberofcorners; j++) { - k = mid.trianglelist[i * mid.numberofcorners + j]; - val += mid.pointattributelist[k]; + //if(THEM->BGM.Typ == ONFILE) { + if(0) { + double xx = 0.0, yy = 0.0; + for(j = 0; j < mid.numberofcorners; j++) { + k = mid.trianglelist[i * mid.numberofcorners + j]; + xx += mid.pointlist[2 * k]; + yy += mid.pointlist[2 * k + 1]; + } + xx /= mid.numberofcorners; + yy /= mid.numberofcorners; + // project the point in real space; this is a mess, since we + // actually change the parameters of the surface in 2d_Mesh.cpp + // x =, y = , z = ; + //val = Lc_XYZ(x, y, z, THEM); + } + else { + val = 0; + for(j = 0; j < mid.numberofcorners; j++) { + k = mid.trianglelist[i * mid.numberofcorners + j]; + val += mid.pointattributelist[k]; + } + val /= mid.numberofcorners; + val = val * val / 1.5; // approx (we want isotropic meshes) } - val /= mid.numberofcorners; - val = val * val / 1.5; // approx (we want isotropic meshes) mid.trianglearealist[i] = val; } diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp index db6316f08a..f5504391f2 100644 --- a/Mesh/Create.cpp +++ b/Mesh/Create.cpp @@ -1,4 +1,4 @@ -// $Id: Create.cpp,v 1.53 2004-05-22 01:24:18 geuzaine Exp $ +// $Id: Create.cpp,v 1.54 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -507,12 +507,12 @@ void End_Curve(Curve * c) } -void End_Surface(Surface * s) +void End_Surface(Surface * s, int reset_orientations) { int i; Vertex *v; - if(s->Orientations) + if(reset_orientations) List_Reset(s->Orientations); if(!s->Control_Points || !List_Nbr(s->Control_Points)) diff --git a/Mesh/Create.h b/Mesh/Create.h index 885f900afc..f0f95c7167 100644 --- a/Mesh/Create.h +++ b/Mesh/Create.h @@ -69,7 +69,7 @@ void Free_EdgeLoop(void *a, void *b); void Free_SurfaceLoop(void *a, void *b); void End_Curve(Curve * c); -void End_Surface(Surface * s); +void End_Surface(Surface * s, int reset_orientations=1); int Add_MeshPartition(int Num, Mesh * M); diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index f4d5996adf..c4a80d76dc 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1,5 +1,5 @@ %{ -// $Id: Gmsh.y,v 1.165 2004-05-14 18:23:58 geuzaine Exp $ +// $Id: Gmsh.y,v 1.166 2004-05-22 01:29:46 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -2415,10 +2415,8 @@ Command : | tDraw tEND { #if defined(HAVE_FLTK) - if(!CTX.batch){ // we're in interactive mode + if(!CTX.batch) // we're in interactive mode Draw(); - DrawUI(); - } #endif } ; -- GitLab