#5019 Use the static methods to color intersections as well

Move all the color/texture  generation methods into a separate tools class.
(Only scope wise)
This commit is contained in:
Jacob Støren
2019-11-20 13:01:25 +01:00
parent 46f335ad0b
commit cd08185678
7 changed files with 182 additions and 311 deletions

View File

@@ -223,3 +223,12 @@ private:
std::array<float, 8> m_weights;
int m_count;
};
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;
};

View File

@@ -37,14 +37,6 @@ class ScalarMapper;
class DrawableGeo;
} // namespace cvf
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
{

View File

@@ -83,7 +83,7 @@ void RivIntersectionBoxPartMgr::applySingleColorEffect()
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
{
RivIntersectionBoxPartMgr::updateCellResultColorStatic( timeStepIndex,
RivIntersectionResultsColoringTools::updateCellResultColorStatic( timeStepIndex,
m_rimIntersectionBox,
m_intersectionBoxGenerator.p(),
m_intersectionBoxFaces.p(),
@@ -93,7 +93,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateCellResultColorStatic(
void RivIntersectionResultsColoringTools::updateCellResultColorStatic(
size_t timeStepIndex,
RimIntersectionHandle* rimIntersectionHandle,
const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF,
@@ -163,17 +163,18 @@ void RivIntersectionBoxPartMgr::updateCellResultColorStatic(
{
if ( eclipseResDef->isTernarySaturationSelected() )
{
updateEclipseTernaryCellResultColors( eclipseResDef,
RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors( eclipseResDef,
ternaryColorMapper,
timeStepIndex,
isLightingDisabled,
intersectionGeomGenIF->triangleToCellIndex(),
intersectionGeomGenIF
->triangleToCellIndex(),
intersectionFacesPart,
intersectionFacesTextureCoords );
}
else
{
updateEclipseCellResultColors( eclipseResDef,
RivIntersectionResultsColoringTools::updateEclipseCellResultColors( eclipseResDef,
scalarColorMapper,
timeStepIndex,
isLightingDisabled,
@@ -184,7 +185,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColorStatic(
}
else if ( geomResultDef )
{
updateGeoMechCellResultColors( geomResultDef,
RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( geomResultDef,
timeStepIndex,
scalarColorMapper,
isLightingDisabled,
@@ -198,7 +199,8 @@ void RivIntersectionBoxPartMgr::updateCellResultColorStatic(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateEclipseCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
void RivIntersectionResultsColoringTools::updateEclipseCellResultColors(
const RimEclipseResultDefinition* eclipseResDef,
const cvf::ScalarMapper* scalarColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
@@ -222,7 +224,7 @@ void RivIntersectionBoxPartMgr::updateEclipseCellResultColors( const RimEclipseR
eclipseResDef );
}
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( intersectionFacesTextureCoords,
RivIntersectionResultsColoringTools::calculateEclipseTextureCoordinates( intersectionFacesTextureCoords,
triangleToCellIndexMapping,
resultAccessor.p(),
scalarColorMapper );
@@ -238,7 +240,8 @@ void RivIntersectionBoxPartMgr::updateEclipseCellResultColors( const RimEclipseR
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateEclipseTernaryCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
void RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors(
const RimEclipseResultDefinition* eclipseResDef,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
@@ -261,7 +264,8 @@ void RivIntersectionBoxPartMgr::updateEclipseTernaryCellResultColors( const RimE
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef,
void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
const RimGeoMechResultDefinition* geomResultDef,
size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
bool isLightingDisabled,
@@ -289,7 +293,7 @@ void RivIntersectionBoxPartMgr::updateGeoMechCellResultColors( const RimGeoMechR
0,
(int)timeStepIndex );
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
resultValues,
triangleToCellIdx,
scalarColorMapper );
@@ -300,14 +304,14 @@ void RivIntersectionBoxPartMgr::updateGeoMechCellResultColors( const RimGeoMechR
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
{
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords,
RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords,
triangelVxes,
resVarAddress,
scalarColorMapper );
}
else
{
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords,
RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords,
triangelVxes,
vertexWeights,
caseData,
@@ -332,7 +336,7 @@ void RivIntersectionBoxPartMgr::updateGeoMechCellResultColors( const RimGeoMechR
RigFemPart* femPart = caseData->femParts()->part( 0 );
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
vertexWeights,
resultValues,
isElementNodalResult,

View File

@@ -44,7 +44,6 @@ class RimGeoMechView;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
//==================================================================================================
///
///
@@ -65,35 +64,6 @@ 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;

View File

@@ -21,6 +21,8 @@
#include "cafPdmPointer.h"
#include "RivHexGridIntersectionTools.h"
#include "cvfArray.h"
#include "cvfBoundingBox.h"
@@ -44,7 +46,7 @@ class ScalarMapper;
class DrawableGeo;
} // namespace cvf
class RivIntersectionGeometryGenerator : public cvf::Object
class RivIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF
{
public:
RivIntersectionGeometryGenerator( RimIntersection* crossSection,

View File

@@ -152,164 +152,17 @@ void RivIntersectionPartMgr::updateCellResultColor( size_t
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper )
{
if ( !m_crossSectionGenerator->isAnyGeometryPresent() ) return;
CVF_ASSERT( scalarColorMapper );
RimEclipseView* eclipseView = nullptr;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
bool isLightingDisabled = eclipseView->isLightingDisabled();
RimEclipseResultDefinition* eclipseResDef = eclipseView->cellResult();
bool isTernaryResult = eclipseResDef->isTernarySaturationSelected();
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
CVF_ASSERT( eclipseResDef );
// CrossSections
if ( m_crossSectionFaces.notNull() )
{
if ( isTernaryResult )
{
RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
texturer.createTextureCoords( m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex() );
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
ternaryColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
else
{
CVF_ASSERT( m_crossSectionGenerator.notNull() );
cvf::ref<RigResultAccessor> resultAccessor;
if ( RiaDefines::isPerCellFaceResult( eclipseResDef->resultVariable() ) )
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData,
0,
timeStepIndex,
eclipseResDef );
}
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(),
scalarColorMapper );
RivScalarMapperUtils::applyTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
scalarColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
}
}
RimGeoMechView* geoView;
m_rimCrossSection->firstAncestorOrThisOfType( geoView );
if ( geoView )
{
bool isLightingDisabled = geoView->isLightingDisabled();
RigGeoMechCaseData* caseData = nullptr;
RigFemResultAddress resVarAddress;
{
RimGeoMechResultDefinition* geomResultDef = geoView->cellResult();
caseData = geomResultDef->ownerCaseData();
resVarAddress = geomResultDef->resultAddress();
}
if ( !caseData ) return;
if ( resVarAddress.resultPosType == RIG_ELEMENT )
{
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
const std::vector<size_t>& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex();
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_crossSectionFacesTextureCoords.p(),
resultValues,
triangleToCellIdx,
scalarColorMapper );
}
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
{
// Special direction sensitive result calculation
const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes();
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
{
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_crossSectionFacesTextureCoords.p(),
triangelVxes,
resVarAddress,
scalarColorMapper );
}
else
{
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( m_crossSectionFacesTextureCoords.p(),
triangelVxes,
vertexWeights,
caseData,
resVarAddress,
(int)timeStepIndex,
scalarColorMapper );
}
}
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_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( m_crossSectionFacesTextureCoords
.p(),
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
scalarColorMapper );
}
RivScalarMapperUtils::applyTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
scalarColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
RivIntersectionResultsColoringTools::updateCellResultColorStatic( timeStepIndex,
m_rimCrossSection,
m_crossSectionGenerator.p(),
m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
@@ -364,7 +217,8 @@ void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
void RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper )
@@ -405,7 +259,7 @@ void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( cvf::Vec
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(
void RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords(
cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
@@ -446,7 +300,7 @@ void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
void RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper )
@@ -493,7 +347,7 @@ void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( cvf::Vec2fArray*
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
void RivIntersectionResultsColoringTools::calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper )

View File

@@ -80,37 +80,6 @@ public:
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat );
public:
static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper );
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper );
static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper );
static void calculateGeoMechTensorXfTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper );
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper );
private:
void generatePartGeometry();
void createFaultLabelParts( const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors );
@@ -144,3 +113,74 @@ private:
bool m_isFlattened;
};
class RimIntersectionHandle;
class RivIntersectionGeometryGeneratorIF;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
class RivIntersectionResultsColoringTools
{
public:
static void updateCellResultColorStatic( size_t timeStepIndex,
RimIntersectionHandle* m_rimIntersectionBox,
const RivIntersectionGeometryGeneratorIF* m_intersectionBoxGenerator,
cvf::Part* m_intersectionBoxFaces,
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
private:
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 );
static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper );
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper );
static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper );
static void calculateGeoMechTensorXfTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper );
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper );
};