9#include "vtksys/FStream.hxx"
18VTK_ABI_NAMESPACE_BEGIN
151 template <
typename T>
167 template <
typename T>
168 bool ReadNumber(T* result,
bool padBeginning =
true,
bool padEnd =
true);
178 template <
typename T>
180 T* result,
vtkIdType n,
bool singleLine =
false,
bool padBeginning =
true,
bool padEnd =
true);
202 bool OpenFile(
const std::string& filename,
bool isCaseFile =
false);
206 std::string FileNamePattern;
207 std::string CurrentOpenFileName;
208 std::shared_ptr<TimeSetInfo> TimeInfo;
209 std::shared_ptr<FileSetInfo> FileInfo;
214 std::map<int, std::vector<std::streampos>> TimeStepBeginPositions;
215 int CurrentFileIndex = -1;
217 int TimeStepIndex = -1;
219 vtksys::ifstream* Stream;
220 bool HasBinaryHeader =
false;
221 int FortranSkipBytes = 0;
236 void MoveToPosition(std::streampos pos);
256 int size = getNumChars<T>() * numsPerLine + 10 * numsPerLine;
264 vtkGenericWarningMacro(
"SkipNNumbers() the full ascii line was not read");
270 int numBytes = n *
static_cast<int>(
sizeof(T)) + this->FortranSkipBytes * 2;
290 if (!this->Stream->read((
char*)result,
sizeof(T)))
292 vtkGenericWarningMacro(
"read failed");
314 bool padBeginning ,
bool padEnd )
325 for (
int i = 0; i < n; i++)
332 int size = getNumChars<T>() * n + 10 * n;
333 auto lineResult = this->
ReadLine(size);
334 if (!lineResult.first)
336 vtkGenericWarningMacro(
"ReadArray() the full ascii line was not read");
339 std::stringstream ss(lineResult.second);
340 for (
int i = 0; i < n; i++)
351 if (padBeginning && this->FortranSkipBytes > 0)
355 if (!this->Stream->read((
char*)result,
sizeof(T) * n))
357 vtkGenericWarningMacro(
"read array failed");
360 if (padEnd && this->FortranSkipBytes > 0)
static void Swap4BERange(void *p, size_t num)
Swap a block of 2-, 4-, or 8-byte segments for storage as Big Endian.
static void Swap4BE(void *p)
Swap 2, 4, or 8 bytes for storage as Big Endian.
static void Swap4LE(void *p)
Swap 2, 4, or 8 bytes for storage as Little Endian.
static void Swap4LERange(void *p, size_t num)
Swap a block of 2-, 4-, or 8-byte segments for storage as Little Endian.
bool stringTo(const std::string &input, T &output)
std::map< int, std::shared_ptr< TimeSetInfo > > TimeSetInfoMapType
constexpr int MAXIMUM_PART_ID
std::map< int, std::shared_ptr< FileSetInfo > > FileSetInfoMapType
constexpr int MAX_LINE_LENGTH
EnSightFile performs processing on a single file, whether it's a case file, geometry,...
void SetTimeSetInfo(std::shared_ptr< TimeSetInfo > info)
Set the time set info.
std::pair< bool, std::string > ReadLine(int size=MAX_LINE_LENGTH)
Reads the next line up to size characters (ASCII) or size characters (binary)
std::shared_ptr< TimeSetInfo > GetTimeSetInfo()
void SetTimeAndFileSetInfo(int timeSet, int fileSet)
Set the time and file set ids.
int GetCurrentOpenTimeStep()
This is used when change_coords_only is set, for determining if the file we currently have open is th...
bool OpenFile(const std::string &filename, bool isCaseFile=false)
Opens the file and performs some processing to determine the format of the file.
void CheckForBeginTimeStepLine()
Checks for a BEGIN TIME STEP line and ensures the file is at the correct position to continue reading...
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.
void SkipNNumbers(vtkIdType n, int numsPerLine=1)
Skip the specified number of numbers when reading.
std::streampos GetCurrentPosition()
Get current position of reader in stream.
bool CheckForEndTimeStepLine()
Checks for a END TIME STEP line.
bool SetTimeStepToRead(double ts)
Set the time step to read.
void GoBackOneLine()
Move the read position of the file stream back by MAX_LINE_LENGTH characters.
bool CheckForMultipleTimeSteps()
Checks if this file has multiple time steps or not.
bool ReadNumber(T *result, bool padBeginning=true, bool padEnd=true)
Read a number from file and store it in result.
bool ReadArray(T *result, vtkIdType n, bool singleLine=false, bool padBeginning=true, bool padEnd=true)
Read an array of size n.
void SkipNLines(vtkIdType n)
Skip the specified number of non-numeric lines when reading.
bool OpenFile(bool isCaseFile=false)
bool SetFileNamePattern(const std::string &filename, bool isCaseFile=false)
Set the filename.
void SetFileSetInfo(std::shared_ptr< FileSetInfo > info)
Set the file set info.
void MoveReadPosition(int numBytes)
Move the read position ahead n bytes.
bool DetectByteOrder(int *result)
Attempts to determine the byte order given an int read from the file.
std::vector< int > FileNameIndex
std::vector< int > TimeStepIndexInFile
std::vector< int > NumberOfSteps
std::vector< int > FileNameNumbers
std::vector< double > TimeValues