#2125 Refactor : Introduce typedef for CurveIntervals

This commit is contained in:
Magne Sjaastad 2017-11-16 13:27:17 +01:00
parent 827cee6093
commit cd368d8ef2
2 changed files with 16 additions and 11 deletions

View File

@ -25,7 +25,9 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals, bool removeNegativeValues)
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values,
CurveIntervals* intervals,
bool removeNegativeValues)
{
CVF_ASSERT(intervals);
@ -63,10 +65,10 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCurveDataTools::computePolyLineStartStopIndices(const std::vector< std::pair<size_t, size_t> >& intervals,
std::vector< std::pair<size_t, size_t> >* fltrIntervals)
void RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices)
{
CVF_ASSERT(fltrIntervals);
CVF_ASSERT(lineStartAndStopIndices);
const size_t intervalCount = intervals.size();
if (intervalCount < 1) return;
@ -75,7 +77,7 @@ void RigCurveDataTools::computePolyLineStartStopIndices(const std::vector< std::
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
{
size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1;
fltrIntervals->push_back(std::make_pair(index, index + intervalSize - 1));
lineStartAndStopIndices->push_back(std::make_pair(index, index + intervalSize - 1));
index += intervalSize;
}

View File

@ -31,14 +31,17 @@
class RigCurveDataTools
{
public:
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
std::vector< std::pair<size_t, size_t> >* intervals,
typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
public:
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
CurveIntervals* intervals,
bool removeNegativeValues);
template <typename T>
static void getValuesByIntervals(const std::vector<T>& values,
const std::vector< std::pair<size_t, size_t> >& intervals,
std::vector<T>* filteredValues)
const CurveIntervals& intervals,
std::vector<T>* filteredValues)
{
CVF_ASSERT(filteredValues);
@ -51,8 +54,8 @@ public:
}
}
static void computePolyLineStartStopIndices(const std::vector< std::pair<size_t, size_t> >& intervals,
std::vector< std::pair<size_t, size_t> >* filteredIntervals);
static void computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices);
private:
static bool isValidValue(double value, bool removeNegativeValues);