Fix bed filling with more existing instances than needed

This commit is contained in:
tamasmeszaros 2020-11-26 13:58:21 +01:00
parent 7f22ce63f6
commit dfbf4cbab2
7 changed files with 49 additions and 16 deletions

View file

@ -741,6 +741,10 @@ public:
return impl_.getResult();
}
inline int lastPackedBinId() const {
return impl_.lastPackedBinId();
}
void clear() { impl_.clear(); }
};
@ -862,6 +866,10 @@ public:
{
return selector_.getResult();
}
inline int lastPackedBinId() const {
return selector_.lastPackedBinId();
}
};
}

View file

@ -71,8 +71,9 @@ public:
std::sort(store_.begin(), store_.end(), sortfunc);
auto total = last-first;
auto makeProgress = [this, &total](Placer& placer, size_t idx) {
packed_bins_[idx] = placer.getItems();
auto makeProgress = [this, &total](Placer& placer, size_t bin_idx) {
packed_bins_[bin_idx] = placer.getItems();
this->last_packed_bin_id_ = int(bin_idx);
this->progress_(static_cast<unsigned>(--total));
};

View file

@ -18,6 +18,8 @@ public:
return packed_bins_;
}
inline int lastPackedBinId() const { return last_packed_bin_id_; }
inline void progressIndicator(ProgressFunction fn) { progress_ = fn; }
inline void stopCondition(StopCondition cond) { stopcond_ = cond; }
@ -54,6 +56,7 @@ protected:
PackGroup packed_bins_;
ProgressFunction progress_ = [](unsigned){};
StopCondition stopcond_ = [](){ return false; };
int last_packed_bin_id_ = -1;
};
}