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

This commit is contained in:
Magne Sjaastad 2021-02-22 11:38:01 +01:00
parent 084835ce66
commit 1caac72715
34 changed files with 37 additions and 67 deletions

View File

@ -46,7 +46,6 @@
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfMath.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRenderStateBlending.h"

View File

@ -264,7 +264,7 @@ bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve( const cvf::Vec
cvf::Vec3d ab = b - a;
// Projected point is clamped to one of the end points of the segment.
double distanceToProjectedPointAlongAB = ap * ab / ( ab * ab );
double clampedDistance = cvf::Math::clamp( distanceToProjectedPointAlongAB, 0.0, 1.0 );
double clampedDistance = std::clamp( distanceToProjectedPointAlongAB, 0.0, 1.0 );
cvf::Vec3d projectionOfGlobalIntersection = a + clampedDistance * ab;
double distance = ( projectionOfGlobalIntersection - globalIntersection ).length();
if ( distance < closestDistance )
@ -461,9 +461,9 @@ cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle( const c
{
*wasInsideTriangle = true;
// Clamp to ensure it is inside the triangle
u = cvf::Math::clamp( u, 0.0, 1.0 );
v = cvf::Math::clamp( v, 0.0, 1.0 );
w = cvf::Math::clamp( w, 0.0, 1.0 );
u = std::clamp( u, 0.0, 1.0 );
v = std::clamp( v, 0.0, 1.0 );
w = std::clamp( w, 0.0, 1.0 );
projectedPoint = triangleVertex1 * u + triangleVertex2 * v + triangleVertex3 * w;
}
return projectedPoint;

View File

@ -106,7 +106,7 @@ public:
void setScalarMapper( const cvf::ScalarMapper* cellScalarMapper );
void setTernaryScalarMapper( const RivTernaryScalarMapper* ternaryScalarMapper );
void setOpacityLevel( float opacity ) { m_opacityLevel = cvf::Math::clamp( opacity, 0.0f, 1.0f ); }
void setOpacityLevel( float opacity ) { m_opacityLevel = std::clamp( opacity, 0.0f, 1.0f ); }
void setUndefinedColor( cvf::Color3f color ) { m_undefinedColor = color; }
void setFaceCulling( caf::FaceCulling faceCulling ) { m_cullBackfaces = faceCulling; }
void setDefaultCellColor( cvf::Color3f color ) { m_defaultCellColor = color; }

View File

@ -54,7 +54,6 @@
#include "cafProgressInfo.h"
#include "cvfDrawableGeo.h"
#include "cvfMath.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRenderStateBlending.h"

View File

@ -40,10 +40,10 @@ cvf::Vec2f RivTernaryScalarMapper::mapToTextureCoord( double soil, double sgas,
double edgeClampDelta = 0.001;
double soilNormalized = ( soil - m_rangeMinSoil ) * m_soilFactor;
soilNormalized = cvf::Math::clamp( soilNormalized, edgeClampDelta, 1.0 - edgeClampDelta );
soilNormalized = std::clamp( soilNormalized, edgeClampDelta, 1.0 - edgeClampDelta );
double sgasNormalized = ( sgas - m_rangeMinSgas ) * m_sgasFactor;
sgasNormalized = cvf::Math::clamp( sgasNormalized, edgeClampDelta, 1.0 - soilNormalized );
sgasNormalized = std::clamp( sgasNormalized, edgeClampDelta, 1.0 - soilNormalized );
sgasNormalized /= 2.0;
if ( isTransparent )

View File

@ -38,7 +38,7 @@ class RivTernaryScalarMapperEffectGenerator : public caf::EffectGenerator
public:
RivTernaryScalarMapperEffectGenerator( const RivTernaryScalarMapper* scalarMapper, caf::PolygonOffset polygonOffset );
void setOpacityLevel( float opacity ) { m_opacityLevel = cvf::Math::clamp( opacity, 0.0f, 1.0f ); }
void setOpacityLevel( float opacity ) { m_opacityLevel = std::clamp( opacity, 0.0f, 1.0f ); }
void setUndefinedColor( cvf::Color3f color ) { m_undefinedColor = color; }
void setFaceCulling( caf::FaceCulling faceCulling ) { m_faceCulling = faceCulling; }
void enableDepthWrite( bool enableWrite ) { m_enableDepthWrite = enableWrite; }

View File

@ -116,7 +116,7 @@ void RivWellPathSourceInfo::normalizedIntersection( size_t triangleIn
double norm = 0.0;
cvf::GeometryTools::projectPointOnLine( segmentStart, segmentEnd, globalIntersectionInDomain, &norm );
norm = cvf::Math::clamp( norm, 0.0, 1.0 );
norm = std::clamp( norm, 0.0, 1.0 );
*firstSegmentIndex = segIndex;
*normalizedSegmentIntersection = norm;

View File

@ -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();
}

View File

@ -42,7 +42,6 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
#include <cmath> // Needed for HUGE_VAL on Linux

View File

@ -33,7 +33,6 @@
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfAssert.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT( RimGeoMechPropertyFilter, "GeoMechPropertyFilter" );

View File

@ -24,7 +24,6 @@
#include "RimWellPath.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT( Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection" );

View File

@ -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 ) );
}

View File

@ -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 )

View File

@ -30,8 +30,6 @@
#include "qwt_plot.h"
#include "cvfMath.h"
#include <cmath>
//==================================================================================================

View File

@ -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 )

View File

@ -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() ) );
}
}

View File

@ -50,8 +50,6 @@
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
#include "cvfMath.h"
//--------------------------------------------------------------------------------------------------
/// Internal functions
//--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,7 @@
#include "RimStackablePlotCurve.h"
#include "RiaColorTables.h"
#include "RiaColorTools.h"
//--------------------------------------------------------------------------------------------------
///

View File

@ -17,8 +17,6 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellMeasurementFilter.h"
#include "cvfMath.h"
#include "RimWellMeasurement.h"
#include "RimWellMeasurementCollection.h"
#include "RimWellPath.h"

View File

@ -18,8 +18,6 @@
#include "RigPerforationTransmissibilityEquations.h"
#include "cvfMath.h"
#include <cmath>
const double RigPerforationTransmissibilityEquations::EPSILON = 1.0e-9;

View File

@ -25,8 +25,6 @@
#include "cvfAssert.h"
#include "cvfMath.h"
#include <Eigen/Core>
#include <Eigen/LU>

View File

@ -19,7 +19,6 @@
#pragma once
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"

View File

@ -19,7 +19,6 @@
#pragma once
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"

View File

@ -26,8 +26,6 @@
#include "clipper/clipper.hpp"
#include "cvfMath.h"
#include <algorithm>
#include <array>
#include <vector>
@ -117,8 +115,8 @@ bool RigCellGeometryTools::estimateHexOverlapWithBoundingBox( const std::array<c
for ( size_t i = 0; i < 4; ++i )
{
const cvf::Vec3d& hexCorner = hexCorners[i];
double x = cvf::Math::clamp( hexCorner.x(), boundingMin.x(), boundingMax.x() );
double y = cvf::Math::clamp( hexCorner.y(), boundingMin.y(), boundingMax.y() );
double x = std::clamp( hexCorner.x(), boundingMin.x(), boundingMax.x() );
double y = std::clamp( hexCorner.y(), boundingMin.y(), boundingMax.y() );
cvf::Vec3d corner;
cvf::Vec3d maxZCorner( x, y, boundingMax.z() );
cvf::Vec3d minZCorner( x, y, boundingMin.z() );
@ -129,7 +127,7 @@ bool RigCellGeometryTools::estimateHexOverlapWithBoundingBox( const std::array<c
}
else
{
double z = cvf::Math::clamp( hexCorner.z(), boundingMin.z(), boundingMax.z() );
double z = std::clamp( hexCorner.z(), boundingMin.z(), boundingMax.z() );
cvf::Vec3d clampedCorner( x, y, z );
overlapBoundingBox->add( clampedCorner );
( *overlapElement )[i] = clampedCorner;
@ -138,8 +136,8 @@ bool RigCellGeometryTools::estimateHexOverlapWithBoundingBox( const std::array<c
for ( size_t i = 4; i < 8; ++i )
{
const cvf::Vec3d& hexCorner = hexCorners[i];
double x = cvf::Math::clamp( hexCorner.x(), boundingMin.x(), boundingMax.x() );
double y = cvf::Math::clamp( hexCorner.y(), boundingMin.y(), boundingMax.y() );
double x = std::clamp( hexCorner.x(), boundingMin.x(), boundingMax.x() );
double y = std::clamp( hexCorner.y(), boundingMin.y(), boundingMax.y() );
cvf::Vec3d corner;
cvf::Vec3d maxZCorner( x, y, boundingMax.z() );
cvf::Vec3d minZCorner( x, y, boundingMin.z() );
@ -150,7 +148,7 @@ bool RigCellGeometryTools::estimateHexOverlapWithBoundingBox( const std::array<c
}
else
{
double z = cvf::Math::clamp( hexCorner.z(), boundingMin.z(), boundingMax.z() );
double z = std::clamp( hexCorner.z(), boundingMin.z(), boundingMax.z() );
cvf::Vec3d clampedCorner( x, y, z );
overlapBoundingBox->add( clampedCorner );
( *overlapElement )[i] = clampedCorner;

View File

@ -28,7 +28,6 @@
#include "cafAppEnum.h"
#include "cafTensor3.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"

View File

@ -20,7 +20,6 @@
#include "RigWellResultPoint.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"

View File

@ -28,8 +28,6 @@
#include "RivWellFracturePartMgr.h"
#include "cvfMath.h"
#include <cmath>
//--------------------------------------------------------------------------------------------------

View File

@ -18,7 +18,6 @@
#pragma once
#include "cvfMath.h"
#include "cvfVector3.h"
class RigTransmissibilityEquations

View File

@ -22,7 +22,6 @@
#include "RigHexIntersectionTools.h"
#include "RigWellLogExtractionTools.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"

View File

@ -20,7 +20,6 @@
#include "cafSignal.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"

View File

@ -27,8 +27,6 @@
#include "RigFlowDiagSolverInterface.h"
#include "cvfAssert.h"
//#include "cvfTrace.h"
#include "cvfMath.h"
#include "qwt_legend.h"
#include "qwt_picker_machine.h"

View File

@ -18,8 +18,6 @@
#include "RiuQwtPlotWheelZoomer.h"
#include "cvfMath.h"
#include "qwt_plot.h"
#include "qwt_scale_div.h"
#include <QEvent>
@ -60,8 +58,8 @@ void RiuQwtPlotWheelZoomer::zoomOnAxis( QwtPlot* plot, QwtPlot::Axis axis, doubl
double maxValue =
std::max( RIU_LOGARITHMIC_MINIMUM, 10.0 * std::max( axisRange.minValue(), axisRange.maxValue() ) );
newMin = cvf::Math::clamp( newMin, minValue, maxValue );
newMax = cvf::Math::clamp( newMax, minValue, maxValue );
newMin = std::clamp( newMin, minValue, maxValue );
newMax = std::clamp( newMax, minValue, maxValue );
}
plot->setAxisScale( axis, newMin, newMax );

View File

@ -100,7 +100,7 @@ void RiuScalarMapperLegendFrame::layoutInfo( LayoutInfo* layout ) const
double t = 0.0;
if ( m_scalarMapper.notNull() )
{
t = cvf::Math::clamp( m_scalarMapper->normalizedValue( m_tickValues[i] ), 0.0, 1.1 );
t = std::clamp( m_scalarMapper->normalizedValue( m_tickValues[i] ), 0.0, 1.1 );
}
if ( i == 0 )

View File

@ -16,7 +16,6 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "cvfMath.h"
#include "cvfObject.h"
#include "cvfVector3.h"