mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#166) Refactored to improve readability of geomech Intersection texture generation
This commit is contained in:
parent
c4aed9c487
commit
40821a05a6
@ -123,10 +123,10 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
|||||||
timeStepIndex,
|
timeStepIndex,
|
||||||
cellResultColors->resultVariable());
|
cellResultColors->resultVariable());
|
||||||
|
|
||||||
calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
|
RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
|
||||||
m_crossSectionGenerator->triangleToCellIndex(),
|
m_crossSectionGenerator->triangleToCellIndex(),
|
||||||
resultAccessor.p(),
|
resultAccessor.p(),
|
||||||
mapper);
|
mapper);
|
||||||
|
|
||||||
|
|
||||||
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
|
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
|
||||||
@ -149,58 +149,23 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
|||||||
|
|
||||||
if (!caseData) return;
|
if (!caseData) return;
|
||||||
|
|
||||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
|
||||||
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
||||||
|
|
||||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
// 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;
|
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<RivVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
|
const std::vector<RivVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||||
|
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
|
||||||
|
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
|
||||||
|
RigFemPart* femPart = caseData->femParts()->part(0);
|
||||||
|
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||||
|
|
||||||
bool isElementNodalResult = true;
|
RivCrossSectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
|
||||||
RigFemPart* femPart = NULL;
|
vertexWeights,
|
||||||
if (resVarAddress.resultPosType == RIG_NODAL)
|
resultValues,
|
||||||
{
|
isElementNodalResult,
|
||||||
isElementNodalResult = false;
|
femPart,
|
||||||
femPart = caseData->femParts()->part(0);
|
mapper);
|
||||||
}
|
|
||||||
|
|
||||||
m_crossSectionFacesTextureCoords->resize(vertexWeights.size());
|
|
||||||
|
|
||||||
if (resultValues.size() == 0)
|
|
||||||
{
|
|
||||||
m_crossSectionFacesTextureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cvf::Vec2f* rawPtr = m_crossSectionFacesTextureCoords->ptr();
|
|
||||||
|
|
||||||
int vxCount = static_cast<int>(vertexWeights.size());
|
|
||||||
|
|
||||||
#pragma omp parallel for schedule(dynamic)
|
|
||||||
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
|
|
||||||
{
|
|
||||||
float resValue = 0;
|
|
||||||
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));
|
|
||||||
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
|
|
||||||
{
|
|
||||||
rawPtr[triangleVxIdx][1] = 1.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
|
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
|
||||||
m_crossSectionFacesTextureCoords.p(),
|
m_crossSectionFacesTextureCoords.p(),
|
||||||
@ -211,14 +176,63 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Calculates the texture coordinates in a "nearly" one dimentional texture.
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivCrossSectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||||
|
const std::vector<RivVertexWeights> &vertexWeights,
|
||||||
|
const std::vector<float> &resultValues,
|
||||||
|
bool isElementNodalResult,
|
||||||
|
const RigFemPart* femPart,
|
||||||
|
const cvf::ScalarMapper* mapper)
|
||||||
|
{
|
||||||
|
textureCoords->resize(vertexWeights.size());
|
||||||
|
|
||||||
|
if (resultValues.size() == 0)
|
||||||
|
{
|
||||||
|
textureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||||
|
|
||||||
|
int vxCount = static_cast<int>(vertexWeights.size());
|
||||||
|
|
||||||
|
#pragma omp parallel for schedule(dynamic)
|
||||||
|
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
|
||||||
|
{
|
||||||
|
float resValue = 0;
|
||||||
|
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));
|
||||||
|
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
|
||||||
|
{
|
||||||
|
rawPtr[triangleVxIdx][1] = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// 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
|
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
void RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||||
const std::vector<size_t>& triangleToCellIdxMap,
|
const std::vector<size_t>& triangleToCellIdxMap,
|
||||||
const RigResultAccessor* resultAccessor,
|
const RigResultAccessor* resultAccessor,
|
||||||
const cvf::ScalarMapper* mapper) const
|
const cvf::ScalarMapper* mapper)
|
||||||
{
|
{
|
||||||
if (!resultAccessor) return;
|
if (!resultAccessor) return;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
void applySingleColorEffect();
|
void applySingleColorEffect();
|
||||||
void updateCellResultColor(size_t timeStepIndex);
|
void updateCellResultColor(size_t timeStepIndex);
|
||||||
|
|
||||||
|
|
||||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||||
|
|
||||||
@ -61,7 +62,16 @@ private:
|
|||||||
void computeData();
|
void computeData();
|
||||||
|
|
||||||
cvf::Vec3d extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const;
|
cvf::Vec3d extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const;
|
||||||
void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, const std::vector<size_t>& triangleToCellIdxMap, const RigResultAccessor* resultAccessor, const cvf::ScalarMapper* mapper) const;
|
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||||
|
const std::vector<size_t>& triangleToCellIdxMap,
|
||||||
|
const RigResultAccessor* resultAccessor,
|
||||||
|
const cvf::ScalarMapper* mapper);
|
||||||
|
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||||
|
const std::vector<RivVertexWeights> &vertexWeights,
|
||||||
|
const std::vector<float> &resultValues,
|
||||||
|
bool isElementNodalResult,
|
||||||
|
const RigFemPart* femPart,
|
||||||
|
const cvf::ScalarMapper* mapper);
|
||||||
cvf::ref<RivCrossSectionHexGridIntf> createHexGridInterface();
|
cvf::ref<RivCrossSectionHexGridIntf> createHexGridInterface();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user