Unification of color texturing code in Intersection and -Box

This commit is contained in:
Jacob Støren 2019-11-19 10:21:22 +01:00
parent 57dfd3b67a
commit dcb32c285f
2 changed files with 29 additions and 23 deletions

View File

@ -86,7 +86,9 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t
{ {
if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return; if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return;
RimEclipseView* eclipseView; CVF_ASSERT( scalarColorMapper );
RimEclipseView* eclipseView = nullptr;
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView ); m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView ) if ( eclipseView )

View File

@ -152,27 +152,29 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
const cvf::ScalarMapper* scalarColorMapper, const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper ) const RivTernaryScalarMapper* ternaryColorMapper )
{ {
CVF_ASSERT( scalarColorMapper );
if ( m_crossSectionGenerator.isNull() ) return;
if ( !m_crossSectionGenerator->isAnyGeometryPresent() ) return; if ( !m_crossSectionGenerator->isAnyGeometryPresent() ) return;
CVF_ASSERT( scalarColorMapper );
RimEclipseView* eclipseView = nullptr; RimEclipseView* eclipseView = nullptr;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView ); m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView ) if ( eclipseView )
{ {
RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); bool isLightingDisabled = eclipseView->isLightingDisabled();
CVF_ASSERT( cellResultColors );
CVF_ASSERT( ternaryColorMapper ); RimEclipseResultDefinition* eclipseResDef = eclipseView->cellResult();
bool isTernaryResult = eclipseResDef->isTernarySaturationSelected();
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
CVF_ASSERT( eclipseResDef );
// CrossSections // CrossSections
if ( m_crossSectionFaces.notNull() ) if ( m_crossSectionFaces.notNull() )
{ {
if ( cellResultColors->isTernarySaturationSelected() ) if ( isTernaryResult )
{ {
RivTernaryTextureCoordsCreator texturer( cellResultColors, ternaryColorMapper, timeStepIndex ); RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
texturer.createTextureCoords( m_crossSectionFacesTextureCoords.p(), texturer.createTextureCoords( m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex() ); m_crossSectionGenerator->triangleToCellIndex() );
@ -182,7 +184,7 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
ternaryColorMapper, ternaryColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled() ); isLightingDisabled );
} }
else else
{ {
@ -190,19 +192,16 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
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_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_crossSectionFacesTextureCoords.p(),
@ -215,7 +214,7 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
scalarColorMapper, scalarColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled() ); isLightingDisabled );
} }
} }
} }
@ -225,13 +224,18 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
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();
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,
@ -298,7 +302,7 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
scalarColorMapper, scalarColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
geoView->isLightingDisabled() ); isLightingDisabled );
} }
} }