diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 35092335f3..0bba48b430 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2666,21 +2666,18 @@ std::optional 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, diff --git a/src/libslic3r/GCode/LayerChanges.cpp b/src/libslic3r/GCode/LayerChanges.cpp index 826c01347a..bb6656383a 100644 --- a/src/libslic3r/GCode/LayerChanges.cpp +++ b/src/libslic3r/GCode/LayerChanges.cpp @@ -43,6 +43,11 @@ Polygon Bed::get_inner_offset(const std::vector &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