Use RivScalarMapperUtils

This commit is contained in:
Magne Sjaastad 2014-08-11 13:59:12 +02:00
parent eca4276adb
commit 03b68e08c3
2 changed files with 42 additions and 98 deletions

View File

@ -18,11 +18,34 @@
#include "RivGridPartMgr.h" #include "RivGridPartMgr.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigResultAccessorFactory.h"
#include "RimCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimTernaryLegendConfig.h"
#include "RimWellCollection.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
#include "RivSourceInfo.h"
#include "RivTernaryScalarMapperEffectGenerator.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "RivTextureCoordsCreator.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
#include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h" #include "cafPdmFieldCvfMat4d.h"
#include "cafProgressInfo.h" #include "cafProgressInfo.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfMath.h" #include "cvfMath.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
@ -35,27 +58,8 @@
#include "cvfShaderSourceProvider.h" #include "cvfShaderSourceProvider.h"
#include "cvfShaderSourceRepository.h" #include "cvfShaderSourceRepository.h"
#include "cvfStructGrid.h" #include "cvfStructGrid.h"
#include "cvfUniform.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimTernaryLegendConfig.h"
#include "RimWellCollection.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RivSourceInfo.h"
#include "cvfStructGridGeometryGenerator.h" #include "cvfStructGridGeometryGenerator.h"
#include "RigResultAccessorFactory.h" #include "cvfUniform.h"
#include "RivResultToTextureMapper.h"
#include "RivTextureCoordsCreator.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "RivTernaryScalarMapperEffectGenerator.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -221,7 +225,6 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
{ {
CVF_ASSERT(cellResultSlot); CVF_ASSERT(cellResultSlot);
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray; cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
@ -238,21 +241,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
//void RivGridPartMgr::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper) const RivTernaryScalarMapper* mapper = cellResultSlot->ternaryLegendConfig()->scalarMapper();
{ RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel);
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
{ {
@ -267,54 +257,10 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper); const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
} RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel);
// 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);
// }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Effect> RivGridPartMgr::createScalarMapperEffect(const cvf::ScalarMapper* mapper)
{
caf::PolygonOffset polygonOffset = caf::PO_1;
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
scalarEffgen.setOpacityLevel(m_opacityLevel);
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
return scalarEffect;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper)
{
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
if (dg) dg->setTextureCoordArray(textureCoords);
cvf::ref<cvf::Effect> scalarEffect = createScalarMapperEffect(mapper);
part->setEffect(scalarEffect.p());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -84,8 +84,6 @@ public:
private: private:
void generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder); void generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder);
void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper);
cvf::ref<cvf::Effect> createScalarMapperEffect(const cvf::ScalarMapper* mapper);
void updateCellEdgeResultColorOnPart(cvf::Part* facePart, void updateCellEdgeResultColorOnPart(cvf::Part* facePart,
cvf::StructGridGeometryGenerator* surfaceGenerator, cvf::StructGridGeometryGenerator* surfaceGenerator,
size_t timeStepIndex, size_t timeStepIndex,