2d intersection view filter support (#11711)

Enable filters in 2d intersection view. Controlled by "Use Cell Filters for Intersections" setting in Intersection Collection properties
This commit is contained in:
jonjenssen
2024-09-19 08:41:57 +02:00
committed by GitHub
parent f95b085419
commit e006fe52c9
5 changed files with 195 additions and 42 deletions

View File

@@ -20,13 +20,16 @@
#include "Rim3dOverlayInfoConfig.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInView.h"
@@ -516,16 +519,19 @@ void Rim2dIntersectionView::onCreateDisplayModel()
nativeOrOverrideViewer()->addFrame( new cvf::Scene(), isUsingOverrideViewer() );
}
m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection(), true );
bool propertiesFiltersActive = false;
bool cellFiltersActive = false;
m_intersectionVizModel->removeAllParts();
RimGridView* grView = m_intersection->firstAncestorOrThisOfType<RimGridView>();
if ( grView && grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() )
{
propertiesFiltersActive = grView->propertyFilterCollection()->hasActiveFilters();
cellFiltersActive = grView->cellFilterCollection()->hasActiveFilters();
}
m_flatIntersectionPartMgr->generatePartGeometry( nullptr, scaleTransform() );
m_flatIntersectionPartMgr->appendIntersectionFacesToModel( m_intersectionVizModel.p(), scaleTransform() );
m_flatIntersectionPartMgr->appendMeshLinePartsToModel( m_intersectionVizModel.p(), scaleTransform() );
m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() );
m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true );
m_flatIntersectionPartMgr->applySingleColorEffect();
appendIntersectionToModel( cellFiltersActive, propertiesFiltersActive );
m_flatSimWellPipePartMgr = nullptr;
m_flatWellHeadPartMgr = nullptr;
@@ -574,6 +580,17 @@ void Rim2dIntersectionView::onUpdateDisplayModelForCurrentTimeStep()
update3dInfo();
onUpdateLegends();
RimGridView* grView = m_intersection->firstAncestorOrThisOfType<RimGridView>();
if ( grView )
{
if ( grView->intersectionCollection()->shouldApplyCellFiltersToIntersections() &&
grView->propertyFilterCollection()->hasActiveFilters() )
{
m_flatIntersectionPartMgr = new RivExtrudedCurveIntersectionPartMgr( m_intersection, true );
appendIntersectionForCurrentTimeStep();
}
}
if ( m_flatSimWellPipePartMgr.notNull() )
{
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
@@ -831,3 +848,118 @@ void Rim2dIntersectionView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTree
{
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::appendIntersectionToModel( bool cellFiltersActive, bool propertyFiltersActive )
{
m_intersectionVizModel->removeAllParts();
RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType<RimEclipseView>();
RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType<RimGeoMechView>();
if ( cellFiltersActive || propertyFiltersActive )
{
if ( eclView )
{
if ( !propertyFiltersActive )
{
cvf::UByteArray visibleCells;
eclView->calculateCellVisibility( &visibleCells, { RANGE_FILTERED_WELL_CELLS, RANGE_FILTERED }, m_currentTimeStep );
appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells );
}
}
else if ( geoView )
{
if ( !propertyFiltersActive )
{
cvf::UByteArray visibleCells;
geoView->calculateCurrentTotalCellVisibility( &visibleCells, m_currentTimeStep );
appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), &visibleCells );
}
}
// NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call
// appendPartsToModel() after appendDynamicPartsToModel()
appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() );
}
else
{
appendDynamicPartsToModel( m_intersectionVizModel.p(), scaleTransform(), nullptr );
// NB! Geometry objects are recreated in appendDynamicPartsToModel(), always call
// appendPartsToModel() after appendDynamicPartsToModel()
appendPartsToModel( m_intersectionVizModel.p(), scaleTransform() );
}
m_intersectionVizModel->updateBoundingBoxesRecursive();
nativeOrOverrideViewer()->addStaticModelOnce( m_intersectionVizModel.p(), isUsingOverrideViewer() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::appendIntersectionForCurrentTimeStep()
{
if ( nativeOrOverrideViewer() )
{
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
if ( frameScene )
{
cvf::String name = "IntersectionDynamicModel";
Rim3dView::removeModelByName( frameScene, name );
cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
frameParts->setName( name );
RimEclipseView* eclView = m_intersection->firstAncestorOrThisOfType<RimEclipseView>();
RimGeoMechView* geoView = m_intersection->firstAncestorOrThisOfType<RimGeoMechView>();
if ( eclView )
{
cvf::UByteArray visibility;
eclView->calculateCellVisibility( &visibility, { PROPERTY_FILTERED, PROPERTY_FILTERED_WELL_CELLS }, m_currentTimeStep );
appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility );
}
else if ( geoView )
{
cvf::UByteArray visibility;
geoView->calculateCurrentTotalCellVisibility( &visibility, m_currentTimeStep );
appendDynamicPartsToModel( frameParts.p(), scaleTransform(), &visibility );
}
else
{
appendDynamicPartsToModel( frameParts.p(), scaleTransform(), nullptr );
}
frameParts->updateBoundingBoxesRecursive();
frameScene->addModel( frameParts.p() );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::appendPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
{
m_flatIntersectionPartMgr->appendPolylinePartsToModel( *this, model, scaleTransform, true /*annotationOnly*/ );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::appendDynamicPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform, cvf::UByteArray* visibleCells )
{
m_flatIntersectionPartMgr->generatePartGeometry( visibleCells, scaleTransform );
m_flatIntersectionPartMgr->appendIntersectionFacesToModel( model, scaleTransform );
m_flatIntersectionPartMgr->appendMeshLinePartsToModel( model, scaleTransform );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::onCellVisibilityChanged( const SignalEmitter* emitter )
{
onCreateDisplayModel();
scheduleCreateDisplayModelAndRedraw();
}