ENH: allow big obj arrange into bed with calibration region

Change-Id: I4dac878e0c5ec75a4b06dd5803c0a4839f312bfe
(cherry picked from commit b216a5f4ae97b29eb5ba0c2b5de3b12da80f374d)
This commit is contained in:
manch1n 2023-05-05 14:04:20 +08:00 committed by Lane.Wei
parent 352f4222b1
commit 4db1a6d46e
5 changed files with 50 additions and 1 deletions

View File

@ -84,6 +84,7 @@ public:
//BBS: virtual object to mark unprintable region on heatbed
bool is_virt_object{ false };
bool is_wipe_tower{ false };
bool has_tried_with_excluded{ false };
/// The type of the shape which was handed over as the template argument.
using ShapeType = RawShape;
@ -662,9 +663,21 @@ public:
/// Get the packed items.
inline ItemGroup getItems() { return impl_.getItems(); }
inline int getPackedSize()
{
int size = 0;
auto items = getItems();
for (const auto &itm : items) {
if (itm.get().isFixed() == false) { size++; }
}
return size;
}
/// Clear the packed items so a new session can be started.
inline void clearItems() { impl_.clearItems(); }
inline void clearItems(const std::function<bool(const Item &itm)> &func) { impl_.clearItems(func); }
inline double filledArea() const { return impl_.filledArea(); }
inline double score() const { return impl_.score(); }

View File

@ -555,6 +555,13 @@ public:
Base::clearItems();
}
//clearFunc: itm will be cleared if return ture
inline void clearItems(const std::function<bool(const Item &itm)> &clearFunc)
{
finalAlign(bin_);
Base::clearItems(clearFunc);
}
void preload(const ItemGroup& packeditems) {
Base::preload(packeditems);
if (config_.on_preload)

View File

@ -96,6 +96,17 @@ public:
farea_valid_ = false;
}
//clearFunc: will be cleared if return true
inline void clearItems(const std::function<bool(const Item &itm)> &clearFunc)
{
ItemGroup newGroup;
for (auto &i : items_) {
if (clearFunc(i.get()) == false) { newGroup.push_back(i); }
}
std::swap(newGroup, items_);
farea_valid_ = false;
}
inline double filledArea() const {
if(farea_valid_) return farea_;
else {

View File

@ -161,6 +161,24 @@ public:
makeProgress(placers[j], j);
}
if (was_packed && it->get().has_tried_with_excluded) {
placers[j].clearItems([](const Item &itm) { return itm.isFixed() && !itm.is_wipe_tower; });
placers[j].preload(fixed_bins[placers.size() - 1]);
}
bool placer_not_packed = !was_packed && !placers.empty() && j == placers.size() && placers[j - 1].getPackedSize() == 0; // large item is not placed into the bin
if (placer_not_packed) {
if (it->get().has_tried_with_excluded == false) {
it->get().has_tried_with_excluded = true;
placers[j - 1].clearItems([](const Item &itm) { return itm.isFixed()&&!itm.is_wipe_tower; });
placers[j - 1].preload(pconfig.m_excluded_items);
j = j - 1;
continue;
} else {
placers[j - 1].clearItems([](const Item &itm) { return itm.isFixed() && !itm.is_wipe_tower; });
placers[j - 1].preload(fixed_bins[placers.size() - 1]);
}
}
if(!was_packed){
if (this->unfitindicator_ && !placers.empty())
this->unfitindicator_(it->get().name + ", height=" +std::to_string(it->get().height)

View File

@ -37,7 +37,7 @@ protected:
// then it should be removed from the list
Placer p{ bin };
p.configure(pcfg);
//p.preload(pcfg.m_excluded_items);
p.preload(pcfg.m_excluded_items);
auto it = c.begin();
while (it != c.end() && !stopcond_()) {