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) 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()) 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) void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, cvf::Color4f color)
{ {
if (geometryType == PROPERTY_FILTERED) RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex );
{ pmgr->updateCellColor(color);
m_propFilteredGeometryFrames[timeStepIndex]->updateCellColor(color );
}
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{
m_propFilteredWellGeometryFrames[timeStepIndex]->updateCellColor(color );
}
else
{
m_geometries[geometryType].updateCellColor(color);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -676,35 +666,40 @@ void RivReservoirViewPartMgr::updateCellColor(ReservoirGeometryCacheType geometr
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::updateCellResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot) void RivReservoirViewPartMgr::updateCellResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot)
{ {
if (geometryType == PROPERTY_FILTERED) RivReservoirPartMgr * pmgr = reservoirPartManager( geometryType, timeStepIndex );
{ pmgr->updateCellResultColor(timeStepIndex, cellResultSlot);
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);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot) 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) if (geometryType == PROPERTY_FILTERED)
{ {
m_propFilteredGeometryFrames[timeStepIndex]->updateCellEdgeResultColor( timeStepIndex, cellResultSlot, cellEdgeResultSlot ); return m_propFilteredGeometryFrames[timeStepIndex].p();
} }
else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) else if (geometryType == PROPERTY_FILTERED_WELL_CELLS)
{ {
m_propFilteredWellGeometryFrames[timeStepIndex]->updateCellEdgeResultColor( timeStepIndex, cellResultSlot, cellEdgeResultSlot ); return m_propFilteredWellGeometryFrames[timeStepIndex].p();
} }
else else
{ {
m_geometries[geometryType].updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot ); return &m_geometries[geometryType];
} }
} }

View File

@ -19,7 +19,6 @@
#pragma once #pragma once
#include "RivReservoirPartMgr.h" #include "RivReservoirPartMgr.h"
#include "cvfTransform.h" #include "cvfTransform.h"
#include "RimReservoirView.h"
#include "cafFixedArray.h" #include "cafFixedArray.h"
#include "cvfArray.h" #include "cvfArray.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@ -35,8 +34,8 @@ class RivReservoirViewPartMgr: public cvf::Object
public: public:
RivReservoirViewPartMgr(RimReservoirView * resv); RivReservoirViewPartMgr(RimReservoirView * resv);
cvf::Transform* scaleTransform() { return m_scaleTransform.p();} cvf::Transform* scaleTransform() { return m_scaleTransform.p();}
void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);} void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);}
enum ReservoirGeometryCacheType 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 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 clearGeometryCache();
void scheduleGeometryRegen(ReservoirGeometryCacheType geometryType); 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 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 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, cvf::Color4f color);
void updateCellColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex, void updateCellColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
cvf::Color4f color); cvf::Color4f color);
void updateCellResultColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex, void updateCellResultColor (ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot); RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex, void updateCellEdgeResultColor(ReservoirGeometryCacheType geometryType, size_t timeStepIndex,
RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot); RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
private: private:
void createGeometry(ReservoirGeometryCacheType geometryType); void createGeometry(ReservoirGeometryCacheType geometryType);
void computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx); void computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx);
void createPropertyFilteredGeometry(size_t frameIndex); void createPropertyFilteredGeometry(size_t frameIndex);
void createPropertyFilteredWellGeometry(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 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 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 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 copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses );
RivReservoirPartMgr * reservoirPartManager(ReservoirGeometryCacheType geometryType, size_t timeStepIndex );
private: private:
caf::FixedArray<RivReservoirPartMgr, PROPERTY_FILTERED> m_geometries; 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; cvf::Collection<RivReservoirPartMgr> m_propFilteredGeometryFrames;
std::vector<uchar> m_propFilteredGeometryFramesNeedsRegen; std::vector<uchar> m_propFilteredGeometryFramesNeedsRegen;
cvf::Collection<RivReservoirPartMgr> m_propFilteredWellGeometryFrames; 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) void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{ {
if (m_rimWell.isNull()) return;
if (m_rimReservoirView.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_rimReservoirView->wellCollection()->showWellHead() == false) return;
if (!m_rimWell->isWellVisible(frameIndex)) return;
if ( m_rimWell->wellResults()->firstResultTimeStep() == cvf::UNDEFINED_SIZE_T
|| frameIndex < m_rimWell->wellResults()->firstResultTimeStep() )
return;
buildWellHeadParts(frameIndex); buildWellHeadParts(frameIndex);

View File

@ -325,14 +325,8 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{ {
if (m_rimReservoirView.isNull()) return; if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return; if (m_rimWell.isNull()) return;
if (!m_rimWell->isWellVisible(frameIndex)) 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_needsTransformUpdate) buildWellPipeParts(); if (m_needsTransformUpdate) buildWellPipeParts();

View File

@ -457,146 +457,155 @@ void RimReservoirView::createDisplayModel()
// static int callCount = 0; // static int callCount = 0;
// qDebug() << "RimReservoirView::createDisplayModel()" << callCount++; // 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. CVF_ASSERT(currentGridCellResults());
// 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 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); timeStepIndices.push_back(0);
}
// Find the number of time frames the animation needs to show the requested data. updateLegends();
if (this->cellResult()->hasDynamicResult() cvf::Collection<cvf::ModelBasicList> frameModels;
|| this->propertyFilterCollection()->hasActiveDynamicFilters() size_t timeIdx;
|| this->wellCollection->hasVisibleWellPipes()) 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()); geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED);
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED_WELL_CELLS);
size_t i; geometryTypesToAdd.push_back(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER);
for (i = 0; i < currentGridCellResults()->cellResults()->maxTimeStepCount(); i++) 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);
} }
else
updateLegends();
cvf::Collection<cvf::ModelBasicList> frameModels;
size_t timeIdx;
for (timeIdx = 0; timeIdx < timeStepIndices.size(); timeIdx++)
{ {
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. if (this->showInactiveCells())
// 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)
{ {
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::INACTIVE);
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();
} }
} }
// Compute triangle count, Debug only size_t frameIdx;
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
if (false)
{ {
size_t totalTriangleCount = 0; for (size_t gtIdx = 0; gtIdx < geometryTypesToAdd.size(); ++gtIdx)
{ {
size_t mIdx; m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices);
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;
}
} }
} }
// Create Scenes from the frameModels // Set static colors
// Animation frames for results display, starts from frame 1 this->updateStaticCellColors();
size_t frameIndex; m_visibleGridParts = geometryTypesToAdd;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++) }
// Compute triangle count, Debug only
if (false)
{
size_t totalTriangleCount = 0;
{ {
cvf::ModelBasicList* model = frameModels.at(frameIndex); size_t mIdx;
model->updateBoundingBoxesRecursive(); 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; size_t modelTriangleCount = 0;
scene->addModel(model); size_t pIdx;
for (pIdx = 0; pIdx < partCollection.size(); pIdx++)
{
modelTriangleCount += partCollection.at(pIdx)->drawable()->triangleCount();
}
if (frameIndex == 0) totalTriangleCount += modelTriangleCount;
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);
} }
} }
// 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()); frameScene->addModel(frameParts.p());
} }
} }
m_visibleGridParts = geometriesToRecolor;
} }
else if (rangeFilterCollection->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells()) else if (rangeFilterCollection->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells())
{ {
@ -650,9 +661,10 @@ void RimReservoirView::updateCurrentTimeStep()
geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS); geometriesToRecolor.push_back(RivReservoirViewPartMgr::ALL_WELL_CELLS);
} }
for (size_t i = 0; i < geometriesToRecolor.size(); ++i) for (size_t i = 0; i < geometriesToRecolor.size(); ++i)
{ {
if (this->animationMode() && this->cellEdgeResult()->hasResult()) if (this->animationMode() && this->cellEdgeResult()->hasResult())
{ {
m_reservoirGridPartManager->updateCellEdgeResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult(), this->cellEdgeResult()); m_reservoirGridPartManager->updateCellEdgeResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult(), this->cellEdgeResult());
@ -1210,7 +1222,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
visibleCells->setAll(false); visibleCells->setAll(false);
// If all wells are forced off, return // 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(); 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) for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx)
{ {
RimWell* well = this->wellCollection()->wells()[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(); RigSingleWellResultsData* wres = well->wellResults();
if (!wres) continue; if (!wres) continue;

View File

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

View File

@ -131,3 +131,76 @@ caf::PdmFieldHandle* RimWell::objectToggleField()
return &showWellPipes; 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;} void setWellResults(RigSingleWellResultsData* wellResults) { m_wellResults = wellResults;}
RigSingleWellResultsData* wellResults() { return m_wellResults.p(); } RigSingleWellResultsData* wellResults() { return m_wellResults.p(); }
bool isWellVisible(size_t frameIndex);
virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* userDescriptionField();
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();

View File

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

View File

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