Skip to content

Commit e7685e9

Browse files
authored
Merge pull request #1323 from danieldresser-ie/imathPrep
Remove Use of Imath Functionality that is Going To Be Deprecated
2 parents cdf6005 + 28207d9 commit e7685e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+234
-329
lines changed

contrib/IECoreUSD/src/IECoreUSD/SceneCacheData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void SceneCacheData::loadSceneIntoCache( ConstSceneInterfacePtr scene )
294294
spec.fields.push_back( FieldValuePair( SdfFieldKeys->TimeCodesPerSecond, m_fps ) );
295295

296296
// figure out start and end frame based on timeSamples in header
297-
float minTime = Imath::limits<float>::max();
297+
float minTime = std::numeric_limits<float>::max();
298298
float maxTime = 0;
299299
bool validTimeSampleRange = false;
300300
if ( auto sampleTimesDir = m_sceneio->subdirectory( g_sampleTimes, IndexedIO::MissingBehaviour::NullIfMissing ) )

include/IECore/BoundedKDTree.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ template<class BoundIterator>
135135
unsigned char BoundedKDTree<BoundIterator>::majorAxis( PermutationConstIterator permFirst, PermutationConstIterator permLast )
136136
{
137137
BaseType min, max;
138-
vecSetAll( min, Imath::limits<typename BaseType::BaseType>::max() );
139-
vecSetAll( max, Imath::limits<typename BaseType::BaseType>::min() );
138+
vecSetAll( min, std::numeric_limits<typename BaseType::BaseType>::max() );
139+
vecSetAll( max, std::numeric_limits<typename BaseType::BaseType>::lowest() );
140140

141141
for( PermutationConstIterator it=permFirst; it!=permLast; it++ )
142142
{

include/IECore/ByteOrder.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#ifndef IE_CORE_BYTEORDER_H
3636
#define IE_CORE_BYTEORDER_H
3737

38-
#include "OpenEXR/ImfInt64.h"
39-
4038
#include "boost/static_assert.hpp"
4139

4240
#include <stdint.h>
@@ -138,7 +136,7 @@ inline float reverseBytes<float>( const float &x )
138136
}
139137

140138
template<>
141-
inline Imf::Int64 reverseBytes<Imf::Int64>( const Imf::Int64 &x )
139+
inline uint64_t reverseBytes<uint64_t>( const uint64_t &x )
142140
{
143141
return ((x & 255) << 56) |
144142
(((x >> 8) & 255) << 48) |
@@ -153,13 +151,13 @@ inline Imf::Int64 reverseBytes<Imf::Int64>( const Imf::Int64 &x )
153151
template<>
154152
inline double reverseBytes<double>( const double &x )
155153
{
156-
BOOST_STATIC_ASSERT( sizeof(Imf::Int64) == sizeof(double) );
154+
BOOST_STATIC_ASSERT( sizeof(uint64_t) == sizeof(double) );
157155
union {
158-
Imf::Int64 i;
156+
uint64_t i;
159157
double d;
160158
} xx;
161159
xx.d = x;
162-
xx.i = reverseBytes<Imf::Int64>(xx.i);
160+
xx.i = reverseBytes<uint64_t>(xx.i);
163161
return xx.d;
164162
}
165163

include/IECore/EuclideanToSphericalTransform.inl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include "IECore/Math.h"
3939
#include "IECore/VectorTraits.h"
4040

41-
#include "OpenEXR/ImathMath.h"
42-
4341
#include <cassert>
4442

4543
namespace IECore
@@ -57,14 +55,14 @@ T EuclideanToSphericalTransform<F, T>::transform( const F &f )
5755
U len = f.length();
5856
F v( f );
5957
v.normalize();
60-
U phi = Imath::Math< U >::atan2( v.y, v.x );
58+
U phi = std::atan2( v.y, v.x );
6159
if ( phi < 0 )
6260
{
6361
phi += static_cast< U >( 2*M_PI );
6462
}
6563
T res;
6664
res[0] = phi;
67-
res[1] = Imath::Math< U >::acos( v.z );
65+
res[1] = std::acos( v.z );
6866
if ( TypeTraits::IsVec3<T>::value )
6967
{
7068
res[2] = len;

include/IECore/HenyeyGreenstein.inl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
#include "IECore/Math.h"
3939

40-
#include "OpenEXR/ImathMath.h"
41-
4240
namespace IECore
4341
{
4442

@@ -51,7 +49,7 @@ inline typename Vec::BaseType henyeyGreenstein( typename Vec::BaseType g, const
5149
template<typename T>
5250
inline T henyeyGreenstein( T g, T theta )
5351
{
54-
return henyeyGreensteinCT( g, Imath::Math<T>::cos( theta ) );
52+
return henyeyGreensteinCT( g, std::cos( theta ) );
5553
}
5654

5755
template<typename T>
@@ -60,7 +58,7 @@ inline T henyeyGreensteinCT( T g, T cosTheta )
6058
T g2 = g * g;
6159
T top = T( 1 ) - g2;
6260
T bottom = T( 1 ) + g2 - ( T( 2 ) * g * cosTheta );
63-
bottom = T( 4 * M_PI ) * Imath::Math<T>::pow( bottom, T( 1.5 ) );
61+
bottom = T( 4 * M_PI ) * std::pow( bottom, T( 1.5 ) );
6462
return top / bottom;
6563
}
6664

include/IECore/IndexedIO.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
//
3333
//////////////////////////////////////////////////////////////////////////
3434

35-
#include "OpenEXR/ImfInt64.h"
3635
#include "OpenEXR/ImfXdr.h"
3736

3837
#include "boost/static_assert.hpp"

include/IECore/InverseDistanceWeightedInterpolation.inl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
#include "IECore/VectorOps.h"
3636

37-
#include "OpenEXR/ImathLimits.h"
38-
3937
#include <algorithm>
4038

4139
namespace IECore
@@ -83,7 +81,7 @@ typename InverseDistanceWeightedInterpolation<PointIterator, ValueIterator>::Val
8381
if( neighbourCount )
8482
{
8583

86-
PointBaseType distanceToFurthest = std::max<PointBaseType>( Imath::Math<PointBaseType>::sqrt( neighbours.rbegin()->distSquared ), 1.e-6 );
84+
PointBaseType distanceToFurthest = std::max<PointBaseType>( std::sqrt( neighbours.rbegin()->distSquared ), 1.e-6 );
8785

8886
PointBaseType totalNeighbourWeight = 0.0;
8987

@@ -93,12 +91,12 @@ typename InverseDistanceWeightedInterpolation<PointIterator, ValueIterator>::Val
9391

9492
const Value &neighbourValue = *(m_firstValue + (neighbourPointIt - m_firstPoint));
9593

96-
PointBaseType distanceToNeighbour = std::max<PointBaseType>( Imath::Math<PointBaseType>::sqrt( it->distSquared ), 1.e-6 );
94+
PointBaseType distanceToNeighbour = std::max<PointBaseType>( std::sqrt( it->distSquared ), 1.e-6 );
9795
assert( distanceToNeighbour <= distanceToFurthest );
9896

9997
// Franke & Nielson's (1980) improvement on Shephard's original weight function
10098
PointBaseType neighbourWeight = ( distanceToFurthest - distanceToNeighbour ) / ( distanceToFurthest * distanceToNeighbour );
101-
assert( neighbourWeight >= -Imath::limits<PointBaseType>::epsilon() );
99+
assert( neighbourWeight >= -std::numeric_limits<PointBaseType>::epsilon() );
102100

103101
neighbourWeight = std::max<PointBaseType>(neighbourWeight * neighbourWeight, 1.e-6 );
104102

include/IECore/KDTree.inl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include "IECore/BoxOps.h"
3636
#include "IECore/VectorOps.h"
3737

38-
#include "OpenEXR/ImathLimits.h"
39-
4038
#include <algorithm>
4139

4240
namespace IECore
@@ -144,8 +142,8 @@ unsigned char KDTree<PointIterator>::majorAxis( PermutationConstIterator permFir
144142
{
145143
Point min, max;
146144
for( unsigned char i=0; i<VectorTraits<Point>::dimensions(); i++ ) {
147-
min[i] = Imath::limits<BaseType>::max();
148-
max[i] = Imath::limits<BaseType>::min();
145+
min[i] = std::numeric_limits<BaseType>::max();
146+
max[i] = std::numeric_limits<BaseType>::lowest();
149147
}
150148
for( PermutationConstIterator it=permFirst; it!=permLast; it++ )
151149
{
@@ -206,7 +204,7 @@ void KDTree<PointIterator>::build( NodeIndex nodeIndex, PermutationIterator perm
206204
template<class PointIterator>
207205
PointIterator KDTree<PointIterator>::nearestNeighbour( const Point &p ) const
208206
{
209-
BaseType maxDistSquared = Imath::limits<BaseType>::max();
207+
BaseType maxDistSquared = std::numeric_limits<BaseType>::max();
210208
PointIterator closestPoint = m_lastPoint;
211209
nearestNeighbourWalk( rootIndex(), p, closestPoint, maxDistSquared );
212210
return closestPoint;
@@ -244,7 +242,7 @@ unsigned int KDTree<PointIterator>::nearestNNeighbours( const Point &p, unsigned
244242

245243
if( numNeighbours )
246244
{
247-
BaseType maxDistSquared = Imath::limits<BaseType>::max();
245+
BaseType maxDistSquared = std::numeric_limits<BaseType>::max();
248246
nearestNNeighboursWalk( rootIndex(), p, numNeighbours, nearNeighbours, maxDistSquared );
249247
std::sort_heap( nearNeighbours.begin(), nearNeighbours.end() );
250248
}

include/IECore/LevenbergMarquardt.inl

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
#include "IECore/Exception.h"
3939

40-
#include "OpenEXR/ImathMath.h"
41-
4240
#include <cassert>
4341

4442
namespace IECore
@@ -70,13 +68,13 @@ struct DefaultLevenbergMarquardtTraits
7068
};
7169

7270
template<typename T>
73-
T DefaultLevenbergMarquardtTraits<T>::g_machinePrecision( Imath::limits<T>::epsilon() );
71+
T DefaultLevenbergMarquardtTraits<T>::g_machinePrecision( std::numeric_limits<T>::epsilon() );
7472

7573
template<typename T>
76-
T DefaultLevenbergMarquardtTraits<T>::g_sqrtMin( Imath::Math<T>::sqrt( Imath::limits<T>::smallest() ) );
74+
T DefaultLevenbergMarquardtTraits<T>::g_sqrtMin( std::sqrt( std::numeric_limits<T>::min() ) );
7775

7876
template<typename T>
79-
T DefaultLevenbergMarquardtTraits<T>::g_sqrtMax( Imath::Math<T>::sqrt( Imath::limits<T>::max() ) );
77+
T DefaultLevenbergMarquardtTraits<T>::g_sqrtMax( std::sqrt( std::numeric_limits<T>::max() ) );
8078

8179
template<typename T, typename ErrorFn, template<typename> class Traits>
8280
LevenbergMarquardt<T, ErrorFn, Traits>::LevenbergMarquardt()
@@ -168,7 +166,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
168166

169167
T delta = 0;
170168
T xnorm = 0;
171-
T eps = Imath::Math<T>::sqrt( std::max<T>( m_epsilon, Traits<T>::machinePrecision() ) );
169+
T eps = std::sqrt( std::max<T>( m_epsilon, Traits<T>::machinePrecision() ) );
172170

173171
if (( m_n <= 0 ) || ( m_m < m_n ) || ( m_ftol < 0. )
174172
|| ( m_xtol < 0. ) || ( m_gtol < 0. ) || ( m_stepBound <= 0. ) )
@@ -186,7 +184,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
186184
for ( unsigned j = 0; j < m_n; j++ )
187185
{
188186
T temp = x[j];
189-
step = eps * Imath::Math<T>::fabs( temp );
187+
step = eps * std::fabs( temp );
190188
if ( step == 0. )
191189
{
192190
step = eps;
@@ -269,7 +267,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
269267
{
270268
sum += m_fjac[j * m_m + i] * m_qtf[i] / fnorm;
271269
}
272-
gnorm = std::max<T>( gnorm, Imath::Math<T>::fabs( sum / wa2[m_ipvt[j]] ) );
270+
gnorm = std::max<T>( gnorm, std::fabs( sum / wa2[m_ipvt[j]] ) );
273271
}
274272
}
275273
}
@@ -333,7 +331,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
333331
}
334332
assert( m_wa3.size() == m_n );
335333
temp1 = euclideanNorm( m_wa3.begin(), m_wa3.end() ) / fnorm;
336-
temp2 = Imath::Math<T>::sqrt( par ) * pnorm / fnorm;
334+
temp2 = std::sqrt( par ) * pnorm / fnorm;
337335
prered = sqr( temp1 ) + 2 * sqr( temp2 );
338336
dirder = -( sqr( temp1 ) + sqr( temp2 ) );
339337

@@ -384,7 +382,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
384382
}
385383

386384
/// tests for convergence
387-
if ( Imath::Math<T>::fabs( actred ) <= m_ftol && prered <= m_ftol && 0.5 * ratio <= 1 )
385+
if ( std::fabs( actred ) <= m_ftol && prered <= m_ftol && 0.5 * ratio <= 1 )
388386
{
389387
return Success;
390388
}
@@ -399,7 +397,7 @@ typename LevenbergMarquardt<T, ErrorFn, Traits>::Status LevenbergMarquardt<T, Er
399397
{
400398
return CallLimit;
401399
}
402-
if ( Imath::Math<T>::fabs( actred ) <= Traits<T>::machinePrecision() &&
400+
if ( std::fabs( actred ) <= Traits<T>::machinePrecision() &&
403401
prered <= Traits<T>::machinePrecision() && 0.5 * ratio <= 1 )
404402
{
405403
return FailedFTol;
@@ -503,7 +501,7 @@ void LevenbergMarquardt<T, ErrorFn, Traits>::qrFactorize()
503501
{
504502
temp = m_fjac[m_m * k + j] / rdiag[k];
505503
temp = std::max<T>( 0., 1 - temp * temp );
506-
rdiag[k] *= Imath::Math<T>::sqrt( temp );
504+
rdiag[k] *= std::sqrt( temp );
507505
temp = rdiag[k] / m_wa3[k];
508506
if ( T( 0.05 ) * sqr( temp ) <= Traits<T>::machinePrecision() )
509507
{
@@ -607,7 +605,7 @@ T LevenbergMarquardt<T, ErrorFn, Traits>::computeLMParameter( std::vector<T> &x,
607605
paru = gnorm / delta;
608606
if ( paru == 0. )
609607
{
610-
paru = Imath::limits<T>::smallest() / std::min<T>( delta, 0.1 );
608+
paru = std::numeric_limits<T>::min() / std::min<T>( delta, 0.1 );
611609
}
612610

613611
par = std::max<T>( par, parl );
@@ -623,9 +621,9 @@ T LevenbergMarquardt<T, ErrorFn, Traits>::computeLMParameter( std::vector<T> &x,
623621
/// evaluate the function at the current value of par.
624622
if ( par == 0. )
625623
{
626-
par = std::max<T>( Imath::limits<T>::smallest(), 0.001 * paru );
624+
par = std::max<T>( std::numeric_limits<T>::min(), 0.001 * paru );
627625
}
628-
temp = Imath::Math<T>::sqrt( par );
626+
temp = std::sqrt( par );
629627
for ( j = 0; j < m_n; j++ )
630628
{
631629
m_wa3[j] = temp * m_diag[j];
@@ -641,7 +639,7 @@ T LevenbergMarquardt<T, ErrorFn, Traits>::computeLMParameter( std::vector<T> &x,
641639

642640
/// if the function is small enough, accept the current value of par. Also test for the exceptional cases where parl
643641
/// is zero or the number of iterations has reached 10.
644-
if ( Imath::Math<T>::fabs( fp ) <= 0.1 * delta || ( parl == 0. && fp <= fp_old && fp_old < 0. ) || iter == 10 )
642+
if ( std::fabs( fp ) <= 0.1 * delta || ( parl == 0. && fp <= fp_old && fp_old < 0. ) || iter == 10 )
645643
{
646644
break;
647645
}
@@ -721,16 +719,16 @@ void LevenbergMarquardt<T, ErrorFn, Traits>::qrSolve( std::vector<T> &r, std::ve
721719
unsigned kk = k + m_m * k;
722720
T sinTheta, cosTheta;
723721

724-
if ( Imath::Math<T>::fabs( r[kk] ) < Imath::Math<T>::fabs( sdiag[k] ) )
722+
if ( std::fabs( r[kk] ) < std::fabs( sdiag[k] ) )
725723
{
726724
T cotTheta = r[kk] / sdiag[k];
727-
sinTheta = 0.5 / Imath::Math<T>::sqrt( 0.25 + 0.25 * sqr( cotTheta ) );
725+
sinTheta = 0.5 / std::sqrt( 0.25 + 0.25 * sqr( cotTheta ) );
728726
cosTheta = sinTheta * cotTheta;
729727
}
730728
else
731729
{
732730
T tanTheta = sdiag[k] / r[kk];
733-
cosTheta = 0.5 / Imath::Math<T>::sqrt( 0.25 + 0.25 * sqr( tanTheta ) );
731+
cosTheta = 0.5 / std::sqrt( 0.25 + 0.25 * sqr( tanTheta ) );
734732
sinTheta = cosTheta * tanTheta;
735733
}
736734

@@ -802,7 +800,7 @@ T LevenbergMarquardt<T, ErrorFn, Traits>::euclideanNorm( typename std::vector<T>
802800
/// sum squares
803801
for ( typename std::vector<T>::const_iterator it = begin; it != end; ++it )
804802
{
805-
T xabs = Imath::Math<T>::fabs( *it );
803+
T xabs = std::fabs( *it );
806804
if ( xabs > Traits<T>::sqrtMin() && xabs < agiant )
807805
{
808806
/// sum for intermediate components.
@@ -845,22 +843,22 @@ T LevenbergMarquardt<T, ErrorFn, Traits>::euclideanNorm( typename std::vector<T>
845843
/// calculation of norm.
846844
if ( s1 != 0 )
847845
{
848-
return x1max * Imath::Math<T>::sqrt( s1 + ( s2 / x1max ) / x1max );
846+
return x1max * std::sqrt( s1 + ( s2 / x1max ) / x1max );
849847
}
850848

851849
if ( s2 != 0 )
852850
{
853851
if ( s2 >= x3max )
854852
{
855-
return Imath::Math<T>::sqrt( s2 * ( 1 + ( x3max / s2 ) * ( x3max * s3 ) ) );
853+
return std::sqrt( s2 * ( 1 + ( x3max / s2 ) * ( x3max * s3 ) ) );
856854
}
857855
else
858856
{
859-
return Imath::Math<T>::sqrt( x3max * (( s2 / x3max ) + ( x3max * s3 ) ) );
857+
return std::sqrt( x3max * (( s2 / x3max ) + ( x3max * s3 ) ) );
860858
}
861859
}
862860

863-
return x3max * Imath::Math<T>::sqrt( s3 );
861+
return x3max * std::sqrt( s3 );
864862
}
865863

866864
} // namespace IECore

include/IECore/NumericParameter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "IECore/Parameter.h"
3939
#include "IECore/TypedData.h"
4040

41-
#include "OpenEXR/ImathLimits.h"
41+
#include "OpenEXR/half.h"
4242

4343
namespace IECore
4444
{
@@ -58,7 +58,7 @@ class IECORE_EXPORT NumericParameter : public Parameter
5858
typedef std::vector<Preset> PresetsContainer;
5959

6060
NumericParameter( const std::string &name, const std::string &description, T defaultValue = T(),
61-
T minValue = Imath::limits<T>::min(), T maxValue = Imath::limits<T>::max(),
61+
T minValue = std::numeric_limits<T>::lowest(), T maxValue = std::numeric_limits<T>::max(),
6262
const PresetsContainer &presets = PresetsContainer(), bool presetsOnly = false, ConstCompoundObjectPtr userData = nullptr );
6363

6464
NumericParameter( const std::string &name, const std::string &description, T defaultValue,

0 commit comments

Comments
 (0)