Fix tree support bed exclusion area calculation (#9633)

Fix tree support bed exclusion area calculation (SoftFever/OrcaSlicer#9624)
This commit is contained in:
Noisyfox 2025-06-01 13:18:03 +08:00 committed by GitHub
parent c93e321ef0
commit 4ae4634976
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 46 deletions

View file

@ -8154,22 +8154,27 @@ Points get_bed_shape(const PrintConfig &cfg)
Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(make_counter_clockwise(cfg.printable_area.values)); }
Polygons get_bed_excluded_area(const PrintConfig& cfg)
{
const Pointfs exclude_area_points = cfg.bed_exclude_area.values;
Polygon exclude_poly;
for (int i = 0; i < exclude_area_points.size(); i++) {
auto pt = exclude_area_points[i];
exclude_poly.points.emplace_back(scale_(pt.x()), scale_(pt.y()));
}
exclude_poly.make_counter_clockwise();
return {exclude_poly};
}
Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg)
{
Polygon bed_poly;
bed_poly.points = get_bed_shape(cfg);
Points excluse_area_points = to_points(cfg.bed_exclude_area.values);
Polygons exclude_polys;
Polygon exclude_poly;
for (int i = 0; i < excluse_area_points.size(); i++) {
auto pt = excluse_area_points[i];
exclude_poly.points.emplace_back(pt);
if (i % 4 == 3) { // exclude areas are always rectangle
exclude_polys.push_back(exclude_poly);
exclude_poly.points.clear();
}
}
Polygons exclude_polys = get_bed_excluded_area(cfg);
auto tmp = diff({ bed_poly }, exclude_polys);
if (!tmp.empty()) bed_poly = tmp[0];
return bed_poly;