ENH: improve auto arranging of multi-color and multi-heights objects
1. Compute score_all_plates correctly. Previously we only compute the first j plates which was wrong. 2. Compute height score correctly. Use average height difference instead of sum. 3. Compute color change score in a different way. If adding the current item increases extruder number, then adds up the score by 1. jira: STUDIO-7013 Change-Id: I921c181bd4b32080627514d3834f4b74ccd00adb (cherry picked from commit 4f6ae81be98109fe61d55203e306686e0d294ec4)
This commit is contained in:
parent
8434ba0c76
commit
afd647d764
|
@ -119,9 +119,9 @@ public:
|
|||
for(; j < placers.size() && !was_packed && !cancelled(); j++) {
|
||||
result = placers[j].pack(*it, rem(it, store_));
|
||||
score = result.score();
|
||||
score_all_plates = std::accumulate(placers.begin(), placers.begin() + j, score,
|
||||
[](double sum, const Placer& elem) { return sum + elem.score(); });
|
||||
if (this->unfitindicator_) this->unfitindicator_(it->get().name + " bed_id="+std::to_string(j) + ",score=" + std::to_string(score));
|
||||
score_all_plates = score;
|
||||
for (int i = 0; i < placers.size(); i++) { score_all_plates += placers[i].score();}
|
||||
if (this->unfitindicator_) this->unfitindicator_(it->get().name + " bed_id="+std::to_string(j) + ",score=" + std::to_string(score)+", score_all_plates="+std::to_string(score_all_plates));
|
||||
|
||||
if(score >= 0 && score < LARGE_COST_TO_REJECT) {
|
||||
if (bed_id_firstfit == -1) {
|
||||
|
|
|
@ -633,17 +633,24 @@ protected:
|
|||
score += lambda4 * hasRowHeightConflict + lambda4 * hasLidHeightConflict;
|
||||
}
|
||||
else {
|
||||
int valid_items_cnt = 0;
|
||||
double height_score = 0;
|
||||
for (int i = 0; i < m_items.size(); i++) {
|
||||
Item& p = m_items[i];
|
||||
if (!p.is_virt_object) {
|
||||
valid_items_cnt++;
|
||||
// 高度接近的件尽量摆到一起
|
||||
score += (1- std::abs(item.height - p.height) / params.printable_height)
|
||||
height_score += (1- std::abs(item.height - p.height) / params.printable_height)
|
||||
* norm(pl::distance(ibb.center(), p.boundingBox().center()));
|
||||
//score += LARGE_COST_TO_REJECT * (item.bed_temp - p.bed_temp != 0);
|
||||
if (!Print::is_filaments_compatible({ item.filament_temp_type,p.filament_temp_type }))
|
||||
if (!Print::is_filaments_compatible({ item.filament_temp_type,p.filament_temp_type })) {
|
||||
score += LARGE_COST_TO_REJECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid_items_cnt > 0)
|
||||
score += height_score / valid_items_cnt;
|
||||
}
|
||||
|
||||
std::set<int> extruder_ids;
|
||||
|
@ -664,9 +671,11 @@ protected:
|
|||
}
|
||||
// for layered printing, we want extruder change as few as possible
|
||||
// this has very weak effect, CAN NOT use a large weight
|
||||
int last_extruder_cnt = extruder_ids.size();
|
||||
extruder_ids.insert(item.extrude_ids.begin(), item.extrude_ids.end());
|
||||
int new_extruder_cnt= extruder_ids.size();
|
||||
if (!params.is_seq_print) {
|
||||
score += 1 * std::max(0, ((int) extruder_ids.size() - 1));
|
||||
score += 1 * (new_extruder_cnt-last_extruder_cnt);
|
||||
}
|
||||
|
||||
return std::make_tuple(score, fullbb);
|
||||
|
|
Loading…
Reference in New Issue