mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3286 A simple default tangent calculation/adjustment when creating targets
Use distance weighted average of line segments
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "RigWellPath.h"
|
||||
#include "RiaPolyArcLineSampler.h"
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "RimWellPathTarget.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RiaSCurveCalculator.h"
|
||||
@@ -32,6 +34,7 @@
|
||||
|
||||
#include "WellPathCommands/RicCreateWellTargetsPickEventHandler.h"
|
||||
#include "RiuViewerCommands.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -157,6 +160,45 @@ void RimWellPathGeometryDef::appendTarget()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathGeometryDef::addSmootheningTangentToNextToLastTargetIfSensible()
|
||||
{
|
||||
if (m_wellTargets.size() < 3) return;
|
||||
size_t targetMaxIdx = m_wellTargets.size() - 1;
|
||||
|
||||
RimWellPathTarget* t1 = m_wellTargets[targetMaxIdx - 2];
|
||||
RimWellPathTarget* t2 = m_wellTargets[targetMaxIdx - 1];
|
||||
RimWellPathTarget* t3 = m_wellTargets[targetMaxIdx - 0];
|
||||
|
||||
if ( t2->targetType() != RimWellPathTarget::POINT ) return;
|
||||
|
||||
cvf::Vec3d t1t2 = t2->targetPointXYZ() - t1->targetPointXYZ();
|
||||
cvf::Vec3d t2t3 = t3->targetPointXYZ() - t2->targetPointXYZ();
|
||||
|
||||
double angle = cvf::GeometryTools::getAngle(t1t2, t2t3);
|
||||
|
||||
if (angle < 0.3927) return; // pi/8
|
||||
|
||||
double length12 = t1t2.length();
|
||||
double length23 = t2t3.length();
|
||||
|
||||
t1t2 /= length12; // Normalize
|
||||
t2t3 /= length23; // Normalize
|
||||
|
||||
// Inverse distance:
|
||||
|
||||
t1t2 /= length12; // Weight
|
||||
t2t3 /= length23; // Weight
|
||||
|
||||
cvf::Vec3d averageTangent = 1.0/(1.0/length12 + 1.0/length23) * (t1t2 + t2t3);
|
||||
|
||||
RiaOffshoreSphericalCoords aziInc(averageTangent);
|
||||
t2->setAsPointXYZAndTangentTarget(t2->targetPointXYZ(), aziInc.azi(), aziInc.inc());
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user