mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-15 05:51:48 +08:00
Merge branch 'tm_fix_cancellation'
This commit is contained in:
commit
0db55a0699
@ -390,16 +390,25 @@ public:
|
|||||||
virtual void apply(const SLAPrinterConfig &cfg) = 0;
|
virtual void apply(const SLAPrinterConfig &cfg) = 0;
|
||||||
|
|
||||||
// Fn have to be thread safe: void(sla::RasterBase& raster, size_t lyrid);
|
// 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);
|
m_layers.resize(layer_num);
|
||||||
sla::ccr::for_each(size_t(0), m_layers.size(),
|
execution::for_each(
|
||||||
[this, &drawfn] (size_t idx) {
|
ep, size_t(0), m_layers.size(),
|
||||||
sla::EncodedRaster& enc = m_layers[idx];
|
[this, &drawfn, &cancelfn](size_t idx) {
|
||||||
|
if (cancelfn()) return;
|
||||||
|
|
||||||
|
sla::EncodedRaster &enc = m_layers[idx];
|
||||||
auto rst = create_raster();
|
auto rst = create_raster();
|
||||||
drawfn(*rst, idx);
|
drawfn(*rst, idx);
|
||||||
enc = rst->encode(get_encoder());
|
enc = rst->encode(get_encoder());
|
||||||
});
|
},
|
||||||
|
execution::max_concurrency(ep));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1093,7 +1093,8 @@ void SLAPrint::Steps::rasterize()
|
|||||||
if(canceled()) return;
|
if(canceled()) return;
|
||||||
|
|
||||||
// Print all the layers in parallel
|
// 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)
|
std::string SLAPrint::Steps::label(SLAPrintObjectStep step)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user