mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Cell edge now handles also ternary
This commit is contained in:
parent
ef3c463128
commit
2c903a0d18
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "RiaStdInclude.h"
|
#include "RiaStdInclude.h"
|
||||||
|
|
||||||
|
#include "RivCellEdgeEffectGenerator.h"
|
||||||
|
|
||||||
#include "RigCaseCellResultsData.h"
|
#include "RigCaseCellResultsData.h"
|
||||||
#include "RigCaseData.h"
|
#include "RigCaseData.h"
|
||||||
#include "RigCellEdgeResultAccessor.h"
|
#include "RigCellEdgeResultAccessor.h"
|
||||||
@ -31,10 +33,12 @@
|
|||||||
#include "RimResultSlot.h"
|
#include "RimResultSlot.h"
|
||||||
#include "RimWellCollection.h"
|
#include "RimWellCollection.h"
|
||||||
|
|
||||||
#include "RivCellEdgeEffectGenerator.h"
|
#include "RivTernaryScalarMapper.h"
|
||||||
|
#include "RimTernaryLegendConfig.h"
|
||||||
|
|
||||||
#include "cvfStructGridGeometryGenerator.h"
|
#include "cvfStructGridGeometryGenerator.h"
|
||||||
#include "cvfqtUtils.h"
|
#include "cvfqtUtils.h"
|
||||||
|
#include "RivTernaryTextureCoordsCreator.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -85,7 +89,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
|||||||
cellEdgeColorTextureCoordsArrays.push_back(colorArray.p());
|
cellEdgeColorTextureCoordsArrays.push_back(colorArray.p());
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::ScalarMapper* cellResultScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
|
cvf::ScalarMapper* cellResultScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||||
cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper();
|
cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper();
|
||||||
|
|
||||||
double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue();
|
double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue();
|
||||||
@ -112,39 +116,42 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
|||||||
faceIndexArray->set(quadIdx * 4 + 2, quadToCellFace->cellFace(quadIdx) );
|
faceIndexArray->set(quadIdx * 4 + 2, quadToCellFace->cellFace(quadIdx) );
|
||||||
faceIndexArray->set(quadIdx * 4 + 3, quadToCellFace->cellFace(quadIdx) );
|
faceIndexArray->set(quadIdx * 4 + 3, quadToCellFace->cellFace(quadIdx) );
|
||||||
|
|
||||||
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
|
size_t cellIndex = quadToCellFace->cellIndex(quadIdx);
|
||||||
size_t cellIndex = quadToCellFace->cellIndex(quadIdx);
|
{
|
||||||
{
|
|
||||||
cvf::StructGridInterface::FaceType cellFace = quadToCellFace->cellFace(quadIdx);
|
cvf::StructGridInterface::FaceType cellFace = quadToCellFace->cellFace(quadIdx);
|
||||||
double scalarValue = cellCenterDataAccessObject->cellFaceScalar(cellIndex, cellFace);
|
double scalarValue = cellCenterDataAccessObject->cellFaceScalar(cellIndex, cellFace);
|
||||||
|
|
||||||
if (scalarValue != HUGE_VAL)
|
{
|
||||||
{
|
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
|
||||||
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
|
if (scalarValue != HUGE_VAL)
|
||||||
// If we are dealing with wellcells, the default is transparent.
|
{
|
||||||
// we need to make cells opaque if there are no wellpipe through them.
|
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
|
||||||
if (opacityLevel < 1.0f)
|
// If we are dealing with wellcells, the default is transparent.
|
||||||
{
|
// we need to make cells opaque if there are no wellpipe through them.
|
||||||
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
if (opacityLevel < 1.0f)
|
||||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
{
|
||||||
{
|
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
||||||
if ( !(*isWellPipeVisible)[wellIndex])
|
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||||
{
|
{
|
||||||
cellColorTextureCoord += 2.0f; // The shader must interpret values in the range 2-3 as "opaque"
|
if (!(*isWellPipeVisible)[wellIndex])
|
||||||
}
|
{
|
||||||
}
|
cellColorTextureCoord += 2.0f; // The shader must interpret values in the range 2-3 as "opaque"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
cellColorTextureCoord = -1.0f; // Undefined texture coord. Shader handles this.
|
else
|
||||||
}
|
{
|
||||||
}
|
cellColorTextureCoord = -1.0f; // Undefined texture coord. Shader handles this.
|
||||||
|
}
|
||||||
|
|
||||||
|
cellColorTextureCoordArray->set(quadIdx * 4 + 0, cellColorTextureCoord);
|
||||||
|
cellColorTextureCoordArray->set(quadIdx * 4 + 1, cellColorTextureCoord);
|
||||||
|
cellColorTextureCoordArray->set(quadIdx * 4 + 2, cellColorTextureCoord);
|
||||||
|
cellColorTextureCoordArray->set(quadIdx * 4 + 3, cellColorTextureCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cellColorTextureCoordArray->set(quadIdx * 4 + 0, cellColorTextureCoord);
|
|
||||||
cellColorTextureCoordArray->set(quadIdx * 4 + 1, cellColorTextureCoord);
|
|
||||||
cellColorTextureCoordArray->set(quadIdx * 4 + 2, cellColorTextureCoord);
|
|
||||||
cellColorTextureCoordArray->set(quadIdx * 4 + 3, cellColorTextureCoord);
|
|
||||||
|
|
||||||
float edgeColor;
|
float edgeColor;
|
||||||
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
|
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
|
||||||
@ -181,32 +188,6 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
|||||||
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegK", cellEdgeColorTextureCoordsArrays.at(5)));
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegK", cellEdgeColorTextureCoordsArrays.at(5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
cvf::ref<RigResultAccessor> RivCellEdgeGeometryGenerator::createCellCenterResultAccessor(RimResultSlot* cellResultSlot, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid)
|
|
||||||
{
|
|
||||||
cvf::ref<RigResultAccessor> resultAccessor = NULL;
|
|
||||||
|
|
||||||
if (cellResultSlot->hasResult())
|
|
||||||
{
|
|
||||||
if (!cellResultSlot->hasDynamicResult())
|
|
||||||
{
|
|
||||||
// Static result values are located at time step 0
|
|
||||||
timeStepIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
|
||||||
resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, timeStepIndex, cellResultSlot->resultVariable());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resultAccessor.isNull())
|
|
||||||
{
|
|
||||||
resultAccessor = new RigHugeValResultAccessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return resultAccessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -236,6 +217,134 @@ cvf::ref<RigResultAccessor> RivCellEdgeGeometryGenerator::createCellEdgeCenterRe
|
|||||||
return cellEdgeResultAccessor;
|
return cellEdgeResultAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivCellEdgeGeometryGenerator::addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot, cvf::StructGridGeometryGenerator* generator, cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel)
|
||||||
|
{
|
||||||
|
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
|
||||||
|
CVF_ASSERT(eclipseCase != NULL);
|
||||||
|
|
||||||
|
const RigGridBase* grid = dynamic_cast<const RigGridBase*>(generator->activeGrid());
|
||||||
|
CVF_ASSERT(grid != NULL);
|
||||||
|
|
||||||
|
cvf::ref<RigResultAccessor> cellEdgeResultAccessor = createCellEdgeCenterResultAccessor(cellResultSlot, cellEdgeResultSlot, timeStepIndex, eclipseCase, grid);
|
||||||
|
|
||||||
|
const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper = generator->quadToCellFaceMapper();
|
||||||
|
|
||||||
|
size_t vertexCount = geo->vertexArray()->size();
|
||||||
|
size_t quadCount = vertexCount / 4;
|
||||||
|
|
||||||
|
cvf::ref<cvf::Vec2fArray> localCoords = new cvf::Vec2fArray;
|
||||||
|
localCoords->resize(vertexCount);
|
||||||
|
|
||||||
|
cvf::ref<cvf::IntArray> faceIndexArray = new cvf::IntArray;
|
||||||
|
faceIndexArray->resize(vertexCount);
|
||||||
|
|
||||||
|
cvf::ref<cvf::Vec2fArray> vCellColorTextureCoordArray = new cvf::Vec2fArray;
|
||||||
|
vCellColorTextureCoordArray->resize(vertexCount);
|
||||||
|
|
||||||
|
// Build six cell face color arrays
|
||||||
|
cvf::Collection<cvf::FloatArray> cellEdgeColorTextureCoordsArrays;
|
||||||
|
size_t idx;
|
||||||
|
for (idx = 0; idx < 6; idx++)
|
||||||
|
{
|
||||||
|
cvf::ref<cvf::FloatArray> colorArray = new cvf::FloatArray;
|
||||||
|
colorArray->resize(vertexCount);
|
||||||
|
cellEdgeColorTextureCoordsArrays.push_back(colorArray.p());
|
||||||
|
}
|
||||||
|
|
||||||
|
RivTernaryScalarMapper* ternaryCellResultScalarMapper = cellResultSlot->ternaryLegendConfig()->scalarMapper();
|
||||||
|
cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper();
|
||||||
|
|
||||||
|
double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue();
|
||||||
|
|
||||||
|
RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(),
|
||||||
|
timeStepIndex,
|
||||||
|
grid->gridIndex(),
|
||||||
|
quadToCellFaceMapper);
|
||||||
|
|
||||||
|
texturer.createTextureCoords(vCellColorTextureCoordArray.p());
|
||||||
|
|
||||||
|
#pragma omp parallel for
|
||||||
|
for (int quadIdx = 0; quadIdx < static_cast<int>(quadCount); quadIdx++)
|
||||||
|
{
|
||||||
|
localCoords->set(quadIdx * 4 + 0, cvf::Vec2f(0, 0));
|
||||||
|
localCoords->set(quadIdx * 4 + 1, cvf::Vec2f(1, 0));
|
||||||
|
localCoords->set(quadIdx * 4 + 2, cvf::Vec2f(1, 1));
|
||||||
|
localCoords->set(quadIdx * 4 + 3, cvf::Vec2f(0, 1));
|
||||||
|
|
||||||
|
faceIndexArray->set(quadIdx * 4 + 0, quadToCellFaceMapper->cellFace(quadIdx));
|
||||||
|
faceIndexArray->set(quadIdx * 4 + 1, quadToCellFaceMapper->cellFace(quadIdx));
|
||||||
|
faceIndexArray->set(quadIdx * 4 + 2, quadToCellFaceMapper->cellFace(quadIdx));
|
||||||
|
faceIndexArray->set(quadIdx * 4 + 3, quadToCellFaceMapper->cellFace(quadIdx));
|
||||||
|
|
||||||
|
size_t cellIndex = quadToCellFaceMapper->cellIndex(quadIdx);
|
||||||
|
|
||||||
|
float edgeColor;
|
||||||
|
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
|
||||||
|
{
|
||||||
|
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
|
||||||
|
|
||||||
|
double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast<cvf::StructGridInterface::FaceType>(cubeFaceIdx));
|
||||||
|
|
||||||
|
if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue)
|
||||||
|
{
|
||||||
|
edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
cvf::FloatArray* colArr = cellEdgeColorTextureCoordsArrays.at(cubeFaceIdx);
|
||||||
|
|
||||||
|
colArr->set(quadIdx * 4 + 0, edgeColor);
|
||||||
|
colArr->set(quadIdx * 4 + 1, edgeColor);
|
||||||
|
colArr->set(quadIdx * 4 + 2, edgeColor);
|
||||||
|
colArr->set(quadIdx * 4 + 3, edgeColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
geo->setVertexAttribute(new cvf::Vec2fVertexAttribute("a_localCoord", localCoords.p()));
|
||||||
|
geo->setVertexAttribute(new cvf::Vec2fVertexAttribute("a_cellTextureCoord", vCellColorTextureCoordArray.p()));
|
||||||
|
|
||||||
|
cvf::ref<cvf::IntVertexAttributeDirect> faceIntAttribute = new cvf::IntVertexAttributeDirect("a_face", faceIndexArray.p());
|
||||||
|
geo->setVertexAttribute(faceIntAttribute.p());
|
||||||
|
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorPosI", cellEdgeColorTextureCoordsArrays.at(0)));
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegI", cellEdgeColorTextureCoordsArrays.at(1)));
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorPosJ", cellEdgeColorTextureCoordsArrays.at(2)));
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegJ", cellEdgeColorTextureCoordsArrays.at(3)));
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorPosK", cellEdgeColorTextureCoordsArrays.at(4)));
|
||||||
|
geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegK", cellEdgeColorTextureCoordsArrays.at(5)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::ref<RigResultAccessor> RivCellEdgeGeometryGenerator::createCellCenterResultAccessor(RimResultSlot* cellResultSlot, size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid)
|
||||||
|
{
|
||||||
|
cvf::ref<RigResultAccessor> resultAccessor = NULL;
|
||||||
|
|
||||||
|
if (cellResultSlot->hasResult())
|
||||||
|
{
|
||||||
|
if (!cellResultSlot->hasDynamicResult())
|
||||||
|
{
|
||||||
|
// Static result values are located at time step 0
|
||||||
|
timeStepIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
||||||
|
resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, timeStepIndex, cellResultSlot->resultVariable());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultAccessor.isNull())
|
||||||
|
{
|
||||||
|
resultAccessor = new RigHugeValResultAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -244,11 +353,10 @@ cvf::ref<RigResultAccessor> RivCellEdgeGeometryGenerator::createCellEdgeCenterRe
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper, const cvf::ScalarMapper* cellScalarMapper)
|
CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(edgeScalarMapper != NULL);
|
CVF_ASSERT(edgeScalarMapper != NULL);
|
||||||
|
|
||||||
m_cellScalarMapper = cellScalarMapper;
|
|
||||||
m_edgeScalarMapper = edgeScalarMapper;
|
m_edgeScalarMapper = edgeScalarMapper;
|
||||||
|
|
||||||
m_cullBackfaces = false;
|
m_cullBackfaces = false;
|
||||||
@ -256,6 +364,21 @@ CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeSc
|
|||||||
m_defaultCellColor = cvf::Color3f(cvf::Color3::WHITE);
|
m_defaultCellColor = cvf::Color3f(cvf::Color3::WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void CellEdgeEffectGenerator::setScalarMapper(const cvf::ScalarMapper* cellScalarMapper)
|
||||||
|
{
|
||||||
|
m_cellScalarMapper = cellScalarMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void CellEdgeEffectGenerator::setTernaryScalarMapper(const RivTernaryScalarMapper* ternaryScalarMapper)
|
||||||
|
{
|
||||||
|
m_ternaryCellScalarMapper = ternaryScalarMapper;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -267,7 +390,8 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const
|
|||||||
if (otherCellFaceEffectGenerator
|
if (otherCellFaceEffectGenerator
|
||||||
&& m_cellScalarMapper.p() == otherCellFaceEffectGenerator->m_cellScalarMapper.p()
|
&& m_cellScalarMapper.p() == otherCellFaceEffectGenerator->m_cellScalarMapper.p()
|
||||||
&& m_edgeScalarMapper.p() == otherCellFaceEffectGenerator->m_edgeScalarMapper.p()
|
&& m_edgeScalarMapper.p() == otherCellFaceEffectGenerator->m_edgeScalarMapper.p()
|
||||||
&& m_cullBackfaces == otherCellFaceEffectGenerator->m_cullBackfaces
|
&& m_ternaryCellScalarMapper.p() == otherCellFaceEffectGenerator->m_ternaryCellScalarMapper.p()
|
||||||
|
&& m_cullBackfaces == otherCellFaceEffectGenerator->m_cullBackfaces
|
||||||
&& m_opacityLevel == otherCellFaceEffectGenerator->m_opacityLevel
|
&& m_opacityLevel == otherCellFaceEffectGenerator->m_opacityLevel
|
||||||
&& m_undefinedColor == otherCellFaceEffectGenerator->m_undefinedColor
|
&& m_undefinedColor == otherCellFaceEffectGenerator->m_undefinedColor
|
||||||
&& m_defaultCellColor == otherCellFaceEffectGenerator->m_defaultCellColor
|
&& m_defaultCellColor == otherCellFaceEffectGenerator->m_defaultCellColor
|
||||||
@ -300,7 +424,9 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
caf::EffectGenerator* CellEdgeEffectGenerator::copy() const
|
caf::EffectGenerator* CellEdgeEffectGenerator::copy() const
|
||||||
{
|
{
|
||||||
CellEdgeEffectGenerator * newEffect = new CellEdgeEffectGenerator(m_edgeScalarMapper.p(), m_cellScalarMapper.p());
|
CellEdgeEffectGenerator * newEffect = new CellEdgeEffectGenerator(m_edgeScalarMapper.p());
|
||||||
|
newEffect->setScalarMapper(m_cellScalarMapper.p());
|
||||||
|
newEffect->setTernaryScalarMapper(m_ternaryCellScalarMapper.p());
|
||||||
newEffect->m_edgeTextureImage = m_edgeTextureImage;
|
newEffect->m_edgeTextureImage = m_edgeTextureImage;
|
||||||
newEffect->m_cellTextureImage = m_cellTextureImage;
|
newEffect->m_cellTextureImage = m_cellTextureImage;
|
||||||
|
|
||||||
@ -317,36 +443,54 @@ caf::EffectGenerator* CellEdgeEffectGenerator::copy() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const
|
void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const
|
||||||
{
|
{
|
||||||
cvf::ref<cvf::Effect> eff = effect;
|
cvf::ref<cvf::Effect> eff = effect;
|
||||||
|
|
||||||
// Set up shader program
|
// Set up shader program
|
||||||
|
|
||||||
cvf::ShaderProgramGenerator shaderGen("CellEdgeFaceShaderProgramGenerator", cvf::ShaderSourceProvider::instance());
|
cvf::ShaderProgramGenerator shaderGen("CellEdgeFaceShaderProgramGenerator", cvf::ShaderSourceProvider::instance());
|
||||||
{
|
{
|
||||||
QFile data(":/Shader/fs_CellFace.glsl");
|
QFile data(":/Shader/fs_CellFace.glsl");
|
||||||
if (data.open(QFile::ReadOnly))
|
if (data.open(QFile::ReadOnly))
|
||||||
{
|
{
|
||||||
QTextStream in(&data);
|
QTextStream in(&data);
|
||||||
|
|
||||||
QString data = in.readAll();
|
QString data = in.readAll();
|
||||||
cvf::String cvfString = cvfqt::Utils::toString(data);
|
cvf::String cvfString = cvfqt::Utils::toString(data);
|
||||||
|
|
||||||
shaderGen.addFragmentCode(cvfString);
|
shaderGen.addFragmentCode(cvfString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (m_ternaryCellScalarMapper.notNull())
|
||||||
QFile data(":/Shader/vs_CellFace.glsl");
|
{
|
||||||
if (data.open(QFile::ReadOnly))
|
{
|
||||||
{
|
QFile data(":/Shader/vs_2dTextureCellFace.glsl");
|
||||||
QTextStream in(&data);
|
if (data.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&data);
|
||||||
|
|
||||||
QString data = in.readAll();
|
QString data = in.readAll();
|
||||||
cvf::String cvfString = cvfqt::Utils::toString(data);
|
cvf::String cvfString = cvfqt::Utils::toString(data);
|
||||||
|
|
||||||
shaderGen.addVertexCode(cvfString);
|
shaderGen.addVertexCode(cvfString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QFile data(":/Shader/vs_CellFace.glsl");
|
||||||
|
if (data.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
QTextStream in(&data);
|
||||||
|
|
||||||
|
QString data = in.readAll();
|
||||||
|
cvf::String cvfString = cvfqt::Utils::toString(data);
|
||||||
|
|
||||||
|
shaderGen.addVertexCode(cvfString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse());
|
shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse());
|
||||||
shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard);
|
shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard);
|
||||||
@ -361,7 +505,12 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
|
|||||||
|
|
||||||
cvf::ref<cvf::TextureImage> modifiedCellTextImage;
|
cvf::ref<cvf::TextureImage> modifiedCellTextImage;
|
||||||
m_edgeScalarMapper->updateTexture(m_edgeTextureImage.p());
|
m_edgeScalarMapper->updateTexture(m_edgeTextureImage.p());
|
||||||
if (m_cellScalarMapper.notNull())
|
if (m_ternaryCellScalarMapper.notNull())
|
||||||
|
{
|
||||||
|
m_ternaryCellScalarMapper->updateTexture(m_cellTextureImage.p(), m_opacityLevel);
|
||||||
|
modifiedCellTextImage = m_cellTextureImage;
|
||||||
|
}
|
||||||
|
else if (m_cellScalarMapper.notNull())
|
||||||
{
|
{
|
||||||
m_cellScalarMapper->updateTexture(m_cellTextureImage.p());
|
m_cellScalarMapper->updateTexture(m_cellTextureImage.p());
|
||||||
modifiedCellTextImage = caf::ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_cellTextureImage.p(), m_undefinedColor, m_opacityLevel);
|
modifiedCellTextImage = caf::ScalarMapperEffectGenerator::addAlphaAndUndefStripes(m_cellTextureImage.p(), m_undefinedColor, m_opacityLevel);
|
||||||
@ -422,3 +571,4 @@ void CellEdgeEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effec
|
|||||||
surfaceGen.updateEffect(effect);
|
surfaceGen.updateEffect(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class RimResultSlot;
|
|||||||
class RigGridBase;
|
class RigGridBase;
|
||||||
class RigResultAccessor;
|
class RigResultAccessor;
|
||||||
class RigCaseData;
|
class RigCaseData;
|
||||||
|
class RivTernaryScalarMapper;
|
||||||
|
|
||||||
class RivCellEdgeGeometryGenerator
|
class RivCellEdgeGeometryGenerator
|
||||||
{
|
{
|
||||||
@ -44,6 +44,15 @@ public:
|
|||||||
size_t gridIndex,
|
size_t gridIndex,
|
||||||
float opacityLevel);
|
float opacityLevel);
|
||||||
|
|
||||||
|
static void addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex,
|
||||||
|
RimResultSlot* cellResultSlot,
|
||||||
|
RimCellEdgeResultSlot* cellEdgeResultSlot,
|
||||||
|
cvf::StructGridGeometryGenerator* generator,
|
||||||
|
cvf::DrawableGeo* geo,
|
||||||
|
size_t gridIndex,
|
||||||
|
float opacityLevel);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static cvf::ref<RigResultAccessor> createCellCenterResultAccessor(
|
static cvf::ref<RigResultAccessor> createCellCenterResultAccessor(
|
||||||
RimResultSlot* cellResultSlot,
|
RimResultSlot* cellResultSlot,
|
||||||
@ -134,7 +143,10 @@ private:
|
|||||||
class CellEdgeEffectGenerator : public caf::EffectGenerator
|
class CellEdgeEffectGenerator : public caf::EffectGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper, const cvf::ScalarMapper* cellScalarMapper);
|
CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper);
|
||||||
|
|
||||||
|
void setScalarMapper(const cvf::ScalarMapper* cellScalarMapper);
|
||||||
|
void setTernaryScalarMapper(const RivTernaryScalarMapper* ternaryScalarMapper);
|
||||||
|
|
||||||
void setOpacityLevel(float opacity) { m_opacityLevel = cvf::Math::clamp(opacity, 0.0f , 1.0f ); }
|
void setOpacityLevel(float opacity) { m_opacityLevel = cvf::Math::clamp(opacity, 0.0f , 1.0f ); }
|
||||||
void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; }
|
void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; }
|
||||||
@ -154,10 +166,11 @@ private:
|
|||||||
cvf::cref<cvf::ScalarMapper> m_cellScalarMapper;
|
cvf::cref<cvf::ScalarMapper> m_cellScalarMapper;
|
||||||
mutable cvf::ref<cvf::TextureImage> m_cellTextureImage;
|
mutable cvf::ref<cvf::TextureImage> m_cellTextureImage;
|
||||||
|
|
||||||
float m_opacityLevel;
|
cvf::cref<RivTernaryScalarMapper> m_ternaryCellScalarMapper;
|
||||||
|
|
||||||
|
float m_opacityLevel;
|
||||||
bool m_cullBackfaces;
|
bool m_cullBackfaces;
|
||||||
cvf::Color3f m_undefinedColor;
|
cvf::Color3f m_undefinedColor;
|
||||||
cvf::Color3f m_defaultCellColor;
|
cvf::Color3f m_defaultCellColor;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,16 +285,31 @@ void RivGridPartMgr::updateCellEdgeResultColorOnPart( cvf::Part* facePart,
|
|||||||
{
|
{
|
||||||
if (facePart)
|
if (facePart)
|
||||||
{
|
{
|
||||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(facePart->drawable());
|
CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultSlot->legendConfig()->scalarMapper());
|
||||||
|
|
||||||
|
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(facePart->drawable());
|
||||||
if (dg)
|
if (dg)
|
||||||
{
|
{
|
||||||
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
|
if (cellResultSlot->isTernarySaturationSelected())
|
||||||
surfaceGenerator, dg, m_grid->gridIndex(), m_opacityLevel );
|
{
|
||||||
|
RivCellEdgeGeometryGenerator::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
|
||||||
|
surfaceGenerator, dg, m_grid->gridIndex(), m_opacityLevel);
|
||||||
|
|
||||||
cvf::ScalarMapper* cellScalarMapper = NULL;
|
RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultSlot->ternaryLegendConfig()->scalarMapper();
|
||||||
if (cellResultSlot->hasResult()) cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
|
cellFaceEffectGen.setTernaryScalarMapper(ternaryCellScalarMapper);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (cellResultSlot->hasResult())
|
||||||
|
{
|
||||||
|
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
|
||||||
|
surfaceGenerator, dg, m_grid->gridIndex(), m_opacityLevel);
|
||||||
|
|
||||||
|
cvf::ScalarMapper* cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||||
|
cellFaceEffectGen.setScalarMapper(cellScalarMapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultSlot->legendConfig()->scalarMapper(), cellScalarMapper);
|
|
||||||
cellFaceEffectGen.setOpacityLevel(m_opacityLevel);
|
cellFaceEffectGen.setOpacityLevel(m_opacityLevel);
|
||||||
cellFaceEffectGen.setDefaultCellColor(m_defaultColor);
|
cellFaceEffectGen.setDefaultCellColor(m_defaultColor);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user