Fix SPE-2068: Helical layer change generating travels out of bounds.

This commit is contained in:
Martin Šach 2023-12-06 10:50:13 +01:00
parent e298593a2e
commit c3132e91c8
2 changed files with 12 additions and 10 deletions

View File

@ -2666,21 +2666,18 @@ std::optional<std::string> GCodeGenerator::get_helical_layer_change_gcode(
const Point n_gon_start_point{this->last_pos()};
static GCode::Impl::LayerChanges::Bed bed{
GCode::Impl::LayerChanges::Bed bed{
this->m_config.bed_shape.values,
circle_radius
circle_radius * 2
};
if (!bed.contains_within_padding(this->point_to_gcode(n_gon_start_point))) {
return std::nullopt;
}
const Point n_gon_centeroid{
n_gon_start_point
+ scaled(Vec2d{
(bed.centroid - unscaled(n_gon_start_point)).normalized()
* circle_radius
})
};
const Vec2crd n_gon_vector{scaled(Vec2d{
(bed.centroid - this->point_to_gcode(n_gon_start_point)).normalized() * circle_radius
})};
const Point n_gon_centeroid{n_gon_start_point + n_gon_vector};
const Polygon n_gon{GCode::Impl::LayerChanges::generate_regular_polygon(
n_gon_centeroid,

View File

@ -43,6 +43,11 @@ Polygon Bed::get_inner_offset(const std::vector<Vec2d> &shape, const double padd
transform(begin(shape), end(shape), back_inserter(shape_scaled), [](const Vec2d &point) {
return scaled(point);
});
return shrink({Polygon{shape_scaled}}, scaled(padding)).front();
const Polygons inner_offset{shrink({Polygon{shape_scaled}}, scaled(padding))};
if (inner_offset.empty()) {
return Polygon{};
}
return inner_offset.front();
}
} // namespace Slic3r::GCode::Impl::LayerChanges