Add Well paths to other well paths

This commit is contained in:
Gaute Lindkvist
2020-10-07 13:53:36 +02:00
parent 2a06f74076
commit 52e3214b0e
6 changed files with 88 additions and 5 deletions

View File

@@ -263,9 +263,17 @@ std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList fileP
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellPath( RimWellPath* wellPath )
void RimWellPathCollection::addWellPath( gsl::not_null<RimWellPath*> wellPath )
{
m_wellPaths.push_back( wellPath );
auto mainWellPath = findSuitableParentWellPath( wellPath );
if ( mainWellPath )
{
mainWellPath->addChildWellPath( wellPath );
}
else
{
m_wellPaths.push_back( wellPath );
}
m_mostRecentlyUpdatedWellPath = wellPath;
}
@@ -648,6 +656,33 @@ void RimWellPathCollection::sortWellsByName()
std::sort( m_wellPaths.begin(), m_wellPaths.end(), lessWellPath );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellPathCollection::findSuitableParentWellPath( gsl::not_null<const RimWellPath*> wellPath ) const
{
auto wellPathGeometry = wellPath->wellPathGeometry();
if ( !wellPathGeometry ) return nullptr;
std::vector<RimWellPath*> allWellPaths;
descendantsOfType( allWellPaths );
const double eps = 1.0e-4;
double maxIdenticalTubeLength = 0.0;
RimWellPath* maxIdenticalWellPath = nullptr;
for ( auto existingWellPath : allWellPaths )
{
double identicalTubeLength = existingWellPath->wellPathGeometry()->identicalTubeLength( *wellPathGeometry );
if ( identicalTubeLength > maxIdenticalTubeLength && identicalTubeLength > eps )
{
maxIdenticalTubeLength = identicalTubeLength;
maxIdenticalWellPath = existingWellPath;
}
}
return maxIdenticalWellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------