//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex) { if (!m_geomechView->geoMechCase()) return; size_t gridCount = m_geomechView->femParts()->partCount(); if (gridCount == 0) return; RigFemPart* part = m_geomechView->femParts()->part(0); int elmCount = part->elementCount(); totalVisibility->resize(elmCount); totalVisibility->setAll(false); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) { RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr(visiblePartMgrs[pmIdx]); cvf::ref<cvf::UByteArray> visibility = partMgr->cellVisibility(0); for (int elmIdx = 0; elmIdx < elmCount; ++ elmIdx) { (*totalVisibility)[elmIdx] |= (*visibility)[elmIdx]; } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::updateStaticCellColors(int timeStepIndex) { std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) { RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr(visiblePartMgrs[pmIdx]); partMgr->updateCellColor(cvf::Color4f(cvf::Color3f::ORANGE)); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors) { std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) { RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr(visiblePartMgrs[pmIdx]); partMgr->updateCellResultColor(timeStepIndex, cellResultColors); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model) { std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs(timeStepIndex); for (size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx) { RivGeoMechPartMgr* partMgr = getUpdatedPartMgr(visiblePartMgrs[pmIdx]); partMgr->appendGridPartsToModel(model); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache::Key pMgrKey) { if (!m_partMgrCache->isNeedingRegeneration(pMgrKey)) { return m_partMgrCache->partMgr(pMgrKey); } RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr(pMgrKey); RigGeoMechCaseData* caseData = m_geomechView->geoMechCase()->geoMechData(); int partCount = caseData->femParts()->partCount(); if (partMgrToUpdate->initializedFemPartCount() != partCount) { partMgrToUpdate->clearAndSetReservoir(caseData); } for (int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx) { cvf::ref<cvf::UByteArray> elmVisibility = partMgrToUpdate->cellVisibility(femPartIdx); partMgrToUpdate->setTransform(m_geomechView->scaleTransform()); if (pMgrKey.geometryType() == RANGE_FILTERED) { cvf::CellRangeFilter cellRangeFilter; m_geomechView->rangeFilterCollection()->compoundCellRangeFilter(&cellRangeFilter, femPartIdx); RivFemElmVisibilityCalculator::computeRangeVisibility( elmVisibility.p(), caseData->femParts()->part(femPartIdx), cellRangeFilter); } else if (pMgrKey.geometryType() == PROPERTY_FILTERED) { RivGeoMechPartMgr* rangefiltered = NULL; if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); } else { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); } cvf::ref<cvf::UByteArray> rangeFiltVisibility = rangefiltered->cellVisibility(femPartIdx); RivFemElmVisibilityCalculator::computePropertyVisibility(elmVisibility.p(), caseData->femParts()->part(femPartIdx), pMgrKey.frameIndex(), rangeFiltVisibility.p(), m_geomechView->geoMechPropertyFilterCollection() ); } else if (pMgrKey.geometryType() == OVERRIDDEN_CELL_VISIBILITY) { RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(elmVisibility.p(), caseData->femParts()->part(femPartIdx), m_geomechView->viewController()); } else if (pMgrKey.geometryType() == ALL_CELLS) { RivFemElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), caseData->femParts()->part(femPartIdx)); } else { CVF_ASSERT(false); // Unsupported CellSet Enum } partMgrToUpdate->setCellVisibility(femPartIdx, elmVisibility.p()); } m_partMgrCache->setGenerationFinished(pMgrKey); return partMgrToUpdate; }