(#166) Added support for ternary result mapping

Removed obsolete interface RigResultAccessor2d
This commit is contained in:
Magne Sjaastad
2015-11-23 15:24:03 +01:00
parent 95f500fefd
commit 6cd4e8a0b7
7 changed files with 144 additions and 62 deletions

View File

@@ -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;
}
}
}