//! length of the tangent of the curve or the surface.
//!
//! Value is P / T
- static inline Standard_Real Parametric (const Standard_Real P, const Standard_Real T) { return P / T; }
+ static constexpr Standard_Real Parametric (const Standard_Real P, const Standard_Real T) { return P / T; }
//! Returns a precision value in parametric space, which may be used :
//! - to test the coincidence of two points in the real space,
//! 2.Pi without impacting on the resulting point.
//! Therefore, take great care when adjusting a parametric
//! tolerance to your own algorithm.
- static inline Standard_Real PConfusion (const Standard_Real T) { return Parametric (Confusion(), T); }
+ static constexpr Standard_Real PConfusion (const Standard_Real T) { return Parametric (Confusion(), T); }
//! Returns square of PConfusion.
//! Created for speed and convenience.
//! segment whose length is equal to 100. (default value), or T.
//! The parametric tolerance of intersection is equal to :
//! - Precision::Intersection() / 100., or Precision::Intersection() / T.
- static inline Standard_Real PIntersection (const Standard_Real T) { return Parametric(Intersection(),T); }
+ static constexpr Standard_Real PIntersection (const Standard_Real T) { return Parametric(Intersection(),T); }
//! Returns a precision value in parametric space, which may
//! be used by approximation algorithms. The purpose of this
//! segment whose length is equal to 100. (default value), or T.
//! The parametric tolerance of intersection is equal to :
//! - Precision::Approximation() / 100., or Precision::Approximation() / T.
- static inline Standard_Real PApproximation (const Standard_Real T) { return Parametric(Approximation(),T); }
+ static constexpr Standard_Real PApproximation (const Standard_Real T) { return Parametric(Approximation(),T); }
//! Convert a real space precision to a parametric
//! space precision on a default curve.
//!
//! Value is Parametric(P,1.e+2)
- static inline Standard_Real Parametric (const Standard_Real P) { return P * 0.01; }
+ static constexpr Standard_Real Parametric (const Standard_Real P) { return P * 0.01; }
//! Used to test distances in parametric space on a
//! default curve.
//! Returns True if R may be considered as a positive
//! infinite number. Currently R > 1e100
- static inline Standard_Boolean IsPositiveInfinite (const Standard_Real R) { return R >= (0.5 * Precision::Infinite()); }
+ static constexpr Standard_Boolean IsPositiveInfinite (const Standard_Real R) { return R >= (0.5 * Precision::Infinite()); }
//! Returns True if R may be considered as a negative
//! infinite number. Currently R < -1e100
- static inline Standard_Boolean IsNegativeInfinite (const Standard_Real R) { return R <= -(0.5 * Precision::Infinite()); }
+ static constexpr Standard_Boolean IsNegativeInfinite (const Standard_Real R) { return R <= -(0.5 * Precision::Infinite()); }
//! Returns a big number that can be considered as
//! infinite. Use -Infinite() for a negative big number.
// ------------------------------------------------------------------
// IsEqual : Returns Standard_True if two characters have the same value
// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual(const Standard_Character One,
- const Standard_Character Two)
+constexpr Standard_Boolean IsEqual(const Standard_Character One,
+ const Standard_Character Two)
{ return One == Two; }
// ===============================================
// ------------------------------------------------------------------
// Abs : Returns the absolute value of an Integer
// ------------------------------------------------------------------
-inline Standard_Integer Abs (const Standard_Integer Value)
+constexpr Standard_Integer Abs (const Standard_Integer Value)
{
return Value >= 0 ? Value : -Value;
}
// ------------------------------------------------------------------
// IsEven : Returns Standard_True if an integer is even
// ------------------------------------------------------------------
-inline Standard_Boolean IsEven (const Standard_Integer Value)
+constexpr Standard_Boolean IsEven (const Standard_Integer Value)
{ return Value % 2 == 0; }
// ------------------------------------------------------------------
// IsOdd : Returns Standard_True if an integer is odd
// ------------------------------------------------------------------
-inline Standard_Boolean IsOdd (const Standard_Integer Value)
+constexpr Standard_Boolean IsOdd (const Standard_Integer Value)
{ return Value % 2 == 1; }
// ------------------------------------------------------------------
// Max : Returns the maximum integer between two integers
// ------------------------------------------------------------------
-inline Standard_Integer Max (const Standard_Integer Val1,
+constexpr Standard_Integer Max (const Standard_Integer Val1,
const Standard_Integer Val2)
{
return Val1 >= Val2 ? Val1 : Val2;
// ------------------------------------------------------------------
// Min : Returns the minimum integer between two integers
// ------------------------------------------------------------------
-inline Standard_Integer Min (const Standard_Integer Val1,
+constexpr Standard_Integer Min (const Standard_Integer Val1,
const Standard_Integer Val2)
{
return Val1 <= Val2 ? Val1 : Val2;
// ------------------------------------------------------------------
// Modulus : Returns the remainder of division between two integers
// ------------------------------------------------------------------
-inline Standard_Integer Modulus (const Standard_Integer Value,
+constexpr Standard_Integer Modulus (const Standard_Integer Value,
const Standard_Integer Divisor)
{ return Value % Divisor; }
// ------------------------------------------------------------------
// Square : Returns the square of an integer
// ------------------------------------------------------------------
-inline Standard_Integer Square(const Standard_Integer Value)
+constexpr Standard_Integer Square(const Standard_Integer Value)
{ return Value * Value; }
// ------------------------------------------------------------------
}
}
-static int HighBitsOfDouble = HardwareHighBitsOfDouble();
-static int LowBitsOfDouble = HardwareLowBitsOfDouble();
+static const int HighBitsOfDouble = HardwareHighBitsOfDouble();
+static const int LowBitsOfDouble = HardwareLowBitsOfDouble();
double NextAfter(const double x, const double y)
{
// If 'Value' is 0 then returns minimal positive value
// of Standard_Real type.
//-------------------------------------------------------------------
-inline Standard_Real Epsilon (const Standard_Real Value)
+inline Standard_Real Epsilon (const Standard_Real Value)
{
- Standard_Real aEpsilon;
-
- if (Value>=0.0){
- aEpsilon = NextAfter(Value, RealLast()) - Value;
- } else {
- aEpsilon = Value - NextAfter(Value, RealFirst());
- }
- return aEpsilon;
+ return Value >= 0.0 ? (NextAfter(Value, RealLast()) - Value)
+ : (Value - NextAfter(Value, RealFirst()));
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Max : Returns the maximum value of two reals
//-------------------------------------------------------------------
-inline Standard_Real Max (const Standard_Real Val1,
+constexpr Standard_Real Max (const Standard_Real Val1,
const Standard_Real Val2)
{
return Val1 >= Val2 ? Val1 : Val2;
//-------------------------------------------------------------------
// Min : Returns the minimum value of two reals
//-------------------------------------------------------------------
-inline Standard_Real Min (const Standard_Real Val1,
+constexpr Standard_Real Min (const Standard_Real Val1,
const Standard_Real Val2)
{
return Val1 <= Val2 ? Val1 : Val2;
// If input value is out of valid range for integers,
// minimal or maximal possible integer is returned.
//-------------------------------------------------------------------
-inline Standard_Integer RealToInt (const Standard_Real theValue)
+constexpr Standard_Integer RealToInt (const Standard_Real theValue)
{
// Note that on WNT under MS VC++ 8.0 conversion of double value less
// than INT_MIN or greater than INT_MAX to integer will cause signal
// for Standard_ShortReal, minimal or maximal
// Standard_ShortReal is returned.
// =======================================================================
-inline Standard_ShortReal RealToShortReal (const Standard_Real theVal)
+constexpr Standard_ShortReal RealToShortReal (const Standard_Real theVal)
{
return theVal < -FLT_MAX ? -FLT_MAX
: theVal > FLT_MAX ? FLT_MAX
//-------------------------------------------------------------------
// Square : Returns a real to the power 2
//-------------------------------------------------------------------
-inline Standard_Real Square(const Standard_Real Value)
+constexpr Standard_Real Square(const Standard_Real Value)
{ return Value * Value; }
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Max : Returns the maximum value of two ShortReals
//-------------------------------------------------------------------
-inline Standard_ShortReal Max (const Standard_ShortReal Val1,
- const Standard_ShortReal Val2)
+constexpr Standard_ShortReal Max(const Standard_ShortReal Val1,
+ const Standard_ShortReal Val2)
{
- if (Val1 >= Val2) {
- return Val1;
- } else {
- return Val2;
- }
+ return Val1 >= Val2 ? Val1 : Val2;
}
//-------------------------------------------------------------------
// Min : Returns the minimum value of two ShortReals
//-------------------------------------------------------------------
-inline Standard_ShortReal Min (const Standard_ShortReal Val1,
- const Standard_ShortReal Val2)
+constexpr Standard_ShortReal Min(const Standard_ShortReal Val1,
+ const Standard_ShortReal Val2)
{
- if (Val1 <= Val2) {
- return Val1;
- } else {
- return Val2;
- }
+ return Val1 <= Val2 ? Val1 : Val2;
}
#endif