Janitor : Use std::clamp and remove obsolete includes of cvfMath

This commit is contained in:
Magne Sjaastad committed 2021-02-22 13:37:05 +01:00
1 parent 084835ce66
commit 1caac72715
34 files changed
+37 -67

No files matched your search

@@ -144,14 +144,14 @@ void RimCellRangeFilter::computeAndSetValidValues()
const cvf::StructGridInterface* grid = selectedGrid();
if ( grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0 )
{
cellCountI = cvf::Math::clamp( cellCountI.v(), 1, static_cast<int>( grid->cellCountI() ) );
startIndexI = cvf::Math::clamp( startIndexI.v(), 1, static_cast<int>( grid->cellCountI() ) );
cellCountI = std::clamp( cellCountI.v(), 1, static_cast<int>( grid->cellCountI() ) );
startIndexI = std::clamp( startIndexI.v(), 1, static_cast<int>( grid->cellCountI() ) );
cellCountJ = cvf::Math::clamp( cellCountJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
startIndexJ = cvf::Math::clamp( startIndexJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
cellCountJ = std::clamp( cellCountJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
startIndexJ = std::clamp( startIndexJ.v(), 1, static_cast<int>( grid->cellCountJ() ) );
cellCountK = cvf::Math::clamp( cellCountK.v(), 1, static_cast<int>( grid->cellCountK() ) );
startIndexK = cvf::Math::clamp( startIndexK.v(), 1, static_cast<int>( grid->cellCountK() ) );
cellCountK = std::clamp( cellCountK.v(), 1, static_cast<int>( grid->cellCountK() ) );
startIndexK = std::clamp( startIndexK.v(), 1, static_cast<int>( grid->cellCountK() ) );
}
this->updateIconState();
}
@@ -42,7 +42,6 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
#include <cmath> // Needed for HUGE_VAL on Linux
@@ -33,7 +33,6 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilter, "GeoMechPropertyFilter" );
@@ -24,7 +24,6 @@
#include "RimWellPath.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT( Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection" );
@@ -82,8 +82,8 @@ void RimMultipleValveLocations::perforationIntervalUpdated()
{
double existingRangeStart = m_rangeStart();
double existingRangeEnd = m_rangeEnd();
m_rangeStart = cvf::Math::clamp( m_rangeStart(), perforationStartMD(), perforationEndMD() );
m_rangeEnd = cvf::Math::clamp( m_rangeEnd(), perforationStartMD(), perforationEndMD() );
m_rangeStart = std::clamp( m_rangeStart(), perforationStartMD(), perforationEndMD() );
m_rangeEnd = std::clamp( m_rangeEnd(), perforationStartMD(), perforationEndMD() );
if ( existingRangeStart != m_rangeStart() || existingRangeEnd != m_rangeEnd() )
{
computeRangesAndLocations();
@@ -318,8 +318,8 @@ void RimMultipleValveLocations::fieldChangedByUi( const caf::PdmFieldHandle* cha
changedField == &m_rangeValveSpacing )
{
recomputeLocations = true;
m_rangeStart = cvf::Math::clamp( m_rangeStart(), perforationStartMD(), perforationEndMD() );
m_rangeEnd = cvf::Math::clamp( m_rangeEnd(), perforationStartMD(), perforationEndMD() );
m_rangeStart = std::clamp( m_rangeStart(), perforationStartMD(), perforationEndMD() );
m_rangeEnd = std::clamp( m_rangeEnd(), perforationStartMD(), perforationEndMD() );
}
if ( changedField == &m_rangeValveSpacing )
@@ -331,13 +331,13 @@ void RimMultipleValveLocations::fieldChangedByUi( const caf::PdmFieldHandle* cha
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet( minimumDistanceMeter );
m_rangeValveSpacing = cvf::Math::clamp( m_rangeValveSpacing(),
m_rangeValveSpacing = std::clamp( m_rangeValveSpacing(),
minimumDistanceFeet,
std::max( m_rangeValveSpacing(), minimumDistanceFeet ) );
}
else
{
m_rangeValveSpacing = cvf::Math::clamp( m_rangeValveSpacing(),
m_rangeValveSpacing = std::clamp( m_rangeValveSpacing(),
minimumDistanceMeter,
std::max( m_rangeValveSpacing(), minimumDistanceMeter ) );
}
@@ -84,7 +84,7 @@ void RimWellPathValve::perforationIntervalUpdated()
this->firstAncestorOrThisOfType( perfInterval );
double startMD = perfInterval->startMD();
double endMD = perfInterval->endMD();
m_measuredDepth = cvf::Math::clamp( m_measuredDepth(), std::min( startMD, endMD ), std::max( startMD, endMD ) );
m_measuredDepth = std::clamp( m_measuredDepth(), std::min( startMD, endMD ), std::max( startMD, endMD ) );
}
else if ( componentType() == RiaDefines::WellPathComponentType::ICD ||
componentType() == RiaDefines::WellPathComponentType::AICD )
@@ -30,8 +30,6 @@
#include "qwt_plot.h"
#include "cvfMath.h"
#include <cmath>
//==================================================================================================
@@ -781,7 +781,7 @@ void RimEclipseView::updateVisibleGeometries()
// Set the transparency on all the Wellcell parts before setting the result color
float opacity =
static_cast<float>( 1 - cvf::Math::clamp( this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0 ) );
static_cast<float>( 1 - std::clamp( this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0 ) );
m_reservoirGridPartManager->updateCellColor( PROPERTY_FILTERED_WELL_CELLS,
m_currentTimeStep,
cvf::Color4f( cvf::Color3f( cvf::Color3::WHITE ), opacity ) );
@@ -1138,7 +1138,7 @@ void RimEclipseView::updateStaticCellColors( RivCellSetEnum geometryType )
cvf::Color4f RimEclipseView::colorFromCellCategory( RivCellSetEnum geometryType ) const
{
float opacity =
static_cast<float>( 1 - cvf::Math::clamp( this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0 ) );
static_cast<float>( 1 - std::clamp( this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0 ) );
cvf::Color4f color( cvf::Color3::ORANGE );
switch ( geometryType )
@@ -273,7 +273,7 @@ void RimRegularLegendConfig::fieldChangedByUi( const caf::PdmFieldHandle* change
if ( changedField == &m_numLevels )
{
int upperLimit = std::numeric_limits<int>::max();
m_numLevels = cvf::Math::clamp( m_numLevels.v(), 1, upperLimit );
m_numLevels = std::clamp( m_numLevels.v(), 1, upperLimit );
}
else if ( changedField == &m_rangeMode || changedField == &m_mappingMode )
{
@@ -585,7 +585,7 @@ void RimRegularLegendConfig::updateLegend()
{
numDecimalDigits -= static_cast<int>( decadesInRange );
}
numDecimalDigits = cvf::Math::clamp( numDecimalDigits, 0, 20 );
numDecimalDigits = std::clamp( numDecimalDigits, 0, 20 );
m_significantDigitsInData = numDecimalDigits;
m_scalarMapperLegend->setTickPrecision( numDecimalDigits );
@@ -857,7 +857,7 @@ void RimRegularLegendConfig::configureCategoryMapper()
{
if ( legendItem->categoryValue() == value )
{
int zeroBasedIndex = cvf::Math::clamp( value - 1, 0, int( colorArray.size() - 1 ) );
int zeroBasedIndex = std::clamp( value - 1, 0, int( colorArray.size() - 1 ) );
colorArray.set( zeroBasedIndex, cvf::Color3ub( legendItem->color() ) );
}
}
@@ -50,8 +50,6 @@
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
#include "cvfMath.h"
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------
@@ -18,6 +18,7 @@
#include "RimStackablePlotCurve.h"
#include "RiaColorTables.h"
#include "RiaColorTools.h"
//--------------------------------------------------------------------------------------------------
///
@@ -17,8 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellMeasurementFilter.h"
#include "cvfMath.h"
#include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h"
#include "RimWellPath.h"