From e58a15bdf8e89270df8a84456fc66e5161c09be0 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 7 Jul 2022 15:51:41 +0200 Subject: [PATCH] Prepare arrange for variable bed distance --- src/libslic3r/Arrange.cpp | 2 +- src/libslic3r/Arrange.hpp | 19 +++++++++++-------- src/slic3r/GUI/GLCanvas3D.hpp | 3 ++- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 1 + 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 8227ea4ad6..a313c46263 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -489,7 +489,7 @@ void _arrange( { // Integer ceiling the min distance from the bed perimeters coord_t md = params.min_obj_distance; - md = md / 2; + md = md / 2 - params.min_bed_distance; auto corrected_bin = bin; sl::offset(corrected_bin, md); diff --git a/src/libslic3r/Arrange.hpp b/src/libslic3r/Arrange.hpp index 47171007ac..02d05e3e48 100644 --- a/src/libslic3r/Arrange.hpp +++ b/src/libslic3r/Arrange.hpp @@ -49,11 +49,11 @@ struct ArrangePolygon { coord_t inflation = 0; /// Arrange with inflated polygon int bed_idx{UNARRANGED}; /// To which logical bed does poly belong... int priority{0}; - + // If empty, any rotation is allowed (currently unsupported) // If only a zero is there, no rotation is allowed std::vector allowed_rotations = {0.}; - + /// Optional setter function which can store arbitrary data in its closure std::function setter = nullptr; @@ -76,29 +76,32 @@ struct ArrangePolygon { using ArrangePolygons = std::vector; struct ArrangeParams { - + /// The minimum distance which is allowed for any /// pair of items on the print bed in any direction. coord_t min_obj_distance = 0; - + + /// The minimum distance of any object from bed edges + coord_t min_bed_distance = 0; + /// The accuracy of optimization. /// Goes from 0.0 to 1.0 and scales performance as well float accuracy = 1.f; - + /// Allow parallel execution. bool parallel = true; bool allow_rotations = false; - + /// Progress indicator callback called when an object gets packed. /// The unsigned argument is the number of items remaining to pack. std::function progressind; std::function on_packed; - + /// A predicate returning true if abort is needed. std::function stopcondition; - + ArrangeParams() = default; explicit ArrangeParams(coord_t md) : min_obj_distance(md) {} }; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index a5b2acb32d..e5d199a932 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -476,7 +476,8 @@ public: struct ArrangeSettings { - float distance = 6.; + float distance = 6.f; + float distance_from_bed = 0.f; // float distance_seq_print = 6.; // Used when sequential print is ON // float distance_sla = 6.; float accuracy = 0.65f; // Unused currently diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index 3c7dad0a61..e75304d7aa 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -286,6 +286,7 @@ arrangement::ArrangeParams get_arrange_params(Plater *p) arrangement::ArrangeParams params; params.allow_rotations = settings.enable_rotation; params.min_obj_distance = scaled(settings.distance); + params.min_bed_distance = scaled(settings.distance_from_bed); return params; }