From cea9411746a07392cd3b980095eb19da59ae493b Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 5 Jul 2004 15:20:06 +0000 Subject: [PATCH] - fixed seg fault in Plugin(Triangulate) - added BBox computation in plugins when the coordinates are changed --- Common/Views.cpp | 85 +++++++++++++++++++----------------- Fltk/Opengl_Window.cpp | 55 ++++++++--------------- Graphics/Entity.cpp | 6 +-- Plugin/DisplacementRaise.cpp | 13 +++++- Plugin/SphericalRaise.cpp | 12 ++++- Plugin/Triangulate.cpp | 7 +-- TODO | 8 +++- 7 files changed, 98 insertions(+), 88 deletions(-) diff --git a/Common/Views.cpp b/Common/Views.cpp index 9a949c238c..a66844f2c7 100644 --- a/Common/Views.cpp +++ b/Common/Views.cpp @@ -1,4 +1,4 @@ -// $Id: Views.cpp,v 1.124 2004-06-16 17:57:07 geuzaine Exp $ +// $Id: Views.cpp,v 1.125 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -285,18 +285,12 @@ void Stat_Element(Post_View * v, int type, int nbnod, int N, } for(i = 0; i < nbnod; i++) { - if(X[i] < v->BBox[0]) - v->BBox[0] = X[i]; - if(X[i] > v->BBox[1]) - v->BBox[1] = X[i]; - if(Y[i] < v->BBox[2]) - v->BBox[2] = Y[i]; - if(Y[i] > v->BBox[3]) - v->BBox[3] = Y[i]; - if(Z[i] < v->BBox[4]) - v->BBox[4] = Z[i]; - if(Z[i] > v->BBox[5]) - v->BBox[5] = Z[i]; + if(X[i] < v->BBox[0]) v->BBox[0] = X[i]; + if(X[i] > v->BBox[1]) v->BBox[1] = X[i]; + if(Y[i] < v->BBox[2]) v->BBox[2] = Y[i]; + if(Y[i] > v->BBox[3]) v->BBox[3] = Y[i]; + if(Z[i] < v->BBox[4]) v->BBox[4] = Z[i]; + if(Z[i] > v->BBox[5]) v->BBox[5] = Z[i]; } v->TextOnly = 0; @@ -1333,7 +1327,7 @@ static void transform(double mat[3][3], double v[3], *z = mat[2][0] * v[0] + mat[2][1] * v[1] + mat[2][2] * v[2]; } -static void transform_list(List_T *list, int nbList, +static void transform_list(Post_View *view, List_T *list, int nbList, int nbVert, double mat[3][3]) { double *x, *y, *z, v[3]; @@ -1351,38 +1345,49 @@ static void transform_list(List_T *list, int nbList, v[1] = y[j]; v[2] = z[j]; transform(mat, v, &x[j], &y[j], &z[j]); + if(x[j] < view->BBox[0]) view->BBox[0] = x[j]; + if(x[j] > view->BBox[1]) view->BBox[1] = x[j]; + if(y[j] < view->BBox[2]) view->BBox[2] = y[j]; + if(y[j] > view->BBox[3]) view->BBox[3] = y[j]; + if(z[j] < view->BBox[4]) view->BBox[4] = z[j]; + if(z[j] > view->BBox[5]) view->BBox[5] = z[j]; } } } void Post_View::transform(double mat[3][3]) { - transform_list(SP, NbSP, 1, mat); - transform_list(SL, NbSL, 2, mat); - transform_list(ST, NbST, 3, mat); - transform_list(SQ, NbSQ, 4, mat); - transform_list(SS, NbSS, 4, mat); - transform_list(SH, NbSH, 8, mat); - transform_list(SI, NbSI, 6, mat); - transform_list(SY, NbSY, 5, mat); - - transform_list(VP, NbVP, 1, mat); - transform_list(VL, NbVL, 2, mat); - transform_list(VT, NbVT, 3, mat); - transform_list(VQ, NbVQ, 4, mat); - transform_list(VS, NbVS, 4, mat); - transform_list(VH, NbVH, 8, mat); - transform_list(VI, NbVI, 6, mat); - transform_list(VY, NbVY, 5, mat); - - transform_list(TP, NbTP, 1, mat); - transform_list(TL, NbTL, 2, mat); - transform_list(TT, NbTT, 3, mat); - transform_list(TQ, NbTQ, 4, mat); - transform_list(TS, NbTS, 4, mat); - transform_list(TH, NbTH, 8, mat); - transform_list(TI, NbTI, 6, mat); - transform_list(TY, NbTY, 5, mat); + for(int i = 0; i < 3; i++) { + BBox[2 * i] = VAL_INF; + BBox[2 * i + 1] = -VAL_INF; + } + + transform_list(this, SP, NbSP, 1, mat); + transform_list(this, SL, NbSL, 2, mat); + transform_list(this, ST, NbST, 3, mat); + transform_list(this, SQ, NbSQ, 4, mat); + transform_list(this, SS, NbSS, 4, mat); + transform_list(this, SH, NbSH, 8, mat); + transform_list(this, SI, NbSI, 6, mat); + transform_list(this, SY, NbSY, 5, mat); + + transform_list(this, VP, NbVP, 1, mat); + transform_list(this, VL, NbVL, 2, mat); + transform_list(this, VT, NbVT, 3, mat); + transform_list(this, VQ, NbVQ, 4, mat); + transform_list(this, VS, NbVS, 4, mat); + transform_list(this, VH, NbVH, 8, mat); + transform_list(this, VI, NbVI, 6, mat); + transform_list(this, VY, NbVY, 5, mat); + + transform_list(this, TP, NbTP, 1, mat); + transform_list(this, TL, NbTL, 2, mat); + transform_list(this, TT, NbTT, 3, mat); + transform_list(this, TQ, NbTQ, 4, mat); + transform_list(this, TS, NbTS, 4, mat); + transform_list(this, TH, NbTH, 8, mat); + transform_list(this, TI, NbTI, 6, mat); + transform_list(this, TY, NbTY, 5, mat); Changed = 1; } diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp index 504eb91d2c..3c04357e90 100644 --- a/Fltk/Opengl_Window.cpp +++ b/Fltk/Opengl_Window.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl_Window.cpp,v 1.35 2004-05-17 18:04:54 geuzaine Exp $ +// $Id: Opengl_Window.cpp,v 1.36 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -246,11 +246,9 @@ int Opengl_Window::handle(int event) } else { if(FirstClick) { - xc1 = - (((double)xpos / (double)w()) * (CTX.vxmax - CTX.vxmin) + CTX.vxmin) + xc1 = (((double)xpos / (double)w()) * (CTX.vxmax - CTX.vxmin) + CTX.vxmin) / CTX.s[0] - CTX.t[0]; - yc1 = - (CTX.vymax - ((double)ypos / (double)h()) * (CTX.vymax - CTX.vymin)) + yc1 = (CTX.vymax - ((double)ypos / (double)h()) * (CTX.vymax - CTX.vymin)) / CTX.s[1] - CTX.t[1]; xt1 = CTX.t[0]; yt1 = CTX.t[1]; @@ -266,49 +264,32 @@ int Opengl_Window::handle(int event) (2.0 * Fl::event_x() - w()) / w(), (h() - 2.0 * Fl::event_y()) / h()); else { - set_r(1, - CTX.r[1] + - ((abs(xmov) > - abs(ymov)) ? 180 * (float)xmov / (float)w() : 0)); - set_r(0, - CTX.r[0] + - ((abs(xmov) > - abs(ymov)) ? 0 : 180 * (float)ymov / (float)h())); + set_r(1, CTX.r[1] + ((abs(xmov) > abs(ymov)) ? + 180 * (double)xmov / (double)w() : 0)); + set_r(0, CTX.r[0] + ((abs(xmov) > abs(ymov)) ? + 0 : 180 * (double)ymov / (double)h())); } } else if(ibut == 2 || (ibut == 1 && Fl::event_state(FL_SHIFT))) { if(!CTX.useTrackball) - set_r(2, - CTX.r[2] + - ((abs(ymov) > - abs(xmov)) ? 0 : -180 * (float)xmov / (float)w())); - set_s(0, - CTX.s[0] * - ((abs(ymov) > - abs(xmov)) ? ((ymov > - 0) ? (float)(CTX.zoom_factor * (abs(ymov) + - h())) / - (float)h() - : (float)(h()) / (float)(CTX.zoom_factor * - (abs(ymov) + h()))) - : 1.)); + set_r(2, CTX.r[2] + ((abs(ymov) > abs(xmov)) ? + 0 : -180 * (double)xmov / (double)w())); + set_s(0, CTX.s[0] * ((abs(ymov) > abs(xmov)) ? + ((ymov > 0) ? (double)(CTX.zoom_factor * (abs(ymov) + h())) / + (double)h() : + (double)(h()) / (double)(CTX.zoom_factor * + (abs(ymov) + h()))) : 1.)); set_s(1, CTX.s[0]); set_s(2, CTX.s[0]); if(abs(ymov) > abs(xmov)) { - set_t(0, - xt1 * (xscale1 / CTX.s[0]) - xc1 * (1. - - (xscale1 / CTX.s[0]))); - set_t(1, - yt1 * (yscale1 / CTX.s[1]) - yc1 * (1. - - (yscale1 / CTX.s[1]))); + set_t(0, xt1 * (xscale1 / CTX.s[0]) - xc1 * (1. - (xscale1 / CTX.s[0]))); + set_t(1, yt1 * (yscale1 / CTX.s[1]) - yc1 * (1. - (yscale1 / CTX.s[1]))); } } else { - xc = - (((double)xpos / (double)w()) * (CTX.vxmax - CTX.vxmin) + CTX.vxmin) + xc = (((double)xpos / (double)w()) * (CTX.vxmax - CTX.vxmin) + CTX.vxmin) / CTX.s[0]; - yc = - (CTX.vymax - ((double)ypos / (double)h()) * (CTX.vymax - CTX.vymin)) + yc = (CTX.vymax - ((double)ypos / (double)h()) * (CTX.vymax - CTX.vymin)) / CTX.s[1]; set_t(0, xc - xc1); set_t(1, yc - yc1); diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index 85eefce51b..a93a093683 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.42 2004-05-30 19:17:58 geuzaine Exp $ +// $Id: Entity.cpp,v 1.43 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -46,7 +46,7 @@ void Draw_Sphere(double size, double x, double y, double z, int light) if(light) glEnable(GL_LIGHTING); static GLUquadricObj *qua; static int first = 1, listnum; - float s = size * CTX.pixel_equiv_x / CTX.s[0]; // size is in pixels + double s = size * CTX.pixel_equiv_x / CTX.s[0]; // size is in pixels if(first) { first = 0; qua = gluNewQuadric(); @@ -57,7 +57,7 @@ void Draw_Sphere(double size, double x, double y, double z, int light) } glPushMatrix(); glTranslated(x, y, z); - glScalef(s, s, s); + glScaled(s, s, s); glCallList(listnum); glPopMatrix(); glDisable(GL_LIGHTING); diff --git a/Plugin/DisplacementRaise.cpp b/Plugin/DisplacementRaise.cpp index 6325df1eab..3700e5bf6e 100644 --- a/Plugin/DisplacementRaise.cpp +++ b/Plugin/DisplacementRaise.cpp @@ -1,4 +1,4 @@ -// $Id: DisplacementRaise.cpp,v 1.15 2004-05-16 20:04:43 geuzaine Exp $ +// $Id: DisplacementRaise.cpp,v 1.16 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -125,6 +125,12 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm, x[k] += factor * val[3 * nbNod * dTimeStep + 3 * k]; y[k] += factor * val[3 * nbNod * dTimeStep + 3 * k + 1]; z[k] += factor * val[3 * nbNod * dTimeStep + 3 * k + 2]; + if(x[k] < iView->BBox[0]) iView->BBox[0] = x[k]; + if(x[k] > iView->BBox[1]) iView->BBox[1] = x[k]; + if(y[k] < iView->BBox[2]) iView->BBox[2] = y[k]; + if(y[k] > iView->BBox[3]) iView->BBox[3] = y[k]; + if(z[k] < iView->BBox[4]) iView->BBox[4] = z[k]; + if(z[k] > iView->BBox[5]) iView->BBox[5] = z[k]; } } @@ -132,6 +138,11 @@ static void displacementRaiseList(Post_View * iView, List_T * iList, int iNbElm, static void displacementRaise(Post_View * v, Post_View * w, double factor, int ts) { + for(int i = 0; i < 3; i++) { + v->BBox[2 * i] = VAL_INF; + v->BBox[2 * i + 1] = -VAL_INF; + } + displacementRaiseList(v, v->SP, v->NbSP, w, w->VP, w->NbVP, 1, factor, ts); displacementRaiseList(v, v->SL, v->NbSL, w, w->VL, w->NbVL, 2, factor, ts); displacementRaiseList(v, v->ST, v->NbST, w, w->VT, w->NbVT, 3, factor, ts); diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp index 7cc6b7492d..9d4f054f69 100644 --- a/Plugin/SphericalRaise.cpp +++ b/Plugin/SphericalRaise.cpp @@ -1,4 +1,4 @@ -// $Id: SphericalRaise.cpp,v 1.17 2004-05-16 20:04:43 geuzaine Exp $ +// $Id: SphericalRaise.cpp,v 1.18 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -130,6 +130,12 @@ static void sphericalRaiseList(Post_View * v, List_T * list, int nbElm, x[j] += coef * d[0]; y[j] += coef * d[1]; z[j] += coef * d[2]; + if(x[j] < v->BBox[0]) v->BBox[0] = x[j]; + if(x[j] > v->BBox[1]) v->BBox[1] = x[j]; + if(y[j] < v->BBox[2]) v->BBox[2] = y[j]; + if(y[j] > v->BBox[3]) v->BBox[3] = y[j]; + if(z[j] < v->BBox[4]) v->BBox[4] = z[j]; + if(z[j] > v->BBox[5]) v->BBox[5] = z[j]; } } } @@ -137,6 +143,10 @@ static void sphericalRaiseList(Post_View * v, List_T * list, int nbElm, static void sphericalRaise(Post_View * v, int timeStep, double center[3], double raise) { + for(int i = 0; i < 3; i++) { + v->BBox[2 * i] = VAL_INF; + v->BBox[2 * i + 1] = -VAL_INF; + } sphericalRaiseList(v, v->SP, v->NbSP, 1, timeStep, center, raise); sphericalRaiseList(v, v->SL, v->NbSL, 2, timeStep, center, raise); sphericalRaiseList(v, v->ST, v->NbST, 3, timeStep, center, raise); diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp index c6ffc2c229..d1771099df 100644 --- a/Plugin/Triangulate.cpp +++ b/Plugin/Triangulate.cpp @@ -1,4 +1,4 @@ -// $Id: Triangulate.cpp,v 1.23 2004-06-24 07:13:18 geuzaine Exp $ +// $Id: Triangulate.cpp,v 1.24 2004-07-05 15:20:06 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -107,7 +107,7 @@ extern "C" void Triangulate(int nbIn, List_T *inList, int *nbOut, List_T *outList, int nbTimeStep, int nbComp) { - if(!nbIn) + if(nbIn < 3) return; List_T *points = List_Create(nbIn, 1, sizeof(Vertex *)); @@ -219,9 +219,6 @@ Post_View *GMSH_TriangulatePlugin::execute(Post_View * v) return v; } - if(v->NbSP < 2 && v->NbVP < 2 && v->NbTP < 2) - return v; - Post_View *v2 = BeginView(1); Post_View *v1 = (Post_View*)List_Pointer(CTX.post.list, iView); diff --git a/TODO b/TODO index db5e327aa6..eb3e5bde77 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.56 2004-07-02 16:34:00 geuzaine Exp $ +$Id: TODO,v 1.57 2004-07-05 15:20:06 geuzaine Exp $ add an interactive way to choose the orientation of surfaces in surface loops and lines in line loops @@ -13,6 +13,12 @@ add ternary operator and <,>,<=,>=,== tests in MathEval ******************************************************************** +On Macs, datasets with a bounding box < 1.e06 don't display properly +(probably because all OpenGL stuff is done inetrnally in single +precision...) + +******************************************************************** + gerard.fleury@inrs.fr: add the capability to mesh some entities using 1st order and some other using 2nd order elements (in the same geometry)? -- GitLab