diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 6340a7af5c..f3d218750b 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -42,6 +42,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config) }; m_max_jerk_z = print_config.machine_max_jerk_z.values.front(); m_max_jerk_e = print_config.machine_max_jerk_e.values.front(); + m_resolution = print_config.resolution.value; } void GCodeWriter::set_extruders(std::vector extruder_ids) @@ -787,8 +788,18 @@ std::string GCodeWriter::_spiral_travel_to_z(double z, const Vec2d &ij_offset, c if (!this->config.enable_arc_fitting) { // Orca: if arc fitting is disabled, approximate the arc with small linear segments std::ostringstream oss; - const double z_start = m_pos(2); // starting Z height - const int segments = 24; // number of linear segments to use for approximating the arc + const double z_start = m_pos(2); // starting Z height + + // -------------------------------------------------------------------- + // Determine number of segments based on Resolution + // -------------------------------------------------------------------- + const double ref_resolution = 0.01; // reference resolution in mm + const double ref_segments = 16.0; // reference number of segments at reference resolution + + // number of linear segments to use for approximating the arc, clamp between 4 and 24 + const int segments = std::clamp(int(std::round(ref_segments * (ref_resolution / m_resolution))), 4, 24); + // -------------------------------------------------------------------- + const double px = m_pos(0) - m_x_offset; // take plate offset into consideration const double py = m_pos(1) - m_y_offset; // take plate offset into consideration const double cx = px + ij_offset(0); // center x diff --git a/src/libslic3r/GCodeWriter.hpp b/src/libslic3r/GCodeWriter.hpp index 729c89263e..32e737164d 100644 --- a/src/libslic3r/GCodeWriter.hpp +++ b/src/libslic3r/GCodeWriter.hpp @@ -168,6 +168,9 @@ public: //BBS: x, y offset for gcode generated double m_x_offset{ 0 }; double m_y_offset{ 0 }; + + // Orca: slicing resolution in mm + double m_resolution = 0.01; std::string m_gcode_label_objects_start; std::string m_gcode_label_objects_end;