#2347 Elm Props: Evaluate result type ELEMENT for Intersections

This commit is contained in:
Rebecca Cox
2018-01-11 11:35:08 +01:00
parent e0d91f90ae
commit e4e160cdd4
5 changed files with 148 additions and 62 deletions

View File

@@ -168,39 +168,35 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex)
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if(!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) )
if (resVarAddress.resultPosType == RIG_ELEMENT)
{
// 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);
const std::vector<size_t>& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex();
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
RigFemPart* femPart = caseData->femParts()->part(0);
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
resultValues,
triangleToCellIdx,
mapper);
RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
mapper);
}
else
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" )
if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc")
{
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(),
triangelVxes,
triangelVxes,
resVarAddress,
mapper);
}
else
{
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(),
triangelVxes,
vertexWeights,
@@ -210,6 +206,23 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex)
mapper);
}
}
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,
mapper);
}
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
@@ -224,12 +237,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper)
void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper)
{
textureCoords->resize(vertexWeights.size());
@@ -250,8 +263,16 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text
int weightCount = vertexWeights[triangleVxIdx].size();
for (int wIdx = 0; wIdx < weightCount; ++wIdx)
{
size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) :
femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
size_t resIdx;
if (isElementNodalResult)
{
resIdx = vertexWeights[triangleVxIdx].vxId(wIdx);
}
else
{
resIdx = femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
}
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
}
@@ -267,6 +288,47 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<float> &resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper)
{
textureCoords->resize(triangleToCellIdx.size()*3);
if (resultValues.size() == 0)
{
textureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
}
else
{
cvf::Vec2f* rawPtr = textureCoords->ptr();
for (int triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++)
{
size_t resIdx = triangleToCellIdx[triangleIdx];
float resValue = resultValues[resIdx];
int triangleVxIdx = triangleIdx * 3;
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
{
rawPtr[triangleVxIdx][1] = 1.0f;
rawPtr[triangleVxIdx + 1][1] = 1.0f;
rawPtr[triangleVxIdx + 2][1] = 1.0f;
}
else
{
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord(resValue);
rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord(resValue);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------