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:
parent
01673f31cb
commit
be75fbc2c1
@ -83,6 +83,8 @@ bool RicCreateWellTargetsPickEventHandler::handlePickEvent(const Ric3DPickEvent&
|
||||
|
||||
m_geometryToAddTargetsTo->insertTarget(nullptr, newTarget);
|
||||
|
||||
m_geometryToAddTargetsTo->addSmootheningTangentToNextToLastTargetIfSensible();
|
||||
|
||||
m_geometryToAddTargetsTo->updateConnectedEditors();
|
||||
m_geometryToAddTargetsTo->updateWellPathVisualization();
|
||||
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -55,6 +55,8 @@ public:
|
||||
void deleteTarget(RimWellPathTarget* targetTodelete);
|
||||
void appendTarget();
|
||||
|
||||
void addSmootheningTangentToNextToLastTargetIfSensible();
|
||||
|
||||
const RimWellPathTarget* firstActiveTarget() const;
|
||||
const RimWellPathTarget* lastActiveTarget() const;
|
||||
|
||||
|
@ -66,12 +66,12 @@ void RimWellPathTarget::setAsPointTargetXYD(const cvf::Vec3d& point)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathTarget::setAsPointAndTangentTarget(const cvf::Vec3d& point,
|
||||
double azimuth,
|
||||
double inclination)
|
||||
void RimWellPathTarget::setAsPointXYZAndTangentTarget(const cvf::Vec3d& point,
|
||||
double azimuth,
|
||||
double inclination)
|
||||
{
|
||||
m_targetType = POINT_AND_TANGENT;
|
||||
m_targetPoint = point;
|
||||
m_targetType = POINT_AND_TANGENT;
|
||||
m_targetPoint = cvf::Vec3d(point.x(), point.y(), -point.z());
|
||||
m_azimuth = cvf::Math::toDegrees(azimuth);
|
||||
m_inclination = cvf::Math::toDegrees(inclination);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
bool isEnabled() const;
|
||||
|
||||
void setAsPointTargetXYD(const cvf::Vec3d& point);
|
||||
void setAsPointAndTangentTarget(const cvf::Vec3d& point, double azimuth, double inclination);
|
||||
void setAsPointXYZAndTangentTarget(const cvf::Vec3d& point, double azimuth, double inclination);
|
||||
void setDerivedTangent(double azimuth, double inclination);
|
||||
|
||||
enum TargetTypeEnum { POINT_AND_TANGENT, POINT };
|
||||
|
Loading…
Reference in New Issue
Block a user