Copy up from pre-proto

This commit is contained in:
Magne Sjaastad 2017-02-03 10:23:07 +01:00
parent 8a26861c03
commit 426d42935f
2 changed files with 41 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#include "RigSimulationWellCoordsAndMD.h" #include "RigSimulationWellCoordsAndMD.h"
#include "cvfGeometryTools.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -81,6 +83,44 @@ cvf::Vec3d RigSimulationWellCoordsAndMD::interpolatedPointAlongWellPath(double m
return wellPathPoint; return wellPathPoint;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigSimulationWellCoordsAndMD::locationAlongWellCoords(const cvf::Vec3d& position) const
{
double location = 0.0;
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)
{
cvf::Vec3d p1 = m_wellPathPoints[closestIndex - 1];
cvf::Vec3d p2 = m_wellPathPoints[closestIndex - 0];
double intersection = 0.0;
cvf::GeometryTools::projectPointOnLine(p1, p2, position, &intersection);
location = m_measuredDepths[closestIndex - 1];
location += intersection * (p1-p2).length();
}
return location;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -39,6 +39,7 @@ public:
const std::vector<double>& measuredDepths() const; const std::vector<double>& measuredDepths() const;
cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth) const; cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth) const;
double locationAlongWellCoords(const cvf::Vec3d& position) const;
private: private:
void computeMeasuredDepths(); void computeMeasuredDepths();