ENH: use spiral lift only when it is needed

If a travel path goes through an overhang expolygons, and their distance
is shorter than threshold, lift type will be set to SpiralLift.

Signed-off-by: yifan.wu <yifan.wu@bambulab.com>
Change-Id: I345788711755dd8611ecf385818e6052cd8abe9e
This commit is contained in:
yifan.wu 2022-11-20 22:04:25 +08:00 committed by Lane.Wei
parent 47a46010bd
commit 5d9bb61f8e
11 changed files with 199 additions and 17 deletions

View file

@ -409,6 +409,48 @@ void PrintObject::ironing()
}
}
// BBS
void PrintObject::clear_overhangs_for_lift()
{
if (!m_shared_object) {
for (Layer* l : m_layers)
l->loverhangs.clear();
}
}
static const float g_min_overhang_percent_for_lift = 0.3f;
void PrintObject::detect_overhangs_for_lift()
{
if (this->set_started(posDetectOverhangsForLift)) {
const float min_overlap = m_config.line_width * g_min_overhang_percent_for_lift;
size_t num_layers = this->layer_count();
size_t num_raft_layers = m_slicing_params.raft_layers();
m_print->set_status(78, L("Detect overhangs for auto-lift"));
this->clear_overhangs_for_lift();
if (m_print->config().z_hop_type != ZHopType::zhtAuto)
return;
tbb::spin_mutex layer_storage_mutex;
tbb::parallel_for(tbb::blocked_range<size_t>(num_raft_layers + 1, num_layers),
[this, min_overlap](const tbb::blocked_range<size_t>& range)
{
for (size_t layer_id = range.begin(); layer_id < range.end(); ++layer_id) {
Layer& layer = *m_layers[layer_id];
Layer& lower_layer = *layer.lower_layer;
ExPolygons overhangs = diff_ex(layer.lslices, offset_ex(lower_layer.lslices, scale_(min_overlap)));
layer.loverhangs = std::move(offset2_ex(overhangs, -0.1f * scale_(m_config.line_width), 0.1f * scale_(m_config.line_width)));
}
});
this->set_done(posDetectOverhangsForLift);
}
}
void PrintObject::generate_support_material()
{
if (this->set_started(posSupportMaterial)) {