2016-11-24 13:05:06 +00:00
|
|
|
#ifndef slic3r_Utils_hpp_
|
|
|
|
#define slic3r_Utils_hpp_
|
|
|
|
|
2017-10-26 15:17:39 +00:00
|
|
|
#include <locale>
|
|
|
|
|
2016-11-24 13:05:06 +00:00
|
|
|
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-10-17 18:00:15 +00:00
|
|
|
// Set a path with GUI resource files.
|
|
|
|
void set_var_dir(const std::string &path);
|
2017-10-25 10:53:31 +00:00
|
|
|
// Return a full path to the GUI resource files.
|
2017-10-17 18:00:15 +00:00
|
|
|
const std::string& var_dir();
|
2017-10-25 10:53:31 +00:00
|
|
|
// Return a full resource path for a file_name.
|
2017-10-17 18:00:15 +00:00
|
|
|
std::string var(const std::string &file_name);
|
|
|
|
|
2017-10-25 10:53:31 +00:00
|
|
|
// Set a path with preset files.
|
|
|
|
void set_data_dir(const std::string &path);
|
|
|
|
// Return a full path to the GUI resource files.
|
|
|
|
const std::string& data_dir();
|
|
|
|
// Return a full path to a configuration file given its file name..
|
|
|
|
std::string config_path(const std::string &file_name);
|
|
|
|
// Return a full path to a configuration file given the section and name.
|
|
|
|
// The suffix ".ini" will be added if it is missing in the name.
|
|
|
|
std::string config_path(const std::string §ion, const std::string &name);
|
|
|
|
|
2017-08-03 15:31:31 +00:00
|
|
|
extern std::string encode_path(const char *src);
|
|
|
|
extern std::string decode_path(const char *src);
|
|
|
|
extern std::string normalize_utf8_nfc(const char *src);
|
|
|
|
|
2017-10-30 17:15:41 +00:00
|
|
|
// Timestamp formatted for header_slic3r_generated().
|
|
|
|
extern std::string timestamp_str();
|
|
|
|
// Standard "generated by Slic3r version xxx timestamp xxx" header string,
|
|
|
|
// to be placed at the top of Slic3r generated files.
|
2017-11-01 18:30:05 +00:00
|
|
|
inline std::string header_slic3r_generated() { return std::string("generated by " SLIC3R_FORK_NAME " " SLIC3R_VERSION " " ) + timestamp_str(); }
|
2017-10-30 17:15:41 +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_
|