Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RigWellPath.h"
|
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
#include "cvfBoundingBox.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "cvfGeometryTools.h"
|
2018-03-20 07:12:20 -05:00
|
|
|
#include "cvfPlane.h"
|
2017-05-05 04:21:40 -05:00
|
|
|
|
2020-10-09 01:38:18 -05:00
|
|
|
#include <algorithm>
|
|
|
|
|
2016-10-25 07:56:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-25 07:56:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigWellPath::RigWellPath()
|
2020-10-26 04:05:07 -05:00
|
|
|
: cvf::Object()
|
|
|
|
, m_hasDatumElevation( false )
|
2019-09-06 03:40:57 -05:00
|
|
|
, m_datumElevation( 0.0 )
|
2021-02-26 07:27:59 -06:00
|
|
|
, m_uniqueStartIndex( 0u )
|
|
|
|
, m_uniqueEndIndex( std::numeric_limits<size_t>::max() )
|
2020-10-06 08:00:39 -05:00
|
|
|
, objectBeingDeleted( this )
|
2016-10-25 07:56:26 -05:00
|
|
|
{
|
|
|
|
}
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigWellPath::RigWellPath( const RigWellPath& rhs )
|
2020-10-26 04:05:07 -05:00
|
|
|
: cvf::Object()
|
|
|
|
, m_wellPathPoints( rhs.m_wellPathPoints )
|
2020-10-06 05:37:16 -05:00
|
|
|
, m_measuredDepths( rhs.m_measuredDepths )
|
|
|
|
, m_hasDatumElevation( rhs.m_hasDatumElevation )
|
|
|
|
, m_datumElevation( rhs.m_datumElevation )
|
2021-02-26 07:27:59 -06:00
|
|
|
, m_uniqueStartIndex( rhs.m_uniqueStartIndex )
|
|
|
|
, m_uniqueEndIndex( rhs.m_uniqueEndIndex )
|
2020-10-06 08:00:39 -05:00
|
|
|
, objectBeingDeleted( this )
|
2020-10-06 05:37:16 -05:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
CVF_ASSERT( m_wellPathPoints.size() == m_measuredDepths.size() );
|
2020-10-06 05:37:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigWellPath::RigWellPath( const std::vector<cvf::Vec3d>& wellPathPoints, const std::vector<double>& measuredDepths )
|
2020-10-26 04:05:07 -05:00
|
|
|
: cvf::Object()
|
|
|
|
, m_wellPathPoints( wellPathPoints )
|
2020-10-06 05:37:16 -05:00
|
|
|
, m_measuredDepths( measuredDepths )
|
2020-12-15 01:34:42 -06:00
|
|
|
, m_hasDatumElevation( false )
|
|
|
|
, m_datumElevation( 0.0 )
|
2021-02-26 07:27:59 -06:00
|
|
|
, m_uniqueStartIndex( 0u )
|
|
|
|
, m_uniqueEndIndex( std::numeric_limits<size_t>::max() )
|
2020-10-06 08:00:39 -05:00
|
|
|
, objectBeingDeleted( this )
|
2020-10-06 05:37:16 -05:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
CVF_ASSERT( m_wellPathPoints.size() == m_measuredDepths.size() );
|
2020-10-06 05:37:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigWellPath& RigWellPath::operator=( const RigWellPath& rhs )
|
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
m_wellPathPoints = rhs.m_wellPathPoints;
|
|
|
|
m_measuredDepths = rhs.m_measuredDepths;
|
|
|
|
CVF_ASSERT( m_wellPathPoints.size() == m_measuredDepths.size() );
|
2020-10-06 05:37:16 -05:00
|
|
|
m_hasDatumElevation = rhs.m_hasDatumElevation;
|
|
|
|
m_datumElevation = rhs.m_datumElevation;
|
2021-02-26 07:27:59 -06:00
|
|
|
m_uniqueStartIndex = rhs.m_uniqueStartIndex;
|
|
|
|
m_uniqueEndIndex = rhs.m_uniqueEndIndex;
|
2020-10-06 05:37:16 -05:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-10-06 08:00:39 -05:00
|
|
|
RigWellPath::~RigWellPath()
|
|
|
|
{
|
|
|
|
objectBeingDeleted.send();
|
|
|
|
}
|
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<cvf::Vec3d>& RigWellPath::wellPathPoints() const
|
|
|
|
{
|
|
|
|
return m_wellPathPoints;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const std::vector<double>& RigWellPath::measuredDepths() const
|
|
|
|
{
|
|
|
|
return m_measuredDepths;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RigWellPath::trueVerticalDepths() const
|
|
|
|
{
|
|
|
|
std::vector<double> tvds;
|
|
|
|
for ( const cvf::Vec3d& point : m_wellPathPoints )
|
|
|
|
{
|
|
|
|
tvds.push_back( std::fabs( point.z() ) );
|
|
|
|
}
|
|
|
|
return tvds;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigWellPath::setWellPathPoints( const std::vector<cvf::Vec3d>& wellPathPoints )
|
|
|
|
{
|
|
|
|
m_wellPathPoints = wellPathPoints;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigWellPath::setMeasuredDepths( const std::vector<double>& measuredDepths )
|
|
|
|
{
|
|
|
|
m_measuredDepths = measuredDepths;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigWellPath::addWellPathPoint( const cvf::Vec3d& wellPathPoint )
|
|
|
|
{
|
|
|
|
m_wellPathPoints.push_back( wellPathPoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigWellPath::addMeasuredDepth( double measuredDepth )
|
|
|
|
{
|
|
|
|
m_measuredDepths.push_back( measuredDepth );
|
|
|
|
}
|
|
|
|
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RigWellPath::setDatumElevation( double value )
|
2016-10-25 07:56:26 -05:00
|
|
|
{
|
|
|
|
m_hasDatumElevation = true;
|
2019-09-06 03:40:57 -05:00
|
|
|
m_datumElevation = value;
|
2016-10-25 07:56:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-25 07:56:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RigWellPath::hasDatumElevation() const
|
|
|
|
{
|
|
|
|
return m_hasDatumElevation;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-25 07:56:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RigWellPath::datumElevation() const
|
|
|
|
{
|
|
|
|
return m_datumElevation;
|
|
|
|
}
|
Added visualization of Well Paths in reservoir views.
Added PDM objects for a list of well paths (RimWellPathCollection) and for individual well paths (RimWellPath).
RimWellPathCollection uses RivWellPathCollectionPartMgr to generate visualization parts for each well path in the collection.
RimWellPath handles geometry defined in RigWellPath, and RivWellPathPartMgr is used to generate visualization parts. The well path visualization parts are generated by reusing RivPipeGeometryGenerator (also used for well pipes).
Added features:
- Select Open Well Paths in File menu to open one or more well path files, file format supported is Statoil JSON format.
- Each well path has a label showing the name, and the PDM window will show additional info (Id, Source System, UTM Zone, Update Date and User, Survey Type, File Path).
- Possible to turn on / off visibility, set thickness, set color for individual well paths.
- List of well paths including specified parameters/settings will be stored in project file.
- Possible to clip all well paths at a specified distance to the reservoir as this is the relevant area to see, and if showing whole well path it may be problematic for auto zoom etc.
p4#: 21652
2013-05-16 06:06:00 -05:00
|
|
|
|
2018-06-29 04:23:59 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RigWellPath::rkbDiff() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( hasDatumElevation() )
|
2018-06-29 04:23:59 -05:00
|
|
|
{
|
|
|
|
return datumElevation();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If measured depth is zero, use the z-value of the well path points
|
2021-02-26 07:27:59 -06:00
|
|
|
if ( !m_wellPathPoints.empty() && !m_measuredDepths.empty() )
|
2018-06-29 04:23:59 -05:00
|
|
|
{
|
|
|
|
double epsilon = 1e-3;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( cvf::Math::abs( m_measuredDepths[0] ) < epsilon )
|
2018-06-29 04:23:59 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double diff = m_measuredDepths[0] - ( -wellPathPoints()[0].z() );
|
2018-06-29 04:23:59 -05:00
|
|
|
|
|
|
|
return diff;
|
|
|
|
}
|
2021-02-26 07:27:59 -06:00
|
|
|
|
|
|
|
if ( cvf::Math::abs( m_wellPathPoints[0].z() ) < epsilon )
|
2020-02-03 07:05:51 -06:00
|
|
|
{
|
|
|
|
return m_measuredDepths[0]; // Assume a vertical drop before the first md point.
|
|
|
|
}
|
2018-06-29 04:23:59 -05:00
|
|
|
}
|
|
|
|
return HUGE_VAL;
|
|
|
|
}
|
|
|
|
|
2017-01-04 06:29:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-01-04 06:29:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:43:15 -06:00
|
|
|
cvf::Vec3d
|
|
|
|
RigWellPath::interpolatedVectorValuesAlongWellPath( const std::vector<cvf::Vec3d>& vectorValuesAlongWellPath,
|
|
|
|
double measuredDepth,
|
|
|
|
double* horizontalLengthAlongWellToStartClipPoint /*= nullptr*/ ) const
|
2017-01-04 06:29:25 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( vectorValuesAlongWellPath.size() == m_wellPathPoints.size() );
|
2018-04-13 07:35:14 -05:00
|
|
|
cvf::Vec3d interpolatedVector = cvf::Vec3d::ZERO;
|
2017-01-04 06:29:25 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( horizontalLengthAlongWellToStartClipPoint ) *horizontalLengthAlongWellToStartClipPoint = 0.0;
|
|
|
|
|
2018-03-20 11:28:27 -05:00
|
|
|
size_t vxIdx = 0;
|
2019-09-06 03:40:57 -05:00
|
|
|
while ( vxIdx < m_measuredDepths.size() && m_measuredDepths.at( vxIdx ) < measuredDepth )
|
2017-01-04 06:29:25 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( vxIdx > 0 && horizontalLengthAlongWellToStartClipPoint )
|
2018-03-20 11:28:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1];
|
|
|
|
segment[2] = 0.0;
|
2018-03-20 11:28:27 -05:00
|
|
|
*horizontalLengthAlongWellToStartClipPoint += segment.length();
|
|
|
|
}
|
|
|
|
vxIdx++;
|
2017-01-04 06:29:25 -06:00
|
|
|
}
|
|
|
|
|
2018-03-20 11:28:27 -05:00
|
|
|
if ( m_measuredDepths.size() > vxIdx )
|
2017-01-04 06:29:25 -06:00
|
|
|
{
|
2018-03-20 11:28:27 -05:00
|
|
|
if ( vxIdx == 0 )
|
2017-01-04 06:29:25 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// For measuredDepth same or lower than first point, use this first point
|
|
|
|
interpolatedVector = vectorValuesAlongWellPath.at( 0 );
|
2017-01-04 06:29:25 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// Do interpolation
|
|
|
|
double segmentFraction = ( measuredDepth - m_measuredDepths.at( vxIdx - 1 ) ) /
|
|
|
|
( m_measuredDepths.at( vxIdx ) - m_measuredDepths.at( vxIdx - 1 ) );
|
2018-04-13 07:35:14 -05:00
|
|
|
cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1];
|
2019-09-06 03:40:57 -05:00
|
|
|
interpolatedVector = ( 1.0 - segmentFraction ) * vectorValuesAlongWellPath[vxIdx - 1] +
|
|
|
|
segmentFraction * vectorValuesAlongWellPath[vxIdx];
|
2018-03-20 11:28:27 -05:00
|
|
|
|
|
|
|
if ( horizontalLengthAlongWellToStartClipPoint )
|
|
|
|
{
|
|
|
|
segment[2] = 0.0;
|
2018-09-27 02:48:08 -05:00
|
|
|
*horizontalLengthAlongWellToStartClipPoint += segment.length() * segmentFraction;
|
2018-03-20 11:28:27 -05:00
|
|
|
}
|
2017-01-04 06:29:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-20 11:28:27 -05:00
|
|
|
// Use endpoint if measuredDepth same or higher than last point
|
2019-09-06 03:40:57 -05:00
|
|
|
interpolatedVector = vectorValuesAlongWellPath.at( vxIdx - 1 );
|
2017-01-04 06:29:25 -06:00
|
|
|
}
|
|
|
|
|
2018-04-13 07:35:14 -05:00
|
|
|
return interpolatedVector;
|
|
|
|
}
|
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d
|
|
|
|
RigWellPath::interpolatedPointAlongWellPath( double measuredDepth,
|
|
|
|
double* horizontalLengthAlongWellToStartClipPoint /*= nullptr*/ ) const
|
2018-04-13 07:35:14 -05:00
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
return interpolatedVectorValuesAlongWellPath( m_wellPathPoints, measuredDepth, horizontalLengthAlongWellToStartClipPoint );
|
2017-01-04 06:29:25 -06:00
|
|
|
}
|
|
|
|
|
2021-01-04 04:09:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Vec3d RigWellPath::tangentAlongWellPath( double measuredDepth ) const
|
|
|
|
{
|
|
|
|
if ( m_measuredDepths.size() < 2u ) return cvf::Vec3d::UNDEFINED;
|
|
|
|
|
|
|
|
if ( measuredDepth <= m_measuredDepths.front() )
|
|
|
|
{
|
|
|
|
return ( m_wellPathPoints[1] - m_wellPathPoints[0] ).getNormalized();
|
|
|
|
}
|
2021-02-26 07:27:59 -06:00
|
|
|
|
|
|
|
if ( measuredDepth >= m_measuredDepths.back() )
|
2021-01-04 04:09:01 -06:00
|
|
|
{
|
|
|
|
auto N = m_measuredDepths.size();
|
|
|
|
return ( m_wellPathPoints[N - 1] - m_wellPathPoints[N - 2] ).getNormalized();
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( size_t i = 1; i < m_measuredDepths.size(); i++ )
|
|
|
|
{
|
|
|
|
cvf::Vec3d point1 = m_wellPathPoints[i - 1];
|
|
|
|
cvf::Vec3d point2 = m_wellPathPoints[i - 0];
|
|
|
|
|
|
|
|
double md1 = m_measuredDepths[i - 1];
|
|
|
|
double md2 = m_measuredDepths[i];
|
|
|
|
|
|
|
|
if ( measuredDepth >= md1 && measuredDepth < md2 )
|
|
|
|
{
|
|
|
|
return ( point2 - point1 ).getNormalized();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cvf::Vec3d::UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2017-02-06 06:12:56 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-02-06 06:12:56 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
double RigWellPath::wellPathAzimuthAngle( const cvf::Vec3d& position ) const
|
2017-02-06 06:12:56 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
// For vertical well (x-component of direction = 0) returned angle will be 90.
|
2018-01-04 12:31:44 -06:00
|
|
|
double azimuthAngleDegrees = 90.0;
|
2017-02-06 06:12:56 -06:00
|
|
|
|
2021-08-13 09:48:33 -05:00
|
|
|
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
|
|
|
|
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
|
|
|
|
twoClosestPoints( position, &p1, &p2 );
|
2017-02-06 06:12:56 -06:00
|
|
|
|
2021-08-13 09:48:33 -05:00
|
|
|
if ( !p1.isUndefined() )
|
|
|
|
{
|
2017-06-27 07:11:55 -05:00
|
|
|
cvf::Vec3d direction = p2 - p1;
|
2017-02-06 06:12:56 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( fabs( direction.y() ) > 1e-5 )
|
2017-02-06 06:12:56 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
double atanValue = direction.x() / direction.y();
|
|
|
|
double azimuthRadians = atan( atanValue );
|
|
|
|
azimuthAngleDegrees = cvf::Math::toDegrees( azimuthRadians );
|
2017-02-06 06:12:56 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-04 12:31:44 -06:00
|
|
|
return azimuthAngleDegrees;
|
2017-02-06 06:12:56 -06:00
|
|
|
}
|
|
|
|
|
2017-05-05 04:21:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-05-05 04:21:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RigWellPath::twoClosestPoints( const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2 ) const
|
2017-05-05 04:21:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( p1 && p2 );
|
2017-05-05 04:21:40 -05:00
|
|
|
|
2021-08-13 09:48:33 -05:00
|
|
|
auto closeIndices = closestIndices( position );
|
|
|
|
if ( closeIndices.first != cvf::UNDEFINED_SIZE_T )
|
2017-05-05 04:21:40 -05:00
|
|
|
{
|
2021-08-13 09:48:33 -05:00
|
|
|
*p1 = m_wellPathPoints[closeIndices.first];
|
|
|
|
*p2 = m_wellPathPoints[closeIndices.second];
|
2017-05-05 04:21:40 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 06:53:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RigWellPath::identicalTubeLength( const RigWellPath& other ) const
|
|
|
|
{
|
|
|
|
const double eps = 1.0e-8;
|
|
|
|
|
2020-10-09 01:38:18 -05:00
|
|
|
size_t minimumVertexCount = std::min( m_wellPathPoints.size(), other.wellPathPoints().size() );
|
|
|
|
if ( minimumVertexCount < 2u ) return 0.0;
|
2020-10-07 06:53:36 -05:00
|
|
|
|
2020-10-09 01:38:18 -05:00
|
|
|
double identicalLength = 0.0;
|
|
|
|
if ( ( m_wellPathPoints.front() - other.wellPathPoints().front() ).length() < eps )
|
|
|
|
{
|
|
|
|
for ( size_t vIndex = 1; vIndex < minimumVertexCount; ++vIndex )
|
|
|
|
{
|
|
|
|
if ( ( m_wellPathPoints[vIndex] - other.wellPathPoints()[vIndex] ).length() < eps )
|
|
|
|
{
|
|
|
|
identicalLength = m_measuredDepths[vIndex];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return identicalLength;
|
|
|
|
}
|
2020-10-07 06:53:36 -05:00
|
|
|
|
2021-08-13 09:48:33 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double RigWellPath::closestMeasuredDepth( const cvf::Vec3d& position ) const
|
|
|
|
{
|
|
|
|
auto [firstIndex, secondIndex] = closestIndices( position );
|
|
|
|
if ( firstIndex != cvf::UNDEFINED_SIZE_T )
|
|
|
|
{
|
|
|
|
cvf::Vec3d p1 = m_wellPathPoints[firstIndex];
|
|
|
|
cvf::Vec3d p2 = m_wellPathPoints[secondIndex];
|
|
|
|
|
|
|
|
double diffP1 = ( p1 - position ).lengthSquared();
|
|
|
|
double diffP2 = ( p2 - position ).lengthSquared();
|
|
|
|
|
|
|
|
double weigth1 = diffP2 / ( diffP1 + diffP2 );
|
|
|
|
|
|
|
|
double measureDepth1 = m_measuredDepths[firstIndex];
|
|
|
|
double measureDepth2 = m_measuredDepths[secondIndex];
|
|
|
|
|
|
|
|
double interpolatedValue = measureDepth1 * weigth1 + measureDepth2 * ( 1.0 - weigth1 );
|
|
|
|
return interpolatedValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1.0;
|
|
|
|
}
|
|
|
|
|
2020-10-09 01:38:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-10-14 11:55:17 -05:00
|
|
|
cvf::ref<RigWellPath> RigWellPath::commonGeometry( const std::vector<const RigWellPath*>& allGeometries )
|
2020-10-09 01:38:18 -05:00
|
|
|
{
|
2020-10-20 08:15:46 -05:00
|
|
|
const double eps = 1.0e-3;
|
2020-10-09 01:38:18 -05:00
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
if ( allGeometries.empty() ) return nullptr;
|
|
|
|
|
|
|
|
if ( allGeometries.size() == 1u ) return cvf::ref<RigWellPath>( new RigWellPath( *allGeometries.front() ) );
|
2020-10-09 01:38:18 -05:00
|
|
|
|
|
|
|
const RigWellPath* firstGeometry = allGeometries.front();
|
|
|
|
|
|
|
|
std::vector<cvf::Vec3d> commonWellPathPoints;
|
|
|
|
std::vector<double> commonMDs;
|
|
|
|
|
|
|
|
for ( size_t vIndex = 0u; vIndex < firstGeometry->wellPathPoints().size(); ++vIndex )
|
2020-10-07 06:53:36 -05:00
|
|
|
{
|
2020-10-09 01:38:18 -05:00
|
|
|
const cvf::Vec3d& firstGeometryVertex = firstGeometry->wellPathPoints()[vIndex];
|
|
|
|
|
|
|
|
bool allMatches = std::all_of( allGeometries.begin() + 1, allGeometries.end(), [=]( const RigWellPath* geometry ) {
|
|
|
|
if ( geometry->wellPathPoints().size() > vIndex )
|
|
|
|
{
|
|
|
|
return ( firstGeometryVertex - geometry->wellPathPoints()[vIndex] ).length() < eps;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
|
|
|
|
if ( allMatches )
|
2020-10-07 06:53:36 -05:00
|
|
|
{
|
2020-10-09 01:38:18 -05:00
|
|
|
commonWellPathPoints.push_back( firstGeometryVertex );
|
|
|
|
commonMDs.push_back( firstGeometry->measuredDepths()[vIndex] );
|
2020-10-07 06:53:36 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-10-14 11:55:17 -05:00
|
|
|
return cvf::ref<RigWellPath>( new RigWellPath( commonWellPathPoints, commonMDs ) );
|
2020-10-07 06:53:36 -05:00
|
|
|
}
|
|
|
|
|
2020-10-16 00:36:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-02-26 07:27:59 -06:00
|
|
|
void RigWellPath::setUniqueStartAndEndIndex( size_t uniqueStartIndex, size_t uniqueEndIndex )
|
2020-10-16 00:36:29 -05:00
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
if ( m_measuredDepths.empty() ) return;
|
|
|
|
|
|
|
|
m_uniqueStartIndex = std::clamp( uniqueStartIndex, (size_t)0u, m_measuredDepths.size() - 1u );
|
|
|
|
m_uniqueEndIndex = std::clamp( uniqueEndIndex, m_uniqueStartIndex, m_measuredDepths.size() - 1u );
|
2020-10-16 00:36:29 -05:00
|
|
|
}
|
|
|
|
|
2021-01-04 04:09:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
size_t RigWellPath::uniqueStartIndex() const
|
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
return m_uniqueStartIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
size_t RigWellPath::uniqueEndIndex() const
|
|
|
|
{
|
2021-05-10 08:12:29 -05:00
|
|
|
if ( m_measuredDepths.empty() ) return 0;
|
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
return std::clamp( m_uniqueEndIndex, m_uniqueStartIndex, m_measuredDepths.size() - 1u );
|
2021-01-04 04:09:01 -06:00
|
|
|
}
|
|
|
|
|
2020-10-16 00:36:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<cvf::Vec3d> RigWellPath::uniqueWellPathPoints() const
|
|
|
|
{
|
2021-05-10 08:12:29 -05:00
|
|
|
if ( m_wellPathPoints.empty() ) return {};
|
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
return std::vector<cvf::Vec3d>( m_wellPathPoints.begin() + uniqueStartIndex(),
|
|
|
|
m_wellPathPoints.begin() + uniqueEndIndex() + 1u );
|
2020-10-16 00:36:29 -05:00
|
|
|
}
|
|
|
|
|
2021-01-04 04:09:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RigWellPath::uniqueMeasuredDepths() const
|
|
|
|
{
|
2021-05-10 08:12:29 -05:00
|
|
|
if ( m_measuredDepths.empty() ) return {};
|
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
return std::vector<double>( m_measuredDepths.begin() + m_uniqueStartIndex,
|
|
|
|
m_measuredDepths.begin() + uniqueEndIndex() + 1u );
|
2021-01-04 04:09:01 -06:00
|
|
|
}
|
|
|
|
|
2017-05-26 05:37:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-05-26 05:37:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::pair<std::vector<cvf::Vec3d>, std::vector<double>>
|
|
|
|
RigWellPath::clippedPointSubset( double startMD, double endMD, double* horizontalLengthAlongWellToStartClipPoint ) const
|
2017-05-26 05:37:01 -05:00
|
|
|
{
|
2021-05-10 08:12:29 -05:00
|
|
|
if ( m_measuredDepths.empty() ) return {};
|
|
|
|
if ( startMD > endMD ) return {};
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::pair<std::vector<cvf::Vec3d>, std::vector<double>> pointsAndMDs;
|
2017-09-19 10:20:49 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
pointsAndMDs.first.push_back( interpolatedPointAlongWellPath( startMD, horizontalLengthAlongWellToStartClipPoint ) );
|
|
|
|
pointsAndMDs.second.push_back( startMD );
|
2017-05-26 05:37:01 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
for ( size_t i = 0; i < m_measuredDepths.size(); ++i )
|
2017-05-26 05:37:01 -05:00
|
|
|
{
|
2017-09-18 09:24:29 -05:00
|
|
|
double measuredDepth = m_measuredDepths[i];
|
2021-01-04 04:09:01 -06:00
|
|
|
if ( measuredDepth > startMD && measuredDepth <= endMD )
|
2017-09-18 09:24:29 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
pointsAndMDs.first.push_back( m_wellPathPoints[i] );
|
|
|
|
pointsAndMDs.second.push_back( measuredDepth );
|
2017-09-18 09:24:29 -05:00
|
|
|
}
|
2017-05-26 05:37:01 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
pointsAndMDs.first.push_back( interpolatedPointAlongWellPath( endMD ) );
|
|
|
|
pointsAndMDs.second.push_back( endMD );
|
2017-05-26 05:37:01 -05:00
|
|
|
|
2017-09-19 10:20:49 -05:00
|
|
|
return pointsAndMDs;
|
2017-05-26 05:37:01 -05:00
|
|
|
}
|
|
|
|
|
2017-08-02 04:13:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-02 04:13:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<cvf::Vec3d>
|
|
|
|
RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint( double intersectionMeasuredDepth ) const
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3d> points;
|
2018-03-20 07:12:20 -05:00
|
|
|
if ( m_measuredDepths.empty() ) return points;
|
2017-08-02 04:13:27 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath( intersectionMeasuredDepth );
|
2017-08-02 04:13:27 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
for ( size_t i = 0; i < m_measuredDepths.size() - 1; i++ )
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
2018-03-20 07:12:20 -05:00
|
|
|
if ( m_measuredDepths[i] == intersectionMeasuredDepth )
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( m_wellPathPoints[i] );
|
2018-01-16 00:54:03 -06:00
|
|
|
}
|
2018-03-20 07:12:20 -05:00
|
|
|
else if ( m_measuredDepths[i] < intersectionMeasuredDepth )
|
2018-01-16 00:54:03 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( m_wellPathPoints[i] );
|
2018-03-20 07:12:20 -05:00
|
|
|
if ( m_measuredDepths[i + 1] > intersectionMeasuredDepth )
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( interpolatedWellPathPoint );
|
2017-08-02 04:13:27 -05:00
|
|
|
}
|
|
|
|
}
|
2018-03-20 07:12:20 -05:00
|
|
|
else if ( m_measuredDepths[i] > intersectionMeasuredDepth )
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
2018-03-20 07:12:20 -05:00
|
|
|
if ( i == 0 )
|
2017-08-02 04:13:27 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( interpolatedWellPathPoint );
|
2018-01-16 00:54:03 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( m_wellPathPoints[i] );
|
2017-08-02 04:13:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
points.push_back( m_wellPathPoints.back() );
|
2017-08-02 04:13:27 -05:00
|
|
|
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-03-20 07:12:20 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RigWellPath::isAnyPointInsideBoundingBox( const std::vector<cvf::Vec3d>& points, const cvf::BoundingBox& boundingBox )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const cvf::Vec3d& point : points )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( boundingBox.contains( point ) ) return true;
|
2018-03-20 07:12:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-03-20 07:12:20 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<cvf::Vec3d> RigWellPath::clipPolylineStartAboveZ( const std::vector<cvf::Vec3d>& polyLine,
|
|
|
|
double maxZ,
|
|
|
|
double* horizontalLengthAlongWellToClipPoint,
|
|
|
|
size_t* indexToFirstVisibleSegment )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( horizontalLengthAlongWellToClipPoint );
|
|
|
|
CVF_ASSERT( indexToFirstVisibleSegment );
|
2018-03-20 07:12:20 -05:00
|
|
|
|
|
|
|
// Find first visible point, and accumulate distance along wellpath
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
*horizontalLengthAlongWellToClipPoint = 0.0;
|
2019-09-06 03:40:57 -05:00
|
|
|
*indexToFirstVisibleSegment = cvf::UNDEFINED_SIZE_T;
|
2018-03-21 07:56:24 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t vxIdx = 0; vxIdx < polyLine.size(); ++vxIdx )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
|
|
|
if ( polyLine[vxIdx].z() > maxZ )
|
|
|
|
{
|
|
|
|
if ( vxIdx > 0 )
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx - 1];
|
|
|
|
segment[2] = 0.0;
|
2018-03-20 07:12:20 -05:00
|
|
|
*horizontalLengthAlongWellToClipPoint += segment.length();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
firstVisiblePointIndex = vxIdx;
|
2018-03-20 07:12:20 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clip line, and add vx to the start of the clipped result
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
std::vector<cvf::Vec3d> clippedPolyLine;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( firstVisiblePointIndex == cvf::UNDEFINED_SIZE_T )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
|
|
|
return clippedPolyLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( firstVisiblePointIndex > 0 )
|
|
|
|
{
|
|
|
|
cvf::Plane topPlane;
|
2020-11-06 03:46:38 -06:00
|
|
|
topPlane.setFromPointAndNormal( { 0.0, 0.0, maxZ }, cvf::Vec3d::Z_AXIS );
|
2018-03-20 07:12:20 -05:00
|
|
|
cvf::Vec3d intersection;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( topPlane.intersect( polyLine[firstVisiblePointIndex - 1], polyLine[firstVisiblePointIndex], &intersection ) )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex - 1];
|
|
|
|
segment[2] = 0.0;
|
2018-03-20 07:12:20 -05:00
|
|
|
*horizontalLengthAlongWellToClipPoint += segment.length();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
clippedPolyLine.push_back( intersection );
|
2018-03-20 07:12:20 -05:00
|
|
|
}
|
|
|
|
|
2018-03-21 07:56:24 -05:00
|
|
|
*indexToFirstVisibleSegment = firstVisiblePointIndex - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*indexToFirstVisibleSegment = 0;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2018-03-20 07:12:20 -05:00
|
|
|
// Add the rest of the polyline
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx )
|
2018-03-20 07:12:20 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
clippedPolyLine.push_back( polyLine[vxIdx] );
|
2018-03-20 07:12:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return clippedPolyLine;
|
|
|
|
}
|
2021-08-13 09:48:33 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Returns the closes indices with smallest index first
|
|
|
|
// If not found, cvf::UNDEFINED_SIZE_T is returned for both
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::pair<size_t, size_t> RigWellPath::closestIndices( const cvf::Vec3d& position ) const
|
|
|
|
{
|
|
|
|
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
|
|
|
|
double closestDistance = cvf::UNDEFINED_DOUBLE;
|
|
|
|
|
|
|
|
for ( size_t i = 1; i < m_wellPathPoints.size(); i++ )
|
|
|
|
{
|
|
|
|
cvf::Vec3d point1 = m_wellPathPoints[i - 1];
|
|
|
|
cvf::Vec3d point2 = m_wellPathPoints[i - 0];
|
|
|
|
|
|
|
|
double candidateDistance = cvf::GeometryTools::linePointSquareDist( point1, point2, position );
|
|
|
|
if ( candidateDistance < closestDistance )
|
|
|
|
{
|
|
|
|
closestDistance = candidateDistance;
|
|
|
|
closestIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( closestIndex != cvf::UNDEFINED_SIZE_T )
|
|
|
|
{
|
|
|
|
if ( closestIndex > 0 )
|
|
|
|
{
|
|
|
|
return { closestIndex - 1, closestIndex };
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return { closestIndex, closestIndex + 1 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return { cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T };
|
|
|
|
}
|