Merge branch 'tm_arrange_perf_improve'

This commit is contained in:
tamasmeszaros 2020-11-24 16:20:17 +01:00
commit 0bfbe18a3c
5 changed files with 17 additions and 10 deletions

View file

@ -309,7 +309,7 @@ protected:
public:
AutoArranger(const TBin & bin,
const ArrangeParams &params,
std::function<void(unsigned)> progressind,
std::function<void(unsigned, unsigned /*bins*/)> progressind,
std::function<bool(void)> stopcond)
: m_pck(bin, params.min_obj_distance)
, m_bin(bin)
@ -348,7 +348,9 @@ public:
m_pconf.object_function = get_objfn();
if (progressind) m_pck.progressIndicator(progressind);
if (progressind) m_pck.progressIndicator([this, &progressind](unsigned rem) {
progressind(rem, m_pck.lastResult().size() - 1);
});
if (stopcond) m_pck.stopCondition(stopcond);
m_pck.configure(m_pconf);
@ -462,7 +464,7 @@ void _arrange(
std::vector<Item> & excludes,
const BinT & bin,
const ArrangeParams &params,
std::function<void(unsigned)> progressfn,
std::function<void(unsigned, unsigned)> progressfn,
std::function<bool()> stopfn)
{
// Integer ceiling the min distance from the bed perimeters

View file

@ -74,7 +74,7 @@ struct ArrangeParams {
/// The accuracy of optimization.
/// Goes from 0.0 to 1.0 and scales performance as well
float accuracy = 0.65f;
float accuracy = 1.f;
/// Allow parallel execution.
bool parallel = true;
@ -83,7 +83,8 @@ struct ArrangeParams {
/// Progress indicator callback called when an object gets packed.
/// The unsigned argument is the number of items remaining to pack.
std::function<void(unsigned)> progressind;
/// Second is the current bed idx being filled.
std::function<void(unsigned, unsigned /*bed_idx*/)> progressind;
/// A predicate returning true if abort is needed.
std::function<bool(void)> stopcondition;