@@ -115,7 +115,6 @@ bool ImportGridFromTETGEN(Grid& grid,
115115 AInt* paElementAttribute)
116116{
117117// read nodes and store them in an array for index access
118-
119118 vector<RegularVertex*> vVertices;
120119
121120 {
@@ -132,6 +131,8 @@ bool ImportGridFromTETGEN(Grid& grid,
132131 in >> numAttribs;
133132 in >> numBoundaryMarkers;
134133
134+ vVertices.reserve (numNodes + 1 );
135+
135136 // set up attachment accessors
136137 if (!grid.has_vertex_attachment (aPos))
137138 grid.attach_to_vertices (aPos);
@@ -158,6 +159,8 @@ bool ImportGridFromTETGEN(Grid& grid,
158159
159160 // read index and coords
160161 in >> index;
162+ if (index > vVertices.size ())
163+ vVertices.resize (index, NULL );
161164 in >> aaPosVRT[v].x ();
162165 in >> aaPosVRT[v].y ();
163166 in >> aaPosVRT[v].z ();
@@ -275,7 +278,6 @@ bool ImportGridFromTETGEN(Grid& grid,
275278
276279 in.close ();
277280 }
278-
279281 return true ;
280282}
281283
@@ -288,7 +290,6 @@ bool ImportGridFromTETGEN(Grid& grid,
288290 std::vector<AFloat>* pvNodeAttributes)
289291{
290292// read nodes and store them in an array for index access
291-
292293 vector<RegularVertex*> vVertices;
293294
294295 {
@@ -305,6 +306,9 @@ bool ImportGridFromTETGEN(Grid& grid,
305306 in >> numAttribs;
306307 in >> numBoundaryMarkers;
307308
309+ vVertices.reserve (numNodes + 1 );
310+ grid.reserve <Vertex>(numNodes);
311+
308312 // set up attachment accessors
309313 if (!grid.has_vertex_attachment (aPos))
310314 grid.attach_to_vertices (aPos);
@@ -323,10 +327,12 @@ bool ImportGridFromTETGEN(Grid& grid,
323327 for (uint i = 0 ; i < numNodes; ++i)
324328 {
325329 RegularVertex* v = *grid.create <RegularVertex>();
326- vVertices.push_back (v);
327330
328331 // read index and coords
329332 in >> index;
333+ if (index > vVertices.size ())
334+ vVertices.resize (index, NULL );
335+ vVertices.push_back (v);
330336 in >> aaPosVRT[v].x ();
331337 in >> aaPosVRT[v].y ();
332338 in >> aaPosVRT[v].z ();
@@ -349,7 +355,7 @@ bool ImportGridFromTETGEN(Grid& grid,
349355 int bm;
350356 in >> bm;
351357 if (psh != NULL )
352- psh->assign_subset (v, bm );
358+ psh->assign_subset (v, abs (bm) );
353359 }
354360 }
355361
@@ -366,6 +372,8 @@ bool ImportGridFromTETGEN(Grid& grid,
366372 in >> numFaces;
367373 in >> numBoundaryMarkers;
368374
375+ grid.reserve <Face>(numFaces);
376+
369377 for (int i = 0 ; i < numFaces; ++i)
370378 {
371379 int index, i1, i2, i3;
@@ -380,9 +388,12 @@ bool ImportGridFromTETGEN(Grid& grid,
380388 int bm;
381389 in >> bm;
382390 if (psh != NULL ){
383- psh->assign_subset (t, bm );
391+ psh->assign_subset (t, abs (bm) );
384392 }
385393 }
394+ else if (psh != NULL ){
395+ psh->assign_subset (t, 0 );
396+ }
386397 }
387398 }
388399 else
@@ -402,11 +413,14 @@ bool ImportGridFromTETGEN(Grid& grid,
402413 in >> numNodesPerTet;
403414 in >> numAttribs;
404415
416+ grid.reserve <Volume>(numTets);
417+
405418 vector<int > vTetNodes (numNodesPerTet);
406419 for (int i = 0 ; i < numTets; ++i)
407420 {
408421 int index;
409422 in >> index;
423+ // UG_LOG(" index = " << index << std::endl);
410424 for (int j = 0 ; j < numNodesPerTet; ++j)
411425 in >> vTetNodes[j];
412426
0 commit comments