mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
FIX: unify cli and GUI auto-arrange
Make sure cli uses same params as GUI's auto-arrange. Previously cli uses wrong skirt_distance. Jira: BLPIOT-255 Change-Id: Iaccfb76acf7413ec614fff006feb770dcd6783cf
This commit is contained in:
parent
f6ac8b60b7
commit
064f3ee0aa
8 changed files with 136 additions and 99 deletions
|
@ -80,6 +80,75 @@ using ItemGroup = std::vector<std::reference_wrapper<Item>>;
|
|||
const double BIG_ITEM_TRESHOLD = 0.02;
|
||||
#define VITRIFY_TEMP_DIFF_THRSH 15 // bed temp can be higher than vitrify temp, but not higher than this thresh
|
||||
|
||||
void update_arrange_params(ArrangeParams& params, const DynamicPrintConfig& print_cfg, const ArrangePolygons& selected)
|
||||
{
|
||||
double skirt_distance = get_real_skirt_dist(print_cfg);
|
||||
double brim_max = 0;
|
||||
std::for_each(selected.begin(), selected.end(), [&](const ArrangePolygon& ap) { brim_max = std::max(brim_max, ap.brim_width); });
|
||||
// Note: skirt_distance is now defined between outermost brim and skirt, not the object and skirt.
|
||||
// So we can't do max but do adding instead.
|
||||
params.brim_skirt_distance = skirt_distance + brim_max;
|
||||
params.bed_shrink_x = params.brim_skirt_distance;
|
||||
params.bed_shrink_y = params.brim_skirt_distance;
|
||||
// for sequential print, we need to inflate the bed because cleareance_radius is so large
|
||||
if (params.is_seq_print) {
|
||||
float shift_dist = params.cleareance_radius / 2 - 5;
|
||||
params.bed_shrink_x -= shift_dist;
|
||||
params.bed_shrink_y -= shift_dist;
|
||||
}
|
||||
}
|
||||
|
||||
void update_selected_items_inflation(ArrangePolygons& selected, const DynamicPrintConfig* print_cfg, const ArrangeParams& params) {
|
||||
// do not inflate brim_width. Objects are allowed to have overlapped brim.
|
||||
Points bedpts = get_shrink_bedpts(print_cfg, params);
|
||||
BoundingBox bedbb = Polygon(bedpts).bounding_box();
|
||||
std::for_each(selected.begin(), selected.end(), [&](ArrangePolygon& ap) {
|
||||
ap.inflation = std::max(scaled(ap.brim_width), params.min_obj_distance / 2);
|
||||
BoundingBox apbb = ap.poly.contour.bounding_box();
|
||||
auto diffx = bedbb.size().x() - apbb.size().x() - 5;
|
||||
auto diffy = bedbb.size().y() - apbb.size().y() - 5;
|
||||
if (diffx > 0 && diffy > 0) {
|
||||
auto min_diff = std::min(diffx, diffy);
|
||||
ap.inflation = std::min(min_diff / 2, ap.inflation);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void update_unselected_items_inflation(ArrangePolygons& unselected, const DynamicPrintConfig* print_cfg, const ArrangeParams& params)
|
||||
{
|
||||
if (params.is_seq_print) {
|
||||
float shift_dist = params.cleareance_radius / 2 - 5;
|
||||
// dont forget to move the excluded region
|
||||
for (auto& region : unselected) {
|
||||
if (region.is_virt_object) region.poly.translate(-scaled(shift_dist), -scaled(shift_dist));
|
||||
}
|
||||
}
|
||||
// For occulusion regions, inflation should be larger to prevent genrating brim on them.
|
||||
// However, extrusion cali regions are exceptional, since we can allow brim overlaps them.
|
||||
// 屏蔽区域只需要膨胀brim宽度,防止brim长过去;挤出标定区域不需要膨胀,brim可以长过去。
|
||||
// 以前我们认为还需要膨胀clearance_radius/2,这其实是不需要的,因为这些区域并不会真的摆放物体,
|
||||
// 其他物体的膨胀轮廓是可以跟它们重叠的。
|
||||
double scaled_exclusion_gap = scale_(1);
|
||||
std::for_each(unselected.begin(), unselected.end(),
|
||||
[&](auto& ap) { ap.inflation = !ap.is_virt_object ? std::max(scaled(ap.brim_width), params.min_obj_distance / 2)
|
||||
: (ap.is_extrusion_cali_object ? 0 : scaled_exclusion_gap); });
|
||||
}
|
||||
|
||||
//it will bed accurate after call update_params
|
||||
Points get_shrink_bedpts(const DynamicPrintConfig* print_cfg, const ArrangeParams& params)
|
||||
{
|
||||
Points bedpts = get_bed_shape(*print_cfg);
|
||||
// shrink bed by moving to center by dist
|
||||
auto shrinkFun = [](Points& bedpts, double dist, int direction) {
|
||||
#define SGN(x) ((x) >= 0 ? 1 : -1)
|
||||
Point center = Polygon(bedpts).bounding_box().center();
|
||||
for (auto& pt : bedpts) pt[direction] += dist * SGN(center[direction] - pt[direction]);
|
||||
};
|
||||
shrinkFun(bedpts, scaled(params.bed_shrink_x), 0);
|
||||
shrinkFun(bedpts, scaled(params.bed_shrink_y), 1);
|
||||
return bedpts;
|
||||
}
|
||||
|
||||
// Fill in the placer algorithm configuration with values carefully chosen for
|
||||
// Slic3r.
|
||||
template<class PConf>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue