2021-02-26 07:27:59 -06:00
|
|
|
#include "RicMswBranch.h"
|
2018-12-06 04:32:59 -06:00
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RicMswCompletions.h"
|
|
|
|
#include "RicMswSegment.h"
|
|
|
|
|
|
|
|
#include "RimWellPath.h"
|
2018-12-06 04:32:59 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
RicMswBranch::RicMswBranch( const QString& label, const RimWellPath* wellPath, double initialMD, double initialTVD )
|
|
|
|
: RicMswItem( label )
|
|
|
|
, m_initialMD( initialMD )
|
|
|
|
, m_initialTVD( initialTVD )
|
|
|
|
, m_branchNumber( -1 )
|
|
|
|
, m_wellPath( wellPath )
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RicMswBranch::addSegment( std::unique_ptr<RicMswSegment> segment )
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
m_segments.push_back( std::move( segment ) );
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RicMswBranch::insertAfterSegment( const RicMswSegment* insertAfter, std::unique_ptr<RicMswSegment> insertItem )
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
auto it = std::find_if( m_segments.begin(), m_segments.end(), [insertAfter]( auto& item ) {
|
|
|
|
return item.get() == insertAfter;
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_segments.insert( it, std::move( insertItem ) );
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RicMswBranch::sortSegments()
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
std::stable_sort( m_segments.begin(),
|
|
|
|
m_segments.end(),
|
|
|
|
[]( const std::unique_ptr<RicMswSegment>& lhs, const std::unique_ptr<RicMswSegment>& rhs ) {
|
|
|
|
return *lhs < *rhs;
|
|
|
|
} );
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
const RimWellPath* RicMswBranch::wellPath() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_wellPath;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
double RicMswBranch::startMD() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_initialMD;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
double RicMswBranch::startTVD() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_initialTVD;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
2018-12-12 02:44:00 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
double RicMswBranch::endMD() const
|
2018-12-12 02:44:00 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
if ( !m_segments.empty() )
|
|
|
|
{
|
|
|
|
return m_segments.back()->endMD();
|
|
|
|
}
|
|
|
|
return m_initialMD;
|
2018-12-12 02:44:00 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:32:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
double RicMswBranch::endTVD() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
if ( !m_segments.empty() )
|
|
|
|
{
|
|
|
|
return m_segments.back()->endTVD();
|
|
|
|
}
|
|
|
|
return m_initialTVD;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
int RicMswBranch::branchNumber() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_branchNumber;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
2018-12-12 02:44:00 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RicMswBranch::setBranchNumber( int branchNumber )
|
2018-12-12 02:44:00 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
m_branchNumber = branchNumber;
|
2018-12-12 02:44:00 -06:00
|
|
|
}
|
|
|
|
|
2018-12-06 04:32:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<const RicMswSegment*> RicMswBranch::segments() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<const RicMswSegment*> allSegments;
|
|
|
|
for ( const auto& segment : m_segments )
|
|
|
|
{
|
|
|
|
allSegments.push_back( segment.get() );
|
|
|
|
}
|
|
|
|
return allSegments;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<RicMswSegment*> RicMswBranch::segments()
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<RicMswSegment*> allSegments;
|
|
|
|
for ( auto& segment : m_segments )
|
|
|
|
{
|
|
|
|
allSegments.push_back( segment.get() );
|
|
|
|
}
|
|
|
|
return allSegments;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
size_t RicMswBranch::segmentCount() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_segments.size();
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
2021-02-26 07:27:59 -06:00
|
|
|
|
2018-12-06 04:32:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<const RicMswBranch*> RicMswBranch::branches() const
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<const RicMswBranch*> branches;
|
|
|
|
for ( const auto& branch : m_branches )
|
|
|
|
{
|
|
|
|
branches.push_back( branch.get() );
|
|
|
|
}
|
|
|
|
return branches;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<RicMswBranch*> RicMswBranch::branches()
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<RicMswBranch*> branches;
|
|
|
|
for ( auto& branch : m_branches )
|
|
|
|
{
|
|
|
|
branches.push_back( branch.get() );
|
|
|
|
}
|
|
|
|
return branches;
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RicMswBranch::addChildBranch( std::unique_ptr<RicMswBranch> branch )
|
2018-12-06 04:32:59 -06:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
m_branches.push_back( std::move( branch ) );
|
2018-12-06 04:32:59 -06:00
|
|
|
}
|