From 875fb6892f36a03706f4de0ad23e059ba9b42dcb Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 20 Sep 2022 10:53:42 +0200 Subject: [PATCH] Fix partial arrange behavior --- .../include/libnest2d/placers/nfpplacer.hpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp index 00f6a999f..5b5311d90 100644 --- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp +++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp @@ -509,28 +509,24 @@ public: return diff; } - template> - PackResult trypack(Item& item, - const Range& remaining = Range()) { - auto result = _trypack(item, remaining); - - // Experimental - // if(!result) repack(item, result); - - return result; - } - ~_NofitPolyPlacer() { clearItems(); } inline void clearItems() { finalAlign(bin_); + merged_pile_ = {}; Base::clearItems(); } void preload(const ItemGroup& packeditems) { Base::preload(packeditems); + + for (const Item& itm : packeditems) + merged_pile_.emplace_back(itm.transformedShape()); + + nfp::merge(merged_pile_); + if (config_.on_preload) config_.on_preload(packeditems, config_); } @@ -606,8 +602,9 @@ private: using Edges = EdgeCache; +public: template> - PackResult _trypack( + PackResult trypack( Item& item, const Range& remaining = Range()) { @@ -897,6 +894,7 @@ private: return ret; } +private: inline void finalAlign(const RawShape& pbin) { auto bbin = sl::boundingBox(pbin); finalAlign(bbin);