mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#166) Added support for ternary result mapping
Removed obsolete interface RigResultAccessor2d
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
@@ -28,22 +31,20 @@
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
#include "RivTernaryTextureCoordsCreator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -94,14 +95,9 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
{
|
||||
if (cellResultColors->isTernarySaturationSelected())
|
||||
{
|
||||
//RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(),
|
||||
// timeStepIndex,
|
||||
// m_grid->gridIndex(),
|
||||
// m_nativeCrossSectionGenerator->quadToCellFaceMapper());
|
||||
//
|
||||
//texturer.createTextureCoords(m_nativeCrossSectionFacesTextureCoords.p());
|
||||
|
||||
CVF_ASSERT(false); // Todo
|
||||
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex);
|
||||
|
||||
texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex());
|
||||
|
||||
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
|
||||
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(),
|
||||
|
||||
@@ -44,10 +44,30 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper)
|
||||
{
|
||||
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
|
||||
|
||||
CVF_ASSERT(quadMapper);
|
||||
m_quadMapper = quadMapper;
|
||||
CVF_ASSERT(quadMapper && eclipseCase );
|
||||
|
||||
initData(cellResultColors, ternaryLegendConfig, timeStepIndex, gridIndex);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
RimEclipseCellColors* cellResultColors,
|
||||
RimTernaryLegendConfig* ternaryLegendConfig,
|
||||
size_t timeStepIndex)
|
||||
: m_quadMapper(NULL)
|
||||
{
|
||||
initData(cellResultColors, ternaryLegendConfig, timeStepIndex, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::initData(RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex)
|
||||
{
|
||||
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
|
||||
|
||||
size_t resTimeStepIdx = timeStepIndex;
|
||||
|
||||
@@ -58,11 +78,11 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
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( cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
eclipseCase->gridCellToWellIndex(gridIndex));
|
||||
|
||||
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
|
||||
@@ -76,9 +96,20 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
||||
{
|
||||
CVF_ASSERT(m_quadMapper.notNull());
|
||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx)
|
||||
{
|
||||
CVF_ASSERT(m_quadMapper.isNull());
|
||||
|
||||
createTextureCoords(triTextureCoords, triangleToCellIdx, m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -113,3 +144,33 @@ void RivTernaryTextureCoordsCreator::createTextureCoords(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<size_t>& triangleToCellIdx, const RigTernaryResultAccessor* resultAccessor, const RivTernaryResultToTextureMapper* texMapper)
|
||||
{
|
||||
CVF_ASSERT(textureCoords && resultAccessor && texMapper);
|
||||
|
||||
size_t numVertices = triangleToCellIdx.size() * 3;
|
||||
textureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
|
||||
cvf::Vec2d resultValue;
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, resultValue)
|
||||
for (int i = 0; i < static_cast<int>(triangleToCellIdx.size()); i++)
|
||||
{
|
||||
size_t cellIdx = triangleToCellIdx[i];
|
||||
|
||||
resultValue = resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
texCoord = texMapper->getTexCoord(resultValue.x(), resultValue.y(), cellIdx);
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
rawPtr[i * 3 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,20 +41,31 @@ namespace cvf
|
||||
class RivTernaryTextureCoordsCreator
|
||||
{
|
||||
public:
|
||||
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
|
||||
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
|
||||
RimTernaryLegendConfig* ternaryLegendConfig,
|
||||
size_t timeStepIndex,
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
||||
|
||||
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
|
||||
RimTernaryLegendConfig* ternaryLegendConfig,
|
||||
size_t timeStepIndex);
|
||||
|
||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords);
|
||||
void createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx);
|
||||
|
||||
private:
|
||||
void initData(RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex);
|
||||
|
||||
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
|
||||
const RigTernaryResultAccessor* resultAccessor,
|
||||
const RivTernaryResultToTextureMapper* texMapper);
|
||||
|
||||
static void createTextureCoords(cvf::Vec2fArray* triTextureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdx,
|
||||
const RigTernaryResultAccessor* resultAccessor,
|
||||
const RivTernaryResultToTextureMapper* texMapper);
|
||||
private:
|
||||
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;
|
||||
|
||||
Reference in New Issue
Block a user