Commit 5397f96a authored by Dan Lipsa's avatar Dan Lipsa

Fix ParaView parameters and remove printouts.

parent 2620aa3f
......@@ -129,8 +129,9 @@ int vtkSegYReader::RequestData(vtkInformation* vtkNotUsed(request),
this->UpdateProgress(0.5);
if (this->Is3D && ! this->StructuredGrid)
{
vtkImageData* imageData = vtkImageData::SafeDownCast(output);
this->Reader->ExportData(
vtkImageData::SafeDownCast(output), this->DataExtent,
imageData, this->DataExtent,
this->DataOrigin, this->DataSpacing, this->DataSpacingSign);
}
else
......@@ -140,7 +141,6 @@ int vtkSegYReader::RequestData(vtkInformation* vtkNotUsed(request),
grid->Squeeze();
}
this->Reader->In.close();
std::cout << "RequestData" << std::endl;
return 1;
}
......@@ -156,37 +156,16 @@ int vtkSegYReader::RequestInformation(vtkInformation * vtkNotUsed(request),
return 0;
}
std::cout << "DataExtent: ";
std::copy(this->DataExtent, this->DataExtent + 6, std::ostream_iterator<int>(std::cout, " "));
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
this->DataExtent, 6);
std::cout << std::endl;
if (this->Is3D && ! this->StructuredGrid)
{
std::cout << "DataOrigin: ";
std::copy(this->DataOrigin, this->DataOrigin + 3, std::ostream_iterator<double>(std::cout, " "));
std::cout << "\nDataSpacing: ";
std::copy(this->DataSpacing, this->DataSpacing + 3, std::ostream_iterator<double>(std::cout, " "));
std::cout << "\nDataSpacingSign: ";
std::copy(this->DataSpacingSign, this->DataSpacingSign + 3, std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
outInfo->Set(vtkDataObject::ORIGIN(), this->DataOrigin, 3);
outInfo->Set(vtkDataObject::SPACING(), this->DataSpacing, 3);
}
return 1;
}
//----------------------------------------------------------------------------
int vtkSegYReader::FillOutputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
const char* outputTypeName =
(this->Is3D && ! this->StructuredGrid) ? "vtkImageData" : "vtkStructuredGrid";
info->Set(vtkDataObject::DATA_TYPE_NAME(), outputTypeName);
std::cout << "FillOutputPortInformation" << std::endl;
return 1;
}
//----------------------------------------------------------------------------
int vtkSegYReader::RequestDataObject(
vtkInformation*,
......@@ -203,15 +182,23 @@ int vtkSegYReader::RequestDataObject(
return 0;
}
this->Reader->In.open(this->FileName, std::ifstream::binary);
if (this->Reader->In.is_open())
{
this->Reader->In.seekg(0, this->Reader->In.beg);
}
else
{
this->Reader->In.open(this->FileName, std::ifstream::binary);
}
if (!this->Reader->In)
{
std::cerr << "File not found:" << this->FileName << std::endl;
vtkErrorMacro("File not found:" << this->FileName);
return 0;
}
this->Is3D = this->Reader->Is3DComputeParameters(
this->DataExtent, this->DataOrigin, this->DataSpacing, this->DataSpacingSign);
const char* outputTypeName = this->Is3D ? "vtkImageData" : "vtkStructuredGrid";
const char* outputTypeName = (this->Is3D && ! this->StructuredGrid) ?
"vtkImageData" : "vtkStructuredGrid";
if (!output || !output->IsA(outputTypeName))
{
......@@ -227,6 +214,5 @@ int vtkSegYReader::RequestDataObject(
info->Set(vtkDataObject::DATA_OBJECT(), newOutput);
newOutput->Delete();
}
std::cout << "RequestDataObject" << std::endl;
return 1;
}
......@@ -125,7 +125,6 @@ protected:
int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
int FillOutputPortInformation(int port, vtkInformation* info) override;
int RequestDataObject(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
......
......@@ -75,23 +75,6 @@ void vtkSegYReaderInternal::SetVerticalCRS(int v)
this->VerticalCRS = v > 0 ? 1 : 0;
}
//-----------------------------------------------------------------------------
bool vtkSegYReaderInternal::LoadFromFile(std::string path)
{
this->In.open(path, std::ifstream::binary);
if (!this->In)
{
std::cerr << "File not found:" << path << std::endl;
return false;
}
this->ReadHeader();
this->LoadTraces();
this->In.close();
return true;
}
//-----------------------------------------------------------------------------
void vtkSegYReaderInternal::LoadTraces()
{
......@@ -149,8 +132,8 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
&inlineFirst, &crosslineFirst,
&xCoord, &yCoord, &coordMultiplier);
double coordinateMultiplier = decodeMultiplier(coordMultiplier);
coordFirst[0] = xCoord * coordinateMultiplier;
coordFirst[1] = yCoord * coordinateMultiplier;
coordFirst[0] = coordinateMultiplier * xCoord;
coordFirst[1] = coordinateMultiplier * yCoord;
coordFirst[2] = 0;
++crosslineCount;
}
......@@ -162,8 +145,8 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
&inlineNumber, &crosslineSecond,
&xCoord, &yCoord, &coordMultiplier);
double coordinateMultiplier = decodeMultiplier(coordMultiplier);
coordSecondX[0] = xCoord * coordinateMultiplier;
coordSecondX[1] = yCoord * coordinateMultiplier;
coordSecondX[0] = coordinateMultiplier * xCoord;
coordSecondX[1] = coordinateMultiplier * yCoord;
coordSecondX[2] = 0;
++crosslineCount;
}
......@@ -197,8 +180,8 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
}
inlineSecond = inlineNumber;
double coordinateMultiplier = decodeMultiplier(coordMultiplier);
coordSecondY[0] = xCoord * coordinateMultiplier;
coordSecondY[1] = yCoord * coordinateMultiplier;
coordSecondY[0] = coordinateMultiplier * xCoord;
coordSecondY[1] = coordinateMultiplier * yCoord;
coordSecondY[2] = 0;
vtkMath::Subtract(coordSecondY, coordFirst, d);
spacingSign[1] = d[1] >= 0 ? 1 : -1;
......@@ -279,14 +262,13 @@ void vtkSegYReaderInternal::ExportData(vtkStructuredGrid* grid, int* extent)
{
auto trace = this->Traces[j * dims[0] + i];
double coordinateMultiplier = decodeMultiplier(trace->CoordinateMultiplier);
float x = trace->XCoordinate * coordinateMultiplier;
float y = trace->YCoordinate * coordinateMultiplier;
double x = coordinateMultiplier * trace->XCoordinate;
double y = coordinateMultiplier * trace->YCoordinate;
// The samples are uniformly placed at sample interval depths
// Dividing by 1000.0 to convert from microseconds to milliseconds.
float z = sign * k * (trace->SampleInterval / 1000.0);
double z = sign * k * (trace->SampleInterval / 1000.0);
points->InsertNextPoint(x, y, z);
scalars->InsertValue(id++, trace->Data[k]);
}
}
......
......@@ -35,8 +35,6 @@ public:
~vtkSegYReaderInternal();
public:
bool LoadFromFile(std::string path);
bool Is3DComputeParameters(int* extent, double* origin, double* spacing, int* spacingSign);
void LoadTraces();
......
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