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));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1093,7 +1093,8 @@ void SLAPrint::Steps::rasterize()
|
|||
if(canceled()) return;
|
||||
|
||||
// Print all the layers in parallel
|
||||
m_print->m_printer->draw_layers(m_print->m_printer_input.size(), lvlfn);
|
||||
m_print->m_printer->draw_layers(m_print->m_printer_input.size(), lvlfn,
|
||||
[this]() { return canceled(); }, ex_tbb);
|
||||
}
|
||||
|
||||
std::string SLAPrint::Steps::label(SLAPrintObjectStep step)
|
||||
|
|
Loading…
Add table
Reference in a new issue