From 71c36208c3f12e5ce094feabb9cff53806f4c443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 27 Sep 2018 14:19:10 +0200 Subject: [PATCH] #3422 Handle straight well paths better --- ApplicationCode/Application/Tools/RiaJCurveCalculator.cpp | 7 +++++-- .../ProjectDataModel/RimWellPathGeometryDef.cpp | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaJCurveCalculator.cpp b/ApplicationCode/Application/Tools/RiaJCurveCalculator.cpp index 1d4844f1b0..d90ff04329 100644 --- a/ApplicationCode/Application/Tools/RiaJCurveCalculator.cpp +++ b/ApplicationCode/Application/Tools/RiaJCurveCalculator.cpp @@ -35,9 +35,10 @@ RiaJCurveCalculator::RiaJCurveCalculator(cvf::Vec3d p1, double azi1, double inc1 cvf::Vec3d p1p2 = p2 - p1; bool isOk = true; - cvf::Vec3d tr1 = (p1p2 - (p1p2.dot(t1)) * t1).getNormalized(&isOk); - if (!isOk) + cvf::Vec3d tr1 = p1p2 - (p1p2.dot(t1)) * t1; + double tr1Length = tr1.length(); + if (tr1Length < 1e-9) { // p2 is on the p1 + t12 line. Degenerates to a line. m_curveStatus = OK_STRAIGHT_LINE; @@ -47,6 +48,8 @@ RiaJCurveCalculator::RiaJCurveCalculator(cvf::Vec3d p1, double azi1, double inc1 return; } + + tr1 /= tr1Length; cvf::Vec3d c1 = p1 + r1 * tr1; cvf::Vec3d p2c1 = c1 - p2; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index 03dc3745f1..253a5321cd 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -395,6 +395,9 @@ std::vector RimWellPathGeometryDef::lineArcEndpoints() const RimWellPathTarget* target1 = activeWellPathTargets[tIdx]; RimWellPathTarget* target2 = activeWellPathTargets[tIdx+1]; + // Ignore targets in the same place + if ((target1->targetPointXYZ() - target2->targetPointXYZ()).length() < 1e-6) continue; + target1->flagRadius2AsIncorrect(false, 0); target2->flagRadius1AsIncorrect(false, 0);