Commit 2620aa3f authored by Dan Lipsa's avatar Dan Lipsa

Flip data if increment is negative.

parent d14ec760
......@@ -67,6 +67,7 @@ int TestSegY3DReader(int argc, char* argv[])
ren->AddActor(actor);
ren->ResetCamera();
ren->GetActiveCamera()->Azimuth(180);
// interact with data
renWin->Render();
......
ccc5e3ba5421472dee0a7adbe475f793
f5d279d0735939b1499c2bf9be485895
......@@ -37,10 +37,10 @@ vtkSegYReader::vtkSegYReader()
this->Reader = new vtkSegYReaderInternal();
this->FileName = nullptr;
this->Is3D = false;
this->DataOrigin[0] = this->DataOrigin[1] = this->DataOrigin[2] = 0.0;
this->DataSpacing[0] = this->DataSpacing[1] = this->DataSpacing[2] = 1.0;
this->DataExtent[0] = this->DataExtent[2] = this->DataExtent[4] = 0;
this->DataExtent[1] = this->DataExtent[3] = this->DataExtent[5] = 0;
std::fill(this->DataOrigin, this->DataOrigin + 3, 0.0);
std::fill(this->DataSpacing, this->DataSpacing + 3, 1.0);
std::fill(this->DataSpacingSign, this->DataSpacingSign + 3, 1);
std::fill(this->DataExtent, this->DataExtent + 6, 0);
this->XYCoordMode = VTK_SEGY_SOURCE;
this->StructuredGrid = 0;
......@@ -129,8 +129,9 @@ int vtkSegYReader::RequestData(vtkInformation* vtkNotUsed(request),
this->UpdateProgress(0.5);
if (this->Is3D && ! this->StructuredGrid)
{
this->Reader->ExportData(vtkImageData::SafeDownCast(output),
this->DataExtent, this->DataOrigin, this->DataSpacing);
this->Reader->ExportData(
vtkImageData::SafeDownCast(output), this->DataExtent,
this->DataOrigin, this->DataSpacing, this->DataSpacingSign);
}
else
{
......@@ -166,6 +167,8 @@ int vtkSegYReader::RequestInformation(vtkInformation * vtkNotUsed(request),
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);
......@@ -207,7 +210,7 @@ int vtkSegYReader::RequestDataObject(
return 0;
}
this->Is3D = this->Reader->Is3DComputeParameters(
this->DataExtent, this->DataOrigin, this->DataSpacing);
this->DataExtent, this->DataOrigin, this->DataSpacing, this->DataSpacingSign);
const char* outputTypeName = this->Is3D ? "vtkImageData" : "vtkStructuredGrid";
if (!output || !output->IsA(outputTypeName))
......
......@@ -28,10 +28,11 @@ class vtkSegYReaderInternal;
* @class vtkSegYReader
* @brief Reads SegY data files.
*
* vtkSegYReader read the SegY data format. We create a
* vtkStructuredGrid for a 2.5D data and an vtkImageData for a 3D
* data. The structure of the data is created in the following order:
* crossline number, inline number, depth
* vtkSegYReader reads SegY data files. We create a
* vtkStructuredGrid for 2.5D SegY data and an vtkImageData for a 3D SegY
* data. If we set the StructuredGrid option we create a vtkStructuredGrid
* for 3D data to show the exact position for each point. The axes for
* the data are: crossline, inline, depth
*/
class VTKIOSEGY_EXPORT vtkSegYReader : public vtkDataSetAlgorithm
{
......@@ -105,9 +106,9 @@ public:
//@{
/**
* Specify if we create a vtkStructuredGrid even if the data is
* Specify if we create a vtkStructuredGrid even when the data is
* 3D. Note this consumes more memory but it shows the precise
* location of the data. It may be useful if we want to show several
* location for each point. This may be useful if we want to show several
* datasets in the same window. The default value is false
* which means that we create a vtkImageData for a SegY 3D dataset.
*/
......@@ -135,6 +136,7 @@ protected:
bool Is3D;
double DataOrigin[3];
double DataSpacing[3];
int DataSpacingSign[3];
int DataExtent[6];
int XYCoordMode;
......
......@@ -130,7 +130,7 @@ bool vtkSegYReaderInternal::ReadHeader()
//-----------------------------------------------------------------------------
bool vtkSegYReaderInternal::Is3DComputeParameters(
int* extent, double* origin, double* spacing)
int* extent, double* origin, double* spacing, int* spacingSign)
{
this->ReadHeader();
int traceStartPos = FIRST_TRACE_START_POS;
......@@ -167,7 +167,8 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
coordSecondX[2] = 0;
++crosslineCount;
}
vtkMath::Subtract(coordFirst, coordSecondX, d);
vtkMath::Subtract(coordSecondX, coordFirst, d);
spacingSign[0] = d[0] >= 0 ? 1 : -1;
float xStep = vtkMath::Norm(d);
while(inlineFirst == inlineNumber && traceStartPos + 240 < fileSize)
{
......@@ -199,7 +200,9 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
coordSecondY[0] = xCoord * coordinateMultiplier;
coordSecondY[1] = yCoord * coordinateMultiplier;
coordSecondY[2] = 0;
vtkMath::Subtract(coordFirst, coordSecondY, d);
vtkMath::Subtract(coordSecondY, coordFirst, d);
spacingSign[1] = d[1] >= 0 ? 1 : -1;
spacingSign[2] = (this->VerticalCRS == 0 ? -1 : 1); // goes
float yStep = vtkMath::Norm(d);
// The samples are uniformly placed at sample interval depths
......@@ -218,8 +221,9 @@ bool vtkSegYReaderInternal::Is3DComputeParameters(
//-----------------------------------------------------------------------------
void vtkSegYReaderInternal::ExportData(vtkImageData* imageData,
int* extent, double* origin, double* spacing)
void vtkSegYReaderInternal::ExportData(
vtkImageData* imageData,
int* extent, double* origin, double* spacing, int* spacingSign)
{
imageData->SetExtent(extent);
imageData->SetOrigin(origin);
......@@ -232,14 +236,18 @@ void vtkSegYReaderInternal::ExportData(vtkImageData* imageData,
scalars->SetName("trace");
imageData->GetPointData()->SetScalars(scalars);
int id = 0;
int destK, destJ, destI;
for (int k = 0; k < dims[2]; ++k)
{
destK = (spacingSign[2] > 0 ? k : dims[2] - k - 1);
for (int j = 0; j < dims[1]; ++j)
{
destJ = (spacingSign[1] > 0 ? j : dims[1] - j - 1);
for (int i = 0; i < dims[0]; ++i)
{
vtkSegYTrace* trace = this->Traces[j * dims[0] + i];
scalars->SetValue(id++, trace->Data[k]);
destI = (spacingSign[0] > 0 ? i : dims[0] - i - 1);
vtkSegYTrace* trace = this->Traces[destJ * dims[0] + destI];
scalars->SetValue(id++, trace->Data[destK]);
}
}
}
......
......@@ -37,10 +37,11 @@ public:
public:
bool LoadFromFile(std::string path);
bool Is3DComputeParameters(int* extent, double* origin, double* spacing);
bool Is3DComputeParameters(int* extent, double* origin, double* spacing, int* spacingSign);
void LoadTraces();
void ExportData(vtkImageData*, int* extent, double* origin, double* spacing);
void ExportData(vtkImageData*, int* extent,
double* origin, double* spacing, int* spacingSign);
void ExportData(vtkStructuredGrid*, int* extent);
void SetXYCoordBytePositions(int x, int y);
......
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