diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2019-07-15 18:30:44 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2019-07-15 18:30:44 +0300 |
commit | 1b0e192046e358ba34941d1895f86c94ad6c6ac0 (patch) | |
tree | 6acd90f4b75a38424d8391358fcd6098824688f4 /src/libnest2d/include | |
parent | df7bb94dafea6a64922184fe65db3c61f7c85da0 (diff) |
Arrange cache in ModeInstance and logical bed remembered.
Diffstat (limited to 'src/libnest2d/include')
-rw-r--r-- | src/libnest2d/include/libnest2d/libnest2d.hpp | 47 | ||||
-rw-r--r-- | src/libnest2d/include/libnest2d/selections/firstfit.hpp | 9 |
2 files changed, 7 insertions, 49 deletions
diff --git a/src/libnest2d/include/libnest2d/libnest2d.hpp b/src/libnest2d/include/libnest2d/libnest2d.hpp index a83a16ecf..11c032fae 100644 --- a/src/libnest2d/include/libnest2d/libnest2d.hpp +++ b/src/libnest2d/include/libnest2d/libnest2d.hpp @@ -127,25 +127,6 @@ public: inline _Item(TContour<RawShape>&& contour, THolesContainer<RawShape>&& holes): sh_(sl::create<RawShape>(std::move(contour), std::move(holes))) {} - -// template<class... Args> -// _Item(std::function<void(const _Item&, unsigned)> applyfn, Args &&... args): -// _Item(std::forward<Args>(args)...) -// { -// applyfn_ = std::move(applyfn); -// } - - // Call the apply callback set in constructor. Within the callback, the - // original caller can apply the stored transformation to the original - // objects inteded for nesting. It might not be the shape handed over - // to _Item (e.g. arranging 3D shapes based on 2D silhouette or the - // client uses a simplified or processed polygon for nesting) - // This callback, if present, will be called for each item after the nesting - // is finished. -// inline void callApplyFunction(unsigned binidx) const -// { -// if (applyfn_) applyfn_(*this, binidx); -// } inline bool isFixed() const noexcept { return fixed_; } inline void markAsFixed(bool fixed = true) { fixed_ = fixed; } @@ -881,34 +862,6 @@ public: { return selector_.getResult(); } - -private: - - - // This function will be used only if the iterators are pointing to - // a type compatible with the libnets2d::_Item template. - // This way we can use references to input elements as they will - // have to exist for the lifetime of this call. -// template<class It, class Key> -// inline ConvertibleOnly<It, void> _execute(It from, It to) -// { -// __execute(from, to); -// } - -// template<class It> inline void _execute(It from, It to) -// { -// auto infl = static_cast<Coord>(std::ceil(min_obj_distance_/2.0)); -// if(infl > 0) std::for_each(from, to, [this](Item& item) { -// item.inflate(infl); -// }); - -// selector_.template packItems<PlacementStrategy>( -// from, to, bin_, pconfig_); - -// if(min_obj_distance_ > 0) std::for_each(from, to, [](Item& item) { -// item.inflate(-infl); -// }); -// } }; } diff --git a/src/libnest2d/include/libnest2d/selections/firstfit.hpp b/src/libnest2d/include/libnest2d/selections/firstfit.hpp index 6a3e2e61b..74207f8cf 100644 --- a/src/libnest2d/include/libnest2d/selections/firstfit.hpp +++ b/src/libnest2d/include/libnest2d/selections/firstfit.hpp @@ -42,8 +42,13 @@ public: std::for_each(first, last, [this](Item& itm) { if(itm.isFixed()) { - if(packed_bins_.empty()) packed_bins_.emplace_back(); - packed_bins_.front().emplace_back(itm); + if (itm.binId() < 0) itm.binId(0); + auto binidx = size_t(itm.binId()); + + while(packed_bins_.size() <= binidx) + packed_bins_.emplace_back(); + + packed_bins_[binidx].emplace_back(itm); } else { store_.emplace_back(itm); } |