mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7927 Add user interface for exporting multiple surfaces.
This commit is contained in:
parent
1e43fd4c36
commit
2b3fbe022e
@ -73,6 +73,8 @@ set(SOURCE_GROUP_HEADER_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesUi.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_GROUP_SOURCE_FILES
|
set(SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -149,6 +151,8 @@ set(SOURCE_GROUP_SOURCE_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicDeletePressureTableItemFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCaseFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicImportGridModelFromSummaryCurveFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicGenerateMultipleSurfacesUi.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(Qt5Charts_FOUND)
|
if(Qt5Charts_FOUND)
|
||||||
|
@ -0,0 +1,135 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2021- 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 "RicGenerateMultipleSurfacesFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
|
#include "CommandRouter/RimcExtractSurfaces.h"
|
||||||
|
#include "RicGenerateMultipleSurfacesUi.h"
|
||||||
|
#include "RicImportEnsembleSurfaceFeature.h"
|
||||||
|
#include "RicRecursiveFileSearchDialog.h"
|
||||||
|
#include "RimDialogData.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
|
||||||
|
#include "Riu3DMainWindowTools.h"
|
||||||
|
#include "RiuPropertyViewTabWidget.h"
|
||||||
|
|
||||||
|
#include "cafCmdFeatureManager.h"
|
||||||
|
#include "cafPdmSettings.h"
|
||||||
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
|
#include "cafProgressInfo.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT( RicGenerateMultipleSurfacesFeature, "RicGenerateMultipleSurfacesFeature" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesFeature::openDialogAndExecuteCommand()
|
||||||
|
{
|
||||||
|
// Get the list of egrid files
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
|
||||||
|
|
||||||
|
QString pathFilter( "*" );
|
||||||
|
QString fileNameFilter( "*" );
|
||||||
|
|
||||||
|
RicRecursiveFileSearchDialogResult result =
|
||||||
|
RicRecursiveFileSearchDialog::runRecursiveSearchDialog( nullptr,
|
||||||
|
"Choose Eclipse Cases",
|
||||||
|
defaultDir,
|
||||||
|
pathFilter,
|
||||||
|
fileNameFilter,
|
||||||
|
QStringList( ".EGRID" ) );
|
||||||
|
|
||||||
|
if ( !result.ok || result.files.isEmpty() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read min/max k layer from first grid case
|
||||||
|
int minLayerK = -1;
|
||||||
|
int maxLayerK = -1;
|
||||||
|
if ( !RimcCommandRouter_extractSurfaces::readMinMaxLayerFromGridFile( result.files[0], minLayerK, maxLayerK ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
RicGenerateMultipleSurfacesUi* ui = RimProject::current()->dialogData()->generateEnsembleSurfacesUi();
|
||||||
|
ui->setLayersMinMax( minLayerK, maxLayerK );
|
||||||
|
|
||||||
|
RiuPropertyViewTabWidget propertyDialog( Riu3DMainWindowTools::mainWindowWidget(),
|
||||||
|
ui,
|
||||||
|
"Export Multiple Surfaces",
|
||||||
|
ui->tabNames() );
|
||||||
|
|
||||||
|
if ( propertyDialog.exec() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
executeCommand( *ui, result.files.toStdList() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesFeature::executeCommand( const RicGenerateMultipleSurfacesUi& ui,
|
||||||
|
const std::list<QString>& fileNames )
|
||||||
|
{
|
||||||
|
std::vector layers = ui.layers();
|
||||||
|
|
||||||
|
caf::ProgressInfo progress( fileNames.size(), "Generating ensemble surfaces" );
|
||||||
|
|
||||||
|
QStringList allSurfaceFileNames;
|
||||||
|
for ( auto fileName : fileNames )
|
||||||
|
{
|
||||||
|
auto task = progress.task( QString( "Extracting surfaces for %1" ).arg( fileName ) );
|
||||||
|
auto [isOk, surfaceFileNames] = RimcCommandRouter_extractSurfaces::extractSurfaces( fileName, layers );
|
||||||
|
if ( isOk ) allSurfaceFileNames << surfaceFileNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ui.autoCreateEnsembleSurfaces() )
|
||||||
|
RicImportEnsembleSurfaceFeature::importEnsembleSurfaceFromFiles( allSurfaceFileNames );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicGenerateMultipleSurfacesFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesFeature::onActionTriggered( bool isChecked )
|
||||||
|
{
|
||||||
|
openDialogAndExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesFeature::setupActionLook( QAction* actionToSetup )
|
||||||
|
{
|
||||||
|
actionToSetup->setText( "Generate Multiple Surfaces..." );
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2021- 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 "cafCmdFeature.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class RicGenerateMultipleSurfacesUi;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicGenerateMultipleSurfacesFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void openDialogAndExecuteCommand();
|
||||||
|
static void executeCommand( const RicGenerateMultipleSurfacesUi& ui, const std::list<QString>& fileNames );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool isCommandEnabled() override;
|
||||||
|
void onActionTriggered( bool isChecked ) override;
|
||||||
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
};
|
141
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.cpp
Normal file
141
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.cpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2021- 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 "RicGenerateMultipleSurfacesUi.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "cafPdmObject.h"
|
||||||
|
#include "cafPdmUiListEditor.h"
|
||||||
|
#include "cafPdmUiOrdering.h"
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT( RicGenerateMultipleSurfacesUi, "RicGenerateMultipleSurfacesUi" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RicGenerateMultipleSurfacesUi::RicGenerateMultipleSurfacesUi()
|
||||||
|
{
|
||||||
|
CAF_PDM_InitObject( "Export Multiple Surfaces", "", "", "" );
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_layers, "Layers", "Layers", "", "", "" );
|
||||||
|
CAF_PDM_InitField( &m_autoCreateEnsembleSurfaces,
|
||||||
|
"AutoCreateEnsembleSurfaces",
|
||||||
|
false,
|
||||||
|
"Create Ensemble Surfaces From Exported Files",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"" );
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_minLayer, "MinLayer", "MinLayer", "", "", "" );
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_maxLayer, "MaxLayer", "MaxLayer", "", "", "" );
|
||||||
|
|
||||||
|
m_tabNames << "Layers"
|
||||||
|
<< "Ensemble Surfaces";
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RicGenerateMultipleSurfacesUi::~RicGenerateMultipleSurfacesUi()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const QStringList& RicGenerateMultipleSurfacesUi::tabNames() const
|
||||||
|
{
|
||||||
|
return m_tabNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesUi::setLayersMinMax( int minLayer, int maxLayer )
|
||||||
|
{
|
||||||
|
m_minLayer = minLayer;
|
||||||
|
m_maxLayer = maxLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesUi::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute )
|
||||||
|
{
|
||||||
|
if ( field == &m_layers )
|
||||||
|
{
|
||||||
|
caf::PdmUiListEditorAttribute* myAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
|
||||||
|
if ( myAttr )
|
||||||
|
{
|
||||||
|
myAttr->m_heightHint = 280;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicGenerateMultipleSurfacesUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||||
|
{
|
||||||
|
if ( uiConfigName == m_tabNames[0] )
|
||||||
|
{
|
||||||
|
uiOrdering.add( &m_layers );
|
||||||
|
}
|
||||||
|
else if ( uiConfigName == m_tabNames[1] )
|
||||||
|
{
|
||||||
|
uiOrdering.add( &m_autoCreateEnsembleSurfaces );
|
||||||
|
}
|
||||||
|
uiOrdering.skipRemainingFields( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QList<caf::PdmOptionItemInfo>
|
||||||
|
RicGenerateMultipleSurfacesUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
|
bool* useOptionsOnly )
|
||||||
|
{
|
||||||
|
QList<caf::PdmOptionItemInfo> options;
|
||||||
|
if ( fieldNeedingOptions == &m_layers )
|
||||||
|
{
|
||||||
|
for ( int layer = m_minLayer; layer < m_maxLayer; layer++ )
|
||||||
|
{
|
||||||
|
options.push_back( caf::PdmOptionItemInfo( QString::number( layer ), layer ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<int> RicGenerateMultipleSurfacesUi::layers() const
|
||||||
|
{
|
||||||
|
return m_layers();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicGenerateMultipleSurfacesUi::autoCreateEnsembleSurfaces() const
|
||||||
|
{
|
||||||
|
return m_autoCreateEnsembleSurfaces;
|
||||||
|
}
|
62
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.h
Normal file
62
ApplicationLibCode/Commands/RicGenerateMultipleSurfacesUi.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2021- 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 "cafPdmField.h"
|
||||||
|
#include "cafPdmObject.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
class RigEclipseCaseData;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicGenerateMultipleSurfacesUi : public caf::PdmObject
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RicGenerateMultipleSurfacesUi();
|
||||||
|
~RicGenerateMultipleSurfacesUi() override;
|
||||||
|
const QStringList& tabNames() const;
|
||||||
|
|
||||||
|
void setLayersMinMax( int minLayer, int maxLayer );
|
||||||
|
|
||||||
|
std::vector<int> layers() const;
|
||||||
|
|
||||||
|
bool autoCreateEnsembleSurfaces() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute ) override;
|
||||||
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
|
|
||||||
|
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
|
bool* useOptionsOnly ) override;
|
||||||
|
|
||||||
|
caf::PdmField<std::vector<int>> m_layers;
|
||||||
|
caf::PdmField<bool> m_autoCreateEnsembleSurfaces;
|
||||||
|
caf::PdmField<int> m_minLayer;
|
||||||
|
caf::PdmField<int> m_maxLayer;
|
||||||
|
|
||||||
|
QStringList m_tabNames;
|
||||||
|
};
|
@ -23,6 +23,7 @@
|
|||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
#include "RiaSummaryTools.h"
|
#include "RiaSummaryTools.h"
|
||||||
|
|
||||||
|
#include "RicImportEnsembleFeature.h"
|
||||||
#include "RicRecursiveFileSearchDialog.h"
|
#include "RicRecursiveFileSearchDialog.h"
|
||||||
|
|
||||||
#include "RimEnsembleSurface.h"
|
#include "RimEnsembleSurface.h"
|
||||||
@ -63,6 +64,13 @@ void RicImportEnsembleSurfaceFeature::onActionTriggered( bool isChecked )
|
|||||||
RiaApplication* app = RiaApplication::instance();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
QString pathCacheName = "ENSEMBLE_SURFACE_FILES";
|
QString pathCacheName = "ENSEMBLE_SURFACE_FILES";
|
||||||
QStringList fileNames = runRecursiveFileSearchDialog( "Import Ensemble Surface", pathCacheName );
|
QStringList fileNames = runRecursiveFileSearchDialog( "Import Ensemble Surface", pathCacheName );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicImportEnsembleSurfaceFeature::importEnsembleSurfaceFromFiles( const QStringList& fileNames )
|
||||||
|
{
|
||||||
if ( fileNames.isEmpty() ) return;
|
if ( fileNames.isEmpty() ) return;
|
||||||
|
|
||||||
QString ensembleName = RiaEnsembleNameTools::findSuitableEnsembleName( fileNames );
|
QString ensembleName = RiaEnsembleNameTools::findSuitableEnsembleName( fileNames );
|
||||||
|
@ -27,10 +27,13 @@
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RicImportEnsembleSurfaceFeature : public caf::CmdFeature
|
class RicImportEnsembleSurfaceFeature : public caf::CmdFeature
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
RicImportEnsembleSurfaceFeature();
|
RicImportEnsembleSurfaceFeature();
|
||||||
|
|
||||||
|
static void importEnsembleSurfaceFromFiles( const QStringList& fileNames );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides
|
// Overrides
|
||||||
bool isCommandEnabled() override;
|
bool isCommandEnabled() override;
|
||||||
|
@ -970,6 +970,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
|||||||
menuBuilder << "RicImportSurfacesFeature";
|
menuBuilder << "RicImportSurfacesFeature";
|
||||||
menuBuilder << "RicNewGridSurfaceFeature";
|
menuBuilder << "RicNewGridSurfaceFeature";
|
||||||
menuBuilder << "RicImportEnsembleSurfaceFeature";
|
menuBuilder << "RicImportEnsembleSurfaceFeature";
|
||||||
|
menuBuilder << "RicGenerateMultipleSurfacesFeature";
|
||||||
menuBuilder.addSeparator();
|
menuBuilder.addSeparator();
|
||||||
menuBuilder << "RicNewSurfaceCollectionFeature";
|
menuBuilder << "RicNewSurfaceCollectionFeature";
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "ExportCommands/RicExportWellPathsUi.h"
|
#include "ExportCommands/RicExportWellPathsUi.h"
|
||||||
#include "FractureCommands/RicCreateMultipleFracturesUi.h"
|
#include "FractureCommands/RicCreateMultipleFracturesUi.h"
|
||||||
#include "HoloLensCommands/RicHoloLensExportToFolderUi.h"
|
#include "HoloLensCommands/RicHoloLensExportToFolderUi.h"
|
||||||
|
#include "RicGenerateMultipleSurfacesUi.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT( RimDialogData, "RimDialogData" );
|
CAF_PDM_SOURCE_INIT( RimDialogData, "RimDialogData" );
|
||||||
|
|
||||||
@ -65,6 +66,14 @@ RimDialogData::RimDialogData()
|
|||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_mockModelSettings, "MockModelSettings", "Mock Model Settings", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_mockModelSettings, "MockModelSettings", "Mock Model Settings", "", "", "" );
|
||||||
m_mockModelSettings = new RimMockModelSettings();
|
m_mockModelSettings = new RimMockModelSettings();
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_generateEnsembleSurfacesUi,
|
||||||
|
"GenerateMultipleSurfacesUi",
|
||||||
|
"Generate Ensmeble Surfaces Ui",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"" );
|
||||||
|
m_generateEnsembleSurfacesUi = new RicGenerateMultipleSurfacesUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -155,3 +164,11 @@ RimMockModelSettings* RimDialogData::mockModelSettings() const
|
|||||||
{
|
{
|
||||||
return m_mockModelSettings;
|
return m_mockModelSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RicGenerateMultipleSurfacesUi* RimDialogData::generateEnsembleSurfacesUi() const
|
||||||
|
{
|
||||||
|
return m_generateEnsembleSurfacesUi;
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ class RicHoloLensExportToFolderUi;
|
|||||||
class RicExportWellPathsUi;
|
class RicExportWellPathsUi;
|
||||||
class RicExportLgrUi;
|
class RicExportLgrUi;
|
||||||
class RimMockModelSettings;
|
class RimMockModelSettings;
|
||||||
|
class RicGenerateMultipleSurfacesUi;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -61,6 +62,7 @@ public:
|
|||||||
RicExportLgrUi* exportLgrData() const;
|
RicExportLgrUi* exportLgrData() const;
|
||||||
RicExportEclipseSectorModelUi* exportSectorModelUi() const;
|
RicExportEclipseSectorModelUi* exportSectorModelUi() const;
|
||||||
RimMockModelSettings* mockModelSettings() const;
|
RimMockModelSettings* mockModelSettings() const;
|
||||||
|
RicGenerateMultipleSurfacesUi* generateEnsembleSurfacesUi() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmChildField<RicExportCarfinUi*> m_exportCarfin;
|
caf::PdmChildField<RicExportCarfinUi*> m_exportCarfin;
|
||||||
@ -71,4 +73,5 @@ private:
|
|||||||
caf::PdmChildField<RicExportLgrUi*> m_exportLgrData;
|
caf::PdmChildField<RicExportLgrUi*> m_exportLgrData;
|
||||||
caf::PdmChildField<RicExportEclipseSectorModelUi*> m_exportSectorModelData;
|
caf::PdmChildField<RicExportEclipseSectorModelUi*> m_exportSectorModelData;
|
||||||
caf::PdmChildField<RimMockModelSettings*> m_mockModelSettings;
|
caf::PdmChildField<RimMockModelSettings*> m_mockModelSettings;
|
||||||
|
caf::PdmChildField<RicGenerateMultipleSurfacesUi*> m_generateEnsembleSurfacesUi;
|
||||||
};
|
};
|
||||||
|
@ -56,20 +56,36 @@ RimcCommandRouter_extractSurfaces::RimcCommandRouter_extractSurfaces( caf::PdmOb
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
caf::PdmObjectHandle* RimcCommandRouter_extractSurfaces::execute()
|
caf::PdmObjectHandle* RimcCommandRouter_extractSurfaces::execute()
|
||||||
{
|
{
|
||||||
|
extractSurfaces( m_gridModelFilename, m_layers(), m_minimumI(), m_maximumI(), m_minimumJ(), m_maximumJ() );
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::pair<bool, QStringList> RimcCommandRouter_extractSurfaces::extractSurfaces( const QString& gridModelFilename,
|
||||||
|
const std::vector<int>& layers,
|
||||||
|
int minI,
|
||||||
|
int maxI,
|
||||||
|
int minJ,
|
||||||
|
int maxJ )
|
||||||
|
{
|
||||||
|
QStringList surfaceFileNames;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string filename = m_gridModelFilename().toStdString();
|
std::string filename = gridModelFilename.toStdString();
|
||||||
Opm::EclIO::EGrid grid1( filename );
|
Opm::EclIO::EGrid grid1( filename );
|
||||||
|
|
||||||
auto dims = grid1.dimension();
|
auto dims = grid1.dimension();
|
||||||
int minI = m_minimumI() == -1 ? 0 : m_minimumI();
|
minI = minI == -1 ? 0 : minI;
|
||||||
int maxI = m_maximumI() == -1 ? dims[0] - 1 : m_maximumI();
|
maxI = maxI == -1 ? dims[0] - 1 : maxI;
|
||||||
int minJ = m_minimumJ() == -1 ? 0 : m_minimumJ();
|
minJ = minJ == -1 ? 0 : minJ;
|
||||||
int maxJ = m_maximumJ() == -1 ? dims[1] - 1 : m_maximumJ();
|
maxJ = maxJ == -1 ? dims[1] - 1 : maxJ;
|
||||||
|
|
||||||
std::array<int, 4> range = { minI, maxI, minJ, maxJ };
|
std::array<int, 4> range = { minI, maxI, minJ, maxJ };
|
||||||
|
|
||||||
for ( auto layer : m_layers() )
|
for ( auto layer : layers )
|
||||||
{
|
{
|
||||||
bool bottom = false;
|
bool bottom = false;
|
||||||
auto xyz_data = grid1.getXYZ_layer( layer, range, bottom );
|
auto xyz_data = grid1.getXYZ_layer( layer, range, bottom );
|
||||||
@ -108,27 +124,62 @@ caf::PdmObjectHandle* RimcCommandRouter_extractSurfaces::execute()
|
|||||||
startOfCellCoordIndex += 4;
|
startOfCellCoordIndex += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to TS file on disk
|
QString surfaceExportDirName = "surfaceexport";
|
||||||
|
|
||||||
QFileInfo fi( m_gridModelFilename );
|
// Create missing directories
|
||||||
QString surfaceFilename = fi.absoluteDir().absolutePath() +
|
QFileInfo fi( gridModelFilename );
|
||||||
QString( "/surfaceexport/layer-%1.ts" ).arg( layer );
|
if ( !fi.absoluteDir().exists( surfaceExportDirName ) )
|
||||||
|
{
|
||||||
|
if ( !fi.absoluteDir().mkpath( surfaceExportDirName ) )
|
||||||
|
{
|
||||||
|
RiaLogging::error( "Unable to create directory for surface export: " + fi.absoluteDir().absolutePath() );
|
||||||
|
return std::make_pair( false, surfaceFileNames );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write to TS file on disk
|
||||||
|
QString surfaceFilename = fi.absoluteDir().absolutePath() +
|
||||||
|
QString( "/%1/layer-%2.ts" ).arg( surfaceExportDirName ).arg( layer );
|
||||||
|
|
||||||
// TODO: Add more info in surface comment
|
// TODO: Add more info in surface comment
|
||||||
if ( !RifSurfaceExporter::writeGocadTSurfFile( surfaceFilename, "Surface comment", vertices, triangleIndices ) )
|
if ( !RifSurfaceExporter::writeGocadTSurfFile( surfaceFilename, "Surface comment", vertices, triangleIndices ) )
|
||||||
{
|
{
|
||||||
RiaLogging::error( "Failed to export surface data to " + surfaceFilename );
|
RiaLogging::error( "Failed to export surface data to " + surfaceFilename );
|
||||||
|
return std::make_pair( false, surfaceFileNames );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RiaLogging::error( "Successfully exported surface data to " + surfaceFilename );
|
surfaceFileNames << surfaceFilename;
|
||||||
|
RiaLogging::info( "Successfully exported surface data to " + surfaceFilename );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return std::make_pair( true, surfaceFileNames );
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
RiaLogging::error( "Error during creation of surface data for model " + m_gridModelFilename() );
|
RiaLogging::error( "Error during creation of surface data for model " + gridModelFilename );
|
||||||
|
return std::make_pair( false, surfaceFileNames );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimcCommandRouter_extractSurfaces::readMinMaxLayerFromGridFile( const QString& gridFileName, int& minK, int& maxK )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Opm::EclIO::EGrid grid1( gridFileName.toStdString() );
|
||||||
|
|
||||||
|
auto dims = grid1.dimension();
|
||||||
|
minK = 1;
|
||||||
|
maxK = dims[2];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch ( ... )
|
||||||
|
{
|
||||||
|
RiaLogging::error( "Unable to read dimensions from " + gridFileName );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -40,6 +41,14 @@ public:
|
|||||||
|
|
||||||
caf::PdmObjectHandle* execute() override;
|
caf::PdmObjectHandle* execute() override;
|
||||||
|
|
||||||
|
static bool readMinMaxLayerFromGridFile( const QString& gridFileName, int& minK, int& maxK );
|
||||||
|
static std::pair<bool, QStringList> extractSurfaces( const QString& gridModelFileName,
|
||||||
|
const std::vector<int>& layers,
|
||||||
|
int minI = -1,
|
||||||
|
int maxI = -1,
|
||||||
|
int minJ = -1,
|
||||||
|
int maxJ = -1 );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmField<QString> m_gridModelFilename;
|
caf::PdmField<QString> m_gridModelFilename;
|
||||||
caf::PdmField<std::vector<int>> m_layers;
|
caf::PdmField<std::vector<int>> m_layers;
|
||||||
|
Loading…
Reference in New Issue
Block a user