#3289 Well path creation. When clicking on a well path, use tangent. Rename arguments

This commit is contained in:
Bjørn Erik Jensen
2018-10-01 10:07:43 +02:00
parent 5a51111db2
commit 063b7121b1
4 changed files with 109 additions and 15 deletions

View File

@@ -17,9 +17,17 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RicCreateWellTargetsPickEventHandler.h"
#include "RiaOffshoreSphericalCoords.h"
#include "RigWellPath.h"
#include "Rim3dView.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RimWellPath.h"
#include "RivWellPathSourceInfo.h"
#include "cafSelectionManager.h"
#include "cafDisplayCoordTransform.h"
@@ -68,18 +76,45 @@ bool RicCreateWellTargetsPickEventHandler::handlePickEvent(const Ric3DPickEvent&
if ( m_geometryToAddTargetsTo )
{
Rim3dView* rimView = eventObject.m_view;
cvf::Vec3d targetPointInDomain = cvf::Vec3d::ZERO;
// If clicked on an other well path, snap target point to well path center line
auto firstPickItem = eventObject.m_pickItemInfos.front();
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(firstPickItem.sourceInfo());
auto intersectionPointInDomain = rimView->displayCoordTransform()->transformToDomainCoord(firstPickItem.globalPickedPoint());
bool doSetAzimuthAndInclination;
double azimuth = 0.0, inclination = 0.0;
if (wellPathSourceInfo)
{
targetPointInDomain = wellPathSourceInfo->closestPointOnCenterLine(firstPickItem.faceIdx(), intersectionPointInDomain);
double md = wellPathSourceInfo->measuredDepth(firstPickItem.faceIdx(), intersectionPointInDomain);
doSetAzimuthAndInclination = calculateAzimuthAndInclinationAtMd(md, wellPathSourceInfo->wellPath()->wellPathGeometry(), &azimuth, &inclination);
}
else
{
targetPointInDomain = intersectionPointInDomain;
doSetAzimuthAndInclination = false;
}
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_pickItemInfos.front().globalPickedPoint());
if (!m_geometryToAddTargetsTo->firstActiveTarget())
{
m_geometryToAddTargetsTo->setReferencePointXyz(domainCoord);
m_geometryToAddTargetsTo->setReferencePointXyz(targetPointInDomain);
}
cvf::Vec3d referencePoint = m_geometryToAddTargetsTo->referencePointXyz();
cvf::Vec3d relativeTagetPoint = domainCoord - referencePoint;
cvf::Vec3d relativeTagetPoint = targetPointInDomain - referencePoint;
RimWellPathTarget* newTarget = new RimWellPathTarget;
newTarget->setAsPointTargetXYD(cvf::Vec3d(relativeTagetPoint.x(), relativeTagetPoint.y(), -relativeTagetPoint.z()));
if (doSetAzimuthAndInclination)
{
newTarget->setAsPointXYZAndTangentTarget(cvf::Vec3d(relativeTagetPoint.x(), relativeTagetPoint.y(), relativeTagetPoint.z()), azimuth, inclination);
}
else
{
newTarget->setAsPointTargetXYD(cvf::Vec3d(relativeTagetPoint.x(), relativeTagetPoint.y(), -relativeTagetPoint.z()));
}
m_geometryToAddTargetsTo->insertTarget(nullptr, newTarget);
@@ -91,3 +126,56 @@ bool RicCreateWellTargetsPickEventHandler::handlePickEvent(const Ric3DPickEvent&
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateWellTargetsPickEventHandler::calculateAzimuthAndInclinationAtMd(double measuredDepth,
const RigWellPath* wellPathGeometry,
double *azimuth,
double *inclination) const
{
int mdIndex = -1;
auto mdList = wellPathGeometry->measureDepths();
for (int i = 0; i < mdList.size(); i++)
{
if (mdList[i] > measuredDepth)
{
mdIndex = i - 1;
break;
}
}
auto ptList = wellPathGeometry->wellPathPoints();
if (mdIndex > 0 && mdIndex < ptList.size() - 2)
{
auto v1 = cvf::Vec3d(ptList[mdIndex - 1]);
auto v2 = cvf::Vec3d(ptList[mdIndex]);
auto v3 = cvf::Vec3d(ptList[mdIndex + 1]);
auto v4 = cvf::Vec3d(ptList[mdIndex + 2]);
auto v21 = v2 - v1;
auto v32 = v3 - v2;
auto v43 = v4 - v3;
v21.normalize();
v32.normalize();
v43.normalize();
auto v13mean = (v21 + v32) / 2;
auto v24mean = (v32 + v43) / 2;
double weight = (measuredDepth - mdList[mdIndex]) / (mdList[mdIndex + 1] - mdList[mdIndex]);
auto vTan = v13mean * weight + v24mean * (1 - weight);
RiaOffshoreSphericalCoords coords(vTan);
*azimuth = coords.azi();
*inclination = coords.inc();
return true;
}
*azimuth = 0.0;
*inclination = 0.0;
return false;
}

View File

@@ -23,6 +23,7 @@
#include "cafPdmPointer.h"
class RimWellPathGeometryDef;
class RigWellPath;
//==================================================================================================
///
@@ -38,5 +39,11 @@ protected:
virtual bool handlePickEvent(const Ric3DPickEvent& eventObject) override;
virtual void notifyUnregistered() override;
private:
bool calculateAzimuthAndInclinationAtMd(double measuredDepth,
const RigWellPath* wellPathGeometry,
double *azimuth,
double *inclination) const;
};