From 2f0516138641aebfbc8d1c946301beb25a26b61a Mon Sep 17 00:00:00 2001 From: Todd Martin <nztoddler@yahoo.com> Date: Sat, 21 Dec 2019 00:48:59 +1300 Subject: [PATCH] Use vtksys::ifstream in SegY IO istream method parameters are sufficient --- IO/SegY/vtkSegYIOUtils.cxx | 18 +++++++++--------- IO/SegY/vtkSegYIOUtils.h | 18 +++++++++--------- IO/SegY/vtkSegYReader.cxx | 2 +- IO/SegY/vtkSegYReaderInternal.h | 3 ++- IO/SegY/vtkSegYTraceReader.cxx | 6 +++--- IO/SegY/vtkSegYTraceReader.h | 6 +++--- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/IO/SegY/vtkSegYIOUtils.cxx b/IO/SegY/vtkSegYIOUtils.cxx index 3554a5971c2..3e8ef0ea21d 100644 --- a/IO/SegY/vtkSegYIOUtils.cxx +++ b/IO/SegY/vtkSegYIOUtils.cxx @@ -34,14 +34,14 @@ vtkSegYIOUtils* vtkSegYIOUtils::Instance() } //---------------------------------------------------------------------------- -short vtkSegYIOUtils::readShortInteger(std::streamoff pos, std::ifstream& in) +short vtkSegYIOUtils::readShortInteger(std::streamoff pos, std::istream& in) { in.seekg(pos, in.beg); return readShortInteger(in); } //---------------------------------------------------------------------------- -short vtkSegYIOUtils::readShortInteger(std::ifstream& in) +short vtkSegYIOUtils::readShortInteger(std::istream& in) { char buffer[2]; in.read(buffer, sizeof(buffer)); @@ -57,14 +57,14 @@ short vtkSegYIOUtils::readShortInteger(std::ifstream& in) } //---------------------------------------------------------------------------- -int vtkSegYIOUtils::readLongInteger(std::streamoff pos, std::ifstream& in) +int vtkSegYIOUtils::readLongInteger(std::streamoff pos, std::istream& in) { in.seekg(pos, in.beg); return readLongInteger(in); } //---------------------------------------------------------------------------- -int vtkSegYIOUtils::readLongInteger(std::ifstream& in) +int vtkSegYIOUtils::readLongInteger(std::istream& in) { char buffer[4]; in.read(buffer, sizeof(buffer)); @@ -81,7 +81,7 @@ int vtkSegYIOUtils::readLongInteger(std::ifstream& in) } //---------------------------------------------------------------------------- -float vtkSegYIOUtils::readFloat(std::ifstream& in) +float vtkSegYIOUtils::readFloat(std::istream& in) { char buffer[4]; in.read(buffer, sizeof(buffer)); @@ -98,7 +98,7 @@ float vtkSegYIOUtils::readFloat(std::ifstream& in) } //---------------------------------------------------------------------------- -float vtkSegYIOUtils::readIBMFloat(std::ifstream& in) +float vtkSegYIOUtils::readIBMFloat(std::istream& in) { char buffer[4]; in.read(buffer, sizeof(buffer)); @@ -141,7 +141,7 @@ float vtkSegYIOUtils::readIBMFloat(std::ifstream& in) } //---------------------------------------------------------------------------- -char vtkSegYIOUtils::readChar(std::ifstream& in) +char vtkSegYIOUtils::readChar(std::istream& in) { char buffer; in.read(&buffer, sizeof(buffer)); @@ -149,7 +149,7 @@ char vtkSegYIOUtils::readChar(std::ifstream& in) } //---------------------------------------------------------------------------- -unsigned char vtkSegYIOUtils::readUChar(std::ifstream& in) +unsigned char vtkSegYIOUtils::readUChar(std::istream& in) { char buffer; in.read(&buffer, sizeof(buffer)); @@ -165,7 +165,7 @@ void vtkSegYIOUtils::swap(char* a, char* b) } //---------------------------------------------------------------------------- -std::streamoff vtkSegYIOUtils::getFileSize(std::ifstream& in) +std::streamoff vtkSegYIOUtils::getFileSize(std::istream& in) { in.seekg(0, in.end); return in.tellg(); diff --git a/IO/SegY/vtkSegYIOUtils.h b/IO/SegY/vtkSegYIOUtils.h index 7930aa3bd65..1e53f989dec 100644 --- a/IO/SegY/vtkSegYIOUtils.h +++ b/IO/SegY/vtkSegYIOUtils.h @@ -21,17 +21,17 @@ class vtkSegYIOUtils { public: - char readChar(std::ifstream& in); - short readShortInteger(std::streamoff pos, std::ifstream& in); - short readShortInteger(std::ifstream& in); - int readLongInteger(std::streamoff pos, std::ifstream& in); - int readLongInteger(std::ifstream& in); - float readFloat(std::ifstream& in); - float readIBMFloat(std::ifstream& in); - unsigned char readUChar(std::ifstream& in); + char readChar(std::istream& in); + short readShortInteger(std::streamoff pos, std::istream& in); + short readShortInteger(std::istream& in); + int readLongInteger(std::streamoff pos, std::istream& in); + int readLongInteger(std::istream& in); + float readFloat(std::istream& in); + float readIBMFloat(std::istream& in); + unsigned char readUChar(std::istream& in); void swap(char* a, char* b); static vtkSegYIOUtils* Instance(); - std::streamoff getFileSize(std::ifstream& in); + std::streamoff getFileSize(std::istream& in); bool IsBigEndian; diff --git a/IO/SegY/vtkSegYReader.cxx b/IO/SegY/vtkSegYReader.cxx index ebc61f7af40..1ac002da649 100644 --- a/IO/SegY/vtkSegYReader.cxx +++ b/IO/SegY/vtkSegYReader.cxx @@ -183,7 +183,7 @@ int vtkSegYReader::RequestDataObject(vtkInformation*, } else { - this->Reader->In.open(this->FileName, std::ifstream::binary); + this->Reader->In.open(this->FileName, std::ios::binary); } if (!this->Reader->In) { diff --git a/IO/SegY/vtkSegYReaderInternal.h b/IO/SegY/vtkSegYReaderInternal.h index 562a5fd70b9..4faa525bd68 100644 --- a/IO/SegY/vtkSegYReaderInternal.h +++ b/IO/SegY/vtkSegYReaderInternal.h @@ -20,6 +20,7 @@ #include <fstream> #include <string> #include <vector> +#include <vtksys/FStream.hxx> // Forward declarations class vtkStructuredGrid; @@ -48,7 +49,7 @@ public: void SetXYCoordBytePositions(int x, int y); void SetVerticalCRS(int); - std::ifstream In; + vtksys::ifstream In; protected: bool ReadHeader(); diff --git a/IO/SegY/vtkSegYTraceReader.cxx b/IO/SegY/vtkSegYTraceReader.cxx index 58380f9d4df..b3c8c3ea0fd 100644 --- a/IO/SegY/vtkSegYTraceReader.cxx +++ b/IO/SegY/vtkSegYTraceReader.cxx @@ -33,7 +33,7 @@ void vtkSegYTraceReader::SetXYCoordBytePositions(int x, int y) } //----------------------------------------------------------------------------- -void vtkSegYTraceReader::PrintTraceHeader(std::ifstream& in, int startPos) +void vtkSegYTraceReader::PrintTraceHeader(std::istream& in, int startPos) { int traceSequenceNumberInLine = vtkSegYIOUtils::Instance()->readLongInteger(startPos + traceHeaderBytesPos.TraceNumber, in); @@ -81,7 +81,7 @@ void vtkSegYTraceReader::PrintTraceHeader(std::ifstream& in, int startPos) //----------------------------------------------------------------------------- void vtkSegYTraceReader::ReadTrace( - std::streamoff& startPos, std::ifstream& in, int formatCode, vtkSegYTrace* trace) + std::streamoff& startPos, std::istream& in, int formatCode, vtkSegYTrace* trace) { trace->InlineNumber = vtkSegYIOUtils::Instance()->readLongInteger(startPos + traceHeaderBytesPos.InlineNumber, in); @@ -139,7 +139,7 @@ void vtkSegYTraceReader::ReadTrace( } //----------------------------------------------------------------------------- -void vtkSegYTraceReader::ReadInlineCrossline(std::streamoff& startPos, std::ifstream& in, +void vtkSegYTraceReader::ReadInlineCrossline(std::streamoff& startPos, std::istream& in, int formatCode, int* inlineNumber, int* crosslineNumber, int* xCoord, int* yCoord, short* coordMultiplier) { diff --git a/IO/SegY/vtkSegYTraceReader.h b/IO/SegY/vtkSegYTraceReader.h index b23d6f0021f..1ec763b7711 100644 --- a/IO/SegY/vtkSegYTraceReader.h +++ b/IO/SegY/vtkSegYTraceReader.h @@ -51,9 +51,9 @@ public: vtkSegYTraceReader(); void SetXYCoordBytePositions(int x, int y); - void PrintTraceHeader(std::ifstream& in, int startPos); - void ReadTrace(std::streamoff& startPos, std::ifstream& in, int formatCode, vtkSegYTrace* trace); - void ReadInlineCrossline(std::streamoff& startPos, std::ifstream& in, int formatCode, + void PrintTraceHeader(std::istream& in, int startPos); + void ReadTrace(std::streamoff& startPos, std::istream& in, int formatCode, vtkSegYTrace* trace); + void ReadInlineCrossline(std::streamoff& startPos, std::istream& in, int formatCode, int* inlineNumber, int* crosslineNumber, int* xCoord, int* yCoord, short* coordMultiplier); int GetTraceSize(int numSamples, int formatCode); -- GitLab