Commit 08c1967e authored by Dan Lipsa's avatar Dan Lipsa

Clean up 2D reader and apply options to both readers.

parent cf88f61c
......@@ -99,41 +99,40 @@ int vtkSegYReader::RequestData(vtkInformation* vtkNotUsed(request),
return 0;
}
this->Reader->SetVerticalCRS(this->VerticalCRS);
switch (this->XYCoordMode)
{
case VTK_SEGY_SOURCE:
{
this->Reader->SetXYCoordBytePositions(72, 76);
break;
}
case VTK_SEGY_CDP:
{
this->Reader->SetXYCoordBytePositions(180, 184);
break;
}
case VTK_SEGY_CUSTOM:
{
this->Reader->SetXYCoordBytePositions(this->XCoordByte - 1,
this->YCoordByte - 1);
break;
}
default:
{
vtkErrorMacro(<< "Unknown value for XYCoordMode " << this->XYCoordMode);
return 1;
}
}
this->Reader->LoadTraces();
if (this->Is3D)
{
this->Reader->LoadTraces();
this->Reader->ExportData3D(vtkImageData::SafeDownCast(output),
this->DataExtent, this->DataOrigin, this->DataSpacing);
}
else
{
switch (this->XYCoordMode)
{
case VTK_SEGY_SOURCE:
{
this->Reader->SetXYCoordBytePositions(72, 76);
break;
}
case VTK_SEGY_CDP:
{
this->Reader->SetXYCoordBytePositions(180, 184);
break;
}
case VTK_SEGY_CUSTOM:
{
this->Reader->SetXYCoordBytePositions(this->XCoordByte - 1,
this->YCoordByte - 1);
break;
}
default:
{
vtkErrorMacro(<< "Unknown value for XYCoordMode " << this->XYCoordMode);
return 1;
}
}
vtkStructuredGrid* grid = vtkStructuredGrid::SafeDownCast(output);
this->Reader->SetVerticalCRS(this->VerticalCRS);
this->Reader->LoadTraces();
this->Reader->ExportData2D(grid);
grid->Squeeze();
}
......
......@@ -246,32 +246,6 @@ void vtkSegYReaderInternal::ExportData3D(vtkImageData* imageData,
}
}
//-----------------------------------------------------------------------------
void vtkSegYReaderInternal::AddScalars(vtkStructuredGrid* grid)
{
vtkSmartPointer<vtkFloatArray> outScalars =
vtkSmartPointer<vtkFloatArray>::New();
outScalars->SetName("trace");
outScalars->SetNumberOfComponents(1);
int crosslineCount = this->Traces.size();
outScalars->Allocate(crosslineCount * this->SampleCountPerTrace);
int j = 0;
for (int k = 0; k < this->SampleCountPerTrace; k++)
{
for (unsigned int i = 0; i < this->Traces.size(); i++)
{
outScalars->InsertValue(j++, this->Traces[i]->Data[k]);
}
}
grid->GetPointData()->SetScalars(outScalars);
grid->GetPointData()->SetActiveScalars("trace");
}
//-----------------------------------------------------------------------------
void vtkSegYReaderInternal::ExportData2D(vtkStructuredGrid* grid)
{
......@@ -279,13 +253,21 @@ void vtkSegYReaderInternal::ExportData2D(vtkStructuredGrid* grid)
{
return;
}
grid->SetDimensions(this->Traces.size(), 1, this->SampleCountPerTrace);
int crosslineCount = this->Traces.size();
grid->SetDimensions(crosslineCount, 1, this->SampleCountPerTrace);
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkFloatArray> outScalars =
vtkSmartPointer<vtkFloatArray>::New();
outScalars->SetName("trace");
outScalars->SetNumberOfComponents(1);
outScalars->Allocate(crosslineCount * this->SampleCountPerTrace);
int sign = this->VerticalCRS == 0 ? -1 : 1;
int j = 0;
for (int k = 0; k < this->SampleCountPerTrace; k++)
{
for (unsigned int i = 0; i < this->Traces.size(); i++)
for (unsigned int i = 0; i < crosslineCount; i++)
{
auto trace = this->Traces[i];
double coordinateMultiplier = decodeMultiplier(trace->CoordinateMultiplier);
......@@ -296,9 +278,11 @@ void vtkSegYReaderInternal::ExportData2D(vtkStructuredGrid* grid)
// Dividing by 1000.0 to convert from microseconds to milliseconds.
float z = sign * k * (trace->SampleInterval / 1000.0);
points->InsertNextPoint(x, y, z);
outScalars->InsertValue(j++, trace->Data[k]);
}
}
grid->SetPoints(points);
this->AddScalars(grid);
grid->GetPointData()->SetScalars(outScalars);
}
......@@ -43,7 +43,6 @@ public:
void ExportData3D(vtkImageData*, int* extent, double* origin, double* spacing);
void ExportData2D(vtkStructuredGrid*);
void AddScalars(vtkStructuredGrid*);
void SetXYCoordBytePositions(int x, int y);
void SetVerticalCRS(int);
......
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