(#401) WIP: Prototyped total cell visibility calculation and

calculation of overridden cell visibility.
This commit is contained in:
Jacob Støren
2015-09-14 16:14:44 +02:00
parent c8751bebe0
commit b6fb85e0a4
14 changed files with 260 additions and 9 deletions

View File

@@ -32,6 +32,8 @@
#include "RigGeoMechCaseData.h"
#include "RigFemPartResultsCollection.h"
#include "RimViewLink.h"
#include "RimViewLinker.h"
//--------------------------------------------------------------------------------------------------
///
@@ -166,3 +168,38 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities,
const RigFemPart* femPart,
RimViewLink* masterViewLink)
{
#if 0
CVF_ASSERT(elmVisibilities != NULL);
CVF_ASSERT(femPart != NULL);
RimView* masterView = masterViewLink->ownerViewLinker()->mainView();
cvf::ref<cvf::UByteArray> totCellVisibility = masterView->currentTotalCellVisibility();
int elmCount = femPart->elementCount();
elmVisibilities->resize(elmCount);
elmVisibilities->setAll(false);
RigCaseCellMapper* cellMapper = masterViewLink->cellMapper();
for (size_t elmIdx = 0; elmIdx < elmCount; ++elmIdx)
{
// We are assuming that there is only one part.
int cellCount = 0;
const int* cellIndicesInMasterCase = cellMapper->masterCaseCellIndex(elmIdx, &cellCount);
for (int mcIdx = 0; mcIdx < cellCount; ++mcIdx)
{
(*elmVisibilities)[elmIdx] |= (*totCellVisibility)[cellIndicesInMasterCase[mcIdx]]; // If any is visible, show
}
}
#endif
}

View File

@@ -28,6 +28,7 @@ namespace cvf
class RigFemPart;
class RimGeoMechPropertyFilterCollection;
class RimViewLink;
class RivFemElmVisibilityCalculator
{
@@ -41,6 +42,11 @@ public:
int timeStepIndex,
const cvf::UByteArray* rangeFilterVisibility,
RimGeoMechPropertyFilterCollection* propFilterColl);
static void computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities,
const RigFemPart* femPart ,
RimViewLink* masterViewLink);
};

View File

@@ -207,6 +207,13 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache:
m_geomechView->propertyFilterCollection()
);
}
else if (pMgrKey.geometryType() == OVERRIDDEN_CELL_VISIBILITY)
{
RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(elmVisibility.p(),
caseData->femParts()->part(femPartIdx),
m_geomechView->controllingViewLink());
}
else if (pMgrKey.geometryType() == ALL_CELLS)
{
RivFemElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), caseData->femParts()->part(femPartIdx));
@@ -224,4 +231,32 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache:
return partMgrToUpdate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex)
{
size_t gridCount = m_geomechView->geoMechCase()->geoMechData()->femParts()->partCount();
if (gridCount == 0) return;
RigFemPart* part = m_geomechView->geoMechCase()->geoMechData()->femParts()->part(0);
size_t 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];
}
}
}

View File

@@ -20,6 +20,7 @@
#pragma once
#include <cstddef>
#include "cvfArray.h"
#include "cvfObject.h"
#include "cvfColor4.h"
#include "RivGeoMechPartMgrCache.h"
@@ -47,6 +48,7 @@ public:
void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors);
void updateStaticCellColors(int timeStepIndex);
void scheduleGeometryRegen(RivCellSetEnum geometryType);
void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex);
private:
std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs(int timeStepIndex);