From c70d714a5de5a22445bd212e76963a7d6bbacaf7 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 29 Mar 2006 01:45:13 +0000 Subject: [PATCH] workaround for Read_Mesh limitation when reading discrete closed curves (missing last vertex due to List_Insert...) --- Geo/GeoUtils.cpp | 18 ++++++++++++++++-- Mesh/Read_Mesh.cpp | 4 ++-- doc/TODO | 9 +-------- doc/gmsh.html | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Geo/GeoUtils.cpp b/Geo/GeoUtils.cpp index 8a0042c4f7..002941e7d2 100644 --- a/Geo/GeoUtils.cpp +++ b/Geo/GeoUtils.cpp @@ -1,4 +1,4 @@ -// $Id: GeoUtils.cpp,v 1.8 2006-01-06 00:34:24 geuzaine Exp $ +// $Id: GeoUtils.cpp,v 1.9 2006-03-29 01:45:13 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -41,8 +41,22 @@ void sortEdgesInLoop(int num, List_T *edges) for(int i = 0; i < nbEdges; i++) { int j; List_Read(edges, i, &j); - if((c = FindCurve(j, THEM))) + if((c = FindCurve(j, THEM))){ List_Add(temp, &c); + // FIXME: if the loop is composed of a single curve and if the + // curve is already discretized, we check if the first vertex + // and the last vertex are the same. If not, we assume that they + // should, and we add the missing end vertex. (This situation + // can arise due to a limitation in Read_Mesh, where we do a + // List_Insert() to add the vertices in discrete curves--so that + // we never get the last vertex for single, closed curves.) + if(nbEdges == 1 && List_Nbr(c->Vertices) && c->Typ == MSH_SEGM_DISCRETE){ + Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0); + Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1); + if(first != last) + List_Add(c->Vertices, &first); + } + } else Msg(GERROR, "Unknown curve %d in line loop %d", j, num); } diff --git a/Mesh/Read_Mesh.cpp b/Mesh/Read_Mesh.cpp index c26fc82d19..c298e28691 100644 --- a/Mesh/Read_Mesh.cpp +++ b/Mesh/Read_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Read_Mesh.cpp,v 1.101 2006-03-24 21:37:14 geuzaine Exp $ +// $Id: Read_Mesh.cpp,v 1.102 2006-03-29 01:45:13 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -432,7 +432,7 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) else{ // this can be quite slow if there are many nodes on the curve... for(i = 0; i < Nbr_Nodes; i++) - List_Insert(c->Vertices, &vertsp[i], fcmp_int); + List_Insert(c->Vertices, &vertsp[i], compareVertex); } break; case TRI1: diff --git a/doc/TODO b/doc/TODO index fae8dd807f..891e85505b 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.4 2006-03-25 14:34:27 geuzaine Exp $ +$Id: TODO,v 1.5 2006-03-29 01:45:13 geuzaine Exp $ ******************************************************************** @@ -6,13 +6,6 @@ add support for off-screen rendering using OSMesa ******************************************************************** -if we try to mesh a surface from a single discrete curve mesh read -from a .msh file we get a "non contour" error in Mesh_2D (since we -List_Insert the vertices in c->Vertices, thus never having -last==first) - -******************************************************************** - add a min_recursion option for adaptve views (to force at least a certain number of subdivisions) diff --git a/doc/gmsh.html b/doc/gmsh.html index 7e5695dbc5..c9a18dd3dd 100644 --- a/doc/gmsh.html +++ b/doc/gmsh.html @@ -232,7 +232,7 @@ thumbnail"></a> (P. Geuzaine). <li>Log-periodic antenna in the demo files: <a href="/gmsh/gallery/antenna.gif">pict1</a>. -<li>Breads: +<li>Braids: <a href="/gmsh/gallery/tresse1.gif">pict1</a>, <a href="/gmsh/gallery/tresse2.gif">pict2</a> (D. Colignon). -- GitLab