@@ -59,9 +59,8 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
5959 {
6060 std::ifstream inputfile;
6161 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
62- inputfile.open (elems_fn. c_str () );
62+ inputfile.open (elems_fn);
6363 }
64-
6564 catch (...)
6665 {
6766 if (pr) pr->error (" Could not open file: " + elems_fn);
@@ -79,7 +78,7 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
7978 std::ifstream inputfile;
8079 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
8180 elems_fn = base + " .elem" ;
82- inputfile.open (elems_fn. c_str () );
81+ inputfile.open (elems_fn);
8382 }
8483 catch (...)
8584 {
@@ -88,7 +87,7 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
8887 std::ifstream inputfile;
8988 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
9089 elems_fn = base + " .tet" ;
91- inputfile.open (elems_fn. c_str () );
90+ inputfile.open (elems_fn);
9291 }
9392 catch (...)
9493 {
@@ -103,9 +102,8 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
103102 {
104103 std::ifstream inputfile;
105104 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
106- inputfile.open (elems_fn. c_str () );
105+ inputfile.open (elems_fn);
107106 }
108-
109107 catch (...)
110108 {
111109 if (pr) pr->error (" Could not open file: " + elems_fn);
@@ -122,9 +120,8 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
122120 {
123121 std::ifstream inputfile;
124122 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
125- inputfile.open (pts_fn. c_str () );
123+ inputfile.open (pts_fn);
126124 }
127-
128125 catch (...)
129126 {
130127 if (pr) pr->error (" Could not open file: " + pts_fn);
@@ -142,7 +139,7 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
142139 std::ifstream inputfile;
143140 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
144141 pts_fn = base + " .pts" ;
145- inputfile.open (pts_fn. c_str () );
142+ inputfile.open (pts_fn);
146143 }
147144 catch (...)
148145 {
@@ -151,9 +148,8 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
151148 std::ifstream inputfile;
152149 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
153150 pts_fn = base + " .pos" ;
154- inputfile.open (pts_fn. c_str () );
151+ inputfile.open (pts_fn);
155152 }
156-
157153 catch (...)
158154 {
159155 if (pr) pr->error (" Could not open file: " + base + " .pts" );
@@ -167,9 +163,8 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
167163 {
168164 std::ifstream inputfile;
169165 inputfile.exceptions (std::ifstream::failbit | std::ifstream::badbit);
170- inputfile.open (pts_fn. c_str () );
166+ inputfile.open (pts_fn);
171167 }
172-
173168 catch (...)
174169 {
175170 if (pr) pr->error (" Could not open file: " + pts_fn);
@@ -179,26 +174,21 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
179174 }
180175
181176 std::string line;
182-
183177 // STAGE 1 - SCAN THE FILE TO DETERMINE THE NUMBER OF NODES
184178 // AND CHECK THE FILE'S INTEGRITY.
185-
186179 int num_nodes = 0 ; int num_elems = 0 ;
187180 std::vector<double > values;
188181 std::vector<double > fvalues;
189182 std::vector<VMesh::index_type> ivalues;
190183 std::string elem_type;
191184
192-
193185 // Check the element type
194-
195186 {
196187 std::ifstream inputfile;
197188 inputfile.exceptions (std::ifstream::badbit);
198-
199189 try
200190 {
201- inputfile.open (elems_fn. c_str () );
191+ inputfile.open (elems_fn);
202192
203193 for (int lineno = 0 ; getline (inputfile, line) && lineno < 2 ; lineno++)
204194 {
@@ -224,43 +214,31 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
224214 return (result);
225215 }
226216 }
227-
228217 // add data to elems (constant basis)
229-
230- // std::cout << "Loading element type: " << std::endl;
231- // std::cout << elem_type << std::endl;
232-
233218 FieldInformation fi (nullptr );
234-
235219 int elem_n = (elem_type == " Tt" ) ? 4 : 3 ;
236220
237221 if (elem_type == " Tt" )
238222 {
239223 fi = FieldInformation (" TetVolMesh" , -1 , " double" );
240224 fi.make_constantdata ();
241-
242225 }
243226 else if (elem_type == " Tr" )
244227 {
245228 fi = FieldInformation (" TriSurfMesh" , -1 , " double" );
246-
247229 }
248230
249231 result = CreateField (fi);
250-
251232 VMesh *mesh = result->vmesh ();
252233 VField *field = result->vfield ();
253234
254235 // Elements file
255-
256236 {
257237 std::ifstream inputfile;
258238 inputfile.exceptions (std::ifstream::badbit);
259-
260239 try
261240 {
262- inputfile.open (elems_fn.c_str ());
263-
241+ inputfile.open (elems_fn);
264242 VMesh::Node::array_type vdata;
265243 vdata.resize (elem_n);
266244
@@ -271,18 +249,13 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
271249
272250 for (int i = 0 ; i < num_elems && getline (inputfile, line, ' \n ' ); ++i)
273251 {
274-
275252 multiple_from_string (line, ivalues);
276-
277253 for (size_t j = 0 ; j < ivalues.size () && j < elem_n; j++)
278254 {
279255 vdata[j] = ivalues[j];
280256 }
281-
282257 fvalues.push_back (ivalues[ivalues.size () - 1 ]);
283-
284258 mesh->add_elem (vdata);
285-
286259 }
287260 }
288261 catch (...)
@@ -292,30 +265,24 @@ FieldHandle SCIRun::CARPMesh_reader(LoggerHandle pr, const char *filename)
292265 }
293266 inputfile.close ();
294267 }
295-
296-
297268 // Points file
298-
299269 {
300270 std::ifstream inputfile;
301271 inputfile.exceptions (std::ifstream::badbit);
302-
303272 try
304273 {
305- inputfile.open (pts_fn. c_str () );
274+ inputfile.open (pts_fn);
306275
307276 std::vector<double > vdata (3 );
308277 getline (inputfile, line, ' \n ' );
309278 multiple_from_string (line, values);
310279 num_nodes = static_cast <int >(values[0 ]);
311280
312- for (int i = 0 ; i < num_nodes && getline (inputfile, line, ' \n ' ); ++i) {
313-
281+ for (int i = 0 ; i < num_nodes && getline (inputfile, line, ' \n ' ); ++i)
282+ {
314283 multiple_from_string (line, values);
315- int sf = 1000 ;
316-
317- if (values.size () == 3 ) mesh->add_point (Point (values[0 ] / sf, values[1 ] / sf, values[2 ] / sf));
318-
284+ if (values.size () == 3 )
285+ mesh->add_point (Point (values[0 ], values[1 ], values[2 ]));
319286 }
320287 }
321288 catch (...)
@@ -342,7 +309,6 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
342309
343310 FieldInformation fi (fh);
344311
345-
346312 // Points file
347313 {
348314 std::ofstream outputfile;
@@ -364,7 +330,7 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
364330
365331 try
366332 {
367- outputfile.open (pts_fn. c_str () );
333+ outputfile.open (pts_fn);
368334
369335 // these appear to be reasonable formatting flags for output
370336 std::ios_base::fmtflags ff;
@@ -376,13 +342,11 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
376342 VMesh::Node::iterator nodeIter;
377343 VMesh::Node::iterator nodeIterEnd;
378344 VMesh::Node::size_type nodeSize;
379-
380345 mesh->begin (nodeIter);
381346 mesh->end (nodeIterEnd);
382347 mesh->size (nodeSize);
383348
384349 // N.B: not writing header
385-
386350 outputfile << nodeSize << std::endl;
387351
388352 while (nodeIter != nodeIterEnd)
@@ -400,7 +364,6 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
400364 }
401365 outputfile.close ();
402366 }
403-
404367 // Elements file
405368 {
406369 std::ofstream outputfile;
@@ -422,48 +385,37 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
422385
423386 try
424387 {
425- outputfile.open (elems_fn.c_str ());
426-
388+ outputfile.open (elems_fn);
427389 VMesh::Cell::iterator cellIter;
428390 VMesh::Cell::iterator cellIterEnd;
429391 VMesh::Cell::size_type cellSize;
430392
431393 mesh->begin (cellIter);
432394 mesh->end (cellIterEnd);
433395 mesh->size (cellSize);
434-
435-
436-
437396#if DEBUG
438397 std::cerr << " Number of tets = " << cellSize << std::endl;
439398#endif
440-
441399 outputfile << cellSize << std::endl;
442400
443401 if (fi.is_tetvolmesh ())
444402 {
445403 VMesh::Node::array_type cellNodes (4 );
446-
447404 double scalaroutput;
448-
449- while (cellIter != cellIterEnd) {
450-
405+ while (cellIter != cellIterEnd)
406+ {
451407 field->get_value (scalaroutput, *cellIter);
452408 mesh->get_nodes (cellNodes, *cellIter);
453-
454409 outputfile << " Tt" << " " << cellNodes[0 ] << " " << cellNodes[1 ] << " " << cellNodes[2 ] << " " << cellNodes[3 ] << " " << scalaroutput << std::endl;
455410 ++cellIter;
456411 }
457412 }
458413 else if (fi.is_trisurfmesh ())
459414 {
460-
461415 VMesh::Node::array_type faceNodes (3 );
462-
463416 double scalaroutput;
464-
465- while (cellIter != cellIterEnd) {
466-
417+ while (cellIter != cellIterEnd)
418+ {
467419 field->get_value (scalaroutput, *cellIter);
468420 mesh->get_nodes (faceNodes, *cellIter);
469421
@@ -473,11 +425,9 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
473425 }
474426 else
475427 {
476-
477428 if (pr) pr->error (" Please convert to TetVol mesh " );
478429 return false ;
479430 }
480-
481431 }
482432 catch (...)
483433 {
@@ -508,7 +458,7 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
508458
509459 try
510460 {
511- outputfile.open (lon_fn. c_str () );
461+ outputfile.open (lon_fn);
512462
513463 VMesh::Cell::iterator cellIter;
514464 VMesh::Cell::iterator cellIterEnd;
@@ -524,11 +474,10 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
524474
525475 outputfile << 1 << std::endl;
526476
527- std::cout << " The generated *.lon file assumes a bath in the smallest mask layer and assigns a fiber direction of [0 0 1] to all other data layers. If a different fiber file is required, please use the CarpFiber exporter/importer." << std::endl ;
477+ if (pr) pr-> remark ( " The generated *.lon file assumes a bath in the smallest mask layer and assigns a fiber direction of [0 0 1] to all other data layers. If a different fiber file is required, please use the CarpFiber exporter/importer." ) ;
528478
529479 if (fi.is_tetvolmesh ())
530480 {
531-
532481 VMesh::Node::array_type cellNodes (4 );
533482
534483 std::vector<double > region;
@@ -552,7 +501,6 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
552501 }
553502
554503 VMesh::Cell::iterator cellIter;
555-
556504 while (cellIter != cellIterEnd)
557505 {
558506 if (region[*cellIter] != min_region)
@@ -563,7 +511,6 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
563511 {
564512 outputfile << 0 << " " << 0 << " " << 0 << std::endl;
565513 }
566-
567514 ++cellIter;
568515 }
569516 }
@@ -572,7 +519,6 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
572519 if (pr) pr->error (" Please convert to Tetvol" );
573520 return false ;
574521 }
575-
576522 }
577523 catch (...)
578524 {
@@ -581,7 +527,5 @@ bool SCIRun::CARPMesh_writer(LoggerHandle pr, FieldHandle fh, const char *filena
581527 }
582528 outputfile.close ();
583529 }
584-
585-
586530 return true ;
587531}
0 commit comments