Merge branch 'fishbones' into pre-proto

This commit is contained in:
Magne Sjaastad
2017-05-23 10:28:42 +02:00
3995 changed files with 17802 additions and 174762 deletions

View File

@@ -19,6 +19,8 @@
#include "RigWellPath.h"
#include "cvfGeometryTools.h"
#include "cvfGeometryTools.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -150,3 +152,41 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2) const
{
CVF_ASSERT(p1 && p2);
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
double closestDistance = cvf::UNDEFINED_DOUBLE;
for (size_t i = 1; i < m_wellPathPoints.size(); i++)
{
cvf::Vec3d p1 = m_wellPathPoints[i - 1];
cvf::Vec3d p2 = m_wellPathPoints[i - 0];
double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position);
if (candidateDistance < closestDistance)
{
closestDistance = candidateDistance;
closestIndex = i;
}
}
if (closestIndex != cvf::UNDEFINED_DOUBLE)
{
if (closestIndex > 0)
{
*p1 = m_wellPathPoints[closestIndex - 1];
*p2 = m_wellPathPoints[closestIndex - 0];
}
else
{
*p1 = m_wellPathPoints[closestIndex + 1];
*p2 = m_wellPathPoints[closestIndex + 0];
}
}
}