(#166) Improvements to ternary result visualization

Show undefined in regions with no results
Always use time step zero for static results
Allow texture coordinate creation without using RigPipeInCellEvaluator
This commit is contained in:
Magne Sjaastad 2015-11-24 09:59:25 +01:00
parent 6cd4e8a0b7
commit 60df95843c
6 changed files with 85 additions and 36 deletions

View File

@ -112,17 +112,31 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
CVF_ASSERT(m_crossSectionGenerator.notNull());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
cvf::ref<RigResultAccessor> resultAccessor;
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(),
0,
RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()),
timeStepIndex,
cellResultColors->resultVariable());
if (RimDefines::isPerCellFaceResult(cellResultColors->resultVariable()))
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
size_t adjustedTimeStepIndex = timeStepIndex;
if (cellResultColors->hasStaticResult())
{
adjustedTimeStepIndex = 0;
}
resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(),
0,
RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel()),
adjustedTimeStepIndex,
cellResultColors->resultVariable());
}
RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(),
mapper);
m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(),
mapper);
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
@ -131,7 +145,7 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled());
}
}
}
}

View File

@ -39,7 +39,19 @@ public:
cvf::Vec2f getTexCoord(double soil, double sgas, size_t cellIndex) const
{
bool isTransparent = m_pipeInCellEvaluator->isWellPipeInCell(cellIndex);
if (soil == HUGE_VAL || soil != soil ||
sgas == HUGE_VAL || sgas != sgas) // a != a is true for NAN's
{
cvf::Vec2f texCoord(1.0, 1.0);
return texCoord;
}
bool isTransparent = false;
if (m_pipeInCellEvaluator.notNull())
{
isTransparent = m_pipeInCellEvaluator->isWellPipeInCell(cellIndex);
}
return m_scalarMapper->mapToTextureCoord(soil, sgas, isTransparent);
}

View File

@ -77,10 +77,7 @@ bool RivTernaryScalarMapper::updateTexture(cvf::TextureImage* image, float opaci
CVF_ASSERT(image);
image->allocate(m_textureSize.x(), m_textureSize.y());
// For now fill with white so we can see any errors more easily
image->fill(cvf::Color4ub(cvf::Color3::WHITE));
image->fill(cvf::Color4ub(cvf::Color3ub(m_undefScalarColor)));
cvf::uint halfTextureHeight = m_textureSize.y() / 2;

View File

@ -47,26 +47,6 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
CVF_ASSERT(quadMapper);
m_quadMapper = quadMapper;
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;
@ -91,6 +71,38 @@ void RivTernaryTextureCoordsCreator::initData(RimEclipseCellColors* cellResultCo
CVF_ASSERT(m_texMapper.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex)
: m_quadMapper(NULL)
{
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
size_t resTimeStepIdx = timeStepIndex;
if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel());
size_t gridIndex = 0;
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());
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
// Create a texture mapper without detecting transparency using RigPipeInCellEvaluator
m_texMapper = new RivTernaryResultToTextureMapper(mapper, NULL);
CVF_ASSERT(m_texMapper.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -55,8 +55,6 @@ public:
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,

View File

@ -109,6 +109,11 @@ cvf::Vec2d RigTernaryResultAccessor::cellScalarGlobIdx(size_t globCellIndex) con
{
soil = m_soilAccessor->cellScalarGlobIdx(globCellIndex);
if (soil == HUGE_VAL)
{
return cvf::Vec2d(HUGE_VAL, HUGE_VAL);
}
if (m_sgasAccessor.notNull())
{
sgas = m_sgasAccessor->cellScalarGlobIdx(globCellIndex);
@ -128,6 +133,11 @@ cvf::Vec2d RigTernaryResultAccessor::cellScalarGlobIdx(size_t globCellIndex) con
{
sgas = m_sgasAccessor->cellScalarGlobIdx(globCellIndex);
if (sgas == HUGE_VAL)
{
return cvf::Vec2d(HUGE_VAL, HUGE_VAL);
}
if (m_swatAccessor.notNull())
{
soil = 1.0 - sgas - m_swatAccessor->cellScalarGlobIdx(globCellIndex);
@ -139,6 +149,12 @@ cvf::Vec2d RigTernaryResultAccessor::cellScalarGlobIdx(size_t globCellIndex) con
}
else if (m_swatAccessor.notNull())
{
double swat = m_swatAccessor->cellScalarGlobIdx(globCellIndex);
if (swat == HUGE_VAL)
{
return cvf::Vec2d(HUGE_VAL, HUGE_VAL);
}
soil = 1.0 - m_swatAccessor->cellScalarGlobIdx(globCellIndex);
}
}