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

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