//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors) { CVF_ASSERT(cellResultColors); cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray; // Outer surface if (m_surfaceFaces.notNull()) { const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); if (!caseData) return; RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); // 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, m_gridIdx, (int)timeStepIndex); const std::vector<size_t>* vxToResultMapping = NULL; if (resVarAddress.resultPosType == RIG_NODAL) { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping()); } else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL || resVarAddress.resultPosType == RIG_INTEGRATION_POINT) { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx()); } m_surfaceFacesTextureCoords->resize(vxToResultMapping->size()); if (resultValues.size() == 0) { m_surfaceFacesTextureCoords->setAll(cvf::Vec2f(0.0, 1.0f)); } else { cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr(); int vxCount = static_cast<int>(vxToResultMapping->size()); #pragma omp parallel for schedule(dynamic) for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4) { float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx]]; float resultValue2 = resultValues[(*vxToResultMapping)[quadStartIdx + 1]]; float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]]; float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]]; if ( resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's || resultValue2 == HUGE_VAL || resultValue2 != resultValue2 || resultValue3 == HUGE_VAL || resultValue3 != resultValue3 || resultValue4 == HUGE_VAL || resultValue4 != resultValue4) { rawPtr[quadStartIdx][1] = 1.0f; rawPtr[quadStartIdx + 1][1] = 1.0f; rawPtr[quadStartIdx + 2][1] = 1.0f; rawPtr[quadStartIdx + 3][1] = 1.0f; } else { rawPtr[quadStartIdx] = mapper->mapToTextureCoord(resultValue1); rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord(resultValue2); rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord(resultValue3); rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord(resultValue4); } } } RimView* view = NULL; cellResultColors->firstAnchestorOrThisOfType(view); CVF_ASSERT(view); RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, view->isLightingDisabled()); } }