Wip: New generalized texturing in play

Only on GridParts
This commit is contained in:
Jacob Støren authored and Magne Sjaastad committed 2014-08-14 10:56:27 +02:00
1 parent 33ab16f7d7
commit 38d2000e29
5 files changed
+103 -161

No files matched your search

@@ -22,6 +22,8 @@ ${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h
${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}RivTextureCoordsCreator.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -42,6 +44,7 @@ ${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp
)
list(APPEND CODE_HEADER_FILES
@@ -50,6 +50,11 @@
#include "RimWellCollection.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RivSourceInfo.h"
#include "cvfStructGridGeometryGenerator.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RivResultToTextureMapper.h"
#include "RivTextureCoordsCreator.h"
//--------------------------------------------------------------------------------------------------
@@ -207,7 +212,7 @@ void RivGridPartMgr::updateCellColor(cvf::Color4f color)
m_surfaceGridLines->setEffect(eff.p());
}
}
#if 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -275,6 +280,96 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
}
}
}
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
CVF_ASSERT(cellResultSlot);
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
// Outer surface
if (m_surfaceFaces.notNull())
{
if (cellResultSlot->isTernarySaturationSelected())
{
surfaceFacesColorArray = new cvf::Color3ubArray;
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), m_surfaceGenerator.quadToCellFaceMapper());
}
else
{
RivTextureCoordsCreator texturer(cellResultSlot, timeStepIndex, m_grid->gridIndex(), m_surfaceGenerator.quadToCellFaceMapper());
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
/*
// If the result is static, only read that.
size_t resTimeStepIdx = timeStepIndex;
const cvf::StructGridQuadToCellFaceMapper* quadMapper = m_surfaceGenerator.quadToCellFaceMapper();
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, m_grid->gridIndex(), porosityModel, resTimeStepIdx, cellResultSlot->resultVariable());
if (resultAccessor.isNull()) return;
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator( cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
eclipseCase->gridCellToWellIndex(m_grid->gridIndex()));
cvf::ref<RivResultToTextureMapper> texMapper = new RivResultToTextureMapper(mapper, pipeInCellEval.p());
size_t numVertices = quadMapper->quadCount()*4;
m_surfaceFacesTextureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
double cellScalarValue;
cvf::Vec2f texCoord;
#pragma omp parallel for private(texCoord, cellScalarValue)
for (int i = 0; i < static_cast<int>(quadMapper->quadCount()); i++)
{
cvf::StructGridInterface::FaceType faceId = quadMapper->cellFace(i);
size_t cellIdx = quadMapper->cellIndex(i);
cellScalarValue = resultAccessor->cellFaceScalar(cellIdx, faceId);
texCoord = texMapper->getTexCoord(cellScalarValue, cellIdx);
size_t j;
for (j = 0; j < 4; j++)
{
rawPtr[i*4 + j] = texCoord;
}
}
*/
}
if (surfaceFacesColorArray.notNull()) // Ternary result
{
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
if (dg)
{
dg->setColorArray(surfaceFacesColorArray.p());
}
cvf::ref<cvf::Effect> perVertexColorEffect = RivGridPartMgr::createPerVertexColoringEffect(m_opacityLevel);
m_surfaceFaces->setEffect(perVertexColorEffect.p());
m_surfaceFaces->setPriority(100);
}
else
{
applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper );
}
}
}
//--------------------------------------------------------------------------------------------------
///