FIX: fill in bed may shift objects outside bed

Do not do final align for filling in bed.

Jira: STUDIO-3265
Change-Id: I2ce2ebed575ba05b1d78ec89923f8e91c4de6648
(cherry picked from commit 581aa4fd0ff1c6f64026d7b934d4bd8a79b803ae)
This commit is contained in:
Arthur 2023-06-19 16:37:12 +08:00 committed by Lane.Wei
parent e567afdcb5
commit 9ad9ba213a
3 changed files with 12 additions and 19 deletions

View File

@ -86,18 +86,21 @@ template<class PConf>
void fill_config(PConf& pcfg, const ArrangeParams &params) {
if (params.is_seq_print) {
// Align the arranged pile into the center of the bin
pcfg.alignment = PConf::Alignment::CENTER;
// Start placing the items from the center of the print bed
pcfg.starting_point = PConf::Alignment::BOTTOM_LEFT;
}
else {
// Align the arranged pile into the center of the bin
pcfg.alignment = PConf::Alignment::CENTER;
// Start placing the items from the center of the print bed
pcfg.starting_point = PConf::Alignment::TOP_RIGHT;
}
if (params.do_final_align) {
// Align the arranged pile into the center of the bin
pcfg.alignment = PConf::Alignment::CENTER;
}else
pcfg.alignment = PConf::Alignment::DONT_ALIGN;
// Try 4 angles (45 degree step) and find the one with min cost
if (params.allow_rotations)
pcfg.rotations = {0., PI / 4., PI/2, 3. * PI / 4. };
@ -542,12 +545,6 @@ public:
if (items.empty()) return;
auto binbb = sl::boundingBox(m_bin);
// BBS: excluded region (virtual object but not wipe tower) should not affect final alignment
//bool all_is_excluded_region = std::all_of(items.begin(), items.end(), [](Item &itm) { return itm.is_virt_object && !itm.is_wipe_tower; });
//if (!all_is_excluded_region)
// cfg.alignment = PConfig::Alignment::DONT_ALIGN;
//else
// cfg.alignment = PConfig::Alignment::CENTER;
auto starting_point = cfg.starting_point == PConfig::Alignment::BOTTOM_LEFT ? binbb.minCorner() : binbb.center();
// if we have wipe tower, items should be arranged around wipe tower
@ -559,15 +556,7 @@ public:
}
cfg.object_function = [this, binbb, starting_point](const Item &item, const ItemGroup &packed_items) {
// 在我们的摆盘中,没有天然的固定对象。固定对象只有:屏蔽区域、挤出补偿区域、料塔。
// 对于屏蔽区域,摆入的对象仍然是可以向右上滑动的;
// 对挤出料塔,摆入的对象不能滑动(必须围绕料塔)
bool pack_around_wipe_tower = std::any_of(packed_items.begin(), packed_items.end(), [](Item& itm) { return itm.is_wipe_tower; });
//if(pack_around_wipe_tower)
return fixed_overfit(objfunc(item, starting_point), binbb);
//else {
// return fixed_overfit_topright_sliding(objfunc(item, starting_point), binbb, m_excluded_and_extruCali_regions);
//}
return fixed_overfit(objfunc(item, starting_point), binbb);
};
};

View File

@ -114,6 +114,8 @@ struct ArrangeParams {
bool allow_rotations = false;
bool do_final_align = true;
//BBS: add specific arrange params
bool allow_multi_materials_on_same_plate = true;
bool avoid_extrusion_cali_region = true;

View File

@ -228,6 +228,8 @@ void FillBedJob::process()
params.on_packed = [&do_stop] (const ArrangePolygon &ap) {
do_stop = ap.bed_idx > 0 && ap.priority == 0;
};
// final align用的是凸包在有fixed item的情况下可能找到的参考点位置是错的这里就不做了。见STUDIO-3265
params.do_final_align = false;
arrangement::arrange(m_selected, m_unselected, m_bedpts, params);