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

Method GetFieldNames

IO/Geometry/vtkOpenFOAMReader.cxx:5697–5771  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

5695
5696//------------------------------------------------------------------------------
5697void vtkOpenFOAMReaderPrivate::GetFieldNames(const std::string& tempPath, bool isLagrangian)
5698{
5699 // Open the directory and get num of files
5700#if VTK_OPENFOAM_TIME_PROFILING
5701 auto start = std::chrono::high_resolution_clock::now();
5702#endif
5703 vtkNew<vtkDirectory> directory;
5704 if (!directory->Open(tempPath.c_str()))
5705 {
5706#if VTK_OPENFOAM_TIME_PROFILING
5707 auto end = std::chrono::high_resolution_clock::now();
5708 this->RequestInformationTimeInMicroseconds +=
5709 std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
5710#endif
5711 // No data
5712 return;
5713 }
5714#if VTK_OPENFOAM_TIME_PROFILING
5715 auto end = std::chrono::high_resolution_clock::now();
5716 this->RequestInformationTimeInMicroseconds +=
5717 std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
5718#endif
5719
5720 // loop over all files and locate valid fields
5721 const vtkIdType nFieldFiles = directory->GetNumberOfFiles();
5722 for (vtkIdType fileI = 0; fileI < nFieldFiles; ++fileI)
5723 {
5724 const std::string fieldFile(directory->GetFile(fileI));
5725 const auto len = fieldFile.length();
5726
5727 if (!len || (fieldFile[len - 1] == '~') || directory->FileIsDirectory(fieldFile.c_str()))
5728 {
5729 continue;
5730 }
5731 else if (this->Parent->IgnoreRestartFiles && len > 2 && (fieldFile[len - 2] == '_') &&
5732 (fieldFile[len - 1] == '0'))
5733 {
5734 // Exclude "*_0" restart files
5735 continue;
5736 }
5737 else
5738 {
5739 // Exclude various backup extensions - cf. Foam::fileName::isBackup()
5740
5741 auto sep = fieldFile.rfind('.');
5742 if (sep != std::string::npos)
5743 {
5744 ++sep;
5745
5746 if (!fieldFile.compare(sep, std::string::npos, "bak") ||
5747 !fieldFile.compare(sep, std::string::npos, "BAK") ||
5748 !fieldFile.compare(sep, std::string::npos, "old") ||
5749 !fieldFile.compare(sep, std::string::npos, "save"))
5750 {
5751 continue;
5752 }
5753 }
5754 }

Callers 2

Calls 12

AddFieldNameMethod · 0.95
SetInputBufferSizeMethod · 0.80
SetOutputBufferSizeMethod · 0.80
OpenMethod · 0.45
c_strMethod · 0.45
countMethod · 0.45
GetNumberOfFilesMethod · 0.45
GetFileMethod · 0.45
lengthMethod · 0.45
FileIsDirectoryMethod · 0.45
compareMethod · 0.45
GetClassNameMethod · 0.45

Tested by

no test coverage detected