9 #include "vtksys/FStream.hxx"
20 VTK_ABI_NAMESPACE_BEGIN
137 std::pair<bool, std::string>
ReadLine(
int size = MAX_LINE_LENGTH);
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);
212 bool OpenFile(
bool isCaseFile =
false);
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);
248 template <
typename T>
251 template <
typename T>
255 template <
typename T>
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;
285 template <
typename T>
297 assert(!this->InBlockRead);
300 if (!this->Stream->read((
char*)result,
sizeof(T)))
302 vtkGenericWarningMacro(
"read failed");
307 assert(!this->InBlockRead);
323 template <
typename T>
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)
387 VTK_ABI_NAMESPACE_END
390 #endif // end EnSightFile_h
void SetFileSetInfo(std::shared_ptr< FileSetInfo > info)
Set the file set info.
void MoveReadPosition(vtkTypeInt64 numBytes)
Move the read position ahead n bytes.
int GetCurrentOpenTimeStep()
This is used when change_coords_only is set, for determining if the file we currently have open is th...
static void Swap4LERange(void *p, size_t num)
Swap a block of 2-, 4-, or 8-byte segments for storage as Little Endian.
static void Swap4BE(void *p)
Swap 2, 4, or 8 bytes for storage as Big Endian.
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::map< int, std::shared_ptr< TimeSetInfo >> TimeSetInfoMapType
void SetTimeSetInfo(std::shared_ptr< TimeSetInfo > info)
Set the time set info.
bool SetFileNamePattern(const std::string &filename, bool isCaseFile=false)
Set the filename.
constexpr int MAX_LINE_LENGTH
std::vector< int > FileNameIndex
std::vector< int > NumberOfSteps
bool ReadNumber(T *result, bool padBeginning=true, bool padEnd=true)
Read a number from file and store it in result.
static void Swap4BERange(void *p, size_t num)
Swap a block of 2-, 4-, or 8-byte segments for storage as Big Endian.
bool DetectByteOrder(int *result)
Attempts to determine the byte order given an int read from the file.
std::vector< double > TimeValues
void CheckForBeginTimeStepLine()
Checks for a BEGIN TIME STEP line and ensures the file is at the correct position to continue reading...
void SetTimeAndFileSetInfo(int timeSet, int fileSet)
Set the time and file set ids.
std::pair< bool, std::string > ReadLine(int size=MAX_LINE_LENGTH)
Reads the next line up to size characters (ASCII) or size characters (binary)
bool OpenFile(const std::string &filename, bool isCaseFile=false)
Opens the file and performs some processing to determine the format of the file.
EnSightFile performs processing on a single file, whether it's a case file, geometry, etc.
void SkipNLines(vtkIdType n)
Skip the specified number of non-numeric lines when reading.
std::vector< int > FileNameNumbers
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...
std::vector< int > TimeStepIndexInFile
bool SetTimeStepToRead(double ts)
Set the time step to read.
std::shared_ptr< TimeSetInfo > GetTimeSetInfo()
std::map< int, std::shared_ptr< FileSetInfo >> FileSetInfoMapType
bool CheckForEndTimeStepLine()
Checks for a END TIME STEP line.
constexpr int MAXIMUM_PART_ID
std::streampos GetCurrentPosition()
Get current position of reader in stream.
bool CheckForMultipleTimeSteps()
Checks if this file has multiple time steps or not.
void GoBackOneLine()
Move the read position of the file stream back by MAX_LINE_LENGTH characters.
bool ReadArray(T *result, vtkIdType n, bool singleLine=false, bool padBeginning=true, bool padEnd=true)
Read an array of size n.
void SkipNNumbers(vtkIdType n, int numsPerLine=1)
Skip the specified number of numbers when reading.
static void Swap4LE(void *p)
Swap 2, 4, or 8 bytes for storage as Little Endian.
bool stringTo(const std::string &input, T &output)