ENH: optimize speed of gcode export

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: Ic641352623f26c7241ae5720ad1baa202a1b00c7
This commit is contained in:
salt.wei 2023-03-02 20:30:47 +08:00 committed by Lane.Wei
parent 3448b7a053
commit 8669291aad
3 changed files with 30 additions and 1 deletions

View file

@ -1461,6 +1461,22 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_enable_cooling_markers = true;
this->apply_print_config(print.config());
//BBS: generate simplified_slices if necessary
if (m_config.reduce_infill_retraction) {
for (auto object : print.objects()) {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, object->layers().size()),
[object](const tbb::blocked_range<size_t>& range) {
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) {
Layer* layer = object->layers()[layer_idx];
if (layer)
layer->simplify_reagon_final_slices();
}
}
);
}
}
//m_volumetric_speed = DoExport::autospeed_volumetric_limit(print);
print.throw_if_canceled();
@ -4048,7 +4064,7 @@ bool GCode::needs_retraction(const Polyline &travel, ExtrusionRole role, LiftTyp
}
//BBS: need retract when long moving to print perimeter to avoid dropping of material
if (!is_perimeter(role) && m_config.reduce_infill_retraction && m_layer != nullptr &&
m_config.sparse_infill_density.value > 0 && m_layer->any_internal_region_slice_contains(travel))
m_config.sparse_infill_density.value > 0 && m_layer->any_internal_region_slmplify_slice_contains(travel))
// Skip retraction if travel is contained in an internal slice *and*
// internal infill is enabled (so that stringing is entirely not visible).
//FIXME any_internal_region_slice_contains() is potentionally very slow, it shall test for the bounding boxes first.