ENH: allow big obj arrange into bed with calibration region
Change-Id: I4dac878e0c5ec75a4b06dd5803c0a4839f312bfe (cherry picked from commit b216a5f4ae97b29eb5ba0c2b5de3b12da80f374d)
This commit is contained in:
parent
352f4222b1
commit
4db1a6d46e
|
@ -84,6 +84,7 @@ public:
|
||||||
//BBS: virtual object to mark unprintable region on heatbed
|
//BBS: virtual object to mark unprintable region on heatbed
|
||||||
bool is_virt_object{ false };
|
bool is_virt_object{ false };
|
||||||
bool is_wipe_tower{ 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.
|
/// The type of the shape which was handed over as the template argument.
|
||||||
using ShapeType = RawShape;
|
using ShapeType = RawShape;
|
||||||
|
@ -662,9 +663,21 @@ public:
|
||||||
/// Get the packed items.
|
/// Get the packed items.
|
||||||
inline ItemGroup getItems() { return impl_.getItems(); }
|
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.
|
/// Clear the packed items so a new session can be started.
|
||||||
inline void clearItems() { impl_.clearItems(); }
|
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 filledArea() const { return impl_.filledArea(); }
|
||||||
|
|
||||||
inline double score() const { return impl_.score(); }
|
inline double score() const { return impl_.score(); }
|
||||||
|
|
|
@ -555,6 +555,13 @@ public:
|
||||||
Base::clearItems();
|
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) {
|
void preload(const ItemGroup& packeditems) {
|
||||||
Base::preload(packeditems);
|
Base::preload(packeditems);
|
||||||
if (config_.on_preload)
|
if (config_.on_preload)
|
||||||
|
|
|
@ -96,6 +96,17 @@ public:
|
||||||
farea_valid_ = false;
|
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 {
|
inline double filledArea() const {
|
||||||
if(farea_valid_) return farea_;
|
if(farea_valid_) return farea_;
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -161,6 +161,24 @@ public:
|
||||||
makeProgress(placers[j], j);
|
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(!was_packed){
|
||||||
if (this->unfitindicator_ && !placers.empty())
|
if (this->unfitindicator_ && !placers.empty())
|
||||||
this->unfitindicator_(it->get().name + ", height=" +std::to_string(it->get().height)
|
this->unfitindicator_(it->get().name + ", height=" +std::to_string(it->get().height)
|
||||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
||||||
// then it should be removed from the list
|
// then it should be removed from the list
|
||||||
Placer p{ bin };
|
Placer p{ bin };
|
||||||
p.configure(pcfg);
|
p.configure(pcfg);
|
||||||
//p.preload(pcfg.m_excluded_items);
|
p.preload(pcfg.m_excluded_items);
|
||||||
auto it = c.begin();
|
auto it = c.begin();
|
||||||
while (it != c.end() && !stopcond_()) {
|
while (it != c.end() && !stopcond_()) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue