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

View File

@ -27,6 +27,7 @@ namespace cvf
class ModelBasicList;
class Transform;
class Part;
class ScalarMapper;
} // namespace cvf
class RigMainGrid;
@ -34,6 +35,7 @@ class RigResultAccessor;
class RimCellEdgeColors;
class RimEclipseCellColors;
class RimIntersectionBox;
class RivTernaryScalarMapper;
//==================================================================================================
///
@ -46,7 +48,9 @@ public:
explicit RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox );
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 appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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