Well cell transparency: Turned off well cell transparency when no well pipe is visible.

For results visulaization, cell edge and faults faces.
Not yet done for visualization without result colors.
p4#: 21462
This commit is contained in:
Jacob Støren
2013-04-26 16:46:38 +02:00
parent 2e2212d7ea
commit 3806ff9baf
14 changed files with 193 additions and 27 deletions

View File

@@ -63,7 +63,9 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
RimResultSlot* cellResultSlot,
RimCellEdgeResultSlot* cellEdgeResultSlot,
cvf::StructGridGeometryGenerator* generator,
cvf::DrawableGeo* geo)
cvf::DrawableGeo* geo,
size_t gridIndex,
float opacityLevel)
{
const std::vector<size_t>& quadToCell = generator->quadToGridCellIndices();
const std::vector<cvf::StructGridInterface::FaceType>& quadToFace = generator->quadToFace();
@@ -136,6 +138,15 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue();
const std::vector<cvf::ubyte>* isWellPipeVisible = NULL;
cvf::ref<cvf::UIntArray> gridCellToWellindexMap;
if (opacityLevel < 1.0f)
{
isWellPipeVisible = &(cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex));
gridCellToWellindexMap = eclipseCase->gridCellToWellIndex( gridIndex );
}
#pragma omp parallel for
for (int quadIdx = 0; quadIdx < static_cast<int>(quadCount); quadIdx++)
{
@@ -162,7 +173,21 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
if (scalarValue != HUGE_VAL)
{
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
// If we are dealing with wellcells, the default is transparent.
// we need to make cells opaque if there are no wellpipe through them.
if (opacityLevel < 1.0f)
{
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !(*isWellPipeVisible)[wellIndex])
{
cellColorTextureCoord += 2.0f; // The shader must interpret values in the range 2-3 as "opaque"
}
}
}
}
else
{

View File

@@ -38,7 +38,9 @@ public:
RimResultSlot* cellResultSlot,
RimCellEdgeResultSlot* cellEdgeResultSlot,
cvf::StructGridGeometryGenerator* generator,
cvf::DrawableGeo* geo);
cvf::DrawableGeo* geo,
size_t gridIndex,
float opacityLevel);
};

View File

@@ -249,16 +249,36 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
if (dataAccessObject.isNull()) return;
// Outer surface
if (m_surfaceFaces.notNull())
{
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_surfaceFacesTextureCoords->size(); ++i)
// if this gridpart manager is set to have some transparency, we
// interpret it as we are displaying beeing wellcells. The cells are then transparent by default, but
// we turn that off for particular cells, if the well pipe is not shown for that cell
if (m_opacityLevel < 1.0f )
{
if ((*m_surfaceFacesTextureCoords)[i].y() != 1.0f)
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_surfaceGenerator.quadToGridCellIndices();
for(size_t i = 0; i < m_surfaceFacesTextureCoords->size(); ++i)
{
if (m_opacityLevel == 1.0f) (*m_surfaceFacesTextureCoords)[i].y() = 0;
if ((*m_surfaceFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_surfaceFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
@@ -280,11 +300,26 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
{
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
for(size_t i = 0; i < m_faultFacesTextureCoords->size(); ++i)
if (m_opacityLevel < 1.0f )
{
if ((*m_faultFacesTextureCoords)[i].y() != 1.0f)
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_faultGenerator.quadToGridCellIndices();
for(size_t i = 0; i < m_faultFacesTextureCoords->size(); ++i)
{
if (m_opacityLevel == 1.0f) (*m_faultFacesTextureCoords)[i].y() = 0;
if ((*m_faultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_faultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
@@ -312,7 +347,8 @@ void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSl
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
if (dg)
{
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot, &m_surfaceGenerator, dg);
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
&m_surfaceGenerator, dg, m_grid->gridIndex(), m_opacityLevel );
cvf::ScalarMapper* cellScalarMapper = NULL;
if (cellResultSlot->hasResult()) cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
@@ -331,7 +367,8 @@ void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSl
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_faultFaces->drawable());
if (dg)
{
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot, &m_faultGenerator, dg);
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
&m_faultGenerator, dg, m_grid->gridIndex(), m_opacityLevel);
cvf::ScalarMapper* cellScalarMapper = NULL;
if (cellResultSlot->hasResult()) cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper();

View File

@@ -270,7 +270,7 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
if (m_rimWell.isNull()) return;
if (m_rimReservoirView.isNull()) return;
if (m_rimReservoirView->wellCollection()->showWellHead() == false) return;
if (!m_rimWell->isWellVisible(frameIndex)) return;
if (!m_rimWell->isWellPipeVisible(frameIndex)) return;
buildWellHeadParts(frameIndex);

View File

@@ -326,7 +326,7 @@ void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
if (!m_rimWell->isWellVisible(frameIndex)) return;
if (!m_rimWell->isWellPipeVisible(frameIndex)) return;
if (m_needsTransformUpdate) buildWellPipeParts();