From 9d75214daa73cb6b6dd1e86f993064ed02a2ed7d Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 18 May 2004 17:44:55 +0000 Subject: [PATCH] - fixed race condition in surface drawing - plugged s->Orientations memory leak - improved "select hole" message --- Fltk/Callbacks.cpp | 4 ++-- Fltk/GUI.cpp | 3 +-- Graphics/Geom.cpp | 35 ++++++++++++++--------------------- Mesh/Create.cpp | 3 ++- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index e8c3101682..cbb158df5a 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.233 2004-05-18 17:00:37 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.234 2004-05-18 17:44:55 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -2076,7 +2076,7 @@ static void _new_surface_volume(int mode) List_Reset(ListUnsorted); List_Add(List2, &num); while(1) { - Msg(ONSCREEN1, "Select hole boundaries (if any)"); + Msg(ONSCREEN1, "Select hole boundaries (if none, press 'e')"); Msg(ONSCREEN2, "[Press 'e' to end selection, 'u' to undo last selection or 'q' to abort]"); ib = SelectEntity(type, &v, &c, &s); if(ib == 'q') { diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 46d454eccd..0402b66dfa 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.301 2004-05-18 17:00:37 geuzaine Exp $ +// $Id: GUI.cpp,v 1.302 2004-05-18 17:44:55 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -1331,7 +1331,6 @@ void GUI::make_opengl_current() void GUI::redraw_opengl() { g_opengl_window->redraw(); - //glFlush(); } // Create the option window diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index 103dbb2d46..a1994277d7 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.57 2004-05-18 04:54:50 geuzaine Exp $ +// $Id: Geom.cpp,v 1.58 2004-05-18 17:44:55 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -306,9 +306,6 @@ void Draw_Plane_Surface(Surface * s) return; } - static List_T *points; - static int deb = 1; - if(!s->Orientations) s->Orientations = List_Create(20, 2, sizeof(Vertex)); @@ -316,12 +313,7 @@ void Draw_Plane_Surface(Surface * s) s->Orientations = List_Create(20, 2, sizeof(Vertex)); - if(deb) { - points = List_Create(10, 10, sizeof(Vertex *)); - deb = 0; - } - else - List_Reset(points); + List_T *points = List_Create(10, 10, sizeof(Vertex *)); for(i = 0; i < List_Nbr(s->Generatrices); i++) { List_Read(s->Generatrices, i, &c); @@ -332,6 +324,8 @@ void Draw_Plane_Surface(Surface * s) MeanPlane(points, s); + List_Delete(points); + k = 0; for(i = 0; i < List_Nbr(s->Generatrices); i++) { @@ -423,20 +417,19 @@ void Draw_Plane_Surface(Surface * s) if(k) List_Add(s->Orientations, &vv); - Msg(STATUS2, "Plane Surface %d (%d points)", s->Num, - List_Nbr(s->Orientations)); + Msg(STATUS2N, "Plane Surface %d (%d points)", s->Num, List_Nbr(s->Orientations)); } - if(CTX.geom.surfaces) { - glBegin(GL_LINES); - for(i = 0; i < List_Nbr(s->Orientations); i++) { - List_Read(s->Orientations, i, &vv); - glVertex3d(vv.Pos.X, vv.Pos.Y, vv.Pos.Z); - } - glEnd(); - } + if(List_Nbr(s->Orientations) > 1) { - if(List_Nbr(s->Orientations) > 1) { //draw_surface can get called during the computation... + if(CTX.geom.surfaces) { + glBegin(GL_LINES); + for(i = 0; i < List_Nbr(s->Orientations); i++) { + List_Read(s->Orientations, i, &vv); + glVertex3d(vv.Pos.X, vv.Pos.Y, vv.Pos.Z); + } + glEnd(); + } if(CTX.geom.surfaces_num) { List_Read(s->Orientations, 0, &vv1); diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp index ce1fa935e2..25b9b793fc 100644 --- a/Mesh/Create.cpp +++ b/Mesh/Create.cpp @@ -1,4 +1,4 @@ -// $Id: Create.cpp,v 1.50 2004-05-18 04:54:50 geuzaine Exp $ +// $Id: Create.cpp,v 1.51 2004-05-18 17:44:55 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -711,6 +711,7 @@ void Free_Surface(void *a, void *b) Tree_Delete(pS->Vertices); List_Delete(pS->TrsfVertices); List_Delete(pS->Contours); + List_Delete(pS->Orientations); List_Delete(pS->Control_Points); List_Delete(pS->Generatrices); if(pS->Edges) { -- GitLab