mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5019 Refactor the color generation in the boxintersection into static methods
These methods are to be used from the normal intersections as well.
This commit is contained in:
parent
c8053284d1
commit
46f335ad0b
@ -37,7 +37,16 @@ class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
} // namespace cvf
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator : public cvf::Object
|
||||
class RivIntersectionGeometryGeneratorIF
|
||||
{
|
||||
public:
|
||||
virtual bool isAnyGeometryPresent() const = 0;
|
||||
virtual const std::vector<size_t>& triangleToCellIndex() const = 0;
|
||||
virtual const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const = 0;
|
||||
virtual const cvf::Vec3fArray* triangleVxes() const = 0;
|
||||
};
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF
|
||||
{
|
||||
public:
|
||||
RivIntersectionBoxGeometryGenerator( RimIntersectionBox* intersectionBox,
|
||||
@ -45,16 +54,16 @@ public:
|
||||
|
||||
~RivIntersectionBoxGeometryGenerator() override;
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
bool isAnyGeometryPresent() const override;
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const override;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const override;
|
||||
const cvf::Vec3fArray* triangleVxes() const override;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
const cvf::Vec3fArray* triangleVxes() const;
|
||||
|
||||
RimIntersectionBox* intersectionBox() const;
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimIntersectionResultDefinition.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
|
||||
@ -80,47 +81,132 @@ void RivIntersectionBoxPartMgr::applySingleColorEffect()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper )
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
|
||||
{
|
||||
if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return;
|
||||
RivIntersectionBoxPartMgr::updateCellResultColorStatic( timeStepIndex,
|
||||
m_rimIntersectionBox,
|
||||
m_intersectionBoxGenerator.p(),
|
||||
m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p() );
|
||||
}
|
||||
|
||||
CVF_ASSERT( scalarColorMapper );
|
||||
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
|
||||
|
||||
if ( eclipseView )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColorStatic(
|
||||
size_t timeStepIndex,
|
||||
RimIntersectionHandle* rimIntersectionHandle,
|
||||
const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF,
|
||||
cvf::Part* intersectionFacesPart,
|
||||
cvf::Vec2fArray* intersectionFacesTextureCoords )
|
||||
{
|
||||
bool isLightingDisabled = eclipseView->isLightingDisabled();
|
||||
if ( !intersectionGeomGenIF->isAnyGeometryPresent() ) return;
|
||||
|
||||
RimEclipseResultDefinition* eclipseResDef = eclipseView->cellResult();
|
||||
bool isTernaryResult = eclipseResDef->isTernarySaturationSelected();
|
||||
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
|
||||
RimGridView* gridView = nullptr;
|
||||
rimIntersectionHandle->firstAncestorOrThisOfType( gridView );
|
||||
|
||||
CVF_ASSERT( eclipseResDef );
|
||||
if ( !gridView ) return;
|
||||
|
||||
// CrossSections
|
||||
if ( m_intersectionBoxFaces.notNull() )
|
||||
bool isLightingDisabled = gridView->isLightingDisabled();
|
||||
|
||||
RimEclipseResultDefinition* eclipseResDef = nullptr;
|
||||
RimGeoMechResultDefinition* geomResultDef = nullptr;
|
||||
const cvf::ScalarMapper* scalarColorMapper = nullptr;
|
||||
const RivTernaryScalarMapper* ternaryColorMapper = nullptr;
|
||||
|
||||
// Separate intersection result
|
||||
|
||||
RimIntersectionResultDefinition* sepResDef = rimIntersectionHandle->activeSeparateResultDefinition();
|
||||
if ( sepResDef && sepResDef->activeCase() )
|
||||
{
|
||||
if ( isTernaryResult )
|
||||
if ( sepResDef->isEclipseResultDefinition() )
|
||||
{
|
||||
RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
|
||||
|
||||
texturer.createTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
m_intersectionBoxGenerator->triangleToCellIndex() );
|
||||
|
||||
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
ternaryColorMapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
isLightingDisabled );
|
||||
eclipseResDef = sepResDef->eclipseResultDefinition();
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT( m_intersectionBoxGenerator.notNull() );
|
||||
geomResultDef = sepResDef->geoMechResultDefinition();
|
||||
}
|
||||
|
||||
scalarColorMapper = sepResDef->regularLegendConfig()->scalarMapper();
|
||||
ternaryColorMapper = sepResDef->ternaryLegendConfig()->scalarMapper();
|
||||
timeStepIndex = sepResDef->timeStep();
|
||||
}
|
||||
|
||||
// Ordinary result
|
||||
|
||||
if ( !eclipseResDef && !geomResultDef )
|
||||
{
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
rimIntersectionHandle->firstAncestorOrThisOfType( eclipseView );
|
||||
|
||||
if ( eclipseView )
|
||||
{
|
||||
eclipseResDef = eclipseView->cellResult();
|
||||
scalarColorMapper = eclipseView->cellResult()->legendConfig()->scalarMapper();
|
||||
ternaryColorMapper = eclipseView->cellResult()->ternaryLegendConfig()->scalarMapper();
|
||||
timeStepIndex = eclipseView->currentTimeStep();
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
rimIntersectionHandle->firstAncestorOrThisOfType( geoView );
|
||||
|
||||
if ( geoView )
|
||||
{
|
||||
geomResultDef = geoView->cellResult();
|
||||
scalarColorMapper = geoView->cellResult()->legendConfig()->scalarMapper();
|
||||
timeStepIndex = geoView->currentTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
if ( eclipseResDef )
|
||||
{
|
||||
if ( eclipseResDef->isTernarySaturationSelected() )
|
||||
{
|
||||
updateEclipseTernaryCellResultColors( eclipseResDef,
|
||||
ternaryColorMapper,
|
||||
timeStepIndex,
|
||||
isLightingDisabled,
|
||||
intersectionGeomGenIF->triangleToCellIndex(),
|
||||
intersectionFacesPart,
|
||||
intersectionFacesTextureCoords );
|
||||
}
|
||||
else
|
||||
{
|
||||
updateEclipseCellResultColors( eclipseResDef,
|
||||
scalarColorMapper,
|
||||
timeStepIndex,
|
||||
isLightingDisabled,
|
||||
intersectionGeomGenIF->triangleToCellIndex(),
|
||||
intersectionFacesPart,
|
||||
intersectionFacesTextureCoords );
|
||||
}
|
||||
}
|
||||
else if ( geomResultDef )
|
||||
{
|
||||
updateGeoMechCellResultColors( geomResultDef,
|
||||
timeStepIndex,
|
||||
scalarColorMapper,
|
||||
isLightingDisabled,
|
||||
intersectionGeomGenIF,
|
||||
intersectionFacesPart,
|
||||
intersectionFacesTextureCoords );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateEclipseCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
size_t timeStepIndex,
|
||||
bool isLightingDisabled,
|
||||
const std::vector<size_t>& triangleToCellIndexMapping,
|
||||
cvf::Part* intersectionFacesPart,
|
||||
cvf::Vec2fArray* intersectionFacesTextureCoords )
|
||||
{
|
||||
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
|
||||
|
||||
cvf::ref<RigResultAccessor> resultAccessor;
|
||||
|
||||
@ -136,46 +222,74 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t
|
||||
eclipseResDef );
|
||||
}
|
||||
|
||||
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_intersectionBoxFacesTextureCoords.p(),
|
||||
m_intersectionBoxGenerator->triangleToCellIndex(),
|
||||
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( intersectionFacesTextureCoords,
|
||||
triangleToCellIndexMapping,
|
||||
resultAccessor.p(),
|
||||
scalarColorMapper );
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( intersectionFacesPart,
|
||||
intersectionFacesTextureCoords,
|
||||
scalarColorMapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
isLightingDisabled );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( geoView );
|
||||
|
||||
if ( geoView )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateEclipseTernaryCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper,
|
||||
size_t timeStepIndex,
|
||||
bool isLightingDisabled,
|
||||
const std::vector<size_t>& triangleToCellIndexMapping,
|
||||
cvf::Part* intersectionFacesPart,
|
||||
cvf::Vec2fArray* intersectionFacesTextureCoords )
|
||||
{
|
||||
bool isLightingDisabled = geoView->isLightingDisabled();
|
||||
RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
|
||||
|
||||
texturer.createTextureCoords( intersectionFacesTextureCoords, triangleToCellIndexMapping );
|
||||
|
||||
RivScalarMapperUtils::applyTernaryTextureResultsToPart( intersectionFacesPart,
|
||||
intersectionFacesTextureCoords,
|
||||
ternaryColorMapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
isLightingDisabled );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef,
|
||||
size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
bool isLightingDisabled,
|
||||
const RivIntersectionGeometryGeneratorIF* geomGenerator,
|
||||
cvf::Part* intersectionFacesPart,
|
||||
cvf::Vec2fArray* intersectionFacesTextureCoords )
|
||||
{
|
||||
RigGeoMechCaseData* caseData = nullptr;
|
||||
RigFemResultAddress resVarAddress;
|
||||
{
|
||||
RimGeoMechResultDefinition* geomResultDef = geoView->cellResult();
|
||||
caseData = geomResultDef->ownerCaseData();
|
||||
resVarAddress = geomResultDef->resultAddress();
|
||||
}
|
||||
|
||||
if ( !caseData ) return;
|
||||
|
||||
const std::vector<size_t>& triangleToCellIdx = geomGenerator->triangleToCellIndex();
|
||||
const cvf::Vec3fArray* triangelVxes = geomGenerator->triangleVxes();
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
|
||||
geomGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
|
||||
if ( resVarAddress.resultPosType == RIG_ELEMENT )
|
||||
{
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
|
||||
0,
|
||||
(int)timeStepIndex );
|
||||
const std::vector<size_t>& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex();
|
||||
|
||||
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
|
||||
resultValues,
|
||||
triangleToCellIdx,
|
||||
scalarColorMapper );
|
||||
@ -183,21 +297,17 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
|
||||
{
|
||||
// Special direction sensitive result calculation
|
||||
const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes();
|
||||
|
||||
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
|
||||
{
|
||||
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords,
|
||||
triangelVxes,
|
||||
resVarAddress,
|
||||
scalarColorMapper );
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
|
||||
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
|
||||
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords,
|
||||
triangelVxes,
|
||||
vertexWeights,
|
||||
caseData,
|
||||
@ -209,19 +319,20 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t
|
||||
else
|
||||
{
|
||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
||||
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
|
||||
{
|
||||
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
}
|
||||
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
|
||||
0,
|
||||
(int)timeStepIndex );
|
||||
|
||||
RigFemPart* femPart = caseData->femParts()->part( 0 );
|
||||
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
|
||||
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
|
||||
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords
|
||||
.p(),
|
||||
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
|
||||
vertexWeights,
|
||||
resultValues,
|
||||
isElementNodalResult,
|
||||
@ -229,14 +340,13 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t
|
||||
scalarColorMapper );
|
||||
}
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( intersectionFacesPart,
|
||||
intersectionFacesTextureCoords,
|
||||
scalarColorMapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
isLightingDisabled );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -32,10 +32,18 @@ class ScalarMapper;
|
||||
|
||||
class RigMainGrid;
|
||||
class RigResultAccessor;
|
||||
|
||||
class RivTernaryScalarMapper;
|
||||
|
||||
class RimCellEdgeColors;
|
||||
class RimEclipseCellColors;
|
||||
class RimIntersectionBox;
|
||||
class RivTernaryScalarMapper;
|
||||
class RimIntersectionHandle;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechView;
|
||||
class RimEclipseResultDefinition;
|
||||
class RimGeoMechResultDefinition;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -48,9 +56,7 @@ public:
|
||||
explicit RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox );
|
||||
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor( size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper );
|
||||
void updateCellResultColor( size_t timeStepIndex );
|
||||
|
||||
void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
@ -59,6 +65,35 @@ private:
|
||||
void updatePartEffect();
|
||||
void generatePartGeometry();
|
||||
|
||||
static void updateCellResultColorStatic( size_t timeStepIndex,
|
||||
RimIntersectionHandle* m_rimIntersectionBox,
|
||||
const RivIntersectionGeometryGeneratorIF* m_intersectionBoxGenerator,
|
||||
cvf::Part* m_intersectionBoxFaces,
|
||||
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
|
||||
static void updateEclipseCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
size_t timeStepIndex,
|
||||
bool isLightingDisabled,
|
||||
const std::vector<size_t>& triangleToCellIndexMapping,
|
||||
cvf::Part* m_intersectionBoxFaces,
|
||||
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
|
||||
|
||||
static void updateEclipseTernaryCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper,
|
||||
size_t timeStepIndex,
|
||||
bool isLightingDisabled,
|
||||
const std::vector<size_t>& triangleToCellIndexMapping,
|
||||
cvf::Part* m_intersectionBoxFaces,
|
||||
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
|
||||
|
||||
static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef,
|
||||
size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
bool isLightingDisabled,
|
||||
const RivIntersectionGeometryGeneratorIF* geomGenerator,
|
||||
cvf::Part* m_intersectionBoxFaces,
|
||||
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
|
||||
|
||||
private:
|
||||
RimIntersectionBox* m_rimIntersectionBox;
|
||||
|
||||
|
@ -115,7 +115,7 @@ void RimIntersectionCollection::updateCellResultColor( size_t
|
||||
{
|
||||
if ( cs->isActive() )
|
||||
{
|
||||
cs->intersectionBoxPartMgr()->updateCellResultColor( timeStepIndex, scalarColorMapper, ternaryColorMapper );
|
||||
cs->intersectionBoxPartMgr()->updateCellResultColor( timeStepIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user