mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2125 Curve Calculations : Extract isValidValue
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "RigCurveDataTools.h"
|
#include "RigCurveDataTools.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -35,20 +35,9 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
|
|||||||
size_t valueCount = values.size();
|
size_t valueCount = values.size();
|
||||||
while (vIdx < valueCount)
|
while (vIdx < valueCount)
|
||||||
{
|
{
|
||||||
double value = values[vIdx];
|
bool isValid = RigCurveDataTools::isValidValue(values[vIdx], removeNegativeValues);
|
||||||
|
|
||||||
bool isInvalidValueDetected = false;
|
if (!isValid)
|
||||||
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
|
|
||||||
{
|
|
||||||
isInvalidValueDetected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removeNegativeValues && value <= 0.0)
|
|
||||||
{
|
|
||||||
isInvalidValueDetected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isInvalidValueDetected)
|
|
||||||
{
|
{
|
||||||
if (startIdx >= 0)
|
if (startIdx >= 0)
|
||||||
{
|
{
|
||||||
@@ -92,3 +81,20 @@ void RigCurveDataTools::computePolyLineStartStopIndices(const std::vector< std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RigCurveDataTools::isValidValue(double value, bool removeNegativeValues)
|
||||||
|
{
|
||||||
|
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeNegativeValues && std::signbit(value))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,4 +53,7 @@ public:
|
|||||||
|
|
||||||
static void computePolyLineStartStopIndices(const std::vector< std::pair<size_t, size_t> >& intervals,
|
static void computePolyLineStartStopIndices(const std::vector< std::pair<size_t, size_t> >& intervals,
|
||||||
std::vector< std::pair<size_t, size_t> >* filteredIntervals);
|
std::vector< std::pair<size_t, size_t> >* filteredIntervals);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool isValidValue(double value, bool removeNegativeValues);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user