2015-04-23 06:24:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-04-23 06:24:15 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-04-23 06:24:15 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-04-23 06:24:15 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RifGeoMechReaderInterface.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RifGeoMechReaderInterface::RifGeoMechReaderInterface()
|
2023-01-24 11:30:30 -06:00
|
|
|
: m_readOnlyLastFrame( false )
|
2020-02-12 04:13:38 -06:00
|
|
|
{
|
|
|
|
}
|
2015-04-23 06:24:15 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-04-23 06:24:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RifGeoMechReaderInterface::~RifGeoMechReaderInterface()
|
|
|
|
{
|
|
|
|
}
|
2018-06-11 06:47:21 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-06-11 06:47:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-01-24 11:30:30 -06:00
|
|
|
void RifGeoMechReaderInterface::setTimeStepFilter( const std::vector<size_t>& fileTimeStepIndices, bool readOnlyLastFrame )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_fileTimeStepIndices.reserve( fileTimeStepIndices.size() );
|
|
|
|
for ( size_t stepIndex : fileTimeStepIndices )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_fileTimeStepIndices.push_back( static_cast<int>( stepIndex ) );
|
2018-06-11 06:47:21 -05:00
|
|
|
}
|
2023-01-24 11:30:30 -06:00
|
|
|
|
|
|
|
m_readOnlyLastFrame = readOnlyLastFrame;
|
2018-06-11 06:47:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-06-11 06:47:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RifGeoMechReaderInterface::isTimeStepIncludedByFilter( int timeStepIndex ) const
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( timeStepIndex >= 0 );
|
|
|
|
if ( m_fileTimeStepIndices.empty() ) return true;
|
2018-06-11 06:47:21 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto i : m_fileTimeStepIndices )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( i == static_cast<size_t>( timeStepIndex ) )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-06-11 06:47:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
int RifGeoMechReaderInterface::timeStepIndexOnFile( int timeStepIndex ) const
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_fileTimeStepIndices.empty() )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
|
|
|
return timeStepIndex;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( timeStepIndex >= 0 );
|
|
|
|
CVF_ASSERT( static_cast<size_t>( timeStepIndex ) < m_fileTimeStepIndices.size() );
|
2018-06-11 06:47:21 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( static_cast<size_t>( timeStepIndex ) < m_fileTimeStepIndices.size() )
|
2018-06-11 06:47:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return static_cast<int>( m_fileTimeStepIndices[timeStepIndex] );
|
2018-06-11 06:47:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return timeStepIndex;
|
2023-01-24 11:30:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RifGeoMechReaderInterface::frameIndexOnFile( int frameIndex ) const
|
|
|
|
{
|
|
|
|
if ( m_readOnlyLastFrame ) return -1;
|
|
|
|
return frameIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RifGeoMechReaderInterface::shouldReadOnlyLastFrame() const
|
|
|
|
{
|
|
|
|
return m_readOnlyLastFrame;
|
|
|
|
}
|