9#include "vtksys/FStream.hxx"
20VTK_ABI_NAMESPACE_BEGIN
143 void SkipLine(vtkTypeInt64 size = std::numeric_limits<std::streamsize>::max());
160 template <
typename T>
176 template <
typename T>
177 bool ReadNumber(T* result,
bool padBeginning =
true,
bool padEnd =
true);
187 template <
typename T>
189 T* result,
vtkIdType n,
bool singleLine =
false,
bool padBeginning =
true,
bool padEnd =
true);
211 bool OpenFile(
const std::string& filename,
bool isCaseFile =
false);
215 std::string FileNamePattern;
216 std::string CurrentOpenFileName;
217 std::shared_ptr<TimeSetInfo> TimeInfo;
218 std::shared_ptr<FileSetInfo> FileInfo;
223 std::map<int, std::vector<std::streampos>> TimeStepBeginPositions;
224 int CurrentFileIndex = -1;
226 int TimeStepIndex = -1;
228 vtksys::ifstream* Stream;
229 bool HasBinaryHeader =
false;
230 int FortranSkipBytes = 0;
245 void MoveToPosition(std::streampos pos);
265 int size = getNumChars<T>() * numsPerLine + 10 * numsPerLine;
273 vtkGenericWarningMacro(
"SkipNNumbers() the full ascii line was not read");
279 vtkTypeInt64 numBytes = n *
sizeof(T) + this->FortranSkipBytes * 2;
297 assert(!this->InBlockRead);
300 if (!this->Stream->read((
char*)result,
sizeof(T)))
302 vtkGenericWarningMacro(
"read failed");
307 assert(!this->InBlockRead);
325 bool padBeginning ,
bool padEnd )
336 for (
int i = 0; i < n; i++)
343 int size = getNumChars<T>() * n + 10 * n;
344 auto lineResult = this->
ReadLine(size);
345 if (!lineResult.first)
347 vtkGenericWarningMacro(
"ReadArray() the full ascii line was not read");
350 std::stringstream ss(lineResult.second);
351 for (
int i = 0; i < n; i++)
362 if (padBeginning && this->FortranSkipBytes > 0)
366 if (!this->Stream->read((
char*)result,
sizeof(T) * n))
368 vtkGenericWarningMacro(
"read array failed");
371 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 MoveReadPosition(vtkTypeInt64 numBytes)
Move the read position ahead n bytes.
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.
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 bee...
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.
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