Files
ResInsight/ApplicationLibCode/FileInterface/RifInputPropertyLoader.cpp
T
Kristian Bendiksen 5e880ffc26 Refactor: migrate fourteen more collections to caf::PdmObjectCollection<T>
Migrated to the templated base, preserving each collection's existing XML
field keyword for project-file backward compatibility:

- RimEnsembleFractureStatisticsCollection
- RimEclipseInputPropertyCollection
- RimPlotDataFilterCollection
- RimGeoMechContourMapViewCollection
- RimIntersectionResultsDefinitionCollection
- RimCustomObjectiveFunctionCollection
- RimStimPlanModelTemplateCollection
- RimEnsembleWellLogsCollection
- RimEclipseContourMapViewCollection
- RimSeismicViewCollection
- RimGridInfoCollection
- RimEclipseStatisticsCaseCollection
- RimWellIASettingsCollection
- RimVfpDataCollection

External callers that accessed the old public/named array fields directly
(RimEclipseInputPropertyCollection::inputProperties,
RimEclipseStatisticsCaseCollection::cases) now use addItem/items() from
the base. RimCustomObjectiveFunction.h replaced its include of the
collection header with a forward declaration to break the new include
cycle introduced by the migration.
2026-05-11 13:42:13 +02:00

110 lines
4.4 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifInputPropertyLoader.h"
#include "RifEclipseInputFileTools.h"
#include "RifEclipseInputPropertyLoader.h"
#include "RifRoffFileTools.h"
#include "RigEclipseCaseData.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "cafProgressInfo.h"
#include <QFile>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RifInputPropertyLoader::loadAndSynchronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const std::vector<QString>& filenames,
bool allowImportOfFaults )
{
std::vector<QString> loadedProperties;
if ( !inputPropertyCollection || !eclipseCaseData || filenames.empty() ) return loadedProperties;
std::vector<RimEclipseInputProperty*> existingProperties = inputPropertyCollection->items();
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() ), "Reading Input properties" );
for ( const auto& filename : filenames )
{
progInfo.setProgressDescription( filename );
auto resultNamesEclipseKeywords = RifInputPropertyLoader::readProperties( filename, eclipseCaseData );
for ( const auto& [resultName, eclipseKeyword] : resultNamesEclipseKeywords )
{
loadedProperties.push_back( eclipseKeyword );
bool isProperyPresent = false;
bool isFaultKeywordPresent = false;
for ( const auto* propertyObj : existingProperties )
{
if ( propertyObj->resultName() == resultName )
{
isProperyPresent = true;
}
else if ( propertyObj->resultName() == "FAULTS" )
{
isFaultKeywordPresent = true;
}
}
if ( !isProperyPresent )
{
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = resultName;
inputProperty->eclipseKeyword = eclipseKeyword;
inputProperty->fileName = filename;
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
inputPropertyCollection->addItem( inputProperty );
}
if ( allowImportOfFaults && isFaultKeywordPresent )
{
RifEclipseInputFileTools::importFaultsFromFile( eclipseCaseData, filename );
}
}
progInfo.incrementProgress();
}
return loadedProperties;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, QString> RifInputPropertyLoader::readProperties( const QString& fileName, RigEclipseCaseData* eclipseCaseData )
{
RiaDefines::ImportFileType fileType = RiaDefines::obtainFileTypeFromFileName( fileName );
if ( fileType == RiaDefines::ImportFileType::ROFF_FILE )
{
auto [isOk, keywordMapping] = RifRoffFileTools::createInputProperties( fileName, eclipseCaseData );
return keywordMapping;
}
return RifEclipseInputPropertyLoader::readProperties( fileName, eclipseCaseData );
}