Intersection color texturing: Remove dependency on view and RimEclipseResultColor

Also start to harmonize intersection and intersection box texturing
This commit is contained in:
Jacob Støren 2019-11-18 16:05:36 +01:00
parent db0bbb96c4
commit 57dfd3b67a
8 changed files with 60 additions and 47 deletions

View File

@ -80,7 +80,9 @@ void RivIntersectionBoxPartMgr::applySingleColorEffect()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex ) void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper )
{ {
if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return; if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return;
@ -89,62 +91,60 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
if ( eclipseView ) if ( eclipseView )
{ {
RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); bool isLightingDisabled = eclipseView->isLightingDisabled();
CVF_ASSERT( cellResultColors );
RimEclipseResultDefinition* eclipseResDef = eclipseView->cellResult();
bool isTernaryResult = eclipseResDef->isTernarySaturationSelected();
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
CVF_ASSERT( eclipseResDef );
// CrossSections // CrossSections
if ( m_intersectionBoxFaces.notNull() ) if ( m_intersectionBoxFaces.notNull() )
{ {
if ( cellResultColors->isTernarySaturationSelected() ) if ( isTernaryResult )
{ {
RivTernaryTextureCoordsCreator texturer( cellResultColors, RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
cellResultColors->ternaryLegendConfig()->scalarMapper(),
timeStepIndex );
texturer.createTextureCoords( m_intersectionBoxFacesTextureCoords.p(), texturer.createTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex() ); m_intersectionBoxGenerator->triangleToCellIndex() );
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
mapper, ternaryColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled() ); isLightingDisabled );
} }
else else
{ {
CVF_ASSERT( m_intersectionBoxGenerator.notNull() ); CVF_ASSERT( m_intersectionBoxGenerator.notNull() );
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
cvf::ref<RigResultAccessor> resultAccessor; cvf::ref<RigResultAccessor> resultAccessor;
if ( RiaDefines::isPerCellFaceResult( cellResultColors->resultVariable() ) ) if ( RiaDefines::isPerCellFaceResult( eclipseResDef->resultVariable() ) )
{ {
resultAccessor = new RigHugeValResultAccessor; resultAccessor = new RigHugeValResultAccessor;
} }
else else
{ {
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( cellResultColors resultAccessor = RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData,
->reservoirView()
->eclipseCase()
->eclipseCaseData(),
0, 0,
timeStepIndex, timeStepIndex,
cellResultColors ); eclipseResDef );
} }
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex(), m_intersectionBoxGenerator->triangleToCellIndex(),
resultAccessor.p(), resultAccessor.p(),
mapper ); scalarColorMapper );
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
mapper, scalarColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled() ); isLightingDisabled );
} }
} }
} }
@ -154,15 +154,18 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
if ( geoView ) if ( geoView )
{ {
RimGeoMechCellColors* cellResultColors = geoView->cellResult(); bool isLightingDisabled = geoView->isLightingDisabled();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
RigGeoMechCaseData* caseData = nullptr;
RigFemResultAddress resVarAddress;
{
RimGeoMechResultDefinition* geomResultDef = geoView->cellResult();
caseData = geomResultDef->ownerCaseData();
resVarAddress = geomResultDef->resultAddress();
}
if ( !caseData ) return; if ( !caseData ) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if ( resVarAddress.resultPosType == RIG_ELEMENT ) if ( resVarAddress.resultPosType == RIG_ELEMENT )
{ {
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress, const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
@ -173,7 +176,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
resultValues, resultValues,
triangleToCellIdx, triangleToCellIdx,
mapper ); scalarColorMapper );
} }
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE ) else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
{ {
@ -185,7 +188,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
triangelVxes, triangelVxes,
resVarAddress, resVarAddress,
mapper ); scalarColorMapper );
} }
else else
{ {
@ -198,7 +201,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
caseData, caseData,
resVarAddress, resVarAddress,
(int)timeStepIndex, (int)timeStepIndex,
mapper ); scalarColorMapper );
} }
} }
else else
@ -221,15 +224,15 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
resultValues, resultValues,
isElementNodalResult, isElementNodalResult,
femPart, femPart,
mapper ); scalarColorMapper );
} }
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
mapper, scalarColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
geoView->isLightingDisabled() ); isLightingDisabled );
} }
} }

View File

@ -27,6 +27,7 @@ namespace cvf
class ModelBasicList; class ModelBasicList;
class Transform; class Transform;
class Part; class Part;
class ScalarMapper;
} // namespace cvf } // namespace cvf
class RigMainGrid; class RigMainGrid;
@ -34,6 +35,7 @@ class RigResultAccessor;
class RimCellEdgeColors; class RimCellEdgeColors;
class RimEclipseCellColors; class RimEclipseCellColors;
class RimIntersectionBox; class RimIntersectionBox;
class RivTernaryScalarMapper;
//================================================================================================== //==================================================================================================
/// ///
@ -46,7 +48,9 @@ public:
explicit RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox ); explicit RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox );
void applySingleColorEffect(); void applySingleColorEffect();
void updateCellResultColor( size_t timeStepIndex ); void updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper );
void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );

View File

@ -247,6 +247,7 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(
RivTernaryTextureCoordsCreator texturer( cellResultColors, RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(), cellResultColors->ternaryLegendConfig(),
cellResultColors->reservoirView()->wellCollection(),
timeStepIndex, timeStepIndex,
gridIndex, gridIndex,
quadToCellFaceMapper ); quadToCellFaceMapper );

View File

@ -120,6 +120,7 @@ void RivFaultPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCel
{ {
RivTernaryTextureCoordsCreator texturer( cellResultColors, RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(), cellResultColors->ternaryLegendConfig(),
eclipseView->wellCollection(),
timeStepIndex, timeStepIndex,
m_grid->gridIndex(), m_grid->gridIndex(),
m_nativeFaultGenerator->quadToCellFaceMapper() ); m_nativeFaultGenerator->quadToCellFaceMapper() );
@ -164,6 +165,7 @@ void RivFaultPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCel
{ {
RivTernaryTextureCoordsCreator texturer( cellResultColors, RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(), cellResultColors->ternaryLegendConfig(),
eclipseView->wellCollection(),
timeStepIndex, timeStepIndex,
m_grid->gridIndex(), m_grid->gridIndex(),
m_oppositeFaultGenerator->quadToCellFaceMapper() ); m_oppositeFaultGenerator->quadToCellFaceMapper() );

View File

@ -254,6 +254,7 @@ void RivGridPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCell
{ {
RivTernaryTextureCoordsCreator texturer( cellResultColors, RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(), cellResultColors->ternaryLegendConfig(),
cellResultColors->reservoirView()->wellCollection(),
timeStepIndex, timeStepIndex,
m_grid->gridIndex(), m_grid->gridIndex(),
m_surfaceGenerator.quadToCellFaceMapper() ); m_surfaceGenerator.quadToCellFaceMapper() );

View File

@ -26,7 +26,7 @@
#include "RigTernaryResultAccessor.h" #include "RigTernaryResultAccessor.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseCellColors.h" #include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimSimWellInViewCollection.h" #include "RimSimWellInViewCollection.h"
#include "RimTernaryLegendConfig.h" #include "RimTernaryLegendConfig.h"
@ -39,16 +39,17 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseResultDefinition* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig, RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex, RimSimWellInViewCollection* simWellInViewCollection,
size_t gridIndex, size_t timeStepIndex,
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper ) const cvf::StructGridQuadToCellFaceMapper* quadMapper )
{ {
CVF_ASSERT( quadMapper ); CVF_ASSERT( quadMapper );
m_quadMapper = quadMapper; m_quadMapper = quadMapper;
RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
size_t resTimeStepIdx = timeStepIndex; size_t resTimeStepIdx = timeStepIndex;
@ -79,8 +80,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellCo
m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() ); m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() );
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = cvf::ref<RigPipeInCellEvaluator> pipeInCellEval =
new RigPipeInCellEvaluator( cellResultColors->reservoirView()->wellCollection()->resultWellGeometryVisibilities( new RigPipeInCellEvaluator( simWellInViewCollection->resultWellGeometryVisibilities( timeStepIndex ),
timeStepIndex ),
eclipseCase->gridCellToResultWellIndex( gridIndex ) ); eclipseCase->gridCellToResultWellIndex( gridIndex ) );
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper(); const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
@ -92,12 +92,12 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellCo
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseResultDefinition* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper, const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex ) size_t timeStepIndex )
: m_quadMapper( nullptr ) : m_quadMapper( nullptr )
{ {
RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
size_t resTimeStepIdx = timeStepIndex; size_t resTimeStepIdx = timeStepIndex;

View File

@ -25,8 +25,9 @@
#include "cvfArray.h" #include "cvfArray.h"
#include "cvfObject.h" #include "cvfObject.h"
class RimEclipseCellColors; class RimEclipseResultDefinition;
class RimTernaryLegendConfig; class RimTernaryLegendConfig;
class RimSimWellInViewCollection;
namespace cvf namespace cvf
{ {
@ -39,13 +40,14 @@ class StructGridQuadToCellFaceMapper;
class RivTernaryTextureCoordsCreator class RivTernaryTextureCoordsCreator
{ {
public: public:
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, RivTernaryTextureCoordsCreator( RimEclipseResultDefinition* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig, RimTernaryLegendConfig* ternaryLegendConfig,
RimSimWellInViewCollection* simWellInViewCollection,
size_t timeStepIndex, size_t timeStepIndex,
size_t gridIndex, size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper ); const cvf::StructGridQuadToCellFaceMapper* quadMapper );
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, RivTernaryTextureCoordsCreator( RimEclipseResultDefinition* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper, const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex ); size_t timeStepIndex );

View File

@ -115,7 +115,7 @@ void RimIntersectionCollection::updateCellResultColor( size_t
{ {
if ( cs->isActive() ) if ( cs->isActive() )
{ {
cs->intersectionBoxPartMgr()->updateCellResultColor( timeStepIndex ); cs->intersectionBoxPartMgr()->updateCellResultColor( timeStepIndex, scalarColorMapper, ternaryColorMapper );
} }
} }
} }