/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef TNW_FILE_OPTIONS_UTILS_H_ #define TNW_FILE_OPTIONS_UTILS_H_ #include "OdPlatformSettings.h" #define STL_USING_LIMITS #include "OdaSTL.h" /** \details Utils of file options using. */ namespace NwFileOptionsUtils { //DOM-IGNORE-BEGIN constexpr double pow10_recursive(int e, double value = 1.0) { return e == 0 ? value : (e > 0 ? pow10_recursive(e - 1, value * 10.0) : pow10_recursive(e + 1, value / 10.0)); } constexpr double pow10(int e) { if (e >= -15 && e <= 15) return pow10_recursive(e); double result = 1.0; double base = 10.0; int abs_e = e < 0 ? -e : e; while (abs_e) { if (abs_e & 1) result *= base; base *= base; abs_e >>= 1; } return e < 0 ? 1.0 / result : result; } //DOM-IGNORE-END /** \details Converts the frame rate to time. \param frameRate [in] The number of frames per second. \returns An OdInt64 value representing the frame processing time. \remarks By default, the time is returned in seconds. However, it is possible to set the exp value to convert the result into milliseconds, microseconds, nanoseconds, or other units. */ template constexpr OdInt64 getTimeByFrameRate(double frameRate) { double time = (1. / frameRate) * pow10(exp) * coef; if (time > std::numeric_limits::max()) return std::numeric_limits::max(); if (time < std::numeric_limits::min()) return std::numeric_limits::min(); return static_cast(std::round(time)); } } #endif // TNW_FILE_OPTIONS_UTILS_H_