Add explicit minimum bed distance (10mm) for XL printers when arranging

This commit is contained in:
tamasmeszaros 2023-03-06 13:57:49 +01:00
parent 0726b0b5c6
commit 16793273a1
3 changed files with 20 additions and 2 deletions

View file

@ -687,7 +687,9 @@ void arrange(ArrangePolygons &items,
const SegmentedRectangleBed &bed,
const ArrangeParams &params)
{
arrange(items, excludes, bed.bb, params);
auto arrbed = bed.bb;
arrbed.offset(-bed.inset);
arrange(items, excludes, arrbed, params);
if (! excludes.empty())
return;
@ -744,6 +746,19 @@ void arrange(ArrangePolygons &items,
Vec2crd d = bb.center() - pilebb[bedidx].center();
auto bedbb = bed.bb;
bedbb.offset(-bed.inset);
auto pilebbx = pilebb[bedidx];
pilebbx.translate(d);
Point corr{0, 0};
corr.x() = -std::min(0, pilebbx.min.x() - bedbb.min.x())
-std::max(0, pilebbx.max.x() - bedbb.max.x());
corr.y() = -std::min(0, pilebbx.min.y() - bedbb.min.y())
-std::max(0, pilebbx.max.y() - bedbb.max.y());
d += corr;
for (auto &itm : items)
if (itm.bed_idx == bedidx)
itm.translation += d;

View file

@ -38,6 +38,7 @@ public:
struct SegmentedRectangleBed {
Vec<2, size_t> segments;
BoundingBox bb;
coord_t inset = 0;
SegmentedRectangleBed (const BoundingBox &bb,
size_t segments_x,

View file

@ -4663,7 +4663,9 @@ Points get_bed_shape(const DynamicPrintConfig &config)
void get_bed_shape(const DynamicPrintConfig &cfg, arrangement::ArrangeBed &out)
{
if (is_XL_printer(cfg)) {
out = arrangement::SegmentedRectangleBed{get_extents(get_bed_shape(cfg)), 4, 4};
arrangement::SegmentedRectangleBed bed{get_extents(get_bed_shape(cfg)), 4, 4};
bed.inset = scaled(10.);
out = bed;
} else {
out = arrangement::to_arrange_bed(get_bed_shape(cfg));
}