#2125 Refactor : Return by value instead of incoming parameter

This commit is contained in:
Magne Sjaastad
2017-11-16 13:37:47 +01:00
parent cd368d8ef2
commit 5cbaf3c1eb
5 changed files with 23 additions and 31 deletions

View File

@@ -25,11 +25,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values,
CurveIntervals* intervals,
bool removeNegativeValues)
RigCurveDataTools::CurveIntervals RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values,
bool removeNegativeValues)
{
CVF_ASSERT(intervals);
CurveIntervals intervals;
int startIdx = -1;
size_t vIdx = 0;
@@ -43,7 +42,7 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
{
if (startIdx >= 0)
{
intervals->push_back(std::make_pair(startIdx, vIdx - 1));
intervals.push_back(std::make_pair(startIdx, vIdx - 1));
startIdx = -1;
}
}
@@ -57,30 +56,33 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
if (startIdx >= 0 && startIdx < ((int)valueCount))
{
intervals->push_back(std::make_pair(startIdx, valueCount - 1));
intervals.push_back(std::make_pair(startIdx, valueCount - 1));
}
return intervals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices)
std::vector<std::pair<size_t, size_t>> RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals)
{
CVF_ASSERT(lineStartAndStopIndices);
std::vector<std::pair<size_t, size_t>> lineStartAndStopIndices;
const size_t intervalCount = intervals.size();
if (intervalCount < 1) return;
if (intervalCount < 1) return lineStartAndStopIndices;
size_t index = 0;
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
{
size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1;
lineStartAndStopIndices->push_back(std::make_pair(index, index + intervalSize - 1));
lineStartAndStopIndices.push_back(std::make_pair(index, index + intervalSize - 1));
index += intervalSize;
}
return lineStartAndStopIndices;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -34,9 +34,8 @@ public:
typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
public:
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
CurveIntervals* intervals,
bool removeNegativeValues);
static CurveIntervals calculateIntervalsOfValidValues(const std::vector<double>& values,
bool removeNegativeValues);
template <typename T>
static void getValuesByIntervals(const std::vector<T>& values,
@@ -54,8 +53,7 @@ public:
}
}
static void computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices);
static std::vector<std::pair<size_t, size_t>> computePolyLineStartStopIndices(const CurveIntervals& intervals);
private:
static bool isValidValue(double value, bool removeNegativeValues);

View File

@@ -168,15 +168,11 @@ std::vector<double> RigWellLogCurveData::measuredDepthPlotValues(RiaDefines::Dep
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector< std::pair<size_t, size_t> > RigWellLogCurveData::polylineStartStopIndices() const
std::vector<std::pair<size_t, size_t>> RigWellLogCurveData::polylineStartStopIndices() const
{
std::vector< std::pair<size_t, size_t> > lineStartStopIndices;
RigCurveDataTools::computePolyLineStartStopIndices(m_intervalsOfContinousValidValues, &lineStartStopIndices);
return lineStartStopIndices;
return RigCurveDataTools::computePolyLineStartStopIndices(m_intervalsOfContinousValidValues);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -250,8 +246,7 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateResampledCurveData(d
//--------------------------------------------------------------------------------------------------
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
{
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues, false);
std::vector<std::pair<size_t, size_t>> intervalsOfValidValues = RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, false);
m_intervalsOfContinousValidValues.clear();