#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -1,47 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigWellPath.h"
#include "cvfGeometryTools.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RigWellPath::RigWellPath()
: m_hasDatumElevation(false),
m_datumElevation(0.0)
: m_hasDatumElevation( false )
, m_datumElevation( 0.0 )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigWellPath::setDatumElevation(double value)
void RigWellPath::setDatumElevation( double value )
{
m_hasDatumElevation = true;
m_datumElevation = value;
m_datumElevation = value;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigWellPath::hasDatumElevation() const
{
@@ -49,7 +49,7 @@ bool RigWellPath::hasDatumElevation() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigWellPath::datumElevation() const
{
@@ -61,19 +61,19 @@ double RigWellPath::datumElevation() const
//--------------------------------------------------------------------------------------------------
double RigWellPath::rkbDiff() const
{
if (hasDatumElevation())
if ( hasDatumElevation() )
{
return datumElevation();
}
// If measured depth is zero, use the z-value of the well path points
if (m_wellPathPoints.size() > 0 && m_measuredDepths.size() > 0)
if ( m_wellPathPoints.size() > 0 && m_measuredDepths.size() > 0 )
{
double epsilon = 1e-3;
if (cvf::Math::abs(m_measuredDepths[0]) < epsilon)
if ( cvf::Math::abs( m_measuredDepths[0] ) < epsilon )
{
double diff = m_measuredDepths[0] - (-wellPathPoints()[0].z());
double diff = m_measuredDepths[0] - ( -wellPathPoints()[0].z() );
return diff;
}
@@ -81,26 +81,26 @@ double RigWellPath::rkbDiff() const
return HUGE_VAL;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigWellPath::interpolatedVectorValuesAlongWellPath(const std::vector<cvf::Vec3d>& vectorValuesAlongWellPath,
double measuredDepth,
double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const
cvf::Vec3d RigWellPath::interpolatedVectorValuesAlongWellPath(
const std::vector<cvf::Vec3d>& vectorValuesAlongWellPath,
double measuredDepth,
double* horizontalLengthAlongWellToStartClipPoint /*= nullptr*/ ) const
{
CVF_ASSERT(vectorValuesAlongWellPath.size() == m_wellPathPoints.size());
CVF_ASSERT( vectorValuesAlongWellPath.size() == m_wellPathPoints.size() );
cvf::Vec3d interpolatedVector = cvf::Vec3d::ZERO;
if (horizontalLengthAlongWellToStartClipPoint) *horizontalLengthAlongWellToStartClipPoint = 0.0;
if ( horizontalLengthAlongWellToStartClipPoint ) *horizontalLengthAlongWellToStartClipPoint = 0.0;
size_t vxIdx = 0;
while ( vxIdx < m_measuredDepths.size() && m_measuredDepths.at(vxIdx) < measuredDepth )
while ( vxIdx < m_measuredDepths.size() && m_measuredDepths.at( vxIdx ) < measuredDepth )
{
if ( vxIdx > 0 && horizontalLengthAlongWellToStartClipPoint)
if ( vxIdx > 0 && horizontalLengthAlongWellToStartClipPoint )
{
cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1];
segment[2] = 0.0;
cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1];
segment[2] = 0.0;
*horizontalLengthAlongWellToStartClipPoint += segment.length();
}
vxIdx++;
@@ -110,16 +110,17 @@ cvf::Vec3d RigWellPath::interpolatedVectorValuesAlongWellPath(const std::vector<
{
if ( vxIdx == 0 )
{
//For measuredDepth same or lower than first point, use this first point
interpolatedVector = vectorValuesAlongWellPath.at(0);
// For measuredDepth same or lower than first point, use this first point
interpolatedVector = vectorValuesAlongWellPath.at( 0 );
}
else
{
//Do interpolation
double segmentFraction = (measuredDepth - m_measuredDepths.at(vxIdx-1)) /
(m_measuredDepths.at(vxIdx) - m_measuredDepths.at(vxIdx - 1));
// Do interpolation
double segmentFraction = ( measuredDepth - m_measuredDepths.at( vxIdx - 1 ) ) /
( m_measuredDepths.at( vxIdx ) - m_measuredDepths.at( vxIdx - 1 ) );
cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1];
interpolatedVector = (1.0 - segmentFraction) * vectorValuesAlongWellPath[vxIdx - 1] + segmentFraction * vectorValuesAlongWellPath[vxIdx];
interpolatedVector = ( 1.0 - segmentFraction ) * vectorValuesAlongWellPath[vxIdx - 1] +
segmentFraction * vectorValuesAlongWellPath[vxIdx];
if ( horizontalLengthAlongWellToStartClipPoint )
{
@@ -131,24 +132,27 @@ cvf::Vec3d RigWellPath::interpolatedVectorValuesAlongWellPath(const std::vector<
else
{
// Use endpoint if measuredDepth same or higher than last point
interpolatedVector = vectorValuesAlongWellPath.at(vxIdx-1);
interpolatedVector = vectorValuesAlongWellPath.at( vxIdx - 1 );
}
return interpolatedVector;
}
cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const
cvf::Vec3d
RigWellPath::interpolatedPointAlongWellPath( double measuredDepth,
double* horizontalLengthAlongWellToStartClipPoint /*= nullptr*/ ) const
{
return interpolatedVectorValuesAlongWellPath(m_wellPathPoints, measuredDepth, horizontalLengthAlongWellToStartClipPoint);
return interpolatedVectorValuesAlongWellPath( m_wellPathPoints,
measuredDepth,
horizontalLengthAlongWellToStartClipPoint );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
double RigWellPath::wellPathAzimuthAngle( const cvf::Vec3d& position ) const
{
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
double closestDistance = cvf::UNDEFINED_DOUBLE;
for ( size_t i = 1; i < m_wellPathPoints.size(); i++ )
@@ -156,15 +160,15 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
cvf::Vec3d p1 = m_wellPathPoints[i - 1];
cvf::Vec3d p2 = m_wellPathPoints[i - 0];
double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position);
double candidateDistance = cvf::GeometryTools::linePointSquareDist( p1, p2, position );
if ( candidateDistance < closestDistance )
{
closestDistance = candidateDistance;
closestIndex = i;
closestIndex = i;
}
}
//For vertical well (x-component of direction = 0) returned angle will be 90.
// For vertical well (x-component of direction = 0) returned angle will be 90.
double azimuthAngleDegrees = 90.0;
if ( closestIndex != cvf::UNDEFINED_DOUBLE )
@@ -185,11 +189,11 @@ 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);
azimuthAngleDegrees = cvf::Math::toDegrees(azimuthRadians);
double atanValue = direction.x() / direction.y();
double azimuthRadians = atan( atanValue );
azimuthAngleDegrees = cvf::Math::toDegrees( azimuthRadians );
}
}
@@ -197,13 +201,13 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2) const
void RigWellPath::twoClosestPoints( const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2 ) const
{
CVF_ASSERT(p1 && p2);
CVF_ASSERT( p1 && p2 );
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
double closestDistance = cvf::UNDEFINED_DOUBLE;
for ( size_t i = 1; i < m_wellPathPoints.size(); i++ )
@@ -211,15 +215,15 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c
cvf::Vec3d point1 = m_wellPathPoints[i - 1];
cvf::Vec3d point2 = m_wellPathPoints[i - 0];
double candidateDistance = cvf::GeometryTools::linePointSquareDist(point1, point2, position);
double candidateDistance = cvf::GeometryTools::linePointSquareDist( point1, point2, position );
if ( candidateDistance < closestDistance )
{
closestDistance = candidateDistance;
closestIndex = i;
closestIndex = i;
}
}
if (closestIndex != cvf::UNDEFINED_SIZE_T)
if ( closestIndex != cvf::UNDEFINED_SIZE_T )
{
if ( closestIndex > 0 )
{
@@ -235,150 +239,146 @@ 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,
double * horizontalLengthAlongWellToStartClipPoint) const
std::pair<std::vector<cvf::Vec3d>, std::vector<double>>
RigWellPath::clippedPointSubset( double startMD, double endMD, double* horizontalLengthAlongWellToStartClipPoint ) const
{
std::pair<std::vector<cvf::Vec3d>, std::vector<double> > pointsAndMDs;
std::pair<std::vector<cvf::Vec3d>, std::vector<double>> pointsAndMDs;
if ( m_measuredDepths.empty() ) return pointsAndMDs;
if ( startMD > endMD ) return pointsAndMDs;
pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD, horizontalLengthAlongWellToStartClipPoint));
pointsAndMDs.second.push_back(startMD);
pointsAndMDs.first.push_back( interpolatedPointAlongWellPath( startMD, horizontalLengthAlongWellToStartClipPoint ) );
pointsAndMDs.second.push_back( startMD );
for ( size_t i = 0; i < m_measuredDepths.size(); ++i )
{
double measuredDepth = m_measuredDepths[i];
if ( measuredDepth > startMD && measuredDepth < endMD )
{
pointsAndMDs.first.push_back(m_wellPathPoints[i]);
pointsAndMDs.second.push_back(measuredDepth);
pointsAndMDs.first.push_back( m_wellPathPoints[i] );
pointsAndMDs.second.push_back( measuredDepth );
}
}
pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(endMD));
pointsAndMDs.second.push_back(endMD);
pointsAndMDs.first.push_back( interpolatedPointAlongWellPath( endMD ) );
pointsAndMDs.second.push_back( endMD );
return pointsAndMDs;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const
std::vector<cvf::Vec3d>
RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint( double intersectionMeasuredDepth ) const
{
std::vector<cvf::Vec3d> points;
if ( m_measuredDepths.empty() ) return points;
cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath(intersectionMeasuredDepth);
cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath( intersectionMeasuredDepth );
for ( size_t i = 0; i < m_measuredDepths.size() - 1; i++ )
{
if ( m_measuredDepths[i] == intersectionMeasuredDepth )
{
points.push_back(m_wellPathPoints[i]);
points.push_back( m_wellPathPoints[i] );
}
else if ( m_measuredDepths[i] < intersectionMeasuredDepth )
{
points.push_back(m_wellPathPoints[i]);
points.push_back( m_wellPathPoints[i] );
if ( m_measuredDepths[i + 1] > intersectionMeasuredDepth )
{
points.push_back(interpolatedWellPathPoint);
points.push_back( interpolatedWellPathPoint );
}
}
else if ( m_measuredDepths[i] > intersectionMeasuredDepth )
{
if ( i == 0 )
{
points.push_back(interpolatedWellPathPoint);
points.push_back( interpolatedWellPathPoint );
}
else
{
points.push_back(m_wellPathPoints[i]);
points.push_back( m_wellPathPoints[i] );
}
}
}
points.push_back(m_wellPathPoints.back());
points.push_back( m_wellPathPoints.back() );
return points;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigWellPath::isAnyPointInsideBoundingBox(const std::vector<cvf::Vec3d>& points, const cvf::BoundingBox& boundingBox)
bool RigWellPath::isAnyPointInsideBoundingBox( const std::vector<cvf::Vec3d>& points, const cvf::BoundingBox& boundingBox )
{
for (const cvf::Vec3d& point : points)
for ( const cvf::Vec3d& point : points )
{
if (boundingBox.contains(point)) return true;
if ( boundingBox.contains( point ) ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RigWellPath::clipPolylineStartAboveZ(const std::vector<cvf::Vec3d>& polyLine,
double maxZ,
double * horizontalLengthAlongWellToClipPoint,
size_t * indexToFirstVisibleSegment)
std::vector<cvf::Vec3d> RigWellPath::clipPolylineStartAboveZ( const std::vector<cvf::Vec3d>& polyLine,
double maxZ,
double* horizontalLengthAlongWellToClipPoint,
size_t* indexToFirstVisibleSegment )
{
CVF_ASSERT(horizontalLengthAlongWellToClipPoint);
CVF_ASSERT(indexToFirstVisibleSegment);
CVF_ASSERT( horizontalLengthAlongWellToClipPoint );
CVF_ASSERT( indexToFirstVisibleSegment );
// Find first visible point, and accumulate distance along wellpath
*horizontalLengthAlongWellToClipPoint = 0.0;
*indexToFirstVisibleSegment = cvf::UNDEFINED_SIZE_T;
*indexToFirstVisibleSegment = cvf::UNDEFINED_SIZE_T;
size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T;
for ( size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx )
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;
cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx - 1];
segment[2] = 0.0;
*horizontalLengthAlongWellToClipPoint += segment.length();
}
}
else
{
firstVisiblePointIndex = vxIdx;
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 )
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);
topPlane.setFromPointAndNormal( {0.0, 0.0, maxZ}, cvf::Vec3d::Z_AXIS );
cvf::Vec3d intersection;
if ( topPlane.intersect(polyLine[firstVisiblePointIndex-1],
polyLine[firstVisiblePointIndex],
&intersection) )
if ( topPlane.intersect( polyLine[firstVisiblePointIndex - 1], polyLine[firstVisiblePointIndex], &intersection ) )
{
cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex-1];
segment[2] = 0.0;
cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex - 1];
segment[2] = 0.0;
*horizontalLengthAlongWellToClipPoint += segment.length();
clippedPolyLine.push_back(intersection);
clippedPolyLine.push_back( intersection );
}
*indexToFirstVisibleSegment = firstVisiblePointIndex - 1;
@@ -387,12 +387,12 @@ std::vector<cvf::Vec3d> RigWellPath::clipPolylineStartAboveZ(const std::vector<c
{
*indexToFirstVisibleSegment = 0;
}
// Add the rest of the polyline
for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx )
for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx )
{
clippedPolyLine.push_back(polyLine[vxIdx]);
clippedPolyLine.push_back( polyLine[vxIdx] );
}
return clippedPolyLine;
@@ -414,10 +414,9 @@ const std::vector<double>& RigWellPath::measureDepths() const
std::vector<double> RigWellPath::trueVerticalDepths() const
{
std::vector<double> tvds;
for (const cvf::Vec3d& point : m_wellPathPoints)
for ( const cvf::Vec3d& point : m_wellPathPoints )
{
tvds.push_back(std::fabs(point.z()));
tvds.push_back( std::fabs( point.z() ) );
}
return tvds;
}