Ensure bed shape is in correct orientation (#9350)

Fix #9345

This also fixes deltamaker's plate logo rendering:
![image](https://github.com/user-attachments/assets/517c9b3c-8eee-4081-a2bc-5913fe35328b)

And fix bed rendering issue for custom shaped bed without model:
![image](https://github.com/user-attachments/assets/9643413e-9b1c-4e74-afe8-edf2306e7021)


Also fix rendering of exclusion area that are defined in clockwise:
![image](https://github.com/user-attachments/assets/0949c1c3-6304-4ece-85c7-f3162249bf90)
This commit is contained in:
SoftFever
2025-05-01 17:28:10 +08:00
committed by GitHub
15 changed files with 42 additions and 28 deletions

View File

@@ -14,6 +14,7 @@ BuildVolume::BuildVolume(const std::vector<Vec2d> &printable_area, const double
assert(printable_height >= 0);
m_polygon = Polygon::new_scale(printable_area);
assert(m_polygon.is_counter_clockwise());
// Calcuate various metrics of the input polygon.
m_convex_hull = Geometry::convex_hull(m_polygon.points);

View File

@@ -1410,4 +1410,14 @@ ExPolygons variable_offset_inner_ex(const ExPolygon &expoly, const std::vector<s
return output;
}
Pointfs make_counter_clockwise(const Pointfs& pointfs)
{
Pointfs ps = pointfs;
if (Polygon::new_scale(pointfs).is_clockwise()) {
std::reverse(ps.begin(), ps.end());
}
return ps;
}
}

View File

@@ -661,6 +661,8 @@ Polygons variable_offset_outer(const ExPolygon &expoly, const std::vector<std::
ExPolygons variable_offset_outer_ex(const ExPolygon &expoly, const std::vector<std::vector<float>> &deltas, double miter_limit = 2.);
ExPolygons variable_offset_inner_ex(const ExPolygon &expoly, const std::vector<std::vector<float>> &deltas, double miter_limit = 2.);
Pointfs make_counter_clockwise(const Pointfs& pointfs);
} // namespace Slic3r
#endif // slic3r_ClipperUtils_hpp_

View File

@@ -831,7 +831,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
const ConfigOptionPoints* printable_area = config.option<ConfigOptionPoints>("printable_area");
if (printable_area != nullptr)
m_result.printable_area = printable_area->values;
m_result.printable_area = make_counter_clockwise(printable_area->values);
//BBS: add bed_exclude_area
const ConfigOptionPoints* bed_exclude_area = config.option<ConfigOptionPoints>("bed_exclude_area");

View File

@@ -8117,15 +8117,15 @@ Points get_bed_shape(const DynamicPrintConfig &config)
return {};
}
return to_points(bed_shape_opt->values);
return to_points(make_counter_clockwise(bed_shape_opt->values));
}
Points get_bed_shape(const PrintConfig &cfg)
{
return to_points(cfg.printable_area.values);
return to_points(make_counter_clockwise(cfg.printable_area.values));
}
Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(cfg.printable_area.values); }
Points get_bed_shape(const SLAPrinterConfig &cfg) { return to_points(make_counter_clockwise(cfg.printable_area.values)); }
Polygon get_bed_shape_with_excluded_area(const PrintConfig& cfg)
{