#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); 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, void RigCurveDataTools::computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector< std::pair<size_t, size_t> >* fltrIntervals) std::vector<std::pair<size_t, size_t>>* lineStartAndStopIndices)
{ {
CVF_ASSERT(fltrIntervals); CVF_ASSERT(lineStartAndStopIndices);
const size_t intervalCount = intervals.size(); const size_t intervalCount = intervals.size();
if (intervalCount < 1) return; if (intervalCount < 1) return;
@ -75,7 +77,7 @@ void RigCurveDataTools::computePolyLineStartStopIndices(const std::vector< std::
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;
fltrIntervals->push_back(std::make_pair(index, index + intervalSize - 1)); lineStartAndStopIndices->push_back(std::make_pair(index, index + intervalSize - 1));
index += intervalSize; index += intervalSize;
} }

View File

@ -31,14 +31,17 @@
class RigCurveDataTools class RigCurveDataTools
{ {
public: public:
static void calculateIntervalsOfValidValues(const std::vector<double>& values, typedef std::vector<std::pair<size_t, size_t>> CurveIntervals;
std::vector< std::pair<size_t, size_t> >* intervals,
public:
static void 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,
const std::vector< std::pair<size_t, size_t> >& intervals, const CurveIntervals& intervals,
std::vector<T>* filteredValues) std::vector<T>* filteredValues)
{ {
CVF_ASSERT(filteredValues); CVF_ASSERT(filteredValues);
@ -51,8 +54,8 @@ public:
} }
} }
static void computePolyLineStartStopIndices(const std::vector< std::pair<size_t, size_t> >& intervals, static void computePolyLineStartStopIndices(const CurveIntervals& intervals,
std::vector< std::pair<size_t, size_t> >* filteredIntervals); 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);