mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
parent
e8af080346
commit
08ca5b29f0
2 changed files with 19 additions and 9 deletions
|
@ -390,16 +390,25 @@ public:
|
|||
virtual void apply(const SLAPrinterConfig &cfg) = 0;
|
||||
|
||||
// Fn have to be thread safe: void(sla::RasterBase& raster, size_t lyrid);
|
||||
template<class Fn> void draw_layers(size_t layer_num, Fn &&drawfn)
|
||||
template<class Fn, class CancelFn, class EP = ExecutionTBB>
|
||||
void draw_layers(
|
||||
size_t layer_num,
|
||||
Fn && drawfn,
|
||||
CancelFn cancelfn = []() { return false; },
|
||||
const EP & ep = {})
|
||||
{
|
||||
m_layers.resize(layer_num);
|
||||
sla::ccr::for_each(size_t(0), m_layers.size(),
|
||||
[this, &drawfn] (size_t idx) {
|
||||
sla::EncodedRaster& enc = m_layers[idx];
|
||||
auto rst = create_raster();
|
||||
drawfn(*rst, idx);
|
||||
enc = rst->encode(get_encoder());
|
||||
});
|
||||
execution::for_each(
|
||||
ep, size_t(0), m_layers.size(),
|
||||
[this, &drawfn, &cancelfn](size_t idx) {
|
||||
if (cancelfn()) return;
|
||||
|
||||
sla::EncodedRaster &enc = m_layers[idx];
|
||||
auto rst = create_raster();
|
||||
drawfn(*rst, idx);
|
||||
enc = rst->encode(get_encoder());
|
||||
},
|
||||
execution::max_concurrency(ep));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue