ENH:allow more same color objects arrange together

Change-Id: I87a9de3c5ed540c87fdebfe4e69ffa539d78ce40

STUDIO-2462

STUDIO-2463
This commit is contained in:
manch1n 2023-03-17 17:09:05 +08:00 committed by Lane.Wei
parent 1f1e5894bb
commit 797c211203
2 changed files with 7 additions and 3 deletions

View file

@ -11,7 +11,7 @@
#include <type_traits>
#include <limits>
#define MAX_NUM_PLATES 50
#define MAX_NUM_PLATES 36
#if defined(_MSC_VER) && _MSC_VER <= 1800 || __cplusplus < 201103L
#define BP2D_NOEXCEPT

View file

@ -453,19 +453,23 @@ protected:
std::set<int> extruder_ids;
int non_virt_cnt = 0;
std::set<int> first_object_extruder_ids;
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_ids.begin(),p.extrude_ids.end());
non_virt_cnt++;
if (non_virt_cnt == 1) { first_object_extruder_ids.insert(p.extrude_ids.begin(), p.extrude_ids.end()); }
}
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) {
bool first_object = non_virt_cnt == 0;
bool same_color_with_first_object = std::all_of(item.extrude_ids.begin(), item.extrude_ids.end(),
[&](int color) { return first_object_extruder_ids.find(color) != first_object_extruder_ids.end(); });
// 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;
if (!(first_object || same_color_with_first_object)) score += LARGE_COST_TO_REJECT * 1.3;
}
// for layered printing, we want extruder change as few as possible
// this has very weak effect, CAN NOT use a large weight