2018-09-25 09:09:13 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2018-09-25 09:09:13 +02: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 10:40:57 +02:00
|
|
|
//
|
2018-09-25 09:09:13 +02: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 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-09-25 09:09:13 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicfExportWellPaths.h"
|
|
|
|
|
|
2018-11-07 15:42:45 +01:00
|
|
|
#include "RicfApplicationTools.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RicfCommandFileExecutor.h"
|
2026-09-16 17:44:16 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2018-09-25 09:09:13 +02:00
|
|
|
|
2026-09-16 17:44:16 +02:00
|
|
|
#include "RiaApplication.h"
|
2018-09-25 09:09:13 +02:00
|
|
|
|
|
|
|
|
#include "RimWellPath.h"
|
2026-09-16 17:44:16 +02:00
|
|
|
#include "RimcWellPath.h"
|
2018-09-25 09:09:13 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2018-09-25 09:09:13 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfExportWellPaths, "exportWellPaths" );
|
2018-09-25 09:09:13 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2018-09-25 09:09:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfExportWellPaths::RicfExportWellPaths()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_mdStepSize, "mdStepSize", 5.0, "MD Step Size" );
|
2018-09-25 09:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2018-09-25 09:09:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfExportWellPaths::execute()
|
2018-09-25 09:09:13 +02:00
|
|
|
{
|
2026-09-16 17:44:16 +02:00
|
|
|
const QString commandName = classKeyword();
|
2018-11-07 15:42:45 +01:00
|
|
|
|
2026-09-16 17:44:16 +02:00
|
|
|
// Empty name list means all well paths
|
|
|
|
|
QStringList wellsNotFound;
|
|
|
|
|
std::vector<RimWellPath*> wellPaths =
|
|
|
|
|
RicfApplicationTools::wellPathsFromNames( RicfApplicationTools::toQStringList( m_wellPathNames ), &wellsNotFound );
|
|
|
|
|
if ( !wellsNotFound.empty() )
|
2018-09-25 09:09:13 +02:00
|
|
|
{
|
2026-09-16 17:44:16 +02:00
|
|
|
return RicfForwarding::errorResponse( "These well paths were not found: " + wellsNotFound.join( ", " ), commandName );
|
2019-05-23 13:59:19 +02:00
|
|
|
}
|
2026-09-16 17:44:16 +02:00
|
|
|
if ( wellPaths.empty() ) return RicfForwarding::errorResponse( "No well paths found", commandName );
|
2018-09-25 09:09:13 +02:00
|
|
|
|
2026-09-16 17:44:16 +02:00
|
|
|
// Resolve the export folder from the command file executor state. The Rimc method requires an explicit folder.
|
2023-02-26 10:48:40 +01:00
|
|
|
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::WELLPATHS );
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( exportFolder.isNull() )
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "wellpaths" );
|
2019-05-23 13:59:19 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 17:44:16 +02:00
|
|
|
for ( RimWellPath* wellPath : wellPaths )
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2026-09-16 17:44:16 +02:00
|
|
|
if ( !wellPath ) continue;
|
|
|
|
|
|
|
|
|
|
RimWellPath_exportGeometry method( wellPath );
|
|
|
|
|
method.setExportFolder( exportFolder );
|
|
|
|
|
method.setMdStepSize( m_mdStepSize() );
|
|
|
|
|
|
|
|
|
|
auto result = method.execute();
|
|
|
|
|
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
|
2018-09-25 09:09:13 +02:00
|
|
|
}
|
2026-09-16 17:44:16 +02:00
|
|
|
|
2020-03-10 14:11:22 +01:00
|
|
|
return caf::PdmScriptResponse();
|
2018-09-25 09:09:13 +02:00
|
|
|
}
|