#11248 Remove caching of simulation well coordinates to avoid state handling bugs

This commit is contained in:
Magne Sjaastad 2024-03-04 10:05:13 +01:00
parent 3689cccae7
commit 1217236d73
6 changed files with 33 additions and 67 deletions

View File

@ -457,7 +457,7 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
if ( changedField == &m_simulationWell || changedField == &m_isActive || changedField == &m_type ) if ( changedField == &m_simulationWell || changedField == &m_isActive || changedField == &m_type )
{ {
recomputeSimulationWellBranchData(); rebuildGeometryAndScheduleCreateDisplayModel();
} }
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex || if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex ||
@ -546,10 +546,14 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL ) else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL )
{ {
geometryGroup->add( &m_simulationWell ); geometryGroup->add( &m_simulationWell );
updateSimulationWellCenterline();
if ( m_simulationWell() && m_simulationWellBranchCenterlines.size() > 1 ) if ( m_simulationWell() )
{ {
geometryGroup->add( &m_branchIndex ); auto branchCenterLines = simulationWellBranchCenterlines();
if ( branchCenterLines.size() > 1 )
{
geometryGroup->add( &m_branchIndex );
}
} }
} }
else if ( type() == CrossSectionEnum::CS_POLYLINE ) else if ( type() == CrossSectionEnum::CS_POLYLINE )
@ -705,9 +709,8 @@ QList<caf::PdmOptionItemInfo> RimExtrudedCurveIntersection::calculateValueOption
} }
else if ( fieldNeedingOptions == &m_branchIndex ) else if ( fieldNeedingOptions == &m_branchIndex )
{ {
updateSimulationWellCenterline(); auto branchCenterLines = simulationWellBranchCenterlines();
size_t branchCount = branchCenterLines.size();
size_t branchCount = m_simulationWellBranchCenterlines.size();
options.push_back( caf::PdmOptionItemInfo( "All", -1 ) ); options.push_back( caf::PdmOptionItemInfo( "All", -1 ) );
@ -812,14 +815,16 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
{ {
int branchIndexToUse = branchIndex(); int branchIndexToUse = branchIndex();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( m_simulationWellBranchCenterlines.size() ) ) auto branchCenterLines = simulationWellBranchCenterlines();
if ( 0 <= branchIndexToUse && branchIndexToUse < static_cast<int>( branchCenterLines.size() ) )
{ {
lines.push_back( m_simulationWellBranchCenterlines[branchIndexToUse] ); lines.push_back( branchCenterLines[branchIndexToUse] );
} }
if ( branchIndexToUse == -1 ) if ( branchIndexToUse == -1 )
{ {
lines = m_simulationWellBranchCenterlines; lines = branchCenterLines;
} }
} }
} }
@ -900,27 +905,6 @@ std::vector<cvf::Vec3d> RimExtrudedCurveIntersection::polyLinesForExtrusionDirec
return m_customExtrusionPoints; return m_customExtrusionPoints;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateSimulationWellCenterline()
{
if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
if ( m_simulationWellBranchCenterlines.empty() )
{
auto simWells = m_simulationWell()->wellBranchesForVisualization();
const auto& [coords, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells );
m_simulationWellBranchCenterlines = coords;
}
}
else
{
m_simulationWellBranchCenterlines.clear();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1019,7 +1003,8 @@ int RimExtrudedCurveIntersection::branchIndex() const
return -1; return -1;
} }
if ( m_branchIndex >= static_cast<int>( m_simulationWellBranchCenterlines.size() ) ) auto branchCenterLines = simulationWellBranchCenterlines();
if ( m_branchIndex >= static_cast<int>( branchCenterLines.size() ) )
{ {
return -1; return -1;
} }
@ -1279,20 +1264,6 @@ double RimExtrudedCurveIntersection::extentLength()
return m_extentLength(); return m_extentLength();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::recomputeSimulationWellBranchData()
{
if ( m_type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
m_simulationWellBranchCenterlines.clear();
updateSimulationWellCenterline();
m_crossSectionPartMgr = nullptr;
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1426,3 +1397,16 @@ RimEclipseView* RimExtrudedCurveIntersection::eclipseView() const
{ {
return firstAncestorOrThisOfType<RimEclipseView>(); return firstAncestorOrThisOfType<RimEclipseView>();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::simulationWellBranchCenterlines() const
{
if ( !m_simulationWell() ) return {};
const auto simWells = m_simulationWell()->wellBranchesForVisualization();
const auto& [branchCenterLines, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells );
return branchCenterLines;
}

View File

@ -127,7 +127,6 @@ public:
void setLengthUp( double heightUp ); void setLengthUp( double heightUp );
void setLengthDown( double heightDown ); void setLengthDown( double heightDown );
double extentLength(); double extentLength();
void recomputeSimulationWellBranchData();
bool hasDefiningPoints() const; bool hasDefiningPoints() const;
std::vector<RimSurfaceIntersectionCurve*> surfaceIntersectionCurves() const; std::vector<RimSurfaceIntersectionCurve*> surfaceIntersectionCurves() const;
@ -152,7 +151,6 @@ private:
RimSimWellInViewCollection* simulationWellCollection() const; RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine(); void updateAzimuthLine();
void updateSimulationWellCenterline();
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const; void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName(); void updateName();
static double azimuthInRadians( cvf::Vec3d vec ); static double azimuthInRadians( cvf::Vec3d vec );
@ -166,6 +164,8 @@ private:
RimEclipseView* eclipseView() const; RimEclipseView* eclipseView() const;
std::vector<std::vector<cvf::Vec3d>> simulationWellBranchCenterlines() const;
private: private:
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;

View File

@ -295,17 +295,6 @@ std::vector<RimBoxIntersection*> RimIntersectionCollection::intersectionBoxes()
return m_intersectionBoxes.childrenByType(); return m_intersectionBoxes.childrenByType();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionCollection::recomputeSimWellBranchData()
{
for ( const auto& intersection : intersections() )
{
intersection->recomputeSimulationWellBranchData();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -68,7 +68,6 @@ public:
void syncronize2dIntersectionViews(); void syncronize2dIntersectionViews();
void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); void scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
void recomputeSimWellBranchData();
bool shouldApplyCellFiltersToIntersections() const; bool shouldApplyCellFiltersToIntersections() const;

View File

@ -49,7 +49,6 @@
#include "RimEclipseInputPropertyCollection.h" #include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimFlowDiagSolution.h" #include "RimFlowDiagSolution.h"
#include "RimIntersectionCollection.h"
#include "RimMockModelSettings.h" #include "RimMockModelSettings.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimReservoirCellResultsStorage.h" #include "RimReservoirCellResultsStorage.h"
@ -660,7 +659,6 @@ void RimEclipseResultCase::fieldChangedByUi( const caf::PdmFieldHandle* changedF
{ {
resView->scheduleSimWellGeometryRegen(); resView->scheduleSimWellGeometryRegen();
resView->scheduleCreateDisplayModelAndRedraw(); resView->scheduleCreateDisplayModelAndRedraw();
resView->intersectionCollection()->recomputeSimWellBranchData();
} }
} }

View File

@ -31,7 +31,6 @@
#include "RimEclipseContourMapView.h" #include "RimEclipseContourMapView.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimIntersectionCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimSimWellFractureCollection.h" #include "RimSimWellFractureCollection.h"
#include "RimSimWellInView.h" #include "RimSimWellInView.h"
@ -483,10 +482,7 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch
if ( &wellPipeCoordType == changedField || &isAutoDetectingBranches == changedField ) if ( &wellPipeCoordType == changedField || &isAutoDetectingBranches == changedField )
{ {
if ( m_reservoirView ) if ( m_reservoirView ) m_reservoirView->scheduleCreateDisplayModelAndRedraw();
{
m_reservoirView->intersectionCollection()->recomputeSimWellBranchData();
}
for ( RimSimWellInView* w : wells ) for ( RimSimWellInView* w : wells )
{ {