From 50424e33c6645873ce423ca92527fa745d28a194 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 17 Jul 2018 16:35:48 +0200 Subject: [PATCH] Safety check for firstfit for larger objects than the print bed. --- xs/src/libnest2d/libnest2d/selections/firstfit.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xs/src/libnest2d/libnest2d/selections/firstfit.hpp b/xs/src/libnest2d/libnest2d/selections/firstfit.hpp index 8a8a09f910..2253a0dfee 100644 --- a/xs/src/libnest2d/libnest2d/selections/firstfit.hpp +++ b/xs/src/libnest2d/libnest2d/selections/firstfit.hpp @@ -55,6 +55,18 @@ public: this->progress_(--total); }; + // Safety test: try to pack each item into an empty bin. If it fails + // then it should be removed from the not_packed list + { auto it = store_.begin(); + while (it != store_.end()) { + Placer p(bin); + if(!p.pack(*it)) { + auto itmp = it++; + store_.erase(itmp); + } else it++; + } + } + for(auto& item : store_ ) { bool was_packed = false; while(!was_packed) {