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:
@@ -54,6 +54,8 @@
|
|||||||
#include "RigResultAccessorFactory.h"
|
#include "RigResultAccessorFactory.h"
|
||||||
#include "RivResultToTextureMapper.h"
|
#include "RivResultToTextureMapper.h"
|
||||||
#include "RivTextureCoordsCreator.h"
|
#include "RivTextureCoordsCreator.h"
|
||||||
|
#include "RivTernaryTextureCoordsCreator.h"
|
||||||
|
#include "RivTernaryScalarMapperEffectGenerator.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -229,9 +231,28 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
|||||||
{
|
{
|
||||||
if (cellResultSlot->isTernarySaturationSelected())
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -241,26 +262,28 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
|||||||
m_surfaceGenerator.quadToCellFaceMapper());
|
m_surfaceGenerator.quadToCellFaceMapper());
|
||||||
|
|
||||||
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
|
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
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());
|
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
|
#pragma once
|
||||||
|
|
||||||
|
#include "RigTernaryResultAccessor2d.h"
|
||||||
|
#include "RivTernaryResultToTextureMapper.h"
|
||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfArray.h"
|
#include "cvfArray.h"
|
||||||
|
|
||||||
class RimResultSlot;
|
class RimResultSlot;
|
||||||
class RigTernaryResultAccessor;
|
|
||||||
class RivTernaryResultToTextureMapper;
|
|
||||||
class RimTernaryLegendConfig;
|
class RimTernaryLegendConfig;
|
||||||
|
|
||||||
namespace cvf
|
namespace cvf
|
||||||
@@ -33,6 +34,9 @@ namespace cvf
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
class RivTernaryTextureCoordsCreator
|
class RivTernaryTextureCoordsCreator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -42,10 +46,7 @@ public:
|
|||||||
size_t gridIndex,
|
size_t gridIndex,
|
||||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
||||||
|
|
||||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords);
|
||||||
{
|
|
||||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
||||||
@@ -53,6 +54,7 @@ private:
|
|||||||
const RigTernaryResultAccessor* resultAccessor,
|
const RigTernaryResultAccessor* resultAccessor,
|
||||||
const RivTernaryResultToTextureMapper* texMapper);
|
const RivTernaryResultToTextureMapper* texMapper);
|
||||||
|
|
||||||
|
private:
|
||||||
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||||
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;
|
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;
|
||||||
cvf::ref<RivTernaryResultToTextureMapper> m_texMapper;
|
cvf::ref<RivTernaryResultToTextureMapper> m_texMapper;
|
||||||
|
|||||||
@@ -52,29 +52,29 @@ void RigTernaryResultAccessor::setTernaryResultAccessors(RigResultAccessor* soil
|
|||||||
cvf::Vec2d RigTernaryResultAccessor::cellScalar(size_t gridLocalCellIndex) const
|
cvf::Vec2d RigTernaryResultAccessor::cellScalar(size_t gridLocalCellIndex) const
|
||||||
{
|
{
|
||||||
double soil = 0.0;
|
double soil = 0.0;
|
||||||
double swat = 0.0;
|
double sgas = 0.0;
|
||||||
|
|
||||||
if (m_soilAccessor.notNull())
|
if (m_soilAccessor.notNull())
|
||||||
{
|
{
|
||||||
soil = m_soilAccessor->cellScalar(gridLocalCellIndex);
|
soil = m_soilAccessor->cellScalar(gridLocalCellIndex);
|
||||||
|
|
||||||
if (m_swatAccessor.notNull())
|
if (m_sgasAccessor.notNull())
|
||||||
{
|
{
|
||||||
swat = m_swatAccessor->cellScalar(gridLocalCellIndex);
|
sgas = m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
swat = 1.0 - soil - m_sgasAccessor->cellScalar(gridLocalCellIndex);
|
sgas = 1.0 - soil - m_swatAccessor->cellScalar(gridLocalCellIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
/// Requires two of the arguments to be present
|
||||||
void setTernaryResultAccessors(RigResultAccessor* soil, RigResultAccessor* sgas, RigResultAccessor* swat);
|
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
|
/// based on the two others
|
||||||
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const;
|
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const;
|
||||||
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
|
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user