MCPcopy Create free account
hub / github.com/Kitware/VTK / ParseTimeStepsInBoundaryFile

Function ParseTimeStepsInBoundaryFile

IO/FDS/vtkFDSReader.cxx:445–502  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

443
444//------------------------------------------------------------------------------
445std::vector<float> ParseTimeStepsInBoundaryFile(const std::string& fileName)
446{
447 vtkNew<vtkFileResourceStream> fileStream;
448 if (fileName.empty() || !fileStream->Open(fileName.c_str()))
449 {
450 vtkErrorWithObjectMacro(
451 nullptr, << "Failed to open file: "
452 << (fileName.empty() ? fileName : "No file name for boundary given"));
453 return std::vector<float>();
454 }
455
456 vtkNew<vtkResourceParser> parser;
457 parser->Reset();
458 parser->SetStream(fileStream);
459 parser->StopOnNewLineOff();
460
461 unsigned int size = 0;
462 // skip header lines
463 for (vtkIdType iL = 0; iL < 3; ++iL)
464 {
465 parser->Read(reinterpret_cast<char*>(&size), 4);
466 parser->ReadUntil(vtkResourceParser::DiscardNone, ReadNothing, size + 4);
467 }
468
469 // read number of patches
470 parser->Read(reinterpret_cast<char*>(&size), 4);
471 unsigned int nBlockages = 0;
472 parser->Read(reinterpret_cast<char*>(&nBlockages), size);
473 parser->Read(reinterpret_cast<char*>(&size), 4);
474
475 // discard blockage descriptions
476 for (unsigned int iBlock = 0; iBlock < nBlockages; ++iBlock)
477 {
478 parser->Read(reinterpret_cast<char*>(&size), 4);
479 parser->ReadUntil(vtkResourceParser::DiscardNone, ReadNothing, size + 4);
480 }
481
482 std::vector<float> timeValues;
483 vtkParseResult result = vtkParseResult::Ok;
484 do
485 {
486 parser->Read(reinterpret_cast<char*>(&size), 4);
487 if (size != sizeof(float))
488 {
489 break;
490 }
491 float time = 0.0;
492 parser->Read(reinterpret_cast<char*>(&time), 4);
493 timeValues.emplace_back(time);
494 parser->Read(reinterpret_cast<char*>(&size), 4);
495 for (unsigned int iBlock = 0; iBlock < nBlockages; ++iBlock)
496 {
497 parser->Read(reinterpret_cast<char*>(&size), 4);
498 result = parser->ReadUntil(vtkResourceParser::DiscardNone, ReadNothing, size + 4);
499 }
500 } while (result != vtkParseResult::EndOfStream);
501 return timeValues;
502}

Callers 1

ParseBNDFBNDCMethod · 0.85

Calls 8

ReadUntilMethod · 0.80
emptyMethod · 0.45
OpenMethod · 0.45
c_strMethod · 0.45
ResetMethod · 0.45
SetStreamMethod · 0.45
ReadMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected