Don't arrange items if the bed has negative area

Also interpret a bounding box with maxCorner lower then minCorner as a negative area box
This commit is contained in:
tamasmeszaros 2022-09-13 16:51:20 +02:00
parent 3e53abf9bd
commit 6197acf576
2 changed files with 13 additions and 6 deletions

View File

@ -200,7 +200,8 @@ public:
template<class Unit = TCompute<P>>
inline Unit area() const BP2D_NOEXCEPT {
return Unit(width())*height();
Unit s = std::signbit(width()) || std::signbit(height()) ? Unit(-1) : Unit(1);
return s * libnest2d::abs(width() * height());
}
static inline _Box infinite(const P &center = {TCoord<P>(0), TCoord<P>(0)});

View File

@ -528,7 +528,13 @@ void _arrange(
}
}
if (sl::area(corrected_bin) > 0)
arranger(inp.begin(), inp.end());
else {
for (Item &itm : inp)
itm.binId(BIN_ID_UNSET);
}
for (Item &itm : inp) itm.inflate(-infl);
}