Commit 0dd74fc4 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri

Added a vertical reference system variable to SegY reader

This variable dictates whether the vertical axis follows a heights
reference i.e. positive up, or a depths reference i.e. positive down.
parent 8d9ffa5d
......@@ -78,6 +78,18 @@ int TestSegY2DReaderZoom(int argc, char* argv[])
retVal++;
}
// Test the Z-coordinate range for VerticalCRS
double bounds[6];
output->GetBounds(bounds);
if (!vtkMathUtilities::FuzzyCompare<double>(bounds[4], -4000.00) ||
(bounds[5] > 1e-3))
{
std::cerr << "Error: Z bounds are incorrect: (" << bounds[4] << ", "
<< bounds[5] << ")" << std::endl
<< "Expected Z bounds: (-4000, 0)" << std::endl;
}
// Test some scalar values
vtkFloatArray* scalars =
vtkFloatArray::SafeDownCast(output->GetPointData()->GetScalars());
......
5664443600e629701d221bfd45ee84b8
25f106e8b1cc641d4a8d587654c9d7e0
......@@ -34,6 +34,8 @@ vtkSegY2DReader::vtkSegY2DReader()
this->XYCoordMode = VTK_SEGY_SOURCE;
this->XCoordByte = 73;
this->YCoordByte = 77;
this->VerticalCRS = VTK_SEGY_VERTICAL_HEIGHTS;
}
//-----------------------------------------------------------------------------
......@@ -102,6 +104,8 @@ int vtkSegY2DReader::RequestData(vtkInformation* vtkNotUsed(request),
}
}
this->Reader->SetVerticalCRS(this->VerticalCRS);
this->Reader->LoadFromFile(FileName);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
......
......@@ -73,6 +73,27 @@ public:
vtkGetMacro(YCoordByte, int);
//@}
enum VTKSegYVerticalCRS
{
VTK_SEGY_VERTICAL_HEIGHTS = 0, // default
VTK_SEGY_VERTICAL_DEPTHS
};
//@{
/**
* Specify whether the vertical coordinates in the SEG-Y file are heights
* (positive up) or depths (positive down). By default, the vertical
* coordinates are treated as heights (i.e. positive up). This means that the
* Z-axis of the dataset goes from 0 (surface) to -ve depth (last sample).
* \note As per the SEG-Y rev 2.0 specification, this information is defined
* in the Location Data Stanza of the Extended Textual Header. However, as of
* this revision, vtkSegY2DReader does not support reading the extended
* textual header.
*/
vtkSetMacro(VerticalCRS, int);
vtkGetMacro(VerticalCRS, int);
//@}
protected:
int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
......@@ -84,6 +105,8 @@ protected:
int XCoordByte;
int YCoordByte;
int VerticalCRS;
private:
char* FileName;
vtkSegYReader* Reader;
......
......@@ -36,6 +36,7 @@ vtkSegYReader::vtkSegYReader()
{
this->BinaryHeaderBytesPos = new vtkSegYBinaryHeaderBytesPositions();
this->TraceReader = new vtkSegYTraceReader();
this->VerticalCRS = 0;
}
//-----------------------------------------------------------------------------
......@@ -53,6 +54,12 @@ void vtkSegYReader::SetXYCoordBytePositions(int x, int y)
this->TraceReader->SetXYCoordBytePositions(x, y);
}
//-----------------------------------------------------------------------------
void vtkSegYReader::SetVerticalCRS(int v)
{
this->VerticalCRS = v > 0 ? 1 : 0;
}
//-----------------------------------------------------------------------------
bool vtkSegYReader::LoadFromFile(std::string path)
{
......@@ -333,7 +340,8 @@ void vtkSegYReader::ExportData2D(vtkStructuredGrid* grid)
// The samples are uniformly placed at sample interval depths
// Dividing by 1000.0 to convert from microseconds to milliseconds.
float z = k * (trace->SampleInterval / 1000.0);
int sign = this->VerticalCRS == 0 ? -1 : 1;
float z = sign * k * (trace->SampleInterval / 1000.0);
points->InsertNextPoint(x, y, z);
}
}
......
......@@ -40,6 +40,7 @@ public:
void ExportData2D(vtkStructuredGrid*);
void AddScalars(vtkStructuredGrid*);
void SetXYCoordBytePositions(int x, int y);
void SetVerticalCRS(int);
private:
bool ReadHeader(std::ifstream& in);
......@@ -48,6 +49,7 @@ private:
vtkSegYBinaryHeaderBytesPositions* BinaryHeaderBytesPos;
vtkSegYTraceReader* TraceReader;
int SampleCountPerTrace;
int VerticalCRS;
};
#endif // vtkSegYReader_h
......
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