Print bed not considered as object in arrange anymore.

This commit is contained in:
tamasmeszaros 2019-06-24 13:01:52 +02:00
parent fab3634931
commit 121b6c078b
2 changed files with 23 additions and 17 deletions

View File

@ -191,6 +191,15 @@ template<class C> bool all_of(const C &container) {
});
}
template<class X, class Y> inline X ceil_i(X x, Y y)
{
static_assert(std::is_integral<X>::value &&
std::is_integral<Y>::value && sizeof(X) >= sizeof(Y),
"");
return (x % y) ? x / y + 1 : x / y;
}
}
#endif // MTUTILS_HPP

View File

@ -2,6 +2,7 @@
#include "Model.hpp"
#include "Geometry.hpp"
#include "SVG.hpp"
#include "MTUtils.hpp"
#include <libnest2d.h>
@ -821,14 +822,12 @@ bool arrange(Model &model, // The model with the geometries
auto& cfn = stopcondition;
auto binbb = Box({
static_cast<libnest2d::Coord>(bbb.min(0)),
static_cast<libnest2d::Coord>(bbb.min(1))
},
{
static_cast<libnest2d::Coord>(bbb.max(0)),
static_cast<libnest2d::Coord>(bbb.max(1))
});
coord_t md = ceil_i(min_obj_distance, 2) - SCALED_EPSILON;
auto binbb = Box({libnest2d::Coord{bbb.min(0)} - md,
libnest2d::Coord{bbb.min(1)} - md},
{libnest2d::Coord{bbb.max(0)} + md,
libnest2d::Coord{bbb.max(1)} + md});
switch(bedhint.type) {
case BedShapeType::BOX: {
@ -917,14 +916,12 @@ void find_new_position(const Model &model,
BoundingBox bbb(bed);
auto binbb = Box({
static_cast<libnest2d::Coord>(bbb.min(0)),
static_cast<libnest2d::Coord>(bbb.min(1))
},
{
static_cast<libnest2d::Coord>(bbb.max(0)),
static_cast<libnest2d::Coord>(bbb.max(1))
});
coord_t md = ceil_i(min_obj_distance, 2) - SCALED_EPSILON;
auto binbb = Box({libnest2d::Coord{bbb.min(0)} - md,
libnest2d::Coord{bbb.min(1)} - md},
{libnest2d::Coord{bbb.max(0)} + md,
libnest2d::Coord{bbb.max(1)} + md});
for(auto it = shapemap.begin(); it != shapemap.end(); ++it) {
if(std::find(toadd.begin(), toadd.end(), it->first) == toadd.end()) {