mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2125 Refactor : Return by value instead of incoming parameter
This commit is contained in:
parent
cd368d8ef2
commit
5cbaf3c1eb
@ -25,11 +25,10 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values,
|
RigCurveDataTools::CurveIntervals RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values,
|
||||||
CurveIntervals* intervals,
|
bool removeNegativeValues)
|
||||||
bool removeNegativeValues)
|
|
||||||
{
|
{
|
||||||
CVF_ASSERT(intervals);
|
CurveIntervals intervals;
|
||||||
|
|
||||||
int startIdx = -1;
|
int startIdx = -1;
|
||||||
size_t vIdx = 0;
|
size_t vIdx = 0;
|
||||||
@ -43,7 +42,7 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
|
|||||||
{
|
{
|
||||||
if (startIdx >= 0)
|
if (startIdx >= 0)
|
||||||
{
|
{
|
||||||
intervals->push_back(std::make_pair(startIdx, vIdx - 1));
|
intervals.push_back(std::make_pair(startIdx, vIdx - 1));
|
||||||
startIdx = -1;
|
startIdx = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,30 +56,33 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
|
|||||||
|
|
||||||
if (startIdx >= 0 && startIdx < ((int)valueCount))
|
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>> RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals)
|
||||||
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices)
|
|
||||||
{
|
{
|
||||||
CVF_ASSERT(lineStartAndStopIndices);
|
std::vector<std::pair<size_t, size_t>> lineStartAndStopIndices;
|
||||||
|
|
||||||
const size_t intervalCount = intervals.size();
|
const size_t intervalCount = intervals.size();
|
||||||
if (intervalCount < 1) return;
|
if (intervalCount < 1) return lineStartAndStopIndices;
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
|
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
|
||||||
{
|
{
|
||||||
size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1;
|
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;
|
index += intervalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return lineStartAndStopIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -34,9 +34,8 @@ public:
|
|||||||
typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
|
typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
|
static CurveIntervals calculateIntervalsOfValidValues(const std::vector<double>& values,
|
||||||
CurveIntervals* intervals,
|
bool removeNegativeValues);
|
||||||
bool removeNegativeValues);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void getValuesByIntervals(const std::vector<T>& values,
|
static void getValuesByIntervals(const std::vector<T>& values,
|
||||||
@ -54,8 +53,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void computePolyLineStartStopIndices(const CurveIntervals& intervals,
|
static std::vector<std::pair<size_t, size_t>> computePolyLineStartStopIndices(const CurveIntervals& intervals);
|
||||||
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool isValidValue(double value, bool removeNegativeValues);
|
static bool isValidValue(double value, bool removeNegativeValues);
|
||||||
|
@ -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;
|
return RigCurveDataTools::computePolyLineStartStopIndices(m_intervalsOfContinousValidValues);
|
||||||
RigCurveDataTools::computePolyLineStartStopIndices(m_intervalsOfContinousValidValues, &lineStartStopIndices);
|
|
||||||
|
|
||||||
return lineStartStopIndices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -250,8 +246,7 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateResampledCurveData(d
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
|
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
|
||||||
{
|
{
|
||||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
std::vector<std::pair<size_t, size_t>> intervalsOfValidValues = RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, false);
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues, false);
|
|
||||||
|
|
||||||
m_intervalsOfContinousValidValues.clear();
|
m_intervalsOfContinousValidValues.clear();
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffInvalidValAtEndsOfVector)
|
|||||||
values.push_back(3.0);
|
values.push_back(3.0);
|
||||||
values.push_back(HUGE_VAL);
|
values.push_back(HUGE_VAL);
|
||||||
|
|
||||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
auto valuesIntervals = RigCurveDataTools::calculateIntervalsOfValidValues(values, false);
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
|
||||||
|
|
||||||
EXPECT_EQ(1, static_cast<int>(valuesIntervals.size()));
|
EXPECT_EQ(1, static_cast<int>(valuesIntervals.size()));
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||||
@ -42,8 +41,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVector
|
|||||||
values.push_back(3.0);
|
values.push_back(3.0);
|
||||||
values.push_back(HUGE_VAL);
|
values.push_back(HUGE_VAL);
|
||||||
|
|
||||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
auto valuesIntervals = RigCurveDataTools::calculateIntervalsOfValidValues(values, false);
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
|
||||||
|
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals.size()));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals.size()));
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||||
|
@ -62,13 +62,12 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vect
|
|||||||
std::vector<double> filteredXValues;
|
std::vector<double> filteredXValues;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
auto intervalsOfValidValues = RigCurveDataTools::calculateIntervalsOfValidValues(yValues, removeNegativeValues);
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(yValues, &intervalsOfValidValues, removeNegativeValues);
|
|
||||||
|
|
||||||
RigCurveDataTools::getValuesByIntervals(yValues, intervalsOfValidValues, &filteredYValues);
|
RigCurveDataTools::getValuesByIntervals(yValues, intervalsOfValidValues, &filteredYValues);
|
||||||
RigCurveDataTools::getValuesByIntervals(xValues, intervalsOfValidValues, &filteredXValues);
|
RigCurveDataTools::getValuesByIntervals(xValues, intervalsOfValidValues, &filteredXValues);
|
||||||
|
|
||||||
RigCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues, &filteredIntervals);
|
filteredIntervals = RigCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
points.reserve(static_cast<int>(filteredXValues.size()));
|
points.reserve(static_cast<int>(filteredXValues.size()));
|
||||||
|
Loading…
Reference in New Issue
Block a user