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

@ -309,7 +309,7 @@ protected:
public:
AutoArranger(const TBin & bin,
const ArrangeParams &params,
std::function<void(unsigned, unsigned /*bins*/)> progressind,
std::function<void(unsigned)> progressind,
std::function<bool(void)> stopcond)
: m_pck(bin, params.min_obj_distance)
, m_bin(bin)
@ -347,10 +347,27 @@ public:
};
m_pconf.object_function = get_objfn();
auto on_packed = params.on_packed;
if (progressind) m_pck.progressIndicator([this, &progressind](unsigned rem) {
progressind(rem, m_pck.lastResult().size() - 1);
if (progressind || on_packed)
m_pck.progressIndicator([this, progressind, on_packed](unsigned rem) {
if (progressind)
progressind(rem);
if (on_packed) {
int last_bed = m_pck.lastPackedBinId();
if (last_bed >= 0) {
Item &last_packed = m_pck.lastResult()[last_bed].back();
ArrangePolygon ap;
ap.bed_idx = last_packed.binId();
ap.priority = last_packed.priority();
on_packed(ap);
}
}
});
if (stopcond) m_pck.stopCondition(stopcond);
m_pck.configure(m_pconf);
@ -464,7 +481,7 @@ void _arrange(
std::vector<Item> & excludes,
const BinT & bin,
const ArrangeParams &params,
std::function<void(unsigned, unsigned)> progressfn,
std::function<void(unsigned)> progressfn,
std::function<bool()> stopfn)
{
// Integer ceiling the min distance from the bed perimeters