(#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);

View File

@ -40,6 +40,8 @@
#include "RimEclipseWellCollection.h"
#include "RivGridPartMgr.h"
#include "RimViewLink.h"
#include "RimViewLinker.h"
//--------------------------------------------------------------------------------------------------
///
@ -59,6 +61,8 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
switch (geometryType)
{
case OVERRIDDEN_CELL_VISIBILITY:
clearGeometryCache(OVERRIDDEN_CELL_VISIBILITY);
case INACTIVE:
clearGeometryCache(INACTIVE);
clearGeometryCache(RANGE_FILTERED_INACTIVE);
@ -184,6 +188,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(RivCellSetEnum geomType)
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::clearGeometryCache()
{
clearGeometryCache(OVERRIDDEN_CELL_VISIBILITY);
clearGeometryCache(ACTIVE);
clearGeometryCache(ALL_WELL_CELLS);
clearGeometryCache(VISIBLE_WELL_CELLS);
@ -268,6 +273,9 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility,
switch (geometryType)
{
case OVERRIDDEN_CELL_VISIBILITY:
computeOverriddenCellVisibility(cellVisibility, grid);
break;
case ACTIVE:
computeNativeVisibility(cellVisibility, grid, activeCellInfo, eclipseCase->wellCellsInGrid(gridIdx), false, false, true, m_reservoirView->showMainGrid() );
break;
@ -582,6 +590,67 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid)
{
RimViewLink* masterViewLink = m_reservoirView->controllingViewLink();
CVF_ASSERT(masterViewLink);
RimView* masterView = masterViewLink->ownerViewLinker()->mainView();
#if 0
// get cell visibility
#if 1
cvf::ref<cvf::UByteArray> totCellVisibility = masterView->currentTotalCellVisibility();
#else
// Could get something more like
std::vector<std::vector<cvf::UByteArray*> > gridsWithCellSetVisibility = masterView->getAllGridsCurrentCellSetsCellVisibility();
#endif
CVF_ASSERT(cellVisibility != NULL);
CVF_ASSERT(grid != NULL);
size_t gridCellCount = grid->cellCount();
cellVisibility->resize(gridCellCount);
cellVisibility->setAll(false);
RigCaseCellMapper* cellMapper = masterViewLink->cellMapper();
for (size_t lcIdx = 0; lcIdx < gridCellCount; ++lcIdx)
{
#if 1
size_t reservoirCellIdx = grid->reservoirCellIndex(lcIdx);
int cellCount = 0;
const int* cellIndicesInMasterCase = cellMapper->masterCaseCellIndex(reservoirCellIdx, &cellCount);
for (int mcIdx = 0; mcIdx < cellCount; ++mcIdx)
{
(*cellVisibility)[lcIdx] |= (*totCellVisibility)[cellIndicesInMasterCase[mcIdx]]; // If any is visible, show
}
#else
const RigGridCells& masterCaseCells = cellMapper->masterCaseGridAndLocalCellIndex(grid->gridIndex, lcIdx);
for (int mcIdx = 0; mcIdx < masterCaseCells.cellCount(); ++mcIdx)
{
int cellSetCount = gridsWithCellSetVisibility[ masterCaseCells.gridIndex[mcIdx] ].size();
for (int csIdx = 0; csIdx < cellSetCount; ++csIdx)
{
(*cellVisibility)[lcIdx] |= gridsWithCellSetVisibility[masterCaseCells.gridIndex[mcIdx]][masterCaseCells.cellIndex[mcIdx]];
}
}
#endif
}
#endif
}
//--------------------------------------------------------------------------------------------------
/// Copy the data from source into destination. This is not trivial to do using cvf::Array ...

View File

@ -83,7 +83,10 @@ private:
static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
void computeRangeVisibility (RivCellSetEnum geometryType, cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl);
static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl);
static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses );
void computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid);
static void copyByteArray(cvf::UByteArray* dest, const cvf::UByteArray* source );
RivReservoirPartMgr * reservoirPartManager(RivCellSetEnum geometryType, size_t timeStepIndex );

View File

@ -838,11 +838,13 @@ void RimEclipseView::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
m_reservoirGridPartManager->scheduleGeometryRegen(geometryType);
RimViewLinker* viewLinker = viewLinkerWithDepViews();
RimViewLinker* viewLinker = viewLinkerWithMyDepViews();
if (viewLinker)
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
}
m_currentReservoirCellVisibility = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -1547,3 +1549,31 @@ void RimEclipseView::setOverridePropertyFilterCollection(RimEclipsePropertyFilte
this->scheduleGeometryRegen(PROPERTY_FILTERED);
this->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility)
{
size_t gridCount = this->eclipseCase()->reservoirData()->gridCount();
size_t cellCount = this->eclipseCase()->reservoirData()->mainGrid()->cells().size();
totalVisibility->resize(cellCount);
totalVisibility->setAll(false);
for (size_t gridIdx = 0; gridIdx < gridCount; ++gridIdx)
{
RigGridBase * grid = this->eclipseCase()->reservoirData()->grid(gridIdx);
int gridCellCount = static_cast<int>(grid->cellCount());
for (size_t gpIdx = 0; gpIdx < m_visibleGridParts.size(); ++gpIdx)
{
cvf::cref<cvf::UByteArray> visibility = m_reservoirGridPartManager->cellVisibility(m_visibleGridParts[gpIdx], gridIdx, m_currentTimeStep);
for (int lcIdx = 0; lcIdx < gridCellCount; ++ lcIdx)
{
(*totalVisibility)[grid->reservoirCellIndex(lcIdx)] |= (*visibility)[lcIdx];
}
}
}
}

View File

@ -164,6 +164,8 @@ private:
virtual RimCase* ownerCase();
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility);
caf::PdmChildField<RimEclipsePropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmPointer<RimEclipsePropertyFilterCollection> m_overridePropertyFilterCollection;

View File

@ -516,11 +516,12 @@ void RimGeoMechView::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
m_vizLogic->scheduleGeometryRegen(geometryType);
RimViewLinker* viewLinker = viewLinkerWithDepViews();
RimViewLinker* viewLinker = viewLinkerWithMyDepViews();
if (viewLinker)
{
viewLinker->scheduleGeometryRegenForDepViews(geometryType);
}
m_currentReservoirCellVisibility = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -549,3 +550,11 @@ RimGeoMechPropertyFilterCollection* RimGeoMechView::propertyFilterCollection()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility)
{
m_vizLogic->calculateCurrentTotalCellVisibility(totalVisibility, m_currentTimeStep);
}

View File

@ -93,6 +93,8 @@ private:
virtual RimCase* ownerCase();
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility);
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;

View File

@ -191,7 +191,7 @@ void RimView::updateViewerWidget()
void RimView::scheduleCreateDisplayModelAndRedraw()
{
RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this);
RimViewLinker* viewLinker = viewLinkerWithDepViews();
RimViewLinker* viewLinker = viewLinkerWithMyDepViews();
if (viewLinker)
{
viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews();
@ -723,7 +723,7 @@ bool RimView::isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimView::viewLinkerWithDepViews()
RimViewLinker* RimView::viewLinkerWithMyDepViews()
{
RimViewLinker* viewLinker = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
@ -739,3 +739,36 @@ RimViewLinker* RimView::viewLinkerWithDepViews()
return viewLinker;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLink* RimView::controllingViewLink()
{
RimViewLink* viewLink = NULL;
std::vector<caf::PdmObjectHandle*> reffingObjs;
this->objectsWithReferringPtrFields(reffingObjs);
for (size_t i = 0; i < reffingObjs.size(); ++i)
{
viewLink = dynamic_cast<RimViewLink*>(reffingObjs[i]);
if (viewLink) break;
}
return viewLink;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::UByteArray> RimView::currentTotalCellVisibility()
{
if (m_currentReservoirCellVisibility.isNull())
{
m_currentReservoirCellVisibility = new cvf::UByteArray;
this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p());
}
return m_currentReservoirCellVisibility;
}

View File

@ -29,6 +29,11 @@
#include "RivCellSetEnum.h"
#include "cvfArray.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include <QPointer>
class Rim3dOverlayInfoConfig;
@ -36,6 +41,7 @@ class RimCase;
class RimCellRangeFilterCollection;
class RiuViewer;
class RimViewLinker;
class RimViewLink;
namespace cvf
{
@ -120,6 +126,8 @@ public:
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0;
void scheduleCreateDisplayModelAndRedraw();
void createDisplayModelAndRedraw();
RimViewLink* controllingViewLink();
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
public:
virtual void loadDataAndUpdate() = 0;
@ -129,7 +137,7 @@ public:
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
protected:
RimViewLinker* viewLinkerWithDepViews();
RimViewLinker* viewLinkerWithMyDepViews();
void setDefaultView();
void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
@ -152,6 +160,7 @@ protected:
virtual void updateViewerWidgetWindowTitle() = 0;
virtual void resetLegendsInViewer() = 0;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) = 0;
QPointer<RiuViewer> m_viewer;
@ -166,13 +175,13 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
private:
static bool isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB, const cvf::BoundingBox& destBB);
private:
bool m_previousGridModeMeshLinesWasFaults;
caf::PdmField<bool> m_disableLighting;
};

View File

@ -500,3 +500,15 @@ void RimViewLink::doSyncCellResult()
linkedViews->updateCellResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker* RimViewLink::ownerViewLinker()
{
RimViewLinker* viewLinker = NULL;
this->firstAnchestorOrThisOfType(viewLinker);
CVF_ASSERT(viewLinker);
return viewLinker;
}

View File

@ -26,6 +26,7 @@
class RimView;
class RimEclipseView;
class RimGeoMechView;
class RimViewLinker;
//==================================================================================================
///
@ -44,6 +45,7 @@ public:
RimView* managedView();
void setManagedView(RimView* view);
RimViewLinker* ownerViewLinker();
// Linked (both ways) properties
caf::PdmField<bool> syncCamera;