mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 15:07:31 -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
|
@ -502,10 +502,10 @@ void ArrangeJob::process()
|
|||
partplate_list.preprocess_nonprefered_areas(m_unselected, MAX_NUM_PLATES);
|
||||
|
||||
update_arrange_params(params, *m_plater, m_selected);
|
||||
update_selected_items_inflation(m_selected, *m_plater, params);
|
||||
update_unselected_items_inflation(m_unselected, *m_plater, params);
|
||||
update_selected_items_inflation(m_selected, m_plater->config(), params);
|
||||
update_unselected_items_inflation(m_unselected, m_plater->config(), params);
|
||||
|
||||
Points bedpts = get_shrink_bedpts(*m_plater,params);
|
||||
Points bedpts = get_shrink_bedpts(m_plater->config(),params);
|
||||
double scaled_exclusion_gap = scale_(1);
|
||||
partplate_list.preprocess_exclude_areas(params.excluded_regions, 1, scaled_exclusion_gap);
|
||||
|
||||
|
@ -519,6 +519,7 @@ void ArrangeJob::process()
|
|||
};
|
||||
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug)<< "Arrange full params: "<< params.to_json();
|
||||
BOOST_LOG_TRIVIAL(debug) << "items selected before arrange: ";
|
||||
for (auto selected : m_selected)
|
||||
BOOST_LOG_TRIVIAL(debug) << selected.name << ", extruder: " << selected.extrude_ids.back() << ", bed: " << selected.bed_idx
|
||||
|
@ -758,7 +759,7 @@ arrangement::ArrangeParams init_arrange_params(Plater *p)
|
|||
return params;
|
||||
}
|
||||
|
||||
//after get selected.call this to update bed_shrink
|
||||
//after get selected call this to update bed_shrink
|
||||
void update_arrange_params(arrangement::ArrangeParams ¶ms, const Plater &p, const arrangement::ArrangePolygons &selected)
|
||||
{
|
||||
const GLCanvas3D::ArrangeSettings &settings = static_cast<const GLCanvas3D *>(p.canvas3D())->get_arrange_settings();
|
||||
|
@ -779,55 +780,4 @@ void update_arrange_params(arrangement::ArrangeParams ¶ms, const Plater &p,
|
|||
}
|
||||
}
|
||||
|
||||
//it will bed accurate after call update_params
|
||||
Points get_shrink_bedpts(const Plater &plater, const arrangement::ArrangeParams ¶ms)
|
||||
{
|
||||
Points bedpts = get_bed_shape(*plater.config());
|
||||
// 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;
|
||||
}
|
||||
|
||||
void update_selected_items_inflation(arrangement::ArrangePolygons &selected, const Plater &p, const arrangement::ArrangeParams ¶ms) {
|
||||
// do not inflate brim_width. Objects are allowed to have overlapped brim.
|
||||
Points bedpts = get_shrink_bedpts(p, 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(arrangement::ArrangePolygons &unselected, const Plater &p, const arrangement::ArrangeParams ¶ms)
|
||||
{
|
||||
if (params.is_seq_print) {
|
||||
float shift_dist = params.cleareance_radius / 2 - 5;
|
||||
// dont forget to move the excluded region
|
||||
for (auto ®ion : 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); });
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue