mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added ternary texture and scalar mappers
This commit is contained in:
parent
5e478d8336
commit
1161ff7c73
@ -23,8 +23,10 @@ ${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryResultToTextureMapper.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -47,6 +49,7 @@ ${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// 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 "RigPipeInCellEvaluator.h"
|
||||
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfVector2.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class RivTernaryResultToTextureMapper : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivTernaryResultToTextureMapper(const RivTernaryScalarMapper* scalarMapper, const RigPipeInCellEvaluator* pipeInCellEvaluator)
|
||||
: m_scalarMapper(scalarMapper), m_pipeInCellEvaluator(pipeInCellEvaluator)
|
||||
{}
|
||||
|
||||
cvf::Vec2f getTexCoord(double soil, double sgas, size_t cellIndex) const
|
||||
{
|
||||
bool isTransparent = m_pipeInCellEvaluator->isWellPipeInCell(cellIndex);
|
||||
|
||||
return m_scalarMapper->mapToTextureCoord(soil, sgas, isTransparent);
|
||||
}
|
||||
|
||||
private:
|
||||
cvf::cref<RivTernaryScalarMapper> m_scalarMapper;
|
||||
cvf::cref<RigPipeInCellEvaluator> m_pipeInCellEvaluator;
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,106 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// 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 "RivTernaryTextureCoordsCreator.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigPipeInCellEvaluator.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RigTernaryResultAccessor2d.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
#include "RivTernaryResultToTextureMapper.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
RimResultSlot* cellResultSlot,
|
||||
RimTernaryLegendConfig* ternaryLegendConfig,
|
||||
size_t timeStepIndex,
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper)
|
||||
{
|
||||
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
|
||||
|
||||
m_quadMapper = quadMapper;
|
||||
CVF_ASSERT(quadMapper && eclipseCase );
|
||||
|
||||
size_t resTimeStepIdx = timeStepIndex;
|
||||
|
||||
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
||||
|
||||
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SOIL");
|
||||
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SGAS");
|
||||
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SWAT");
|
||||
|
||||
m_resultAccessor = new RigTernaryResultAccessor();
|
||||
m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p());
|
||||
|
||||
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator( cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
eclipseCase->gridCellToWellIndex(gridIndex));
|
||||
|
||||
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
|
||||
|
||||
m_texMapper = new RivTernaryResultToTextureMapper(mapper, pipeInCellEval.p());
|
||||
CVF_ASSERT(m_texMapper.notNull());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::createTextureCoords(
|
||||
cvf::Vec2fArray* quadTextureCoords,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
|
||||
const RigTernaryResultAccessor* resultAccessor,
|
||||
const RivTernaryResultToTextureMapper* texMapper)
|
||||
{
|
||||
CVF_ASSERT(quadTextureCoords && quadMapper && resultAccessor && texMapper);
|
||||
|
||||
size_t numVertices = quadMapper->quadCount()*4;
|
||||
quadTextureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = quadTextureCoords->ptr();
|
||||
|
||||
cvf::Vec2d resultValue;
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, resultValue)
|
||||
for (int i = 0; i < static_cast<int>(quadMapper->quadCount()); i++)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType faceId = quadMapper->cellFace(i);
|
||||
size_t cellIdx = quadMapper->cellIndex(i);
|
||||
|
||||
resultValue = resultAccessor->cellFaceScalar(cellIdx, faceId);
|
||||
texCoord = texMapper->getTexCoord(resultValue.x(), resultValue.y(), cellIdx);
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
rawPtr[i*4 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, Ceetron Solutions AS
|
||||
//
|
||||
// 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 "cvfArray.h"
|
||||
|
||||
class RimResultSlot;
|
||||
class RigTernaryResultAccessor;
|
||||
class RivTernaryResultToTextureMapper;
|
||||
class RimTernaryLegendConfig;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class StructGridQuadToCellFaceMapper;
|
||||
}
|
||||
|
||||
|
||||
class RivTernaryTextureCoordsCreator
|
||||
{
|
||||
public:
|
||||
RivTernaryTextureCoordsCreator( RimResultSlot* cellResultSlot,
|
||||
RimTernaryLegendConfig* ternaryLegendConfig,
|
||||
size_t timeStepIndex,
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
||||
|
||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
||||
{
|
||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
|
||||
private:
|
||||
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
|
||||
const RigTernaryResultAccessor* resultAccessor,
|
||||
const RivTernaryResultToTextureMapper* texMapper);
|
||||
|
||||
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;
|
||||
cvf::ref<RivTernaryResultToTextureMapper> m_texMapper;
|
||||
};
|
@ -25,9 +25,11 @@
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RivTernarySaturationOverlayItem.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig");
|
||||
@ -93,6 +95,8 @@ RimTernaryLegendConfig::RimTernaryLegendConfig()
|
||||
m_localAutoMin.resize(3, 0.0);
|
||||
m_localAutoMax.resize(3, 1.0);
|
||||
|
||||
m_scalarMapper = new RivTernaryScalarMapper(cvf::Color3f::GRAY);
|
||||
|
||||
recreateLegend();
|
||||
updateLegend();
|
||||
}
|
||||
@ -163,6 +167,7 @@ void RimTernaryLegendConfig::updateLegend()
|
||||
double swatUpper = 1.0;
|
||||
|
||||
ternaryRanges(soilLower, soilUpper, sgasLower, sgasUpper, swatLower, swatUpper);
|
||||
m_scalarMapper->setTernaryRanges(soilLower, soilUpper, sgasLower, sgasUpper);
|
||||
|
||||
cvf::String soilRange;
|
||||
cvf::String sgasRange;
|
||||
@ -438,3 +443,11 @@ void RimTernaryLegendConfig::updateLabelText()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper()
|
||||
{
|
||||
return m_scalarMapper.p();
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
class RimReservoirView;
|
||||
class RivTernarySaturationOverlayItem;
|
||||
class RivTernaryScalarMapper;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@ -70,7 +71,8 @@ public:
|
||||
|
||||
void recreateLegend();
|
||||
|
||||
RivTernarySaturationOverlayItem* legend();
|
||||
RivTernarySaturationOverlayItem* legend();
|
||||
RivTernaryScalarMapper* scalarMapper();
|
||||
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
@ -106,4 +108,5 @@ private:
|
||||
|
||||
caf::PdmPointer<RimReservoirView> m_reservoirView;
|
||||
cvf::ref<RivTernarySaturationOverlayItem> m_legend;
|
||||
cvf::ref<RivTernaryScalarMapper> m_scalarMapper;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user