VTK
9.4.20241121
|
EnSightFile performs processing on a single file, whether it's a case file, geometry, etc. More...
#include <EnSightFile.h>
Public Member Functions | |
EnSightFile () | |
~EnSightFile () | |
bool | SetFileNamePattern (const std::string &filename, bool isCaseFile=false) |
Set the filename. | |
void | SetTimeAndFileSetInfo (int timeSet, int fileSet) |
Set the time and file set ids. | |
void | SetTimeSetInfo (std::shared_ptr< TimeSetInfo > info) |
Set the time set info. | |
std::shared_ptr< TimeSetInfo > | GetTimeSetInfo () |
void | SetFileSetInfo (std::shared_ptr< FileSetInfo > info) |
Set the file set info. | |
bool | SetTimeStepToRead (double ts) |
Set the time step to read. | |
bool | CheckForMultipleTimeSteps () |
Checks if this file has multiple time steps or not. | |
void | CheckForBeginTimeStepLine () |
Checks for a BEGIN TIME STEP line and ensures the file is at the correct position to continue reading. | |
bool | CheckForEndTimeStepLine () |
Checks for a END TIME STEP line. | |
std::pair< bool, std::string > | ReadNextLine (int size=MAX_LINE_LENGTH) |
For ASCII files, reads the next line while skipping lines that contain only whitespace or a comment. | |
std::pair< bool, std::string > | ReadLine (int size=MAX_LINE_LENGTH) |
Reads the next line up to size characters (ASCII) or size characters (binary) | |
void | SkipLine (vtkTypeInt64 size=std::numeric_limits< std::streamsize >::max()) |
Ignore the the next characters until either the line end delimiter is met or size characters have been ignored (if provided). | |
void | SkipNLines (vtkIdType n) |
Skip the specified number of non-numeric lines when reading. | |
template<typename T > | |
void | SkipNNumbers (vtkIdType n, int numsPerLine=1) |
Skip the specified number of numbers when reading. | |
void | GoBackOneLine () |
Move the read position of the file stream back by MAX_LINE_LENGTH characters. | |
bool | DetectByteOrder (int *result) |
Attempts to determine the byte order given an int read from the file. | |
template<typename T > | |
bool | ReadNumber (T *result, bool padBeginning=true, bool padEnd=true) |
Read a number from file and store it in result. | |
template<typename T > | |
bool | ReadArray (T *result, vtkIdType n, bool singleLine=false, bool padBeginning=true, bool padEnd=true) |
Read an array of size n. | |
void | MoveReadPosition (vtkTypeInt64 numBytes) |
Move the read position ahead n bytes. | |
std::streampos | GetCurrentPosition () |
Get current position of reader in stream. | |
int | GetCurrentOpenTimeStep () |
This is used when change_coords_only is set, for determining if the file we currently have open is the file that contains the connectivity. | |
bool | OpenFile (const std::string &filename, bool isCaseFile=false) |
Opens the file and performs some processing to determine the format of the file. | |
bool | OpenFile (bool isCaseFile=false) |
Public Attributes | |
FileType | Format = FileType::Unknown |
Endianness | ByteOrder = Endianness::Unknown |
int | TimeSet = -1 |
int | FileSet = -1 |
bool | InBlockRead = false |
EnSightFile performs processing on a single file, whether it's a case file, geometry, etc.
It also works on ASCII, C binary, and Fortran binary files.
Definition at line 63 of file EnSightFile.h.
ensight_gold::EnSightFile::EnSightFile | ( | ) |
ensight_gold::EnSightFile::~EnSightFile | ( | ) |
bool ensight_gold::EnSightFile::SetFileNamePattern | ( | const std::string & | filename, |
bool | isCaseFile = false |
||
) |
Set the filename.
isCaseFile should be set to true for case files, or other similar type of metadata files (like a filename numbers file). When true, it will immediately open that file. Returns true that the filename was set and in the case of casefiles, returns true if OpenFile was successful
void ensight_gold::EnSightFile::SetTimeAndFileSetInfo | ( | int | timeSet, |
int | fileSet | ||
) |
Set the time and file set ids.
void ensight_gold::EnSightFile::SetTimeSetInfo | ( | std::shared_ptr< TimeSetInfo > | info | ) |
Set the time set info.
|
inline |
Definition at line 91 of file EnSightFile.h.
void ensight_gold::EnSightFile::SetFileSetInfo | ( | std::shared_ptr< FileSetInfo > | info | ) |
Set the file set info.
bool ensight_gold::EnSightFile::SetTimeStepToRead | ( | double | ts | ) |
Set the time step to read.
If data is not transient, will just open the file if it's not already. For transient data, it will make sure the correct file is open, and go to the correct time step in the file. If it returns false, that means some file open or seek operation failed. See output messages for details on the failure.
bool ensight_gold::EnSightFile::CheckForMultipleTimeSteps | ( | ) |
Checks if this file has multiple time steps or not.
If there's a wildcard in the FileNamePattern, return true, otherwise it will check for the existence of the BEGIN TIME STEP line.
void ensight_gold::EnSightFile::CheckForBeginTimeStepLine | ( | ) |
Checks for a BEGIN TIME STEP line and ensures the file is at the correct position to continue reading.
bool ensight_gold::EnSightFile::CheckForEndTimeStepLine | ( | ) |
Checks for a END TIME STEP line.
Returns true if found and sets the position to be just after that line. Returns false if that line isn't found and resets the position to the place the file was at before this call.
std::pair< bool, std::string > ensight_gold::EnSightFile::ReadNextLine | ( | int | size = MAX_LINE_LENGTH | ) |
For ASCII files, reads the next line while skipping lines that contain only whitespace or a comment.
For binary files, just calls ReadLine().
std::pair< bool, std::string > ensight_gold::EnSightFile::ReadLine | ( | int | size = MAX_LINE_LENGTH | ) |
Reads the next line up to size characters (ASCII) or size characters (binary)
void ensight_gold::EnSightFile::SkipLine | ( | vtkTypeInt64 | size = std::numeric_limits< std::streamsize >::max() | ) |
Ignore the the next characters until either the line end delimiter is met or size characters have been ignored (if provided).
For binary formats, ignore the next size characters + padding (but you should probably use another method)
void ensight_gold::EnSightFile::SkipNLines | ( | vtkIdType | n | ) |
Skip the specified number of non-numeric lines when reading.
WARNING: Should only be used for non-numeric lines, even in ASCII mode! Some sections in ASCII will contain multiple numbers per line, in which case the MAX_LINE_LENGTH limit will probably cut off the line.
void ensight_gold::EnSightFile::SkipNNumbers | ( | vtkIdType | n, |
int | numsPerLine = 1 |
||
) |
Skip the specified number of numbers when reading.
For binary files, moves the read position the appropriate number of bytes (numsPerLine arg is irrelevant). For ASCII files, one or more numbers can be contained on a line, depending on the section, so numsPerLine should be specified if it's not 1.
Definition at line 256 of file EnSightFile.h.
void ensight_gold::EnSightFile::GoBackOneLine | ( | ) |
Move the read position of the file stream back by MAX_LINE_LENGTH characters.
bool ensight_gold::EnSightFile::DetectByteOrder | ( | int * | result | ) |
Attempts to determine the byte order given an int read from the file.
bool ensight_gold::EnSightFile::ReadNumber | ( | T * | result, |
bool | padBeginning = true , |
||
bool | padEnd = true |
||
) |
Read a number from file and store it in result.
Definition at line 286 of file EnSightFile.h.
bool ensight_gold::EnSightFile::ReadArray | ( | T * | result, |
vtkIdType | n, | ||
bool | singleLine = false , |
||
bool | padBeginning = true , |
||
bool | padEnd = true |
||
) |
Read an array of size n.
singleLine applies only to ASCII files (ignored for binary). Set true if all numbers in the array to be read are written on the same line, false otherwise. padBeginning and padEnd applies only to Fortran binary files. If the array to be read is a full fortran write (i.e., there is the 4 padding bytes on both sides), then both will be true. Setting one or both to false enables partial arrays to be read (such as when reading cells).
Definition at line 324 of file EnSightFile.h.
void ensight_gold::EnSightFile::MoveReadPosition | ( | vtkTypeInt64 | numBytes | ) |
Move the read position ahead n bytes.
std::streampos ensight_gold::EnSightFile::GetCurrentPosition | ( | ) |
Get current position of reader in stream.
int ensight_gold::EnSightFile::GetCurrentOpenTimeStep | ( | ) |
This is used when change_coords_only is set, for determining if the file we currently have open is the file that contains the connectivity.
bool ensight_gold::EnSightFile::OpenFile | ( | const std::string & | filename, |
bool | isCaseFile = false |
||
) |
Opens the file and performs some processing to determine the format of the file.
Appropriately resets the position of the file stream depending on the type of file.
bool ensight_gold::EnSightFile::OpenFile | ( | bool | isCaseFile = false | ) |
FileType ensight_gold::EnSightFile::Format = FileType::Unknown |
Definition at line 65 of file EnSightFile.h.
Endianness ensight_gold::EnSightFile::ByteOrder = Endianness::Unknown |
Definition at line 66 of file EnSightFile.h.
int ensight_gold::EnSightFile::TimeSet = -1 |
Definition at line 67 of file EnSightFile.h.
int ensight_gold::EnSightFile::FileSet = -1 |
Definition at line 68 of file EnSightFile.h.
bool ensight_gold::EnSightFile::InBlockRead = false |
Definition at line 69 of file EnSightFile.h.