Remove redundant part of hierarchical well paths

This commit is contained in:
Gaute Lindkvist 2020-10-16 07:36:29 +02:00
parent 7684596829
commit 362dcb4dd1
7 changed files with 95 additions and 20 deletions

View File

@ -652,7 +652,7 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d
RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry();
if ( !wellPathGeometry ) return;
const std::vector<cvf::Vec3d>& wellpathCenterLine = wellPathGeometry->wellPathPoints();
std::vector<cvf::Vec3d> wellpathCenterLine = wellPathGeometry->uniqueWellPathPoints();
if ( wellpathCenterLine.size() < 2 ) return;

View File

@ -53,7 +53,6 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafProgressInfo.h"
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QString>
@ -150,6 +149,7 @@ void RimWellPathCollection::loadDataAndUpdate()
RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>( wellPath );
RimModeledWellPath* mWPath = dynamic_cast<RimModeledWellPath*>( wellPath );
RimWellPathGroup* branch = dynamic_cast<RimWellPathGroup*>( wellPath );
if ( fWPath )
{
if ( !fWPath->filePath().isEmpty() )
@ -165,6 +165,10 @@ void RimWellPathCollection::loadDataAndUpdate()
{
mWPath->createWellPathGeometry();
}
else if ( branch )
{
branch->updateWellPathName();
}
if ( wellPath )
{
@ -191,7 +195,10 @@ void RimWellPathCollection::loadDataAndUpdate()
}
progress.incrementProgress();
}
for ( auto group : topLevelGroups() )
{
group->createWellPathGeometry();
}
this->checkAndFixBranchNames();
this->sortWellsByName();
}
@ -669,12 +676,14 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath )
{
for ( auto possibleParentWellPath : allWellPaths() )
{
auto wellPathGroup = dynamic_cast<RimWellPathGroup*>( possibleParentWellPath );
if ( wellPathGroup->hasChildWellPath( wellPath ) )
if ( auto wellPathGroup = dynamic_cast<RimWellPathGroup*>( possibleParentWellPath ); wellPathGroup )
{
wellPathGroup->removeChildWellPath( wellPath );
removed = true;
break;
if ( wellPathGroup->hasChildWellPath( wellPath ) )
{
wellPathGroup->removeChildWellPath( wellPath );
removed = true;
break;
}
}
}
}
@ -726,6 +735,22 @@ void RimWellPathCollection::sortWellsByName()
std::sort( m_wellPaths.begin(), m_wellPaths.end(), lessWellPath );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPathGroup*> RimWellPathCollection::topLevelGroups() const
{
std::vector<RimWellPathGroup*> groups;
for ( auto wellPath : m_wellPaths )
{
if ( auto group = dynamic_cast<RimWellPathGroup*>( wellPath.p() ); group )
{
groups.push_back( group );
}
}
return groups;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -734,8 +759,6 @@ RimWellPathGroup* RimWellPathCollection::findOrCreateWellPathGroup( gsl::not_nul
auto wellPathGeometry = wellPath->wellPathGeometry();
if ( !wellPathGeometry ) return nullptr;
qDebug() << wellPath->name();
const double eps = 1.0e-4;
std::map<RimWellPath*, double> wellPathsWithCommonGeometry;

View File

@ -139,7 +139,8 @@ private:
void readAndAddWellPaths( std::vector<RimFileWellPath*>& wellPathArray, bool importGrouped );
void sortWellsByName();
RimWellPathGroup* findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath );
std::vector<RimWellPathGroup*> topLevelGroups() const;
RimWellPathGroup* findOrCreateWellPathGroup( gsl::not_null<RimWellPath*> wellPath );
RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath( const RimWellPath* wellPath );

View File

@ -45,9 +45,9 @@ void RimWellPathGroup::addChildWellPath( RimWellPath* wellPath )
{
if ( !this->wellPathGeometry()->wellPathPoints().empty() )
{
auto commonGeometry = RigWellPath::commonGeometry( {this->wellPathGeometry(), wellPath->wellPathGeometry()} );
setWellPathGeometry( commonGeometry.p() );
m_childWellPaths.push_back( wellPath );
createWellPathGeometry();
makeMoreLevelsIfNecessary();
}
else
@ -89,8 +89,7 @@ bool RimWellPathGroup::hasChildWellPath( RimWellPath* wellPath )
void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath )
{
m_childWellPaths.removeChildObject( wellPath );
auto commonGeometry = RigWellPath::commonGeometry( wellPathGeometries() );
setWellPathGeometry( commonGeometry.p() );
createWellPathGeometry();
updateWellPathName();
}
@ -100,11 +99,33 @@ void RimWellPathGroup::removeChildWellPath( RimWellPath* wellPath )
void RimWellPathGroup::removeAllChildWellPaths()
{
m_childWellPaths.clear();
auto commonGeometry = RigWellPath::commonGeometry( wellPathGeometries() );
setWellPathGeometry( commonGeometry.p() );
setWellPathGeometry( cvf::ref<RigWellPath>( new RigWellPath ).p() );
updateWellPathName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGroup::createWellPathGeometry()
{
for ( auto wellPath : m_childWellPaths )
{
if ( auto group = dynamic_cast<RimWellPathGroup*>( wellPath.p() ); group )
{
group->createWellPathGeometry();
}
}
auto commonGeometry = RigWellPath::commonGeometry( wellPathGeometries() );
for ( auto wellPath : m_childWellPaths )
{
size_t startIndex = 0u;
size_t commonSize = commonGeometry->wellPathPoints().size();
if ( commonSize > 0u ) startIndex = commonSize - 1u;
wellPath->wellPathGeometry()->setUniqueStartIndex( startIndex );
}
setWellPathGeometry( commonGeometry.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -223,6 +244,10 @@ void RimWellPathGroup::makeMoreLevelsIfNecessary()
if ( branches.size() <= 1u ) return;
size_t startIndex = 0u;
size_t commonSize = wellPathGeometry()->wellPathPoints().size();
if ( commonSize > 0u ) startIndex = commonSize - 1u;
for ( const auto& [firstDeviation, wellPaths] : branches )
{
if ( wellPaths.size() > 1u )
@ -232,6 +257,7 @@ void RimWellPathGroup::makeMoreLevelsIfNecessary()
{
m_childWellPaths().removeChildObject( wellPath );
newGroup->addChildWellPath( wellPath );
newGroup->wellPathGeometry()->setUniqueStartIndex( startIndex );
}
m_childWellPaths().push_back( newGroup );
}

View File

@ -34,15 +34,17 @@ public:
bool hasChildWellPath( RimWellPath* wellPath );
void removeChildWellPath( RimWellPath* wellPath );
void removeAllChildWellPaths();
void fixBranchNames();
void makeMoreLevelsIfNecessary();
void createWellPathGeometry();
void updateWellPathName();
void fixBranchNames();
void makeMoreLevelsIfNecessary();
protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName );
private:
std::vector<const RigWellPath*> wellPathGeometries() const;
void updateWellPathName();
QString createWellPathName() const;
private:

View File

@ -30,6 +30,7 @@
RigWellPath::RigWellPath()
: m_hasDatumElevation( false )
, m_datumElevation( 0.0 )
, m_startIndex( 0u )
, objectBeingDeleted( this )
{
}
@ -42,6 +43,7 @@ RigWellPath::RigWellPath( const RigWellPath& rhs )
, m_measuredDepths( rhs.m_measuredDepths )
, m_hasDatumElevation( rhs.m_hasDatumElevation )
, m_datumElevation( rhs.m_datumElevation )
, m_startIndex( rhs.m_startIndex )
, objectBeingDeleted( this )
{
}
@ -52,6 +54,7 @@ RigWellPath::RigWellPath( const RigWellPath& rhs )
RigWellPath::RigWellPath( const std::vector<cvf::Vec3d>& wellPathPoints, const std::vector<double>& measuredDepths )
: m_wellPathPoints( wellPathPoints )
, m_measuredDepths( measuredDepths )
, m_startIndex( 0u )
, objectBeingDeleted( this )
{
}
@ -65,6 +68,7 @@ RigWellPath& RigWellPath::operator=( const RigWellPath& rhs )
m_measuredDepths = rhs.m_measuredDepths;
m_hasDatumElevation = rhs.m_hasDatumElevation;
m_datumElevation = rhs.m_datumElevation;
m_startIndex = rhs.m_startIndex;
return *this;
}
@ -413,6 +417,22 @@ cvf::ref<RigWellPath> RigWellPath::commonGeometry( const std::vector<const RigWe
return cvf::ref<RigWellPath>( new RigWellPath( commonWellPathPoints, commonMDs ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPath::setUniqueStartIndex( size_t uniqueStartIndex )
{
m_startIndex = uniqueStartIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RigWellPath::uniqueWellPathPoints() const
{
return std::vector<cvf::Vec3d>( m_wellPathPoints.begin() + m_startIndex, m_wellPathPoints.end() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -71,6 +71,8 @@ public:
double identicalTubeLength( const RigWellPath& otherWellPathGeometry ) const;
static cvf::ref<RigWellPath> commonGeometry( const std::vector<const RigWellPath*>& allGeometries );
void setUniqueStartIndex( size_t uniqueStartIndex );
std::vector<cvf::Vec3d> uniqueWellPathPoints() const;
std::pair<std::vector<cvf::Vec3d>, std::vector<double>>
clippedPointSubset( double startMD, double endMD, double* horizontalLengthAlongWellToStartClipPoint = nullptr ) const;
@ -90,4 +92,5 @@ private:
bool m_hasDatumElevation;
double m_datumElevation;
size_t m_startIndex;
};