Added well pipe visibility filter based on cell visibility.

Only show pipes with wells with open connections in visible cells
p4#: 21349
This commit is contained in:
Jacob Støren 2013-04-22 09:13:37 +02:00
parent 638e82d24c
commit 6cac031fff
11 changed files with 304 additions and 212 deletions

View File

@ -91,7 +91,7 @@ void RivReservoirPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform
//--------------------------------------------------------------------------------------------------
void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::FORCE_ALL_OFF) return;
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF) return;
if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size())
{

View File

@ -646,18 +646,8 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, cvf::Color4f color)
{
if (geometryType == PROPERTY_FILTERED)
{
m_propFilteredGeometryFrames[timeStepIndex]->updateCellColor(color );
}
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{
m_propFilteredWellGeometryFrames[timeStepIndex]->updateCellColor(color );
}
else
{
m_geometries[geometryType].updateCellColor(color);
}
RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex );
pmgr->updateCellColor(color);
}
//--------------------------------------------------------------------------------------------------
@ -676,35 +666,40 @@ void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometr
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::updateCellResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
if (geometryType == PROPERTY_FILTERED)
{
m_propFilteredGeometryFrames[timeStepIndex]->updateCellResultColor(timeStepIndex, cellResultSlot);
}
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{
m_propFilteredWellGeometryFrames[timeStepIndex]->updateCellResultColor(timeStepIndex, cellResultSlot);
}
else
{
m_geometries[geometryType].updateCellResultColor(timeStepIndex, cellResultSlot);
}
RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex );
pmgr->updateCellResultColor(timeStepIndex, cellResultSlot);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
{
RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex );
pmgr->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::cref<cvf::UByteArray> RivReservoirViewPartMgr::cellVisibility(ReservoirGeometryCacheType geometryType, size_t gridIndex, size_t timeStepIndex) const
{
RivReservoirPartMgr * pmgr = (const_cast<RivReservoirViewPartMgr*>(this))->reservoirPartManager( geometryType, timeStepIndex );
return pmgr->cellVisibility(gridIndex).p();
}
RivReservoirPartMgr * RivReservoirViewPartMgr::reservoirPartManager(ReservoirGeometryCacheType geometryType, size_t timeStepIndex )
{
if (geometryType == PROPERTY_FILTERED)
{
m_propFilteredGeometryFrames[timeStepIndex]->updateCellEdgeResultColor( timeStepIndex, cellResultSlot, cellEdgeResultSlot );
return m_propFilteredGeometryFrames[timeStepIndex].p();
}
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{
m_propFilteredWellGeometryFrames[timeStepIndex]->updateCellEdgeResultColor( timeStepIndex, cellResultSlot, cellEdgeResultSlot );
return m_propFilteredWellGeometryFrames[timeStepIndex].p();
}
else
{
m_geometries[geometryType].updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot );
return &m_geometries[geometryType];
}
}
}

View File

@ -19,7 +19,6 @@
#pragma once
#include "RivReservoirPartMgr.h"
#include "cvfTransform.h"
#include "RimReservoirView.h"
#include "cafFixedArray.h"
#include "cvfArray.h"
#include "cafPdmObject.h"
@ -35,8 +34,8 @@ class RivReservoirViewPartMgr: public cvf::Object
public:
RivReservoirViewPartMgr(RimReservoirView * resv);
cvf::Transform* scaleTransform() { return m_scaleTransform.p();}
void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);}
cvf::Transform* scaleTransform() { return m_scaleTransform.p();}
void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);}
enum ReservoirGeometryCacheType
{
@ -54,49 +53,49 @@ public:
PROPERTY_FILTERED_WELL_CELLS // Includes RANGE_FILTERED_WELL_CELLS and VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER and VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER
};
void clearGeometryCache();
void scheduleGeometryRegen(ReservoirGeometryCacheType geometryType);
void clearGeometryCache();
void scheduleGeometryRegen(ReservoirGeometryCacheType geometryType);
cvf::cref<cvf::UByteArray> cellVisibility(ReservoirGeometryCacheType geometryType, size_t gridIndex, size_t frameIndex) const;
void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, const std::vector<size_t>& gridIndices);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex, const std::vector<size_t>& gridIndices);
void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, const std::vector<size_t>& gridIndices);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, ReservoirGeometryCacheType geometryType, size_t frameIndex, const std::vector<size_t>& gridIndices);
void updateCellColor (ReservoirGeometryCacheType geometryType, cvf::Color4f color);
void updateCellColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
cvf::Color4f color);
void updateCellResultColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
void updateCellColor (ReservoirGeometryCacheType geometryType, cvf::Color4f color);
void updateCellColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
cvf::Color4f color);
void updateCellResultColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
private:
void createGeometry(ReservoirGeometryCacheType geometryType);
void computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx);
void createGeometry(ReservoirGeometryCacheType geometryType);
void computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx);
void createPropertyFilteredGeometry(size_t frameIndex);
void createPropertyFilteredWellGeometry(size_t frameIndex);
void createPropertyFilteredGeometry(size_t frameIndex);
void createPropertyFilteredWellGeometry(size_t frameIndex);
void clearGeometryCache(ReservoirGeometryCacheType geomType);
void clearGeometryCache(ReservoirGeometryCacheType geomType);
static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
static void computeRangeVisibility (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, RimCellPropertyFilterCollection* propFilterColl);
static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses );
static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
static void computeRangeVisibility (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, RimCellPropertyFilterCollection* propFilterColl);
static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses );
RivReservoirPartMgr * reservoirPartManager(ReservoirGeometryCacheType geometryType, size_t timeStepIndex );
private:
caf::FixedArray<RivReservoirPartMgr, PROPERTY_FILTERED> m_geometries;
caf::FixedArray<bool, PROPERTY_FILTERED> m_geometriesNeedsRegen;
caf::FixedArray<bool, PROPERTY_FILTERED> m_geometriesNeedsRegen;
cvf::Collection<RivReservoirPartMgr> m_propFilteredGeometryFrames;
std::vector<uchar> m_propFilteredGeometryFramesNeedsRegen;
std::vector<uchar> m_propFilteredGeometryFramesNeedsRegen;
cvf::Collection<RivReservoirPartMgr> m_propFilteredWellGeometryFrames;
std::vector<uchar> m_propFilteredWellGeometryFramesNeedsRegen;
std::vector<uchar> m_propFilteredWellGeometryFramesNeedsRegen;
cvf::ref<cvf::Transform> m_scaleTransform;
caf::PdmPointer<RimReservoirView> m_reservoirView;
cvf::ref<cvf::Transform> m_scaleTransform;
caf::PdmPointer<RimReservoirView> m_reservoirView;
};

View File

@ -267,17 +267,10 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
//--------------------------------------------------------------------------------------------------
void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimWell.isNull()) return;
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;
if (m_rimReservoirView->wellCollection()->showWellHead() == false) return;
if ( m_rimWell->wellResults()->firstResultTimeStep() == cvf::UNDEFINED_SIZE_T
|| frameIndex < m_rimWell->wellResults()->firstResultTimeStep() )
return;
if (!m_rimWell->isWellVisible(frameIndex)) return;
buildWellHeadParts(frameIndex);

View File

@ -325,14 +325,8 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;
if ( m_rimWell->wellResults()->firstResultTimeStep() == cvf::UNDEFINED_SIZE_T
|| frameIndex < m_rimWell->wellResults()->firstResultTimeStep() )
return;
if (m_rimWell.isNull()) return;
if (!m_rimWell->isWellVisible(frameIndex)) return;
if (m_needsTransformUpdate) buildWellPipeParts();

View File

@ -457,146 +457,155 @@ void RimReservoirView::createDisplayModel()
// static int callCount = 0;
// qDebug() << "RimReservoirView::createDisplayModel()" << callCount++;
if (m_reservoir && m_reservoir->reservoirData())
if (!(m_reservoir && m_reservoir->reservoirData())) return;
// Define a vector containing time step indices to produce geometry for.
// First entry in this vector is used to define the geometry only result mode with no results.
std::vector<size_t> timeStepIndices;
// The one and only geometry entry
timeStepIndices.push_back(0);
// Find the number of time frames the animation needs to show the requested data.
if (this->cellResult()->hasDynamicResult()
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|| this->wellCollection->hasVisibleWellPipes())
{
// Define a vector containing time step indices to produce geometry for.
// First entry in this vector is used to define the geometry only result mode with no results.
std::vector<size_t> timeStepIndices;
CVF_ASSERT(currentGridCellResults());
// The one and only geometry entry
size_t i;
for (i = 0; i < currentGridCellResults()->cellResults()->maxTimeStepCount(); i++)
{
timeStepIndices.push_back(i);
}
}
else if (this->cellResult()->hasStaticResult()
|| this->cellEdgeResult()->hasResult()
|| this->propertyFilterCollection()->hasActiveFilters())
{
// The one and only result entry
timeStepIndices.push_back(0);
}
// Find the number of time frames the animation needs to show the requested data.
updateLegends();
if (this->cellResult()->hasDynamicResult()
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|| this->wellCollection->hasVisibleWellPipes())
cvf::Collection<cvf::ModelBasicList> frameModels;
size_t timeIdx;
for (timeIdx = 0; timeIdx < timeStepIndices.size(); timeIdx++)
{
frameModels.push_back(new cvf::ModelBasicList);
}
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
bool isAnimationActive = m_viewer->isAnimationActive();
m_viewer->removeAllFrames();
// Create vector of grid indices to render
std::vector<size_t> gridIndices;
this->indicesToVisibleGrids(&gridIndices);
///
// Get or create the parts for "static" type geometry. The same geometry is used
// for the different frames. updateCurrentTimeStep updates the colors etc.
// For property filtered geometry : just set all the models as empty scenes
// updateCurrentTimeStep requests the actual parts
if (! this->propertyFilterCollection()->hasActiveFilters())
{
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometryTypesToAdd;
if (this->rangeFilterCollection()->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells())
{
CVF_ASSERT(currentGridCellResults());
size_t i;
for (i = 0; i < currentGridCellResults()->cellResults()->maxTimeStepCount(); i++)
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED);
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS);
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER);
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER);
if (this->showInactiveCells())
{
timeStepIndices.push_back(i);
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
}
}
else if (this->cellResult()->hasStaticResult()
|| this->cellEdgeResult()->hasResult()
|| this->propertyFilterCollection()->hasActiveFilters())
{
// The one and only result entry
timeStepIndices.push_back(0);
}
updateLegends();
cvf::Collection<cvf::ModelBasicList> frameModels;
size_t timeIdx;
for (timeIdx = 0; timeIdx < timeStepIndices.size(); timeIdx++)
else
{
frameModels.push_back(new cvf::ModelBasicList);
}
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); // Should be all well cells
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::ACTIVE);
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
bool isAnimationActive = m_viewer->isAnimationActive();
m_viewer->removeAllFrames();
// Create vector of grid indices to render
std::vector<size_t> gridIndices;
this->indicesToVisibleGrids(&gridIndices);
///
// Get or create the parts for "static" type geometry. The same geometry is used
// for the different frames. updateCurrentTimeStep updates the colors etc.
// For property filtered geometry : just set all the models as empty scenes
// updateCurrentTimeStep requests the actual parts
if (! this->propertyFilterCollection()->hasActiveFilters())
{
size_t frameIdx;
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
if (this->showInactiveCells())
{
if (this->rangeFilterCollection()->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells())
{
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER, gridIndices); // Should be visible well cells outside range filter
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER, gridIndices); // Should be visible well cells outside range filter
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS, gridIndices);
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::RANGE_FILTERED, gridIndices);
if (this->showInactiveCells())
{
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE, gridIndices);
}
}
else
{
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::ALL_WELL_CELLS, gridIndices); // Should be all well cells
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::ACTIVE, gridIndices);
if (this->showInactiveCells())
{
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), RivReservoirViewPartMgr::INACTIVE, gridIndices);
}
}
// Set static colors
this->updateStaticCellColors();
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::INACTIVE);
}
}
// Compute triangle count, Debug only
if (false)
size_t frameIdx;
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
{
size_t totalTriangleCount = 0;
for (size_t gtIdx = 0; gtIdx < geometryTypesToAdd.size(); ++gtIdx)
{
size_t mIdx;
for (mIdx = 0; mIdx < frameModels.size(); mIdx++)
{
cvf::Collection<cvf::Part> partCollection;
frameModels.at(mIdx)->allParts(&partCollection);
size_t modelTriangleCount = 0;
size_t pIdx;
for (pIdx = 0; pIdx < partCollection.size(); pIdx++)
{
modelTriangleCount += partCollection.at(pIdx)->drawable()->triangleCount();
}
totalTriangleCount += modelTriangleCount;
}
m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices);
}
}
// Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1
// Set static colors
this->updateStaticCellColors();
size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
m_visibleGridParts = geometryTypesToAdd;
}
// Compute triangle count, Debug only
if (false)
{
size_t totalTriangleCount = 0;
{
cvf::ModelBasicList* model = frameModels.at(frameIndex);
model->updateBoundingBoxesRecursive();
size_t mIdx;
for (mIdx = 0; mIdx < frameModels.size(); mIdx++)
{
cvf::Collection<cvf::Part> partCollection;
frameModels.at(mIdx)->allParts(&partCollection);
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model);
size_t modelTriangleCount = 0;
size_t pIdx;
for (pIdx = 0; pIdx < partCollection.size(); pIdx++)
{
modelTriangleCount += partCollection.at(pIdx)->drawable()->triangleCount();
}
if (frameIndex == 0)
m_viewer->setMainScene(scene.p());
else
m_viewer->addFrame(scene.p());
}
// If the animation was active before recreating everything, make viewer view current frame
if (isAnimationActive)
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
totalTriangleCount += modelTriangleCount;
}
}
}
// Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1
size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
{
cvf::ModelBasicList* model = frameModels.at(frameIndex);
model->updateBoundingBoxesRecursive();
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model);
if (frameIndex == 0)
m_viewer->setMainScene(scene.p());
else
m_viewer->addFrame(scene.p());
}
// If the animation was active before recreating everything, make viewer view current frame
if (isAnimationActive)
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
}
}
@ -636,6 +645,8 @@ void RimReservoirView::updateCurrentTimeStep()
frameScene->addModel(frameParts.p());
}
}
m_visibleGridParts = geometriesToRecolor;
}
else if (rangeFilterCollection->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells())
{
@ -650,9 +661,10 @@ void RimReservoirView::updateCurrentTimeStep()
geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS);
}
for (size_t i = 0; i < geometriesToRecolor.size(); ++i)
{
if (this->animationMode() && this->cellEdgeResult()->hasResult())
{
m_reservoirGridPartManager->updateCellEdgeResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult(), this->cellEdgeResult());
@ -1210,7 +1222,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
visibleCells->setAll(false);
// If all wells are forced off, return
if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_OFF) return;
if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_NONE) return;
RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo();
@ -1220,7 +1232,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx)
{
RimWell* well = this->wellCollection()->wells()[wIdx];
if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_ON || well->showWellCells())
if (this->wellCollection()->wellCellsToRangeFilterMode() == RimWellCollection::RANGE_ADD_ALL || well->showWellCells())
{
RigSingleWellResultsData* wres = well->wellResults();
if (!wres) continue;

View File

@ -42,7 +42,6 @@
class RiuViewer;
class RigGridBase;
class RigGridCellFaceVisibilityFilter;
class RivReservoirViewPartMgr;
namespace cvf
{
@ -157,6 +156,9 @@ public:
void schedulePipeGeometryRegen();
void updateDisplayModelForWellResults();
const std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType>&
visibleGridParts() const { return m_visibleGridParts;}
cvf::cref<RivReservoirViewPartMgr> reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); }
// Display model generation
private:
@ -190,5 +192,7 @@ private:
caf::PdmField<int> m_currentTimeStep;
QPointer<RiuViewer> m_viewer;
caf::PdmPointer<RimCase> m_reservoir;
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> m_visibleGridParts;
};

View File

@ -131,3 +131,76 @@ caf::PdmFieldHandle* RimWell::objectToggleField()
return &showWellPipes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWell::isWellVisible(size_t frameIndex)
{
if (m_reservoirView == NULL) return false;
if (this->wellResults() == NULL) return false;
if ( this->wellResults()->firstResultTimeStep() == cvf::UNDEFINED_SIZE_T
|| frameIndex < this->wellResults()->firstResultTimeStep()
|| frameIndex >= this->wellResults()->m_wellCellsTimeSteps.size())
return false;
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_ON)
return true;
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_FORCE_ALL_OFF)
return false;
if ( this->showWellPipes() == false )
return false;
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_INDIVIDUALLY)
return true;
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS)
{
const std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType>& visGridParts = m_reservoirView->visibleGridParts();
cvf::cref<RivReservoirViewPartMgr> rvMan = m_reservoirView->reservoirGridPartManager();
for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx)
{
const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex);
// First check the wellhead:
size_t gridIndex = wrsf.m_wellHead.m_gridIndex;
size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
{
return true;
}
// Then check the rest of the well, with all the branches
const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{
gridIndex = wsResCells[cIdx].m_gridIndex;
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
{
return true;
}
}
}
}
return false;
}
CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ?
return false;
}

View File

@ -44,6 +44,8 @@ public:
void setWellResults(RigSingleWellResultsData* wellResults) { m_wellResults = wellResults;}
RigSingleWellResultsData* wellResults() { return m_wellResults.p(); }
bool isWellVisible(size_t frameIndex);
virtual caf::PdmFieldHandle* userDescriptionField();
virtual caf::PdmFieldHandle* objectToggleField();

View File

@ -32,10 +32,22 @@ namespace caf
template<>
void RimWellCollection::WellVisibilityEnum::setUp()
{
addItem(RimWellCollection::FORCE_ALL_OFF, "FORCE_ALL_OFF", "Off");
addItem(RimWellCollection::ALL_ON, "ALL_ON", "Individual");
//addItem(RimWellCollection::RANGE_INTERSECTING, "RANGE_INTERSECTING", "Intersecting range filter only");
addItem(RimWellCollection::FORCE_ALL_ON, "FORCE_ALL_ON", "On");
addItem(RimWellCollection::PIPES_FORCE_ALL_OFF, "FORCE_ALL_OFF", "All Off");
addItem(RimWellCollection::PIPES_INDIVIDUALLY, "ALL_ON", "Individual");
addItem(RimWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS,"OPEN_IN_VISIBLE_CELLS", "Visible cells filtered");
addItem(RimWellCollection::PIPES_FORCE_ALL_ON, "FORCE_ALL_ON", "All On");
}
}
namespace caf
{
template<>
void RimWellCollection::WellCellsRangeFilterEnum::setUp()
{
addItem(RimWellCollection::RANGE_ADD_NONE, "FORCE_ALL_OFF", "Off");
addItem(RimWellCollection::RANGE_ADD_INDIVIDUAL, "ALL_ON", "Individually");
addItem(RimWellCollection::RANGE_ADD_ALL, "FORCE_ALL_ON", "On");
}
}
@ -65,13 +77,13 @@ RimWellCollection::RimWellCollection()
CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, " Show well labels", "", "", "");
CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, " Well head scale", "", "", "");
CAF_PDM_InitField(&wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(ALL_ON), "Global well pipe visibility", "", "", "");
CAF_PDM_InitField(&wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_INDIVIDUALLY), "Global well pipe visibility", "", "", "");
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale", 0.1, " Pipe radius scale", "", "", "");
CAF_PDM_InitField(&pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe vertex count", "", "", "");
pipeCrossSectionVertexCount.setUiHidden(true);
CAF_PDM_InitField(&wellCellVisibility, "GlobalWellCellVisibility", WellVisibilityEnum(FORCE_ALL_OFF), "Add cells to range filter", "", "", "");
CAF_PDM_InitField(&wellCellsToRangeFilterMode, "GlobalWellCellVisibility", WellCellsRangeFilterEnum(RANGE_ADD_NONE), "Add cells to range filter", "", "", "");
CAF_PDM_InitField(&showWellCellFences, "ShowWellFences", false, " Use well fence", "", "", "");
CAF_PDM_InitField(&wellCellFenceType, "DefaultWellFenceDirection", WellFenceEnum(K_DIRECTION), " Well Fence direction", "", "", "");
@ -112,14 +124,14 @@ RimWell* RimWellCollection::findWell(QString name)
//--------------------------------------------------------------------------------------------------
bool RimWellCollection::hasVisibleWellCells()
{
if (this->wellCellVisibility() == FORCE_ALL_OFF) return false;
if (this->wellCellsToRangeFilterMode() == RANGE_ADD_NONE) return false;
if (this->wells().size() == 0 ) return false;
bool hasCells = false;
for (size_t i = 0 ; !hasCells && i < this->wells().size(); ++i)
{
RimWell* well = this->wells()[i];
if ( well && well->wellResults() && (well->showWellCells() || this->wellCellVisibility() == FORCE_ALL_ON) )
if ( well && well->wellResults() && (well->showWellCells() || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) )
{
for (size_t tIdx = 0; !hasCells && tIdx < well->wellResults()->m_wellCellsTimeSteps.size(); ++tIdx )
{
@ -134,7 +146,7 @@ bool RimWellCollection::hasVisibleWellCells()
if (!hasCells) return false;
if (this->wellCellVisibility() == ALL_ON || this->wellCellVisibility() == FORCE_ALL_ON) return true;
if (this->wellCellsToRangeFilterMode() == RANGE_ADD_INDIVIDUAL || this->wellCellsToRangeFilterMode() == RANGE_ADD_ALL) return true;
// Todo: Handle range filter intersection
@ -146,9 +158,9 @@ bool RimWellCollection::hasVisibleWellCells()
//--------------------------------------------------------------------------------------------------
bool RimWellCollection::hasVisibleWellPipes()
{
if (this->wellPipeVisibility() == FORCE_ALL_OFF) return false;
if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false;
if (this->wells().size() == 0 ) return false;
if (this->wellPipeVisibility() == FORCE_ALL_ON) return true;
if (this->wellPipeVisibility() == PIPES_FORCE_ALL_ON) return true;
return true;
}
@ -166,7 +178,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
m_reservoirView->createDisplayModelAndRedraw();
}
}
if (&wellCellVisibility == changedField)
if (&wellCellsToRangeFilterMode == changedField)
{
if (m_reservoirView)
{

View File

@ -44,13 +44,21 @@ public:
enum WellVisibilityType
{
FORCE_ALL_OFF,
ALL_ON,
RANGE_INTERSECTING,
FORCE_ALL_ON
PIPES_FORCE_ALL_OFF,
PIPES_INDIVIDUALLY,
PIPES_OPEN_IN_VISIBLE_CELLS,
PIPES_FORCE_ALL_ON
};
typedef caf::AppEnum<RimWellCollection::WellVisibilityType> WellVisibilityEnum;
enum WellCellsRangeFilterType
{
RANGE_ADD_ALL,
RANGE_ADD_INDIVIDUAL,
RANGE_ADD_NONE
};
typedef caf::AppEnum<RimWellCollection::WellCellsRangeFilterType> WellCellsRangeFilterEnum;
enum WellFenceType
{
K_DIRECTION,
@ -61,7 +69,7 @@ public:
caf::PdmField<bool> showWellLabel;
caf::PdmField<WellVisibilityEnum> wellCellVisibility;
caf::PdmField<WellCellsRangeFilterEnum> wellCellsToRangeFilterMode;
caf::PdmField<bool> showWellCellFences;
caf::PdmField<WellFenceEnum> wellCellFenceType;
caf::PdmField<double> wellCellTransparencyLevel;