mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Basic seismic support (#10010)
Add basic seismic section support to eclipse and geomech views.
This commit is contained in:
@@ -77,6 +77,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRftSegment.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifPressureDepthTextFileReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifReaderPressureDepthData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSeismicZGYReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifOpmGridTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvSummaryReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRevealSummaryCsvReader.h
|
||||
@@ -160,6 +161,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRftSegment.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifPressureDepthTextFileReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifReaderPressureDepthData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSeismicZGYReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifOpmGridTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvSummaryReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRevealCsvSummaryReader.cpp
|
||||
|
300
ApplicationLibCode/FileInterface/RifSeismicZGYReader.cpp
Normal file
300
ApplicationLibCode/FileInterface/RifSeismicZGYReader.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RifSeismicZGYReader.h"
|
||||
|
||||
#include <zgyaccess/seismicslice.h>
|
||||
#include <zgyaccess/zgyreader.h>
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSeismicZGYReader::RifSeismicZGYReader()
|
||||
: m_filename( "" )
|
||||
, m_reader( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSeismicZGYReader::~RifSeismicZGYReader()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSeismicZGYReader::open( QString filename )
|
||||
{
|
||||
if ( isOpen() ) close();
|
||||
|
||||
m_filename = filename;
|
||||
|
||||
try
|
||||
{
|
||||
m_reader = std::make_unique<ZGYAccess::ZGYReader>();
|
||||
if ( !m_reader->open( filename.toStdString() ) )
|
||||
{
|
||||
m_reader.reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch ( const std::exception& err )
|
||||
{
|
||||
m_reader.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSeismicZGYReader::isOpen() const
|
||||
{
|
||||
return m_reader.get() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSeismicZGYReader::isValid()
|
||||
{
|
||||
if ( !isOpen() ) return false;
|
||||
|
||||
bool valid = ( zStep() > 0.0 ) && ( inlineMinMaxStep()[2] > 0 ) && ( xlineMinMaxStep()[2] > 0 );
|
||||
return valid;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifSeismicZGYReader::close()
|
||||
{
|
||||
if ( !isOpen() ) return;
|
||||
|
||||
try
|
||||
{
|
||||
m_reader->close();
|
||||
}
|
||||
catch ( const std::exception& )
|
||||
{
|
||||
}
|
||||
|
||||
m_reader.reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<QString, QString>> RifSeismicZGYReader::metaData()
|
||||
{
|
||||
std::vector<std::pair<QString, QString>> retValues;
|
||||
|
||||
if ( !isOpen() ) return retValues;
|
||||
|
||||
auto stats = m_reader->metaData();
|
||||
|
||||
for ( auto& [name, val] : stats )
|
||||
{
|
||||
retValues.push_back( std::make_pair( QString::fromStdString( name ), QString::fromStdString( val ) ) );
|
||||
}
|
||||
|
||||
return retValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RifSeismicZGYReader::boundingBox()
|
||||
{
|
||||
cvf::BoundingBox retBox;
|
||||
|
||||
if ( isOpen() )
|
||||
{
|
||||
auto [zmin, zmax] = m_reader->zRange();
|
||||
|
||||
auto outline = m_reader->seismicWorldOutline();
|
||||
|
||||
auto corners = outline.points();
|
||||
for ( auto p : corners )
|
||||
{
|
||||
retBox.add( cvf::Vec3d( p.x(), p.y(), -zmin ) );
|
||||
retBox.add( cvf::Vec3d( p.x(), p.y(), -zmax ) );
|
||||
}
|
||||
}
|
||||
|
||||
return retBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifSeismicZGYReader::histogramData( std::vector<double>& xvals, std::vector<double>& yvals )
|
||||
{
|
||||
if ( !isOpen() ) return;
|
||||
|
||||
auto histdata = m_reader->histogram();
|
||||
|
||||
xvals = histdata->Xvalues;
|
||||
yvals = histdata->Yvalues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<double, double> RifSeismicZGYReader::dataRange()
|
||||
{
|
||||
if ( !isOpen() ) return std::make_pair( 0.0, 0.0 );
|
||||
|
||||
return m_reader->dataRange();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RifSeismicZGYReader::worldCorners()
|
||||
{
|
||||
if ( !isOpen() ) return {};
|
||||
|
||||
auto [zmin, zmax] = m_reader->zRange();
|
||||
auto outline = m_reader->seismicWorldOutline();
|
||||
|
||||
std::vector<cvf::Vec3d> retval;
|
||||
|
||||
for ( auto p : outline.points() )
|
||||
{
|
||||
retval.push_back( cvf::Vec3d( p.x(), p.y(), -zmin ) );
|
||||
retval.push_back( cvf::Vec3d( p.x(), p.y(), -zmax ) );
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RifSeismicZGYReader::zStep()
|
||||
{
|
||||
if ( !isOpen() ) return 0.0;
|
||||
|
||||
return m_reader->zStep();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RifSeismicZGYReader::zSize()
|
||||
{
|
||||
if ( !isOpen() ) return 0;
|
||||
|
||||
return m_reader->zSize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3i RifSeismicZGYReader::inlineMinMaxStep()
|
||||
{
|
||||
if ( !isOpen() ) return { 0, 0, 0 };
|
||||
|
||||
auto [minVal, maxVal] = m_reader->inlineRange();
|
||||
int step = m_reader->inlineStep();
|
||||
|
||||
return { minVal, maxVal, step };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3i RifSeismicZGYReader::xlineMinMaxStep()
|
||||
{
|
||||
if ( !isOpen() ) return { 0, 0, 0 };
|
||||
|
||||
auto [minVal, maxVal] = m_reader->xlineRange();
|
||||
int step = m_reader->xlineStep();
|
||||
|
||||
return { minVal, maxVal, step };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RifSeismicZGYReader::convertToWorldCoords( int iLine, int xLine, double depth )
|
||||
{
|
||||
if ( !isOpen() ) return { 0, 0, 0 };
|
||||
|
||||
auto [x, y] = m_reader->toWorldCoordinate( iLine, xLine );
|
||||
|
||||
return cvf::Vec3d( x, y, depth );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<int, int> RifSeismicZGYReader::convertToInlineXline( double worldx, double worldy )
|
||||
{
|
||||
if ( !isOpen() ) return { 0, 0 };
|
||||
|
||||
return m_reader->toInlineXline( worldx, worldy );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<ZGYAccess::SeismicSliceData>
|
||||
RifSeismicZGYReader::slice( RiaDefines::SeismicSliceDirection direction, int sliceIndex, int zStartIndex, int zSize )
|
||||
{
|
||||
if ( isOpen() )
|
||||
{
|
||||
switch ( direction )
|
||||
{
|
||||
case RiaDefines::SeismicSliceDirection::INLINE:
|
||||
if ( zStartIndex < 0 ) return m_reader->inlineSlice( sliceIndex );
|
||||
return m_reader->inlineSlice( sliceIndex, zStartIndex, zSize );
|
||||
case RiaDefines::SeismicSliceDirection::XLINE:
|
||||
if ( zStartIndex < 0 ) return m_reader->xlineSlice( sliceIndex );
|
||||
return m_reader->xlineSlice( sliceIndex, zStartIndex, zSize );
|
||||
case RiaDefines::SeismicSliceDirection::DEPTH:
|
||||
return m_reader->zSlice( sliceIndex );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<ZGYAccess::SeismicSliceData> RifSeismicZGYReader::trace( int inlineIndex, int xlineIndex, int zStartIndex, int zSize )
|
||||
{
|
||||
if ( isOpen() )
|
||||
{
|
||||
if ( zStartIndex < 0 ) return m_reader->zTrace( inlineIndex, xlineIndex );
|
||||
return m_reader->zTrace( inlineIndex, xlineIndex, zStartIndex, zSize );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
81
ApplicationLibCode/FileInterface/RifSeismicZGYReader.h
Normal file
81
ApplicationLibCode/FileInterface/RifSeismicZGYReader.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RiaSeismicDefines.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ZGYAccess
|
||||
{
|
||||
class ZGYReader;
|
||||
class SeismicSliceData;
|
||||
} // namespace ZGYAccess
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
} // namespace cvf
|
||||
|
||||
class RifSeismicZGYReader
|
||||
{
|
||||
public:
|
||||
RifSeismicZGYReader();
|
||||
~RifSeismicZGYReader();
|
||||
|
||||
bool open( QString filename );
|
||||
void close();
|
||||
|
||||
bool isValid();
|
||||
|
||||
bool isOpen() const;
|
||||
|
||||
std::vector<std::pair<QString, QString>> metaData();
|
||||
|
||||
cvf::BoundingBox boundingBox();
|
||||
|
||||
void histogramData( std::vector<double>& xvals, std::vector<double>& yvals );
|
||||
|
||||
std::pair<double, double> dataRange();
|
||||
|
||||
std::vector<cvf::Vec3d> worldCorners();
|
||||
|
||||
cvf::Vec3i inlineMinMaxStep();
|
||||
cvf::Vec3i xlineMinMaxStep();
|
||||
|
||||
double zStep();
|
||||
int zSize();
|
||||
|
||||
cvf::Vec3d convertToWorldCoords( int iLine, int xLine, double depth );
|
||||
std::pair<int, int> convertToInlineXline( double worldx, double worldy );
|
||||
|
||||
std::shared_ptr<ZGYAccess::SeismicSliceData>
|
||||
slice( RiaDefines::SeismicSliceDirection direction, int sliceIndex, int zStartIndex = -1, int zSize = 0 );
|
||||
std::shared_ptr<ZGYAccess::SeismicSliceData> trace( int inlineIndex, int xlineIndex, int zStartIndex = -1, int zSize = 0 );
|
||||
|
||||
private:
|
||||
QString m_filename;
|
||||
std::unique_ptr<ZGYAccess::ZGYReader> m_reader;
|
||||
};
|
Reference in New Issue
Block a user