mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2481, #2605, #2486 Use a flattened version of the normal wellpath visualization in 2D intersection view
This commit is contained in:
@@ -17,9 +17,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigWellPath.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfPlane.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -63,14 +64,14 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) con
|
||||
cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO;
|
||||
|
||||
size_t i = 0;
|
||||
while (i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth )
|
||||
while ( i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (m_measuredDepths.size() > i)
|
||||
if ( m_measuredDepths.size() > i )
|
||||
{
|
||||
if (i == 0)
|
||||
if ( i == 0 )
|
||||
{
|
||||
//For measuredDepth same or lower than first point, use this first point
|
||||
wellPathPoint = m_wellPathPoints.at(0);
|
||||
@@ -78,8 +79,8 @@ cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) con
|
||||
else
|
||||
{
|
||||
//Do interpolation
|
||||
double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) /
|
||||
(m_measuredDepths.at(i) - m_measuredDepths.at(i - 1));
|
||||
double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) /
|
||||
(m_measuredDepths.at(i) - m_measuredDepths.at(i - 1));
|
||||
wellPathPoint = m_wellPathPoints.at(i - 1) + stepsize * (m_wellPathPoints.at(i) - m_wellPathPoints.at(i-1));
|
||||
}
|
||||
}
|
||||
@@ -101,13 +102,13 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
|
||||
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
|
||||
double closestDistance = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
for (size_t i = 1; i < m_wellPathPoints.size(); i++)
|
||||
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)
|
||||
if ( candidateDistance < closestDistance )
|
||||
{
|
||||
closestDistance = candidateDistance;
|
||||
closestIndex = i;
|
||||
@@ -117,12 +118,12 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
|
||||
//For vertical well (x-component of direction = 0) returned angle will be 90.
|
||||
double azimuthAngleDegrees = 90.0;
|
||||
|
||||
if (closestIndex != cvf::UNDEFINED_DOUBLE)
|
||||
if ( closestIndex != cvf::UNDEFINED_DOUBLE )
|
||||
{
|
||||
cvf::Vec3d p1;
|
||||
cvf::Vec3d p2;
|
||||
|
||||
if (closestIndex > 0)
|
||||
if ( closestIndex > 0 )
|
||||
{
|
||||
p1 = m_wellPathPoints[closestIndex - 1];
|
||||
p2 = m_wellPathPoints[closestIndex - 0];
|
||||
@@ -135,7 +136,7 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
|
||||
|
||||
cvf::Vec3d direction = p2 - p1;
|
||||
|
||||
if (fabs(direction.y()) > 1e-5)
|
||||
if ( fabs(direction.y()) > 1e-5 )
|
||||
{
|
||||
double atanValue = direction.x() / direction.y();
|
||||
double azimuthRadians = atan(atanValue);
|
||||
@@ -156,13 +157,13 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c
|
||||
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
|
||||
double closestDistance = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
for (size_t i = 1; i < m_wellPathPoints.size(); i++)
|
||||
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)
|
||||
if ( candidateDistance < closestDistance )
|
||||
{
|
||||
closestDistance = candidateDistance;
|
||||
closestIndex = i;
|
||||
@@ -171,7 +172,7 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c
|
||||
|
||||
if (closestIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
if (closestIndex > 0)
|
||||
if ( closestIndex > 0 )
|
||||
{
|
||||
*p1 = m_wellPathPoints[closestIndex - 1];
|
||||
*p2 = m_wellPathPoints[closestIndex - 0];
|
||||
@@ -190,16 +191,16 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c
|
||||
std::pair<std::vector<cvf::Vec3d>, std::vector<double> > RigWellPath::clippedPointSubset(double startMD, double endMD) const
|
||||
{
|
||||
std::pair<std::vector<cvf::Vec3d>, std::vector<double> > pointsAndMDs;
|
||||
if (m_measuredDepths.empty()) return pointsAndMDs;
|
||||
if (startMD > endMD) return pointsAndMDs;
|
||||
if ( m_measuredDepths.empty() ) return pointsAndMDs;
|
||||
if ( startMD > endMD ) return pointsAndMDs;
|
||||
|
||||
pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD));
|
||||
pointsAndMDs.second.push_back(startMD);
|
||||
|
||||
for (size_t i = 0; i < m_measuredDepths.size(); ++i)
|
||||
for ( size_t i = 0; i < m_measuredDepths.size(); ++i )
|
||||
{
|
||||
double measuredDepth = m_measuredDepths[i];
|
||||
if (measuredDepth > startMD && measuredDepth < endMD)
|
||||
if ( measuredDepth > startMD && measuredDepth < endMD )
|
||||
{
|
||||
pointsAndMDs.first.push_back(m_wellPathPoints[i]);
|
||||
pointsAndMDs.second.push_back(measuredDepth);
|
||||
@@ -218,27 +219,27 @@ std::pair<std::vector<cvf::Vec3d>, std::vector<double> > RigWellPath::clippedPoi
|
||||
std::vector<cvf::Vec3d> RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const
|
||||
{
|
||||
std::vector<cvf::Vec3d> points;
|
||||
if (m_measuredDepths.empty()) return points;
|
||||
if ( m_measuredDepths.empty() ) return points;
|
||||
|
||||
cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath(intersectionMeasuredDepth);
|
||||
|
||||
for (size_t i = 0; i < m_measuredDepths.size() - 1; i++)
|
||||
for ( size_t i = 0; i < m_measuredDepths.size() - 1; i++ )
|
||||
{
|
||||
if (m_measuredDepths[i] == intersectionMeasuredDepth)
|
||||
if ( m_measuredDepths[i] == intersectionMeasuredDepth )
|
||||
{
|
||||
points.push_back(m_wellPathPoints[i]);
|
||||
}
|
||||
else if (m_measuredDepths[i] < intersectionMeasuredDepth)
|
||||
else if ( m_measuredDepths[i] < intersectionMeasuredDepth )
|
||||
{
|
||||
points.push_back(m_wellPathPoints[i]);
|
||||
if (m_measuredDepths[i + 1] > intersectionMeasuredDepth)
|
||||
if ( m_measuredDepths[i + 1] > intersectionMeasuredDepth )
|
||||
{
|
||||
points.push_back(interpolatedWellPathPoint);
|
||||
}
|
||||
}
|
||||
else if (m_measuredDepths[i] > intersectionMeasuredDepth)
|
||||
else if ( m_measuredDepths[i] > intersectionMeasuredDepth )
|
||||
{
|
||||
if (i == 0)
|
||||
if ( i == 0 )
|
||||
{
|
||||
points.push_back(interpolatedWellPathPoint);
|
||||
}
|
||||
@@ -253,3 +254,88 @@ std::vector<cvf::Vec3d> RigWellPath::wellPathPointsIncludingInterpolatedIntersec
|
||||
return points;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigWellPath::isPolylineTouchingBBox(const std::vector<cvf::Vec3d> &polyLine,
|
||||
const cvf::BoundingBox& caseBB)
|
||||
{
|
||||
for ( const cvf::Vec3d& point : polyLine )
|
||||
{
|
||||
if ( caseBB.contains(point) ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RigWellPath::clipPolylineStartAboveZ(const std::vector<cvf::Vec3d>& polyLine,
|
||||
double maxZ,
|
||||
double * horizontalLengthAlongWellToClipPoint)
|
||||
{
|
||||
CVF_ASSERT(horizontalLengthAlongWellToClipPoint != nullptr);
|
||||
|
||||
// Find first visible point, and accumulate distance along wellpath
|
||||
|
||||
*horizontalLengthAlongWellToClipPoint = 0.0;
|
||||
size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
for ( size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx )
|
||||
{
|
||||
if ( polyLine[vxIdx].z() > maxZ )
|
||||
{
|
||||
if ( vxIdx > 0 )
|
||||
{
|
||||
cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx-1];
|
||||
segment[2] = 0.0;
|
||||
*horizontalLengthAlongWellToClipPoint += segment.length();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
firstVisiblePointIndex = vxIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Clip line, and add vx to the start of the clipped result
|
||||
|
||||
std::vector<cvf::Vec3d> clippedPolyLine;
|
||||
|
||||
if ( firstVisiblePointIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
return clippedPolyLine;
|
||||
}
|
||||
|
||||
if ( firstVisiblePointIndex > 0 )
|
||||
{
|
||||
|
||||
cvf::Plane topPlane;
|
||||
topPlane.setFromPointAndNormal({ 0.0, 0.0, maxZ }, cvf::Vec3d::Z_AXIS);
|
||||
cvf::Vec3d intersection;
|
||||
|
||||
if ( topPlane.intersect(polyLine[firstVisiblePointIndex-1],
|
||||
polyLine[firstVisiblePointIndex],
|
||||
&intersection) )
|
||||
{
|
||||
cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex-1];
|
||||
segment[2] = 0.0;
|
||||
*horizontalLengthAlongWellToClipPoint += segment.length();
|
||||
|
||||
clippedPolyLine.push_back(intersection);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the rest of the polyline
|
||||
|
||||
for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx )
|
||||
{
|
||||
clippedPolyLine.push_back(polyLine[vxIdx]);
|
||||
}
|
||||
|
||||
return clippedPolyLine;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user