Commit 92cabf61 authored by Dan Lipsa's avatar Dan Lipsa

Add ability to read from short integers.

parent 200888e7
......@@ -37,6 +37,12 @@ vtkSegYIOUtils* vtkSegYIOUtils::Instance()
short vtkSegYIOUtils::readShortInteger(int pos, std::ifstream& in)
{
in.seekg(pos, in.beg);
return readShortInteger(in);
}
//----------------------------------------------------------------------------
short vtkSegYIOUtils::readShortInteger(std::ifstream& in)
{
char buffer[2];
in.read(buffer, sizeof(buffer));
......@@ -54,18 +60,7 @@ short vtkSegYIOUtils::readShortInteger(int pos, std::ifstream& in)
int vtkSegYIOUtils::readLongInteger(int pos, std::ifstream& in)
{
in.seekg(pos, in.beg);
char buffer[4];
in.read(buffer, sizeof(buffer));
if (!this->IsBigEndian)
{
swap(buffer, buffer + 3);
swap(buffer + 1, buffer + 2);
}
int num;
memcpy(&num, buffer, 4);
return num;
return readLongInteger(in);
}
//----------------------------------------------------------------------------
......
......@@ -24,6 +24,7 @@ class vtkSegYIOUtils
public:
char readChar(std::ifstream& in);
short readShortInteger(int pos, std::ifstream& in);
short readShortInteger(std::ifstream& in);
int readLongInteger(int pos, std::ifstream& in);
int readLongInteger(std::ifstream& in);
float readFloat(std::ifstream& in);
......
......@@ -121,6 +121,13 @@ void vtkSegYTraceReader::ReadTrace(int& startPos,
trace->Data.push_back(value);
}
break;
case 3:
for (int i = 0; i < numSamples; i++)
{
value = vtkSegYIOUtils::Instance()->readShortInteger(in);
trace->Data.push_back(value);
}
break;
case 5:
for (int i = 0; i < numSamples; i++)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment