Improve well path modeling

* Improve handling of MD at first target
* When sea level well target is disabled, update MD of first target
* Show well target spheres by default, allow toggling of spheres
* Activate well target modifiers when clicking on well targets
* Remove selection update causing an unstable 3D view
* Improve display and handling of multiple locations
* Add special 3D target for tie in well target
* Add slider to tie in MD input field
* Show MD in well path target table
* Delete all well path laterals when deleting a well path

* Python : Add lateral to parent well
* Python : Add perforation interval
This commit is contained in:
Magne Sjaastad
2021-08-13 16:48:33 +02:00
committed by GitHub
parent 40bd4c285a
commit 8dbb1d5ccd
50 changed files with 1377 additions and 310 deletions

View File

@@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathPickEventHandler.h
@@ -40,6 +41,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathPickEventHandler.cpp

View File

@@ -79,6 +79,14 @@ void RicPointTangentManipulator::setHandleSize( double handleSize )
m_partManager->setHandleSize( handleSize );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulator::setPolyline( const std::vector<cvf::Vec3d>& polyline )
{
m_partManager->setPolyline( polyline );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -94,7 +102,7 @@ bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
{
if ( inputEvent->type() == QEvent::MouseButtonPress )
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
auto* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
if ( mouseEvent->button() == Qt::LeftButton )
{
@@ -119,7 +127,7 @@ bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
{
if ( m_partManager->isManipulatorActive() )
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
auto* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
cvf::ref<cvf::RayIntersectSpec> rayIs =
m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(),

View File

@@ -55,6 +55,7 @@ public:
void setOrigin( const cvf::Vec3d& origin );
void setTangent( const cvf::Vec3d& tangent );
void setHandleSize( double handleSize );
void setPolyline( const std::vector<cvf::Vec3d>& polyline );
void appendPartsToModel( cvf::ModelBasicList* model );

View File

@@ -15,6 +15,7 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicPointTangentManipulatorPartMgr.h"
#include "RivPartPriority.h"
@@ -36,17 +37,16 @@
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfRay.h"
#include "cvfGeometryTools.h"
#include "cvfMath.h"
#include <QDebug>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr()
: m_tangentOnStartManipulation( cvf::Vec3d::UNDEFINED )
, m_originOnStartManipulation( cvf::Vec3d::UNDEFINED )
, m_activeHandle( NONE )
, m_activeHandle( HandleType::NONE )
, m_handleSize( 1.0 )
, m_isGeometryUpdateNeeded( true )
{
@@ -104,12 +104,20 @@ void RicPointTangentManipulatorPartMgr::originAndTangent( cvf::Vec3d* origin, cv
*tangent = m_tangent;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulatorPartMgr::setPolyline( const std::vector<cvf::Vec3d>& polyline )
{
m_polyline = polyline;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPointTangentManipulatorPartMgr::isManipulatorActive() const
{
return m_activeHandle != NONE;
return m_activeHandle != HandleType::NONE;
}
//--------------------------------------------------------------------------------------------------
@@ -172,7 +180,37 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray
{
if ( !isManipulatorActive() ) return;
if ( m_activeHandle == HORIZONTAL_PLANE )
if ( m_activeHandle == HandleType::PRESCRIBED_POLYLINE )
{
cvf::Plane plane;
plane.setFromPointAndNormal( m_origin, newMouseRay->direction() );
cvf::Vec3d newIntersection;
newMouseRay->planeIntersect( plane, &newIntersection );
const cvf::Vec3d newOrigin = m_originOnStartManipulation + ( newIntersection - m_initialPickPoint );
double closestDistance = std::numeric_limits<double>::max();
cvf::Vec3d closestPoint;
for ( size_t i = 1; i < m_polyline.size(); i++ )
{
const auto& p1 = m_polyline[i];
const auto& p2 = m_polyline[i - 1];
double normalizedIntersection;
const auto pointOnLine = cvf::GeometryTools::projectPointOnLine( p1, p2, newOrigin, &normalizedIntersection );
const double candidateDistance = pointOnLine.pointDistanceSquared( newOrigin );
if ( candidateDistance < closestDistance )
{
closestDistance = candidateDistance;
closestPoint = pointOnLine;
}
}
m_origin = closestPoint;
}
else if ( m_activeHandle == HandleType::HORIZONTAL_PLANE )
{
cvf::Plane plane;
plane.setFromPointAndNormal( m_origin, cvf::Vec3d::Z_AXIS );
@@ -183,7 +221,7 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray
m_origin = newOrigin;
}
else if ( m_activeHandle == VERTICAL_AXIS )
else if ( m_activeHandle == HandleType::VERTICAL_AXIS )
{
cvf::Plane plane;
cvf::Vec3d planeNormal = ( newMouseRay->direction() ^ cvf::Vec3d::Z_AXIS ) ^ cvf::Vec3d::Z_AXIS;
@@ -201,7 +239,6 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray
m_origin = newOrigin;
}
// m_tangent = newTangent;
m_isGeometryUpdateNeeded = true;
}
@@ -211,7 +248,7 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulatorPartMgr::endManipulator()
{
m_activeHandle = NONE;
m_activeHandle = HandleType::NONE;
}
//--------------------------------------------------------------------------------------------------
@@ -219,8 +256,15 @@ void RicPointTangentManipulatorPartMgr::endManipulator()
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts()
{
createHorizontalPlaneHandle();
createVerticalAxisHandle();
if ( m_polyline.empty() )
{
createHorizontalPlaneHandle();
createVerticalAxisHandle();
}
else
{
createPolylineHandle();
}
}
//--------------------------------------------------------------------------------------------------
@@ -228,8 +272,15 @@ void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts()
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulatorPartMgr::createGeometryOnly()
{
m_handleParts[HORIZONTAL_PLANE]->setDrawable( createHorizontalPlaneGeo().p() );
m_handleParts[VERTICAL_AXIS]->setDrawable( createVerticalAxisGeo().p() );
if ( m_polyline.empty() )
{
m_handleParts[HandleType::HORIZONTAL_PLANE]->setDrawable( createHorizontalPlaneGeo().p() );
m_handleParts[HandleType::VERTICAL_AXIS]->setDrawable( createVerticalAxisGeo().p() );
}
else
{
m_handleParts[HandleType::PRESCRIBED_POLYLINE]->setDrawable( createPolylineGeo().p() );
}
}
//--------------------------------------------------------------------------------------------------
@@ -241,7 +292,7 @@ void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle()
ref<cvf::DrawableGeo> geo = createHorizontalPlaneGeo();
HandleType handleId = HORIZONTAL_PLANE;
HandleType handleId = HandleType::HORIZONTAL_PLANE;
cvf::Color4f color = cvf::Color4f( 1.0f, 0.0f, 1.0f, 0.7f );
cvf::String partName( "PointTangentManipulator Horizontal Plane Handle" );
@@ -318,7 +369,7 @@ void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle()
using namespace cvf;
cvf::ref<cvf::DrawableGeo> geo = createVerticalAxisGeo();
HandleType handleId = VERTICAL_AXIS;
HandleType handleId = HandleType::VERTICAL_AXIS;
cvf::Color4f color = cvf::Color4f( 0.0f, 0.7f, 0.8f, 0.7f );
cvf::String partName( "PointTangentManipulator Vertical Axis Handle" );
@@ -362,6 +413,42 @@ cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createVerticalAxis
return createIndexedTriangelDrawableGeo( vertexArray.p(), indexArray.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPointTangentManipulatorPartMgr::createPolylineHandle()
{
cvf::ref<cvf::DrawableGeo> geo = createPolylineGeo();
HandleType handleId = HandleType::PRESCRIBED_POLYLINE;
cvf::Color4f color = cvf::Color4f( 0.8f, 0.7f, 0.8f, 0.7f );
cvf::String partName( "PointTangentManipulator Polyline Handle" );
addHandlePart( geo.p(), color, handleId, partName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RicPointTangentManipulatorPartMgr::createPolylineGeo()
{
using namespace cvf;
cvf::ref<cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles;
double radius = m_handleSize * 0.3;
cvf::GeometryUtils::createSphere( radius, 10, 10, geomBuilder.p() );
Vec3f origin( m_origin );
geomBuilder->transformVertexRange( 0, geomBuilder->vertexCount() - 1, cvf::Mat4f::fromTranslation( origin ) );
cvf::ref<cvf::Vec3fArray> vertexArray = geomBuilder->vertices();
cvf::ref<cvf::UIntArray> indexArray = geomBuilder->triangles();
return createIndexedTriangelDrawableGeo( vertexArray.p(), indexArray.p() );
}
#if 0
//--------------------------------------------------------------------------------------------------
///

View File

@@ -38,18 +38,19 @@ class String;
template <typename>
class Array;
typedef Array<Vec3f> Vec3fArray;
typedef Array<uint> UIntArray;
using Vec3fArray = Array<Vec3f>;
using UIntArray = Array<uint>;
} // namespace cvf
class RicPointTangentManipulatorPartMgr : public cvf::Object
{
public:
enum HandleType
enum class HandleType
{
HORIZONTAL_PLANE,
VERTICAL_AXIS,
PRESCRIBED_POLYLINE,
AZIMUTH,
INCLINATION,
NONE
@@ -63,6 +64,7 @@ public:
void setTangent( const cvf::Vec3d& tangent );
void setHandleSize( double handleSize );
void originAndTangent( cvf::Vec3d* origin, cvf::Vec3d* tangent );
void setPolyline( const std::vector<cvf::Vec3d>& polyline );
bool isManipulatorActive() const;
void tryToActivateManipulator( const cvf::HitItem* hitItem );
@@ -81,6 +83,9 @@ private:
void createVerticalAxisHandle();
cvf::ref<cvf::DrawableGeo> createVerticalAxisGeo();
void createPolylineHandle();
cvf::ref<cvf::DrawableGeo> createPolylineGeo();
void addHandlePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
void addActiveModePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
@@ -99,6 +104,8 @@ private:
double m_handleSize;
bool m_isGeometryUpdateNeeded;
std::vector<cvf::Vec3d> m_polyline;
HandleType m_activeHandle;
cvf::Vec3d m_initialPickPoint;
cvf::Vec3d m_tangentOnStartManipulation;

View File

@@ -20,12 +20,15 @@
#include "RicPointTangentManipulator.h"
#include "RigWellPath.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimModeledWellPath.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathGeometryDefTools.h"
#include "RimWellPathTarget.h"
#include "RimWellPathTieIn.h"
#include "RiuViewer.h"
@@ -50,7 +53,7 @@ RicWellTarget3dEditor::RicWellTarget3dEditor()
//--------------------------------------------------------------------------------------------------
RicWellTarget3dEditor::~RicWellTarget3dEditor()
{
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
auto* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
if ( m_cvfModel.notNull() && ownerRiuViewer )
{
@@ -68,9 +71,9 @@ RicWellTarget3dEditor::~RicWellTarget3dEditor()
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
auto* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
auto* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !target->isEnabled() || !view )
{
@@ -110,6 +113,29 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
m_manipulator->setTangent( target->tangent() );
m_manipulator->setHandleSize( handleSize );
{
RimWellPath* wellPath = nullptr;
target->firstAncestorOrThisOfType( wellPath );
if ( wellPath && !wellPath->isTopLevelWellPath() && geomDef->firstActiveTarget() == target )
{
if ( auto parentWellPath = wellPath->wellPathTieIn()->parentWell() )
{
auto geo = parentWellPath->wellPathGeometry();
auto points = geo->wellPathPoints();
for ( auto& p : points )
{
p = dispXf->transformToDisplayCoord( p );
}
// For the first target of a lateral, use the coordinates from the parent well as snap-to locations for
// the 3D manipulator sphere
m_manipulator->setPolyline( points );
}
}
}
m_cvfModel->removeAllParts();
m_manipulator->appendPartsToModel( m_cvfModel.p() );
@@ -129,64 +155,167 @@ void RicWellTarget3dEditor::cleanupBeforeSettingPdmObject()
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
Rim3dView* view = mainOrComparisonView();
auto* manipulatedTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !view )
if ( !manipulatedTarget || !view )
{
return;
}
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
manipulatedTarget->firstAncestorOrThisOfTypeAsserted( geomDef );
if ( !geomDef ) return;
if ( geomDef->useReferencePointFromTopLevelWell() )
RimModeledWellPath* modeledWellPath = nullptr;
geomDef->firstAncestorOfType( modeledWellPath );
cvf::Vec3d domainCoordXYZ; // domain coordinate of the new location
cvf::Vec3d deltaManipulatorMovement; // delta change relative current location of target
cvf::Vec3d relativePositionXYZ; // position of well target relative to anchor point
{
RimModeledWellPath* modeledWellPath = nullptr;
geomDef->firstAncestorOfType( modeledWellPath );
if ( modeledWellPath )
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
domainCoordXYZ = dispXf->transformToDomainCoord( origin );
relativePositionXYZ = domainCoordXYZ - geomDef->anchorPointXyz();
deltaManipulatorMovement = manipulatedTarget->targetPointXYZ() - relativePositionXYZ;
}
if ( geomDef->activeWellTargets().front() == manipulatedTarget )
{
// The first well target of a lateral is the tie-in well target
if ( modeledWellPath && modeledWellPath->wellPathTieIn() && modeledWellPath->wellPathTieIn()->parentWell() )
{
auto topLevelWellPath = dynamic_cast<RimModeledWellPath*>( modeledWellPath->topLevelWellPath() );
if ( topLevelWellPath )
auto parentWell = modeledWellPath->wellPathTieIn()->parentWell();
auto wellPathGeo = parentWell->wellPathGeometry();
auto closestMD = wellPathGeo->closestMeasuredDepth( domainCoordXYZ );
modeledWellPath->wellPathTieIn()->setTieInMeasuredDepth( closestMD );
modeledWellPath->wellPathTieIn()->updateChildWellGeometry();
}
bool modifyAllTargetsOnAllWells = ( ( QApplication::keyboardModifiers() & Qt::ControlModifier ) &&
( QApplication::keyboardModifiers() & Qt::SHIFT ) );
if ( modifyAllTargetsOnAllWells )
{
for ( auto wellLateral : modeledWellPath->wellPathLaterals() )
{
// Manipulate the reference point of top level well path
geomDef = topLevelWellPath->geometryDefinition();
if ( auto modeledLateral = dynamic_cast<RimModeledWellPath*>( wellLateral ) )
{
auto activeTargets = modeledLateral->geometryDefinition()->activeWellTargets();
for ( auto t : activeTargets )
{
if ( t == activeTargets.front() ) continue;
if ( t == manipulatedTarget ) continue;
// Does not work very well
// Must update the tie-in MD also
updateTargetWithDeltaChange( t, deltaManipulatorMovement );
}
}
}
}
if ( QApplication::keyboardModifiers() & Qt::ControlModifier )
{
for ( auto target : geomDef->activeWellTargets() )
{
if ( target == geomDef->activeWellTargets().front() ) continue;
updateTargetWithDeltaChange( target, deltaManipulatorMovement );
}
}
cvf::Vec3d relativePositionXYD = relativePositionXYZ;
relativePositionXYD.z() = -relativePositionXYD.z();
manipulatedTarget->updateFrom3DManipulator( relativePositionXYD );
return;
}
if ( modeledWellPath && modeledWellPath->isTopLevelWellPath() )
{
// Modification of top level well path
bool modifyReferencePoint = ( ( QApplication::keyboardModifiers() & Qt::ControlModifier ) &&
( QApplication::keyboardModifiers() & Qt::SHIFT ) );
if ( modifyReferencePoint )
{
// Find all linked wells and update reference point with delta change
std::vector<RimWellPathGeometryDef*> linkedWellPathGeoDefs;
if ( geomDef->isReferencePointUpdatesLinked() )
{
linkedWellPathGeoDefs = RimWellPathGeometryDefTools::linkedDefinitions();
}
else
{
linkedWellPathGeoDefs.push_back( geomDef );
}
RimWellPathGeometryDefTools::updateLinkedGeometryDefinitions( linkedWellPathGeoDefs, deltaManipulatorMovement );
return;
}
bool modifyAllTargetOnWell = ( QApplication::keyboardModifiers() & Qt::ControlModifier );
if ( modifyAllTargetOnWell )
{
for ( auto t : geomDef->activeWellTargets() )
{
if ( t == manipulatedTarget ) continue;
updateTargetWithDeltaChange( t, deltaManipulatorMovement );
}
}
}
else if ( modeledWellPath && !modeledWellPath->isTopLevelWellPath() )
{
bool modifyAllTargetsOnAllWells = ( ( QApplication::keyboardModifiers() & Qt::ControlModifier ) &&
( QApplication::keyboardModifiers() & Qt::SHIFT ) );
if ( modifyAllTargetsOnAllWells )
{
// Update all well targets on all connected laterals
for ( auto wellLateral : modeledWellPath->wellPathLaterals() )
{
if ( auto modeledLateral = dynamic_cast<RimModeledWellPath*>( wellLateral ) )
{
auto activeTargets = modeledLateral->geometryDefinition()->activeWellTargets();
for ( auto t : activeTargets )
{
if ( t == activeTargets.front() ) continue;
if ( t == manipulatedTarget ) continue;
updateTargetWithDeltaChange( t, deltaManipulatorMovement );
}
}
}
}
bool modifyAllTargets = ( QApplication::keyboardModifiers() & Qt::ControlModifier );
if ( modifyAllTargets )
{
// Update all well targets on current well path
for ( auto t : geomDef->activeWellTargets() )
{
if ( t == geomDef->activeWellTargets().front() ) continue;
if ( t == manipulatedTarget ) continue;
updateTargetWithDeltaChange( t, deltaManipulatorMovement );
}
}
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
auto domainCoordXYZ = dispXf->transformToDomainCoord( origin );
// If CTRL is pressed, modify the reference point instead of the well path target
bool modifyReferencePoint = ( QApplication::keyboardModifiers() & Qt::ControlModifier );
if ( modifyReferencePoint )
// Modify a single well target
{
auto relativePositionXYZ = domainCoordXYZ - geomDef->anchorPointXyz();
auto delta = target->targetPointXYZ() - relativePositionXYZ;
// Find all linked wells and update with delta change
std::vector<RimWellPathGeometryDef*> linkedWellPathGeoDefs;
if ( geomDef->isReferencePointUpdatesLinked() )
{
linkedWellPathGeoDefs = RimWellPathGeometryDefTools::linkedDefinitions();
}
else
{
linkedWellPathGeoDefs.push_back( geomDef );
}
RimWellPathGeometryDefTools::updateLinkedGeometryDefinitions( linkedWellPathGeoDefs, delta );
}
else
{
cvf::Vec3d relativePositionXYD = domainCoordXYZ - geomDef->anchorPointXyz();
cvf::Vec3d relativePositionXYD = relativePositionXYZ;
relativePositionXYD.z() = -relativePositionXYD.z();
target->updateFrom3DManipulator( relativePositionXYD );
manipulatedTarget->updateFrom3DManipulator( relativePositionXYD );
}
}
@@ -195,7 +324,7 @@ void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Ve
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::slotSelectedIn3D()
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
auto* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
if ( !target )
{
return;
@@ -209,7 +338,7 @@ void RicWellTarget3dEditor::slotSelectedIn3D()
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::slotDragFinished()
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
auto* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
if ( !target )
{
return;
@@ -223,7 +352,7 @@ void RicWellTarget3dEditor::slotDragFinished()
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::removeAllFieldEditors()
{
if ( RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() ) )
if ( auto* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() ) )
{
for ( auto field : oldTarget->fieldsFor3dManipulator() )
{
@@ -231,3 +360,13 @@ void RicWellTarget3dEditor::removeAllFieldEditors()
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::updateTargetWithDeltaChange( RimWellPathTarget* target, const cvf::Vec3d& delta )
{
auto coordXYZ = target->targetPointXYZ() - delta;
target->setPointXYZ( coordXYZ );
target->updateConnectedEditors();
}

View File

@@ -26,6 +26,7 @@
#include <QPointer>
class RicPointTangentManipulator;
class RimWellPathTarget;
namespace cvf
{
@@ -54,6 +55,8 @@ private slots:
private:
void removeAllFieldEditors();
static void updateTargetWithDeltaChange( RimWellPathTarget* target, const cvf::Vec3d& delta );
private:
QPointer<RicPointTangentManipulator> m_manipulator;
cvf::ref<cvf::ModelBasicList> m_cvfModel;

View File

@@ -66,21 +66,27 @@ void RicCreateMultipleWellPathLaterals::onActionTriggered( bool isChecked )
if ( selected )
{
m_ui->setSourceLateral( selected );
m_ui->setTopLevelWellPath( selected->topLevelWellPath() );
double startMD = 0.0;
double endMD = 0.0;
if ( auto tieIn = selected->wellPathTieIn() )
auto sourceLateral = m_ui->sourceLateral();
if ( sourceLateral )
{
startMD = selected->wellPathTieIn()->tieInMeasuredDepth() + 50.0;
endMD = startMD + 50.0;
if ( auto parentWell = selected->wellPathTieIn()->parentWell() )
if ( auto tieIn = sourceLateral->wellPathTieIn() )
{
if ( !parentWell->wellPathGeometry()->measuredDepths().empty() )
{
double candidate = parentWell->wellPathGeometry()->measuredDepths().back() - 50.0;
startMD = sourceLateral->wellPathTieIn()->tieInMeasuredDepth() + 50.0;
endMD = startMD + 50.0;
if ( candidate > startMD ) endMD = candidate;
if ( auto parentWell = sourceLateral->wellPathTieIn()->parentWell() )
{
if ( !parentWell->wellPathGeometry()->measuredDepths().empty() )
{
double candidate = parentWell->wellPathGeometry()->measuredDepths().back() - 50.0;
if ( candidate > startMD ) endMD = candidate;
}
}
}
}

View File

@@ -47,6 +47,9 @@ RicCreateMultipleWellPathLateralsUi::RicCreateMultipleWellPathLateralsUi()
{
CAF_PDM_InitFieldNoDefault( &m_sourceLateral, "SourceLaterals", "Source Well Path Lateral", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_topLevelWellPath, "TopLevelWellPath", "Top Level Well Path", "", "", "" );
m_topLevelWellPath.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_locations, "Locations", "Locations", "", "", "" );
m_locations = new RimMultipleLocations;
}
@@ -54,9 +57,13 @@ RicCreateMultipleWellPathLateralsUi::RicCreateMultipleWellPathLateralsUi()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateMultipleWellPathLateralsUi::setSourceLateral( RimModeledWellPath* lateral )
void RicCreateMultipleWellPathLateralsUi::setTopLevelWellPath( RimWellPath* wellPath )
{
m_sourceLateral = lateral;
m_topLevelWellPath = wellPath;
auto laterals = RimTools::wellPathCollection()->connectedWellPathLaterals( m_topLevelWellPath );
if ( !laterals.empty() ) m_sourceLateral = dynamic_cast<RimModeledWellPath*>( laterals.front() );
}
//--------------------------------------------------------------------------------------------------
@@ -108,14 +115,15 @@ QList<caf::PdmOptionItemInfo>
if ( fieldNeedingOptions == &m_sourceLateral )
{
if ( sourceLateral()->wellPathTieIn() && sourceLateral()->wellPathTieIn()->parentWell() )
if ( m_topLevelWellPath )
{
auto parentWell = sourceLateral()->wellPathTieIn()->parentWell();
auto laterals = RimTools::wellPathCollection()->connectedWellPathLaterals( parentWell );
auto laterals = RimTools::wellPathCollection()->connectedWellPathLaterals( m_topLevelWellPath );
for ( auto lateral : laterals )
{
options.push_back( caf::PdmOptionItemInfo( lateral->name(), lateral ) );
caf::IconProvider iconProvider = lateral->uiIconProvider();
options.push_back( caf::PdmOptionItemInfo( lateral->name(), lateral, false, iconProvider ) );
}
}
}

View File

@@ -30,6 +30,7 @@
#include <QPointer>
class RimModeledWellPath;
class RimWellPath;
namespace caf
{
@@ -46,7 +47,7 @@ class RicCreateMultipleWellPathLateralsUi : public caf::PdmObject
public:
RicCreateMultipleWellPathLateralsUi();
void setSourceLateral( RimModeledWellPath* lateral );
void setTopLevelWellPath( RimWellPath* wellPath );
void setDefaultValues( double start, double end );
RimModeledWellPath* sourceLateral() const;
@@ -60,6 +61,7 @@ private:
private:
caf::PdmPtrField<RimModeledWellPath*> m_sourceLateral;
caf::PdmPtrField<RimWellPath*> m_topLevelWellPath;
caf::PdmChildField<RimMultipleLocations*> m_locations;
};

View File

@@ -27,6 +27,7 @@
#include "RigHexIntersectionTools.h"
#include "RigMainGrid.h"
#include "RigWellPath.h"
#include "RigWellPathGeometryTools.h"
#include "Rim3dView.h"
#include "RimEclipseView.h"
@@ -111,8 +112,15 @@ bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEve
targetPointInDomain =
wellPathSourceInfo->closestPointOnCenterLine( firstPickItem.faceIdx(), intersectionPointInDomain );
double md = wellPathSourceInfo->measuredDepth( firstPickItem.faceIdx(), intersectionPointInDomain );
doSetAzimuthAndInclination = calculateAzimuthAndInclinationAtMd( md, wellPathGeometry, &azimuth, &inclination );
double rkbDiff = wellPathGeometry->rkbDiff();
{
const auto [az, inc] = RigWellPathGeometryTools::calculateAzimuthAndInclinationAtMd( md, wellPathGeometry );
azimuth = az;
inclination = inc;
doSetAzimuthAndInclination = true;
}
double rkbDiff = wellPathGeometry->rkbDiff();
if ( m_geometryToAddTargetsTo->airGap() == 0.0 && rkbDiff != std::numeric_limits<double>::infinity() )
{
m_geometryToAddTargetsTo->setAirGap( rkbDiff );
@@ -190,59 +198,6 @@ bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEve
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateWellTargetsPickEventHandler::calculateAzimuthAndInclinationAtMd( double measuredDepth,
gsl::not_null<const RigWellPath*> wellPathGeometry,
double* azimuth,
double* inclination ) const
{
int mdIndex = -1;
auto mdList = wellPathGeometry->measuredDepths();
for ( int i = 0; i < (int)mdList.size(); i++ )
{
if ( mdList[i] > measuredDepth )
{
mdIndex = i - 1;
break;
}
}
auto ptList = wellPathGeometry->wellPathPoints();
if ( mdIndex > 0 && mdIndex < (int)ptList.size() - 2 )
{
auto v1 = cvf::Vec3d( ptList[mdIndex - 1] );
auto v2 = cvf::Vec3d( ptList[mdIndex] );
auto v3 = cvf::Vec3d( ptList[mdIndex + 1] );
auto v4 = cvf::Vec3d( ptList[mdIndex + 2] );
auto v21 = v2 - v1;
auto v32 = v3 - v2;
auto v43 = v4 - v3;
v21.normalize();
v32.normalize();
v43.normalize();
auto v13mean = ( v21 + v32 ) / 2;
auto v24mean = ( v32 + v43 ) / 2;
double weight = ( measuredDepth - mdList[mdIndex] ) / ( mdList[mdIndex + 1] - mdList[mdIndex] );
auto vTan = v13mean * weight + v24mean * ( 1 - weight );
RiaOffshoreSphericalCoords coords( vTan );
*azimuth = coords.azi();
*inclination = coords.inc();
return true;
}
*azimuth = 0.0;
*inclination = 0.0;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -43,11 +43,6 @@ protected:
void notifyUnregistered() override;
private:
bool calculateAzimuthAndInclinationAtMd( double measuredDepth,
gsl::not_null<const RigWellPath*> wellPathGeometry,
double* azimuth,
double* inclination ) const;
static bool isGridSourceObject( const cvf::Object* object );
static cvf::Vec3d findHexElementIntersection( gsl::not_null<Rim3dView*> view,
const RiuPickItemInfo& pickItem,

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- Equinor ASA
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicDeleteWellPathFeature.h"
#include "RimTools.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDeleteWellPathFeature, "RicDeleteWellPathFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellPathFeature::isCommandEnabled()
{
std::vector<RimWellPath*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
return !objects.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteWellPathFeature::onActionTriggered( bool isChecked )
{
std::vector<RimWellPath*> wellPaths;
caf::SelectionManager::instance()->objectsByType( &wellPaths );
if ( !wellPaths.empty() )
{
auto wpc = RimTools::wellPathCollection();
for ( auto w : wellPaths )
{
for ( auto wl : w->allWellPathLaterals() )
{
wpc->deleteWell( wl );
}
}
wpc->rebuildWellPathNodes();
wpc->scheduleRedrawAffectedViews();
wpc->updateAllRequiredEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteWellPathFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Delete Well Path" );
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- Equinor ASA
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicDeleteWellPathFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -24,6 +24,7 @@
#include "Riu3dSelectionManager.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
@@ -34,7 +35,7 @@ CAF_CMD_SOURCE_INIT( RicLinkWellPathFeature, "RicLinkWellPathFeature" );
//--------------------------------------------------------------------------------------------------
bool RicLinkWellPathFeature::isCommandEnabled()
{
return ( wellPathGeometryDef() != nullptr );
return ( !wellPaths().empty() );
}
//--------------------------------------------------------------------------------------------------
@@ -42,10 +43,14 @@ bool RicLinkWellPathFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicLinkWellPathFeature::onActionTriggered( bool isChecked )
{
if ( auto geoDef = wellPathGeometryDef() )
for ( auto w : wellPaths() )
{
geoDef->enableLinkOfReferencePointUpdates( isChecked );
geoDef->updateConnectedEditors();
if ( auto modeledWell = dynamic_cast<RimModeledWellPath*>( w ) )
{
auto geoDef = modeledWell->geometryDefinition();
geoDef->enableLinkOfReferencePointUpdates( isChecked );
geoDef->updateConnectedEditors();
}
}
}
@@ -58,6 +63,8 @@ void RicLinkWellPathFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setText( text );
actionToSetup->setCheckable( true );
actionToSetup->setChecked( isCommandChecked() );
actionToSetup->setIcon( QIcon( ":/chain.png" ) );
}
//--------------------------------------------------------------------------------------------------
@@ -65,27 +72,39 @@ void RicLinkWellPathFeature::setupActionLook( QAction* actionToSetup )
//--------------------------------------------------------------------------------------------------
bool RicLinkWellPathFeature::isCommandChecked()
{
if ( auto geoDef = wellPathGeometryDef() )
if ( !wellPaths().empty() )
{
return geoDef->isReferencePointUpdatesLinked();
auto firstWell = dynamic_cast<RimModeledWellPath*>( wellPaths().front() );
if ( auto geoDef = firstWell->geometryDefinition() )
{
return geoDef->isReferencePointUpdatesLinked();
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathGeometryDef* RicLinkWellPathFeature::wellPathGeometryDef()
std::vector<RimWellPath*> RicLinkWellPathFeature::wellPaths()
{
std::vector<RimWellPath*> wellPaths;
auto wellPathSelectionItem = RiuWellPathSelectionItem::wellPathSelectionItem();
if ( wellPathSelectionItem && wellPathSelectionItem->m_wellpath )
{
if ( auto modeledWellPath = dynamic_cast<RimModeledWellPath*>( wellPathSelectionItem->m_wellpath ) )
if ( auto modeledWellPath =
dynamic_cast<RimModeledWellPath*>( wellPathSelectionItem->m_wellpath->topLevelWellPath() ) )
{
return modeledWellPath->geometryDefinition();
wellPaths.push_back( modeledWellPath );
}
}
return nullptr;
auto selectedWells = caf::selectedObjectsByTypeStrict<RimWellPath*>();
for ( auto w : selectedWells )
{
wellPaths.push_back( w->topLevelWellPath() );
}
return wellPaths;
}

View File

@@ -20,7 +20,7 @@
#include "cafCmdFeature.h"
class RimWellPathGeometryDef;
class RimWellPath;
//==================================================================================================
///
@@ -36,5 +36,5 @@ public:
bool isCommandChecked() override;
private:
static RimWellPathGeometryDef* wellPathGeometryDef();
static std::vector<RimWellPath*> wellPaths();
};

View File

@@ -84,8 +84,8 @@ void RicNewWellPathLateralAtDepthFeature::setupActionLook( QAction* actionToSetu
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RicNewWellPathLateralAtDepthFeature::createLateralAtMeasuredDepth( RimWellPath* parentWellPath,
double parentWellMD )
RimModeledWellPath* RicNewWellPathLateralAtDepthFeature::createLateralAtMeasuredDepth( RimWellPath* parentWellPath,
double parentWellMD )
{
RimProject* project = RimProject::current();
RimWellPathCollection* wellPathColl = RimTools::wellPathCollection();

View File

@@ -20,6 +20,7 @@
#include "cafCmdFeature.h"
class RimModeledWellPath;
class RimWellPath;
//==================================================================================================
@@ -34,6 +35,6 @@ public:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
static RimWellPath* createLateralAtMeasuredDepth( RimWellPath* parentWellPath, double parentWellMD );
static QString updateNameOfParentAndFindNameOfSideStep( RimWellPath* parentWellPath );
static RimModeledWellPath* createLateralAtMeasuredDepth( RimWellPath* parentWellPath, double parentWellMD );
static QString updateNameOfParentAndFindNameOfSideStep( RimWellPath* parentWellPath );
};

View File

@@ -31,14 +31,15 @@
#include "RimWellPath.h"
#include "RimWellPathAttribute.h"
#include "RimWellPathAttributeCollection.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathValve.h"
#include "RiuMainWindow.h"
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "RivObjectSourceInfo.h"
#include "RivWellPathSourceInfo.h"
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include "cvfPart.h"
@@ -179,6 +180,10 @@ bool RicWellPathPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& event
}
}
}
else if ( auto geoDef = dynamic_cast<RimWellPathGeometryDef*>( sourceInfo->object() ) )
{
RiuMainWindow::instance()->selectAsCurrentItem( geoDef );
}
}
if ( dynamic_cast<const RivWellPathSourceInfo*>( firstPickedPart->sourceInfo() ) )