Skip to content

Commit

Permalink
COMP: Allow use of older system vxl
Browse files Browse the repository at this point in the history
Break dependance of older vxl versions by directly providing newer vxl
version compatible implementations directly in ITK.
  • Loading branch information
hjmjohnson committed Dec 13, 2021
1 parent d80b751 commit 0401269
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion Modules/Core/Common/include/itkMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,66 @@ using vnl_math::sgn;
using vnl_math::sgn0;
using vnl_math::remainder_truncated;
using vnl_math::remainder_floored;
using vnl_math::abs;
using vnl_math::sqr;
using vnl_math::cube;
using vnl_math::squared_magnitude;


/*============================================
Decouple dependance and exposure of vnl_math::abs operations
in ITK. Placing this small amount of duplicate vnl_math
code directly in ITK removes backward compatibility
issues with system installed VXL versions.
*/
inline bool
abs(bool x)
{
return x;
}
inline unsigned char
abs(unsigned char x)
{
return x;
}
inline unsigned char
abs(signed char x)
{
return x < 0 ? static_cast<unsigned char>(-x) : x;
}
inline unsigned char
abs(char x)
{
return static_cast<unsigned char>(x);
}
inline unsigned short
abs(short x)
{
return x < 0 ? static_cast<unsigned short>(-x) : x;
}
inline unsigned short
abs(unsigned short x)
{
return x;
}
inline unsigned int
abs(unsigned int x)
{
return x;
}
inline unsigned long
abs(unsigned long x)
{
return x;
}
// long long - target type will have width of at least 64 bits. (since C++11)
inline unsigned long long
abs(unsigned long long x)
{
return x;
}

using std::abs;

} // end namespace Math
} // end namespace itk

Expand Down

0 comments on commit 0401269

Please sign in to comment.