#811, #812 WIP, Formation names coloring of cells. First shot. Works but needs refinment.

This commit is contained in:
Jacob Støren 2016-09-06 10:27:30 +02:00
parent ca6e650a72
commit c903e87dfd
28 changed files with 373 additions and 50 deletions

View File

@ -28,6 +28,7 @@
#include "RigStatisticsDataCache.h"
#include "RigFemPartResults.h"
#include "RigFemPartCollection.h"
#include "RigFormationNames.h"
#include "cafProgressInfo.h"
#include "cvfBoundingBox.h"
@ -38,6 +39,7 @@
#include "RigFemNativeStatCalc.h"
#include "cafTensor3.h"
#include "cafProgressInfo.h"
#include "RigFemPartGrid.h"
//--------------------------------------------------------------------------------------------------
@ -66,6 +68,21 @@ RigFemPartResultsCollection::~RigFemPartResultsCollection()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::setActiveFormationNames(RigFormationNames* activeFormationNames)
{
m_activeFormationNamesData = activeFormationNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames* RigFemPartResultsCollection::activeFormationNames()
{
return m_activeFormationNamesData.p();
}
//--------------------------------------------------------------------------------------------------
/// Will always return a valid object, but it can be empty
@ -151,6 +168,11 @@ std::map<std::string, std::vector<std::string> > RigFemPartResultsCollection::sc
{
std::map<std::string, std::vector<std::string> > fieldCompNames;
if (resPos == RIG_FORMATION_NAMES)
{
if (activeFormationNames()) fieldCompNames["Active Formation Names"];
}
if (m_readerInterface.notNull())
{
if (resPos == RIG_NODAL)
@ -619,6 +641,38 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in
return m_femPartResults[partIndex]->createScalarResult(resVarAddr);
}
if (resVarAddr.resultPosType == RIG_FORMATION_NAMES)
{
RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
const RigFemPart * femPart = m_femParts->part(partIndex);
std::vector<float>& dstFrameData = resFrames->frameData(0);
size_t valCount = femPart->elementNodeResultCount();
float inf = std::numeric_limits<float>::infinity();
dstFrameData.resize(valCount, inf);
RigFormationNames* activeFormNames = m_activeFormationNamesData.p();
int elementCount = femPart->elementCount();
for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx)
{
RigElementType elmType = femPart->elementType(elmIdx);
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
size_t i, j, k;
femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k);
int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k);
for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
{
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
dstFrameData[elmNodResIdx] = formNameIdx;
}
}
return resFrames;
}
return NULL;
}

View File

@ -32,6 +32,7 @@ class RigFemPartResultsCollection;
class RigFemPartResults;
class RigStatisticsDataCache;
class RigFemPartCollection;
class RigFormationNames;
class RigFemPartResultsCollection: public cvf::Object
{
@ -39,6 +40,9 @@ public:
RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection);
~RigFemPartResultsCollection();
void setActiveFormationNames(RigFormationNames* activeFormationNames);
RigFormationNames* activeFormationNames();
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
bool assertResultsLoaded(const RigFemResultAddress& resVarAddr);
@ -72,6 +76,7 @@ private:
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
cvf::cref<RigFemPartCollection> m_femParts;
cvf::ref<RigFormationNames> m_activeFormationNamesData;
RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr);
std::vector< RigFemResultAddress> getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr);

View File

@ -43,7 +43,8 @@ RigFemResultAddress(RigFemResultPosEnum resPosType,
{
bool isTypeValid = resultPosType == RIG_NODAL
|| resultPosType == RIG_ELEMENT_NODAL
|| resultPosType == RIG_INTEGRATION_POINT;
|| resultPosType == RIG_INTEGRATION_POINT
|| resultPosType == RIG_FORMATION_NAMES;
bool isFieldValid = fieldName != "";
return isTypeValid && isFieldValid;
}

View File

@ -3,5 +3,6 @@
enum RigFemResultPosEnum {
RIG_NODAL,
RIG_ELEMENT_NODAL,
RIG_INTEGRATION_POINT
RIG_INTEGRATION_POINT,
RIG_FORMATION_NAMES
};

View File

@ -244,7 +244,8 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping());
}
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL
|| resVarAddress.resultPosType == RIG_INTEGRATION_POINT)
|| resVarAddress.resultPosType == RIG_INTEGRATION_POINT
|| resVarAddress.resultPosType == RIG_FORMATION_NAMES)
{
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx());
}

View File

@ -59,6 +59,8 @@ public:
virtual cvf::Vec3d displayModelOffset() const;
virtual void updateFormationNamesData() = 0;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual caf::PdmFieldHandle* userDescriptionField() override { return &caseUserDescription; }

View File

@ -31,7 +31,7 @@ namespace caf
addItem(RimDefines::STATIC_NATIVE, "STATIC_NATIVE", "Static");
addItem(RimDefines::GENERATED, "GENERATED", "Generated");
addItem(RimDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property");
addItem(RimDefines::FORMATION_NAMES, "FORMATION_NAMES", "Formation Names");
setDefault(RimDefines::DYNAMIC_NATIVE);
}

View File

@ -32,6 +32,7 @@ public:
STATIC_NATIVE,
GENERATED,
INPUT_PROPERTY,
FORMATION_NAMES,
REMOVED
};

View File

@ -33,6 +33,7 @@
#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
#include "RimFormationNames.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
@ -283,6 +284,30 @@ void RimEclipseCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
}
}
}
else if(changedField == &activeFormationNames)
{
updateFormationNamesData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::updateFormationNamesData()
{
RigCaseData* rigEclipseCase = reservoirData();
if(rigEclipseCase)
{
if(activeFormationNames())
{
rigEclipseCase->setActiveFormationNames(activeFormationNames()->formationNamesData());
}
else
{
rigEclipseCase->setActiveFormationNames(nullptr);
}
}
}
//--------------------------------------------------------------------------------------------------
@ -303,9 +328,14 @@ void RimEclipseCase::computeCachedData()
rigEclipseCase->mainGrid()->computeCachedData();
pInf.incrementProgress();
pInf.setNextProgressIncrement(17);
pInf.setProgressDescription("Calculating faults");
rigEclipseCase->mainGrid()->calculateFaults(rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS));
pInf.incrementProgress();
pInf.setProgressDescription("Calculating Formation Names Result");
this->updateFormationNamesData();
pInf.incrementProgress();
}
}

View File

@ -98,6 +98,8 @@ protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
virtual void updateFormationNamesData() override;
// Internal methods
protected:
void computeCachedData();

View File

@ -453,6 +453,11 @@ bool RimEclipseResultDefinition::isTernarySaturationSelected() const
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultDefinition::hasCategoryResult() const
{
if (this->m_resultType() == RimDefines::FORMATION_NAMES
&& m_eclipseCase
&& m_eclipseCase->reservoirData()
&& m_eclipseCase->reservoirData()->activeFormationNames() ) return true;
if (!this->hasStaticResult()) return false;
return this->resultVariable().contains("NUM", Qt::CaseInsensitive);

View File

@ -74,6 +74,7 @@
#include <QMessageBox>
#include <limits.h>
#include "RigFormationNames.h"
@ -990,7 +991,20 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
{
size_t adjustedTimeStep = m_currentTimeStep;
if (resultColors->hasStaticResult()) adjustedTimeStep = 0;
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()), cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex(), adjustedTimeStep));
if(resultColors->resultType() != RimDefines::FORMATION_NAMES)
{
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()),
cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex(), adjustedTimeStep));
}
else
{
const std::vector<QString>& fnVector =
eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
std::set<int> nameIndices;
for(int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
resultColors->legendConfig()->setCategories(nameIndices, nameIndices);
}
}
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend());

View File

@ -18,6 +18,8 @@
#include "RimFormationNames.h"
#include "RigFormationNames.h"
#include "RimTools.h"
#include "cafPdmUiFilePathEditor.h"

View File

@ -50,40 +50,3 @@ private:
cvf::ref<RigFormationNames> m_formationNamesData;
};
class RigFormationNames: public cvf::Object
{
public:
int formationIndexFromKLayerIdx(size_t Kidx)
{
if(Kidx >= m_nameIndexPrKLayer.size()) return -1;
return m_nameIndexPrKLayer[Kidx];
}
QString formationNameFromKLayerIdx(size_t Kidx)
{
int idx = formationIndexFromKLayerIdx(Kidx);
if (idx >= m_formationNames.size()) return "";
if (idx == -1) return "";
return m_formationNames[idx];
}
void appendFormationRange(const QString& name, int kStartIdx, int kEndIdx)
{
CVF_ASSERT(kStartIdx <= kEndIdx);
int nameIdx = static_cast<int>(m_formationNames.size());
m_formationNames.push_back(name);
if (kEndIdx >= static_cast<int>(m_nameIndexPrKLayer.size())) m_nameIndexPrKLayer.resize(kEndIdx + 1, -1);
for (int kIdx = kStartIdx; kIdx <= kEndIdx; ++kIdx)
{
m_nameIndexPrKLayer[kIdx] = nameIdx;
}
}
private:
std::vector<int> m_nameIndexPrKLayer;
std::vector<QString> m_formationNames;
};

View File

@ -27,12 +27,14 @@
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigFormationNames.h"
#include "RimGeoMechView.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimTools.h"
#include "RimWellLogPlotCollection.h"
#include "RimFormationNames.h"
#include <QFile>
@ -114,7 +116,10 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
// Also, several places is checked for this data to validate availability of data
m_geoMechCaseData = NULL;
}
else
{
this->updateFormationNamesData();
}
return fileOpenSuccess;
}
@ -240,6 +245,36 @@ std::vector<QDateTime> RimGeoMechCase::dateTimeVectorFromTimeStepStrings(const Q
return dates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if(changedField == &activeFormationNames)
{
updateFormationNamesData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::updateFormationNamesData()
{
RigGeoMechCaseData* rigCaseData = geoMechData();
if(rigCaseData && rigCaseData->femPartResults())
{
if(activeFormationNames())
{
rigCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData());
}
else
{
rigCaseData->femPartResults()->setActiveFormationNames(nullptr);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -69,7 +69,13 @@ public:
static std::vector<QDateTime> dateTimeVectorFromTimeStepStrings(const QStringList& timeStepStrings);
private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void updateFormationNamesData() override;
virtual void initAfterRead();
static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind);

View File

@ -43,6 +43,7 @@ void caf::AppEnum< RigFemResultPosEnum >::setUp()
addItem(RIG_NODAL, "NODAL", "Nodal");
addItem(RIG_ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal");
addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point");
addItem(RIG_FORMATION_NAMES, "FORMATION_NAMES", "Formation Names");
setDefault(RIG_NODAL);
}
}
@ -143,7 +144,6 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
{
m_resultVariableUiField = "";
}
}
// Get the possible property filter owner

View File

@ -60,6 +60,8 @@ public:
QString resultFieldUiName();
QString resultComponentUiName();
bool hasCategoryResult() { return m_resultPositionType() == RIG_FORMATION_NAMES; }
protected:
private:

View File

@ -61,6 +61,7 @@
#include "cvfqtUtils.h"
#include <QMessageBox>
#include "RigFormationNames.h"
CAF_PDM_SOURCE_INIT(RimGeoMechView, "GeoMechView");
@ -418,7 +419,17 @@ void RimGeoMechView::updateLegends()
cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
if (cellResult()->hasCategoryResult())
{
const std::vector<QString>& fnVector =
gmCase->femPartResults()->activeFormationNames()->formationNames();
std::set<int> nameIndices;
for (int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
cellResult()->legendConfig->setCategories(nameIndices, nameIndices);
}
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
cvf::String legendTitle = cvfqt::Utils::toString(

View File

@ -41,6 +41,7 @@
#include "cvfScalarMapperDiscreteLog.h"
#include <cmath>
#include "RimGeoMechCellColors.h"
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
@ -757,11 +758,17 @@ QList<caf::PdmOptionItemInfo> RimLegendConfig::calculateValueOptions(const caf::
QStringList optionTexts;
bool isCategoryResult = false;
RimEclipseCellColors* cellColors = NULL;
this->firstAnchestorOrThisOfType(cellColors);
if (cellColors && cellColors->hasCategoryResult())
{
isCategoryResult = true;
RimEclipseCellColors* eclCellColors = nullptr;
this->firstAnchestorOrThisOfType(eclCellColors);
RimGeoMechCellColors* gmCellColors = nullptr;
this->firstAnchestorOrThisOfType(gmCellColors);
if ( ( eclCellColors && eclCellColors->hasCategoryResult())
|| ( gmCellColors && gmCellColors->hasCategoryResult()) )
{
isCategoryResult = true;
}
}
if (fieldNeedingOptions == &m_mappingMode)

View File

@ -19,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h
${CEE_CURRENT_LIST_DIR}RigResultModifier.h
${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.h
${CEE_CURRENT_LIST_DIR}RigFormationNames.h
${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.h
${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.h
${CEE_CURRENT_LIST_DIR}RigLocalGrid.h
@ -56,6 +57,7 @@ ${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp
${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.cpp
${CEE_CURRENT_LIST_DIR}RigFormationNames.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.cpp
${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.cpp
${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp

View File

@ -247,6 +247,11 @@ size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName)
scalarResultIndex = this->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName);
}
if(scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::FORMATION_NAMES, resultName);
}
return scalarResultIndex;
}

View File

@ -22,6 +22,7 @@
#include "RigMainGrid.h"
#include "RigCaseCellResultsData.h"
#include "RigResultAccessorFactory.h"
#include "RigFormationNames.h"
//--------------------------------------------------------------------------------------------------
///
@ -468,6 +469,56 @@ void RigCaseData::computeActiveCellsGeometryBoundingBox()
m_mainGrid->setDisplayModelOffset(bb.min());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseData::setActiveFormationNames(RigFormationNames* activeFormationNames)
{
m_activeFormationNamesData = activeFormationNames;
if (!activeFormationNames) return;
size_t totalGlobCellCount = m_mainGrid->globalCellArray().size();
size_t resIndex = m_matrixModelResults->addStaticScalarResult(RimDefines::FORMATION_NAMES,
"Active Formation Names",
false,
totalGlobCellCount);
std::vector<double>& fnData = m_matrixModelResults->cellScalarResults(resIndex,0);
size_t localCellCount = m_mainGrid->cellCount();
for (size_t cIdx = 0; cIdx < localCellCount; ++cIdx)
{
size_t i (cvf::UNDEFINED_SIZE_T), j(cvf::UNDEFINED_SIZE_T), k(cvf::UNDEFINED_SIZE_T);
if(!m_mainGrid->ijkFromCellIndex(cIdx, &i, &j, &k)) continue;
int formNameIdx = activeFormationNames->formationIndexFromKLayerIdx(k);
fnData[cIdx] = formNameIdx;
}
for (size_t cIdx = localCellCount; cIdx < totalGlobCellCount; ++cIdx)
{
size_t mgrdCellIdx = m_mainGrid->globalCellArray()[cIdx].mainGridCellIndex();
size_t i (cvf::UNDEFINED_SIZE_T), j(cvf::UNDEFINED_SIZE_T), k(cvf::UNDEFINED_SIZE_T);
if(!m_mainGrid->ijkFromCellIndex(mgrdCellIdx, &i, &j, &k)) continue;
int formNameIdx = activeFormationNames->formationIndexFromKLayerIdx(k);
fnData[cIdx] = formNameIdx;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames* RigCaseData::activeFormationNames()
{
return m_activeFormationNamesData.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -30,7 +30,7 @@
#include "RigActiveCellInfo.h"
class RigCaseCellResultsData;
class RigFormationNames;
class RigCaseData : public cvf::Object
{
@ -62,7 +62,10 @@ public:
RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel);
const RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const;
void setActiveCellInfo(RifReaderInterface::PorosityModelResultType porosityModel, RigActiveCellInfo* activeCellInfo);
void setActiveFormationNames(RigFormationNames* activeFormationNames);
RigFormationNames* activeFormationNames();
void setWellResults(const cvf::Collection<RigSingleWellResultsData>& data);
const cvf::Collection<RigSingleWellResultsData>& wellResults() { return m_wellResults; }
@ -90,9 +93,12 @@ private:
cvf::ref<RigCaseCellResultsData> m_matrixModelResults;
cvf::ref<RigCaseCellResultsData> m_fractureModelResults;
cvf::ref<RigFormationNames> m_activeFormationNamesData;
cvf::Collection<RigSingleWellResultsData> m_wellResults; //< A WellResults object for each well in the reservoir
cvf::Collection<cvf::UByteArray> m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling wether the cell is a well cell or not
cvf::Collection<cvf::UIntArray> m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in
UnitsType m_unitsType;
};

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil 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 "RigFormationNames.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames::RigFormationNames()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames::~RigFormationNames()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigFormationNames::formationNameFromKLayerIdx(size_t Kidx)
{
int idx = formationIndexFromKLayerIdx(Kidx);
if(idx >= m_formationNames.size()) return "";
if(idx == -1) return "";
return m_formationNames[idx];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFormationNames::appendFormationRange(const QString& name, int kStartIdx, int kEndIdx)
{
CVF_ASSERT(kStartIdx <= kEndIdx);
int nameIdx = static_cast<int>(m_formationNames.size());
m_formationNames.push_back(name);
if(kEndIdx >= static_cast<int>(m_nameIndexPrKLayer.size())) m_nameIndexPrKLayer.resize(kEndIdx + 1, -1);
for(int kIdx = kStartIdx; kIdx <= kEndIdx; ++kIdx)
{
m_nameIndexPrKLayer[kIdx] = nameIdx;
}
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil 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 "cvfBase.h"
#include "cvfObject.h"
#include <QString>
#include <vector>
class RigFormationNames: public cvf::Object
{
public:
RigFormationNames();
~RigFormationNames();
int formationIndexFromKLayerIdx(size_t Kidx)
{
if(Kidx >= m_nameIndexPrKLayer.size()) return -1;
return m_nameIndexPrKLayer[Kidx];
}
QString formationNameFromKLayerIdx(size_t Kidx);
const std::vector<QString>& formationNames() const { return m_formationNames;}
void appendFormationRange(const QString& name, int kStartIdx, int kEndIdx);
private:
std::vector<int> m_nameIndexPrKLayer;
std::vector<QString> m_formationNames;
};

View File

@ -28,6 +28,7 @@
#include "RimGeoMechCellColors.h"
#include "RigFemPartResultsCollection.h"
#include "RimFormationNames.h"
#include "RigFormationNames.h"

View File

@ -32,6 +32,7 @@
#include "RimEclipseView.h"
#include "RimEclipseCellColors.h"
#include "RimFormationNames.h"
#include "RigFormationNames.h"