diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 22be036ae..2068b4e2b 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -772,6 +772,7 @@ void GCodeProcessorResult::reset() { filament_diameters = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_DIAMETER); filament_densities = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_DENSITY); custom_gcode_per_print_z = std::vector(); + spiral_vase_layers = std::vector>>(); time = 0; //BBS: add mutex for protection of gcode result @@ -797,6 +798,7 @@ void GCodeProcessorResult::reset() { required_nozzle_HRC = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_HRC); filament_densities = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_DENSITY); custom_gcode_per_print_z = std::vector(); + spiral_vase_layers = std::vector>>(); warnings.clear(); //BBS: add mutex for protection of gcode result @@ -944,6 +946,10 @@ void GCodeProcessor::apply_config(const PrintConfig& config) m_first_layer_height = std::abs(initial_layer_print_height->value); m_result.printable_height = config.printable_height; + + const ConfigOptionBool* spiral_vase = config.option("spiral_mode"); + if (spiral_vase != nullptr) + m_spiral_vase_active = spiral_vase->value; } void GCodeProcessor::apply_config(const DynamicPrintConfig& config) @@ -1206,6 +1212,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) const ConfigOptionFloat* printable_height = config.option("printable_height"); if (printable_height != nullptr) m_result.printable_height = printable_height->value; + + const ConfigOptionBool* spiral_vase = config.option("spiral_mode"); + if (spiral_vase != nullptr) + m_spiral_vase_active = spiral_vase->value; } void GCodeProcessor::enable_stealth_time_estimator(bool enabled) @@ -1276,6 +1286,8 @@ void GCodeProcessor::reset() m_options_z_corrector.reset(); + m_spiral_vase_active = false; + #if ENABLE_GCODE_VIEWER_DATA_CHECKING m_mm3_per_mm_compare.reset(); m_height_compare.reset(); @@ -2022,6 +2034,18 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers // layer change tag if (comment == reserved_tag(ETags::Layer_Change)) { ++m_layer_id; + if (m_spiral_vase_active) { + if (m_result.moves.empty() || m_result.spiral_vase_layers.empty()) + // add a placeholder for layer height. the actual value will be set inside process_G1() method + m_result.spiral_vase_layers.push_back({ FLT_MAX, { 0, 0 } }); + else { + const size_t move_id = m_result.moves.size() - 1; + if (!m_result.spiral_vase_layers.empty()) + m_result.spiral_vase_layers.back().second.second = move_id; + // add a placeholder for layer height. the actual value will be set inside process_G1() method + m_result.spiral_vase_layers.push_back({ FLT_MAX, { move_id, move_id } }); + } + } return; } @@ -2904,6 +2928,14 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) m_seams_detector.set_first_vertex(m_result.moves.back().position - m_extruder_offsets[m_extruder_id] - plate_offset); } + if (m_spiral_vase_active && !m_result.spiral_vase_layers.empty()) { + if (m_result.spiral_vase_layers.back().first == FLT_MAX && delta_pos[Z] > 0.0) + // replace layer height placeholder with correct value + m_result.spiral_vase_layers.back().first = static_cast(m_end_position[Z]); + if (!m_result.moves.empty()) + m_result.spiral_vase_layers.back().second.second = m_result.moves.size() - 1; + } + // store move store_move_vertex(type); } diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index d29b18f32..6d03d7d45 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -165,6 +165,7 @@ namespace Slic3r { std::vector filament_vitrification_temperature; PrintEstimatedStatistics print_statistics; std::vector custom_gcode_per_print_z; + std::vector>> spiral_vase_layers; //BBS std::vector warnings; int nozzle_hrc; @@ -193,6 +194,7 @@ namespace Slic3r { filament_densities = other.filament_densities; print_statistics = other.print_statistics; custom_gcode_per_print_z = other.custom_gcode_per_print_z; + spiral_vase_layers = other.spiral_vase_layers; warnings = other.warnings; #if ENABLE_GCODE_VIEWER_STATISTICS time = other.time; @@ -630,6 +632,7 @@ namespace Slic3r { SeamsDetector m_seams_detector; OptionsZCorrector m_options_z_corrector; size_t m_last_default_color_id; + bool m_spiral_vase_active; #if ENABLE_GCODE_VIEWER_STATISTICS std::chrono::time_point m_start_time; #endif // ENABLE_GCODE_VIEWER_STATISTICS diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 369486056..03b8bb6d8 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3082,6 +3082,13 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result, const } m_plater_extruder = plater_extruder; + // replace layers for spiral vase mode + if (!gcode_result.spiral_vase_layers.empty()) { + m_layers.reset(); + for (const auto& layer : gcode_result.spiral_vase_layers) { + m_layers.append(layer.first, { layer.second.first, layer.second.second }); + } + } // set layers z range if (!m_layers.empty())