FIX: arranging multi-color objects not correct

Arranging multi-color objects with disabled
multi_materials_on_same_plate option was not currect.

Previously we only consider the first extruder id for multi-color
objects. Now we consider all extruders.

Jira: STUDIO-2164
Change-Id: If64ff4f88f0fe4f6c31ebf657b3449b19bf063f0
(cherry picked from commit f4f6bdd00a0c3d3e13406b69be9b5b0468b27d44)
This commit is contained in:
Arthur 2023-02-02 17:26:49 +08:00 committed by Lane.Wei
parent 126ef98690
commit 59f7c4595c
3 changed files with 16 additions and 10 deletions

View file

@ -452,20 +452,25 @@ protected:
}
std::set<int> extruder_ids;
int non_virt_cnt = 0;
for (int i = 0; i < m_items.size(); i++) {
Item& p = m_items[i];
if (p.is_virt_object) continue;
extruder_ids.insert(p.extrude_id);
// add a large cost if not multi materials on same plate is not allowed
if (!params.allow_multi_materials_on_same_plate)
score += LARGE_COST_TO_REJECT * (item.extrude_id != p.extrude_id);
extruder_ids.insert(p.extrude_ids.begin(),p.extrude_ids.end());
non_virt_cnt++;
}
extruder_ids.insert(item.extrude_ids.begin(),item.extrude_ids.end());
// add a large cost if not multi materials on same plate is not allowed
if (!params.allow_multi_materials_on_same_plate) {
// non_virt_cnt==0 means it's the first object, which can be multi-color
if (extruder_ids.size() > 1 && non_virt_cnt > 0)
score += LARGE_COST_TO_REJECT * 1.1;
}
// for layered printing, we want extruder change as few as possible
// this has very weak effect, CAN NOT use a large weight
if (!params.is_seq_print) {
extruder_ids.insert(item.extrude_id);
score += 1 * std::max(0, ((int)extruder_ids.size() - 1));
score += 1 * std::max(0, ((int) extruder_ids.size() - 1));
}
return std::make_tuple(score, fullbb);
@ -601,7 +606,7 @@ public:
}
else {
return i1.bed_temp != i2.bed_temp ? (i1.bed_temp > i2.bed_temp) :
(i1.extrude_id != i2.extrude_id ? (i1.extrude_id < i2.extrude_id) : (i1.area() > i2.area()));
(i1.extrude_ids != i2.extrude_ids ? (i1.extrude_ids.front() < i2.extrude_ids.front()) : (i1.area() > i2.area()));
}
};
@ -850,7 +855,7 @@ static void process_arrangeable(const ArrangePolygon &arrpoly,
item.binId(arrpoly.bed_idx);
item.priority(arrpoly.priority);
item.itemId(arrpoly.itemid);
item.extrude_id = arrpoly.extrude_ids.front();
item.extrude_ids = arrpoly.extrude_ids;
item.height = arrpoly.height;
item.name = arrpoly.name;
//BBS: add virtual object logic