7 #define _USE_MATH_DEFINES 12 #include <boost/thread.hpp> 21 #define CONFESS(...) confess_at(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) 23 #define CONFESS(...) confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__) 25 void confess_at(
const char *file,
int line,
const char *func,
const char *pat, ...);
30 #if __cplusplus==201402L 31 #define SLIC3R_CPPVER 14 32 #define STDMOVE(WHAT) std::move(WHAT) 33 #elif __cplusplus==201103L 34 #define SLIC3R_CPPVER 11 35 #define STDMOVE(WHAT) std::move(WHAT) 37 #define SLIC3R_CPPVER 0 38 #define STDMOVE(WHAT) (WHAT) 48 #ifndef SLIC3R_BUILD_COMMIT 49 #define SLIC3R_BUILD_COMMIT (Unknown revision) 52 #define VER_(x) VER1_(x) 53 #define BUILD_COMMIT VER_(SLIC3R_BUILD_COMMIT) 82 constexpr
auto PI = 3.141592653589793238;
96 inline void append_to(std::vector<T> &dst,
const std::vector<T> &src)
98 dst.insert(dst.end(), src.begin(), src.end());
101 template <
class T>
void 102 _parallelize_do(std::queue<T>* queue, boost::mutex* queue_mutex, boost::function<
void(T)> func)
108 boost::lock_guard<boost::mutex> l(*queue_mutex);
109 if (queue->empty())
return;
115 boost::this_thread::interruption_point();
119 template <
class T>
void 121 int threads_count = boost::thread::hardware_concurrency())
123 if (threads_count == 0) threads_count = 2;
124 boost::mutex queue_mutex;
125 boost::thread_group workers;
126 for (
int i = 0; i < std::min(threads_count, (
int)queue.size()); i++)
127 workers.add_thread(
new boost::thread(&_parallelize_do<T>, &queue, &queue_mutex, func));
131 template <
class T>
void 133 int threads_count = boost::thread::hardware_concurrency())
136 for (T i = start; i <= end; ++i) queue.push(i);
constexpr auto SLIC3R_VERSION
Definition: libslic3r.h:45
void confess_at(const char *file, int line, const char *func, const char *pat,...)
Definition: utils.cpp:12
Definition: libslic3r.h:93
constexpr auto EPSILON
Definition: libslic3r.h:77
long coord_t
Definition: libslic3r.h:62
const auto SLIC3R_GIT_STR
Definition: libslic3r.h:55
void append_to(std::vector< T > &dst, const std::vector< T > &src)
Definition: libslic3r.h:96
constexpr auto SCALING_FACTOR
Definition: libslic3r.h:69
constexpr coord_t SMALL_PERIMETER_LENGTH
Definition: libslic3r.h:86
constexpr coordf_t INSET_OVERLAP_TOLERANCE
Definition: libslic3r.h:87
constexpr coordf_t unscale(const coord_t &val)
Definition: libslic3r.h:71
constexpr auto SCALED_RESOLUTION
Definition: libslic3r.h:81
constexpr coord_t scale_(const coordf_t &val)
Definition: libslic3r.h:70
Definition: libslic3r.h:93
constexpr auto RESOLUTION
Definition: libslic3r.h:80
double coordf_t
Definition: libslic3r.h:63
Definition: BoundingBox.cpp:4
constexpr coordf_t EXTERNAL_INFILL_MARGIN
Definition: libslic3r.h:88
constexpr auto PI
Definition: libslic3r.h:82
constexpr auto SCALED_EPSILON
Definition: libslic3r.h:78
Definition: libslic3r.h:93
constexpr coord_t SCALED_EXTERNAL_INFILL_MARGIN
Definition: libslic3r.h:89
constexpr float CLIPPER_OFFSET_SCALE
Definition: libslic3r.h:91
#define BUILD_COMMIT
Definition: libslic3r.h:53
const auto SLIC3R_GIT
Definition: libslic3r.h:56
Axis
Definition: libslic3r.h:93
constexpr auto LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER
Definition: libslic3r.h:84
void _parallelize_do(std::queue< T > *queue, boost::mutex *queue_mutex, boost::function< void(T)> func)
Definition: libslic3r.h:102
void parallelize(std::queue< T > queue, boost::function< void(T)> func, int threads_count=boost::thread::hardware_concurrency())
Definition: libslic3r.h:120