fix rotation for initial placement

This commit is contained in:
tamasmeszaros 2020-11-30 20:48:45 +01:00
parent 8027f6608a
commit 3e73473334

View File

@ -663,12 +663,6 @@ private:
remlist.insert(remlist.end(), remaining.from, remaining.to); remlist.insert(remlist.end(), remaining.from, remaining.to);
} }
if(items_.empty()) {
setInitialPosition(item);
best_overfit = overfit(item.transformedShape(), bin_);
can_pack = best_overfit <= 0;
} else {
double global_score = std::numeric_limits<double>::max(); double global_score = std::numeric_limits<double>::max();
auto initial_tr = item.translation(); auto initial_tr = item.translation();
@ -719,6 +713,29 @@ private:
}; };
} }
if(items_.empty()) {
setInitialPosition(item);
auto best_tr = item.translation();
auto best_rot = item.rotation();
best_overfit = overfit(item.transformedShape(), bin_);
for(auto rot : config_.rotations) {
item.translation(initial_tr);
item.rotation(initial_rot + rot);
setInitialPosition(item);
double of = 0.;
if ((of = overfit(item.transformedShape(), bin_)) < best_overfit) {
best_overfit = of;
best_tr = item.translation();
best_rot = item.rotation();
}
}
can_pack = best_overfit <= 0;
item.rotation(best_rot);
item.translation(best_tr);
} else {
Pile merged_pile = merged_pile_; Pile merged_pile = merged_pile_;
for(auto rot : config_.rotations) { for(auto rot : config_.rotations) {
@ -948,10 +965,9 @@ private:
if(items_.empty() || if(items_.empty() ||
config_.alignment == Config::Alignment::DONT_ALIGN) return; config_.alignment == Config::Alignment::DONT_ALIGN) return;
nfp::Shapes<RawShape> m; Box bb = items_.front().get().boundingBox();
m.reserve(items_.size()); for(Item& item : items_)
for(Item& item : items_) m.emplace_back(item.transformedShape()); bb = sl::boundingBox(item.boundingBox(), bb);
auto&& bb = sl::boundingBox(m);
Vertex ci, cb; Vertex ci, cb;