From 48e93dab9901916228c30832806d1ddd372c8e14 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 31 Jul 2018 08:44:37 +0200 Subject: [PATCH] #2609 Well Path Creation: Discard disabled well targets --- .../RimWellPathGeometryDef.cpp | 46 +++++++++++++------ .../ProjectDataModel/RimWellPathGeometryDef.h | 8 ++-- .../ProjectDataModel/RimWellPathTarget.cpp | 18 ++++++-- .../ProjectDataModel/RimWellPathTarget.h | 18 ++++---- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index 511000b965..31224a567c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -82,7 +82,7 @@ cvf::ref RimWellPathGeometryDef::createWellPathGeometry() { cvf::ref wellPathGeometry = new RigWellPath; - if (m_wellTargets.size() < 2) return wellPathGeometry; + if (activeWellTargets().size() < 2) return wellPathGeometry; RiaPolyArcLineSampler arcLineSampler(startTangent(), lineArcEndpoints()); @@ -189,21 +189,37 @@ void RimWellPathGeometryDef::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTree //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimWellPathGeometryDef::lineArcEndpoints() +std::vector RimWellPathGeometryDef::activeWellTargets() const { - CVF_ASSERT(m_wellTargets.size() > 1); + std::vector active; + for (const auto& wt : m_wellTargets) + { + if (wt->isEnabled()) + { + active.push_back(wt); + } + } + + return active; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPathGeometryDef::lineArcEndpoints() const +{ + std::vector activeWellPathTargets = activeWellTargets(); + + CVF_ASSERT(activeWellPathTargets.size() > 1); std::vector endPoints; + endPoints.push_back( activeWellPathTargets[0]->targetPointXYZ() + m_referencePoint() ); - endPoints.push_back( m_wellTargets[0]->targetPointXYZ() + m_referencePoint() ); - - for ( size_t tIdx = 0; tIdx < m_wellTargets.size() - 1; ++tIdx) + for ( size_t tIdx = 0; tIdx < activeWellPathTargets.size() - 1; ++tIdx) { + RimWellPathTarget* target1 = activeWellPathTargets[tIdx]; + RimWellPathTarget* target2 = activeWellPathTargets[tIdx+1]; - RimWellPathTarget* target1 = m_wellTargets[tIdx]; - RimWellPathTarget* target2 = m_wellTargets[tIdx+1]; - - if (target1->targetType() == RimWellPathTarget::POINT_AND_TANGENT && target2->targetType() == RimWellPathTarget::POINT_AND_TANGENT) { @@ -231,15 +247,17 @@ std::vector RimWellPathGeometryDef::lineArcEndpoints() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RimWellPathGeometryDef::startTangent() +cvf::Vec3d RimWellPathGeometryDef::startTangent() const { - if (m_wellTargets[0]->targetType() == RimWellPathTarget::POINT_AND_TANGENT) + std::vector wellTargets = activeWellTargets(); + + if (!wellTargets.empty() && wellTargets[0]->targetType() == RimWellPathTarget::POINT_AND_TANGENT) { - return m_wellTargets[0]->tangent(); + return wellTargets[0]->tangent(); } else { - return { 0, 0, -1}; + return { 0, 0, -1 }; } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h index 74d3f26e40..ffcd4df378 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h @@ -61,9 +61,11 @@ private: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; - std::vector lineArcEndpoints(); - cvf::Vec3d startTangent(); + std::vector activeWellTargets() const; + std::vector lineArcEndpoints() const; + cvf::Vec3d startTangent() const; +private: caf::PdmField > m_wellStartType; caf::PdmField m_referencePoint; @@ -71,8 +73,6 @@ private: caf::PdmPtrField m_parentWell; caf::PdmChildArrayField m_wellTargets; - - }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp b/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp index 754a11930a..3dd27c16e3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathTarget.cpp @@ -41,6 +41,14 @@ RimWellPathTarget::~RimWellPathTarget() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellPathTarget::isEnabled() const +{ + return m_isEnabled; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -80,7 +88,7 @@ void RimWellPathTarget::setDerivedTangent(double azimuth, double inclination) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPathTarget::TargetTypeEnum RimWellPathTarget::targetType() +RimWellPathTarget::TargetTypeEnum RimWellPathTarget::targetType() const { return m_targetType(); } @@ -88,7 +96,7 @@ RimWellPathTarget::TargetTypeEnum RimWellPathTarget::targetType() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RimWellPathTarget::targetPointXYZ() +cvf::Vec3d RimWellPathTarget::targetPointXYZ() const { cvf::Vec3d xyzPoint(m_targetPoint()); xyzPoint.z() = -xyzPoint.z(); @@ -98,7 +106,7 @@ cvf::Vec3d RimWellPathTarget::targetPointXYZ() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimWellPathTarget::azimuth() +double RimWellPathTarget::azimuth() const { if ( m_targetType() == POINT_AND_TANGENT ) { @@ -113,7 +121,7 @@ double RimWellPathTarget::azimuth() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimWellPathTarget::inclination() +double RimWellPathTarget::inclination() const { if ( m_targetType() == POINT_AND_TANGENT ) { @@ -128,7 +136,7 @@ double RimWellPathTarget::inclination() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RimWellPathTarget::tangent() +cvf::Vec3d RimWellPathTarget::tangent() const { return cvf::Vec3d (sin(m_azimuth) * sin(m_inclination), cos(m_azimuth) * sin(m_inclination), diff --git a/ApplicationCode/ProjectDataModel/RimWellPathTarget.h b/ApplicationCode/ProjectDataModel/RimWellPathTarget.h index 55bd3de4d8..7312b0c349 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathTarget.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathTarget.h @@ -32,29 +32,29 @@ public: RimWellPathTarget(); ~RimWellPathTarget(); + bool isEnabled() const; + void setAsPointTargetXYD(const cvf::Vec3d& point); void setAsPointAndTangentTarget(const cvf::Vec3d& point, double azimuth, double inclination); void setDerivedTangent(double azimuth, double inclination); enum TargetTypeEnum { POINT_AND_TANGENT, POINT }; - TargetTypeEnum targetType(); - cvf::Vec3d targetPointXYZ(); - double azimuth(); - double inclination(); - cvf::Vec3d tangent(); - - - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + TargetTypeEnum targetType() const; + cvf::Vec3d targetPointXYZ() const; + double azimuth() const; + double inclination() const; + cvf::Vec3d tangent() const; private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; +private: caf::PdmField m_isEnabled; caf::PdmField > m_targetType; caf::PdmField m_targetPoint; caf::PdmField m_azimuth; caf::PdmField m_inclination; - };