mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Sets depth property for regular file surfaces
Ensures that the depth property is correctly set for regular file surfaces after loading data. This allows the property to be utilized as a depth value.
This commit is contained in:
1 parent
60eb77ec67
commit
0eb980e8e1
8 files changed
+17
-18
No files matched your search
@@ -110,9 +110,9 @@ void RicImportEnsembleSurfaceFeature::importSingleEnsembleSurfaceFromFiles( cons
|
||||
std::map<QString, QStringList> keyFileComponentsForAllFiles = RiaFilePathTools::keyPathComponentsForEachFilePath( layerFileNames );
|
||||
|
||||
std::vector<RimSurface*> surfaces;
|
||||
for ( int i = 0; i < layerFileNames.size(); i++ )
|
||||
for ( const auto& layerFileName : layerFileNames )
|
||||
{
|
||||
surfaces.push_back( RimSurfaceCollection::createSurfaceFromFile( layerFileNames[i] ) );
|
||||
surfaces.push_back( RimSurfaceCollection::createSurfaceFromFile( layerFileName ) );
|
||||
}
|
||||
|
||||
auto fileCount = static_cast<int>( layerFileNames.size() );
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimRegularFileSurface, "RegularFileSurface" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimRegularFileSurface::propertyName()
|
||||
{
|
||||
return "Property Values in File";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -72,8 +80,7 @@ bool RimRegularFileSurface::onLoadData()
|
||||
|
||||
if ( !values.empty() )
|
||||
{
|
||||
const QString propertyName = "File Property Values";
|
||||
setProperty( propertyName, values );
|
||||
setProperty( RimRegularFileSurface::propertyName(), values );
|
||||
}
|
||||
|
||||
RimRegularSurface::onLoadData();
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
|
||||
bool onLoadData() override;
|
||||
|
||||
static QString propertyName();
|
||||
|
||||
// File-based surface interface (from RimSurface)
|
||||
bool isFileBased() const override { return true; }
|
||||
QString filePath() const override;
|
||||
|
||||
@@ -390,12 +390,9 @@ void RimRegularSurface::setProperty( const QString& key, const std::vector<float
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimRegularSurface::setPropertyAsDepth( const QString& key )
|
||||
void RimRegularSurface::setPropertyAsDepth( const QString& key )
|
||||
{
|
||||
if ( !m_properties.contains( key ) ) return false;
|
||||
|
||||
m_depthProperty = key;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
void setRotation( double rotation );
|
||||
|
||||
void setProperty( const QString& key, const std::vector<float>& values );
|
||||
bool setPropertyAsDepth( const QString& key );
|
||||
void setPropertyAsDepth( const QString& key );
|
||||
|
||||
int nx() const;
|
||||
int ny() const;
|
||||
|
||||
@@ -151,6 +151,7 @@ RimSurface* RimSurfaceCollection::createSurfaceFromFile( const QString& fileName
|
||||
{
|
||||
auto regularFileSurface = new RimRegularFileSurface;
|
||||
regularFileSurface->setFilePath( fileName );
|
||||
regularFileSurface->setPropertyAsDepth( RimRegularFileSurface::propertyName() );
|
||||
newSurface = regularFileSurface;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -94,8 +94,7 @@ std::expected<caf::PdmObjectHandle*, QString> RimcRegularSurface_setPropertyAsDe
|
||||
RimRegularSurface* surface = self<RimRegularSurface>();
|
||||
if ( !surface ) return std::unexpected( "No surface found" );
|
||||
|
||||
if ( !surface->setPropertyAsDepth( m_name ) ) return std::unexpected( "Failed to set depth property." );
|
||||
|
||||
surface->setPropertyAsDepth( m_name );
|
||||
surface->onLoadData();
|
||||
|
||||
if ( auto coll = surface->firstAncestorOrThisOfType<RimSurfaceCollection>() )
|
||||
|
||||
@@ -68,9 +68,6 @@ def test_create_regular_surface(rips_instance, initialize_test):
|
||||
assert s.nx == nx
|
||||
assert s.ny == ny
|
||||
|
||||
with pytest.raises(rips.RipsError, match="Failed to set depth property."):
|
||||
s.set_property_as_depth(name="non_existing_property")
|
||||
|
||||
with pytest.raises(
|
||||
rips.RipsError, match="Failed to set property: incorrect dimensions."
|
||||
):
|
||||
@@ -84,10 +81,6 @@ def test_create_regular_surface(rips_instance, initialize_test):
|
||||
s.nx = 30
|
||||
s.update()
|
||||
|
||||
# 'depth' property is now gone
|
||||
with pytest.raises(rips.RipsError, match="Failed to set depth property."):
|
||||
s.set_property_as_depth(name="depth")
|
||||
|
||||
|
||||
def test_create_regular_surface_invalid_values(rips_instance, initialize_test):
|
||||
case_path = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
|
||||
|
||||
Reference in new issue
Block a user