ENH: large object with size close to bed could arrange into bed

Change large object's inflation to (bedsize-objectsize)/2 when it could actually be placed into bed but couldn't with default inflation.
JIRA: STUDIO-1536

Change-Id: Ibf8ed066ee20a9a7b1c604371a9e030c94711080
(cherry picked from commit 093bad1a1765f05d909984d24a113e125870d55b)
This commit is contained in:
miaoxin 2022-12-06 17:10:35 +08:00 committed by Lane.Wei
parent 41c310bf25
commit ad22dec6d9
1 changed files with 12 additions and 2 deletions

View File

@ -534,7 +534,18 @@ void ArrangeJob::process()
}
// do not inflate brim_width. Objects are allowed to have overlapped brim.
std::for_each(m_selected.begin(), m_selected.end(), [&](auto& ap) {ap.inflation = params.min_obj_distance / 2; });
Points bedpts = get_bed_shape(*m_plater->config());
BoundingBox bedbb = Polygon(bedpts).bounding_box();
std::for_each(m_selected.begin(), m_selected.end(), [&](ArrangePolygon &ap) {
ap.inflation = params.min_obj_distance / 2;
BoundingBox apbb = ap.poly.contour.bounding_box();
coord_t diffx = bedbb.size().x() - apbb.size().x();
coord_t diffy = bedbb.size().y() - apbb.size().y();
if (diffx > 0 && diffy > 0) {
coord_t min_diff = std::min(diffx, diffy);
ap.inflation = std::min(min_diff / 2, ap.inflation);
}
});
// 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可以长过去。
@ -551,7 +562,6 @@ void ArrangeJob::process()
partplate_list.preprocess_exclude_areas(params.excluded_regions, 1, scaled_exclusion_gap);
// shrink bed by moving to center by dist
Points bedpts = get_bed_shape(*m_plater->config());
auto shrinkFun = [](Points& bedpts, double dist, int direction) {
#define SGN(x) ((x)>=0?1:-1)
Point center = Polygon(bedpts).bounding_box().center();