From 895b0bfb9d554f092e3e55730453b8c880f6a3bf Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 20 Feb 2005 07:11:04 +0000 Subject: [PATCH] modified Read_Mesh and Print_Geo so that we can save line/surface meshes loaded from a file as discrete geometries --- Geo/CAD.cpp | 3 +-- Geo/Print_Geo.cpp | 6 +++--- Mesh/1D_Mesh.cpp | 3 +-- Mesh/3D_Extrude.cpp | 5 +---- Mesh/Create.cpp | 4 ++-- Mesh/DiscreteSurface.cpp | 4 +--- Mesh/Read_Mesh.cpp | 38 +++++++++++++++++++++++++++++++++++++- 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/Geo/CAD.cpp b/Geo/CAD.cpp index 0223a3db5d..196d760cdf 100644 --- a/Geo/CAD.cpp +++ b/Geo/CAD.cpp @@ -1,4 +1,4 @@ -// $Id: CAD.cpp,v 1.82 2005-02-20 06:36:54 geuzaine Exp $ +// $Id: CAD.cpp,v 1.83 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -635,7 +635,6 @@ Curve *CreateReversedCurve(Mesh * M, Curve * c) newc->Typ = MSH_SEGM_ELLI_INV; if(c->Typ == MSH_SEGM_ELLI_INV) newc->Typ = MSH_SEGM_ELLI; - newc->Vertices = List_Create(10, 1, sizeof(Vertex *)); newc->Method = c->Method; newc->degre = c->degre; newc->beg = c->end; diff --git a/Geo/Print_Geo.cpp b/Geo/Print_Geo.cpp index 721d91cbf4..91d4dd35d0 100644 --- a/Geo/Print_Geo.cpp +++ b/Geo/Print_Geo.cpp @@ -1,4 +1,4 @@ -// $Id: Print_Geo.cpp,v 1.35 2005-02-20 06:36:54 geuzaine Exp $ +// $Id: Print_Geo.cpp,v 1.36 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -164,7 +164,7 @@ void Print_Discrete_Curve(void *a, void *b) // else, print the mesh: - if(c->Dirty || !List_Nbr(c->Vertices)) + if(!List_Nbr(c->Vertices)) return; if(!List_Nbr(c->Control_Points)) @@ -302,7 +302,7 @@ void Print_Discrete_Surface(void *a, void *b) // else, print the surface mesh: - if(s->Dirty || !Tree_Nbr(s->Vertices)) + if(!Tree_Nbr(s->Vertices)) return; List_T *verts = Tree2List(s->Vertices); diff --git a/Mesh/1D_Mesh.cpp b/Mesh/1D_Mesh.cpp index 2aa199c8d2..0aed7d5778 100644 --- a/Mesh/1D_Mesh.cpp +++ b/Mesh/1D_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: 1D_Mesh.cpp,v 1.43 2005-02-20 06:36:54 geuzaine Exp $ +// $Id: 1D_Mesh.cpp,v 1.44 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -182,7 +182,6 @@ void Maillage_Curve(void *data, void *dummy) } } b = a / (double)(N - 1); - c->Vertices = List_Create(N, 2, sizeof(Vertex *)); v = &c->beg; if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, v))) { diff --git a/Mesh/3D_Extrude.cpp b/Mesh/3D_Extrude.cpp index 4acf83e3c6..4364ff929f 100644 --- a/Mesh/3D_Extrude.cpp +++ b/Mesh/3D_Extrude.cpp @@ -1,4 +1,4 @@ -// $Id: 3D_Extrude.cpp,v 1.86 2005-01-26 15:26:53 geuzaine Exp $ +// $Id: 3D_Extrude.cpp,v 1.87 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -734,8 +734,6 @@ void copy_mesh(Curve * from, Curve * to, int direction) return; } - to->Vertices = List_Create(List_Nbr(from->Vertices), 2, sizeof(Vertex *)); - v = to->beg; if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) { (*vexist)->u = to->ubeg; @@ -829,7 +827,6 @@ int Extrude_Mesh(Curve * c) Extrude_Vertex(&c->beg, NULL); L = getnxl(c->beg, DIM); if(!L) return false; - c->Vertices = List_Create(List_Nbr(L), 2, sizeof(Vertex *)); v = c->beg; if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) { diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp index 40758e7b32..c038c859ea 100644 --- a/Mesh/Create.cpp +++ b/Mesh/Create.cpp @@ -1,4 +1,4 @@ -// $Id: Create.cpp,v 1.67 2005-02-20 06:36:54 geuzaine Exp $ +// $Id: Create.cpp,v 1.68 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -532,7 +532,7 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste, pC->Color.type = 0; pC->Visible = VIS_GEOM | VIS_MESH; pC->cp = NULL; - pC->Vertices = NULL; + pC->Vertices = List_Create(10, 100, sizeof(Vertex *)); pC->Extrude = NULL; pC->theSegmRep = 0; pC->Typ = Typ; diff --git a/Mesh/DiscreteSurface.cpp b/Mesh/DiscreteSurface.cpp index d770d9b3a4..4a96645a6e 100644 --- a/Mesh/DiscreteSurface.cpp +++ b/Mesh/DiscreteSurface.cpp @@ -1,4 +1,4 @@ -// $Id: DiscreteSurface.cpp,v 1.2 2005-02-20 06:36:54 geuzaine Exp $ +// $Id: DiscreteSurface.cpp,v 1.3 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -511,8 +511,6 @@ void SEGM_rep_To_Mesh(SEGM_rep *srep, Curve *c) Vertex **verts = new Vertex*[N]; - c->Vertices = List_Create(N, 2, sizeof(Vertex *)); - for(int i = 0; i < List_Nbr(srep->points); i+=3){ double *point = (double*)List_Pointer(srep->points, i); Vertex *v = Create_Vertex(++THEM->MaxPointNum, point[0], point[1], point[2], 1.0, 0.0); diff --git a/Mesh/Read_Mesh.cpp b/Mesh/Read_Mesh.cpp index 98bcb2ad5b..f43571b4f7 100644 --- a/Mesh/Read_Mesh.cpp +++ b/Mesh/Read_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Read_Mesh.cpp,v 1.84 2005-02-16 05:48:28 geuzaine Exp $ +// $Id: Read_Mesh.cpp,v 1.85 2005-02-20 07:11:04 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -328,6 +328,10 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Line element %d already exists", simp->Num); Free_SimplexBase(&simp, 0); } + else{ + for(i = 0; i < Nbr_Nodes; i++) + List_Insert(c->Vertices, &vertsp[i], fcmp_int); + } break; case TRI1: case TRI2: @@ -348,6 +352,10 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Triangle %d already exists", simp->Num); Free_SimplexBase(&simp, 0); } + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(s->Vertices, &vertsp[i]); + } break; case QUA1: case QUA2: @@ -368,6 +376,10 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Quadrangle %d already exists", quad->Num); Free_SimplexBase(&quad, 0); } + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(s->Vertices, &vertsp[i]); + } break; case TET1: case TET2: @@ -388,6 +400,12 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Tetrahedron %d already exists", simp->Num); Free_SimplexBase(&simp, 0); } +#if 0 // removed to speed things up (not used at the moment anyway) + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(v->Vertices, &vertsp[i]); + } +#endif break; case HEX1: case HEX2: @@ -409,6 +427,12 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Hexahedron %d already exists", hex->Num); Free_Hexahedron(&hex, 0); } +#if 0 // removed to speed things up (not used at the moment anyway) + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(v->Vertices, &vertsp[i]); + } +#endif break; case PRI1: case PRI2: @@ -430,6 +454,12 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Prism %d already exists", pri->Num); Free_Prism(&pri, 0); } +#if 0 // removed to speed things up (not used at the moment anyway) + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(v->Vertices, &vertsp[i]); + } +#endif break; case PYR1: case PYR2: @@ -451,6 +481,12 @@ void Read_Mesh_MSH(Mesh * M, FILE * fp) Msg(GERROR, "Pyramid %d already exists", pyr->Num); Free_Pyramid(&pyr, 0); } +#if 0 // removed to speed things up (not used at the moment anyway) + else{ + for(i = 0; i < Nbr_Nodes; i++) + Tree_Insert(v->Vertices, &vertsp[i]); + } +#endif break; case PNT: addPhysicalGroup(M, MSH_PHYSICAL_POINT, Physical, Elementary); -- GitLab