mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use texture based ternary visualization
This commit is contained in:
parent
1b69f93a11
commit
24a464ecf9
@ -54,6 +54,8 @@
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivTextureCoordsCreator.h"
|
||||
#include "RivTernaryTextureCoordsCreator.h"
|
||||
#include "RivTernaryScalarMapperEffectGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -229,9 +231,28 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
if (cellResultSlot->isTernarySaturationSelected())
|
||||
{
|
||||
surfaceFacesColorArray = new cvf::Color3ubArray;
|
||||
RivTernaryTextureCoordsCreator texturer(cellResultSlot, cellResultSlot->ternaryLegendConfig(),
|
||||
timeStepIndex,
|
||||
m_grid->gridIndex(),
|
||||
m_surfaceGenerator.quadToCellFaceMapper());
|
||||
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), m_surfaceGenerator.quadToCellFaceMapper());
|
||||
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
|
||||
|
||||
//void RivGridPartMgr::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces.p()->drawable());
|
||||
if (dg) dg->setTextureCoordArray(m_surfaceFacesTextureCoords.p());
|
||||
}
|
||||
|
||||
// void RivGridPartMgr::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
RivTernaryScalarMapperEffectGenerator scalarEffgen(cellResultSlot->ternaryLegendConfig()->scalarMapper(), polygonOffset);
|
||||
scalarEffgen.setOpacityLevel(m_opacityLevel);
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
|
||||
m_surfaceFaces->setEffect(scalarEffect.p());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,26 +262,28 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
m_surfaceGenerator.quadToCellFaceMapper());
|
||||
|
||||
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
|
||||
|
||||
applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper);
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,14 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
|
||||
CVF_ASSERT(m_texMapper.notNull());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
||||
{
|
||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigTernaryResultAccessor2d.h"
|
||||
#include "RivTernaryResultToTextureMapper.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
class RimResultSlot;
|
||||
class RigTernaryResultAccessor;
|
||||
class RivTernaryResultToTextureMapper;
|
||||
class RimTernaryLegendConfig;
|
||||
|
||||
namespace cvf
|
||||
@ -33,6 +34,9 @@ namespace cvf
|
||||
}
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RivTernaryTextureCoordsCreator
|
||||
{
|
||||
public:
|
||||
@ -42,10 +46,7 @@ public:
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
||||
|
||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
||||
{
|
||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords);
|
||||
|
||||
private:
|
||||
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
||||
@ -53,6 +54,7 @@ private:
|
||||
const RigTernaryResultAccessor* resultAccessor,
|
||||
const RivTernaryResultToTextureMapper* texMapper);
|
||||
|
||||
private:
|
||||
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;
|
||||
cvf::ref<RivTernaryResultToTextureMapper> m_texMapper;
|
||||
|
@ -52,29 +52,29 @@ void RigTernaryResultAccessor::setTernaryResultAccessors(RigResultAccessor* soil
|
||||
cvf::Vec2d RigTernaryResultAccessor::cellScalar(size_t gridLocalCellIndex) const
|
||||
{
|
||||
double soil = 0.0;
|
||||
double swat = 0.0;
|
||||
double sgas = 0.0;
|
||||
|
||||
if (m_soilAccessor.notNull())
|
||||
{
|
||||
soil = m_soilAccessor->cellScalar(gridLocalCellIndex);
|
||||
|
||||
if (m_swatAccessor.notNull())
|
||||
if (m_sgasAccessor.notNull())
|
||||
{
|
||||
swat = m_swatAccessor->cellScalar(gridLocalCellIndex);
|
||||
sgas = m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
swat = 1.0 - soil - m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
||||
sgas = 1.0 - soil - m_swatAccessor->cellScalar(gridLocalCellIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
swat = m_swatAccessor->cellScalar(gridLocalCellIndex);
|
||||
sgas = m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
||||
|
||||
soil = 1.0 - swat - m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
||||
soil = 1.0 - sgas - m_swatAccessor->cellScalar(gridLocalCellIndex);
|
||||
}
|
||||
|
||||
return cvf::Vec2d(soil, swat);
|
||||
return cvf::Vec2d(soil, sgas);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
/// Requires two of the arguments to be present
|
||||
void setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat);
|
||||
|
||||
/// Returns [SOil, SWat] regardless of which one of the three is missing. if Soil or SWat is missing, it is calculated
|
||||
/// Returns [SOIL, SGAS] regardless of which one of the three is missing. if Soil or SWat is missing, it is calculated
|
||||
/// based on the two others
|
||||
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const;
|
||||
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
|
||||
|
Loading…
Reference in New Issue
Block a user