From 996aebc7ac20c00d1e9fd35f65d9b7eddafbf833 Mon Sep 17 00:00:00 2001 From: astridkbjorke <abjorke@emgs.com> Date: Wed, 4 Jan 2017 13:29:25 +0100 Subject: [PATCH] pre-proto - For WellPathFractures, position along well path is updated when setting a new value for measured depth --- .../ProjectDataModel/RimWellPathFracture.cpp | 25 +++++++++++- .../ProjectDataModel/RimWellPathFracture.h | 1 + .../ReservoirDataModel/RigWellPath.cpp | 39 +++++++++++++++++++ .../ReservoirDataModel/RigWellPath.h | 1 + 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp index ca4bcbc301..6bc478bb74 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathFracture.cpp @@ -49,7 +49,7 @@ RimWellPathFracture::RimWellPathFracture(void) CAF_PDM_InitField(&name, "UserDescription", QString("Fracture Name"), "Name", "", "", ""); CAF_PDM_InitField( &measuredDepth, "MeasuredDepth", 0.0f, "Measured Depth Location (if along well path)", "", "", ""); - CAF_PDM_InitField( &positionAtWellpath, "PositionAtWellpath", cvf::Vec3d::ZERO, "Fracture Position at Well Path", "", "", ""); + CAF_PDM_InitField( &positionAtWellpath, "PositionAtWellpath", cvf::Vec3d::ZERO, "Fracture Position along Well Path", "", "", ""); CAF_PDM_InitFieldNoDefault(&ui_positionAtWellpath, "ui_positionAtWellpath", "Fracture Position at Well Path", "", "", ""); ui_positionAtWellpath.registerGetMethod(this, &RimWellPathFracture::wellPositionForUi); @@ -120,6 +120,29 @@ RimFractureDefinition* RimWellPathFracture::attachedFractureDefinition() return fractureDefinition(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &measuredDepth) + { + positionAtWellpath = cvf::Vec3d::ZERO; + + caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(this); + if (!objHandle) return; + + RimWellPath* wellPath = nullptr; + objHandle->firstAncestorOrThisOfType(wellPath); + if (!wellPath) return; + + RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); + positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(measuredDepth); + + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathFracture.h b/ApplicationCode/ProjectDataModel/RimWellPathFracture.h index bf53b686ff..474df0dfa7 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathFracture.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathFracture.h @@ -59,6 +59,7 @@ public: virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; // Overrides from RimFracture virtual cvf::Vec3d centerPointForFracture() override; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index 7c84a68612..02559086f2 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -52,3 +52,42 @@ double RigWellPath::datumElevation() const return m_datumElevation; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) +{ + cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO; + if (measuredDepth < 0) return wellPathPoint; + + int i = 0; + while (i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth ) + { + i++; + } + + if (m_measuredDepths.size() > i) + { + if (i == 0) + { + //For measuredDepth=0 use startpoint + wellPathPoint = m_wellPathPoints.at(0); + } + else + { + //Do interpolation + double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) / + (m_measuredDepths.at(i) - m_measuredDepths.at(i - 1)); + wellPathPoint = m_wellPathPoints.at(i - 1) + stepsize * (m_wellPathPoints.at(i) - m_wellPathPoints.at(i-1)); + } + } + else + { + //Use endpoint if measuredDepth same or higher than last point + wellPathPoint = m_wellPathPoints.at(i-1); + } + + + return wellPathPoint; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index d77cf8e77e..6bc5d89777 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -40,6 +40,7 @@ public: void setDatumElevation(double value); bool hasDatumElevation() const; double datumElevation() const; + cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth); private: bool m_hasDatumElevation;