2016-11-24 13:05:06 +00:00
|
|
|
#ifndef slic3r_Utils_hpp_
|
|
|
|
#define slic3r_Utils_hpp_
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
extern void set_logging_level(unsigned int level);
|
2017-03-03 11:53:05 +00:00
|
|
|
extern void trace(unsigned int level, const char *message);
|
2016-11-24 13:05:06 +00:00
|
|
|
|
2017-03-28 15:09:57 +00:00
|
|
|
// Compute the next highest power of 2 of 32-bit v
|
|
|
|
// http://graphics.stanford.edu/~seander/bithacks.html
|
2017-03-28 16:02:26 +00:00
|
|
|
template<typename T>
|
|
|
|
inline T next_highest_power_of_2(T v)
|
2017-03-28 15:09:57 +00:00
|
|
|
{
|
|
|
|
if (v != 0)
|
|
|
|
-- v;
|
|
|
|
v |= v >> 1;
|
|
|
|
v |= v >> 2;
|
|
|
|
v |= v >> 4;
|
2017-03-28 16:02:26 +00:00
|
|
|
if (sizeof(T) >= sizeof(uint16_t))
|
|
|
|
v |= v >> 8;
|
|
|
|
if (sizeof(T) >= sizeof(uint32_t))
|
|
|
|
v |= v >> 16;
|
|
|
|
if (sizeof(T) >= sizeof(uint64_t))
|
|
|
|
v |= v >> 32;
|
2017-03-28 15:09:57 +00:00
|
|
|
return ++ v;
|
|
|
|
}
|
|
|
|
|
2016-11-24 13:05:06 +00:00
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_Utils_hpp_
|