From 82d1f31458e7de64f2ce2385e0876c0d4e05bb98 Mon Sep 17 00:00:00 2001 From: FormerLurker Date: Fri, 5 Feb 2021 18:45:34 -0600 Subject: Fix first comment for UltiGcode --- ArcWelder/arc_welder.cpp | 27 ++++++++++++++++++--------- ArcWelder/segmented_arc.h | 1 - ArcWelderTest/ArcWelderTest.cpp | 2 +- GcodeProcessorLib/array_list.h | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ArcWelder/arc_welder.cpp b/ArcWelder/arc_welder.cpp index 5d53a90..c49f64d 100644 --- a/ArcWelder/arc_welder.cpp +++ b/ArcWelder/arc_welder.cpp @@ -250,20 +250,31 @@ arc_welder_results results; p_logger_->log(logger_type_, DEBUG, "Target file opened successfully."); std::string line; int lines_with_no_commands = 0; - //gcodeFile.sync_with_stdio(false); - //output_file_.sync_with_stdio(false); - - add_arcwelder_comment_to_target(); - parsed_command cmd; // Communicate every second p_logger_->log(logger_type_, DEBUG, "Sending initial progress update."); continue_processing = on_progress_(get_progress_(static_cast(gcodeFile.tellg()), static_cast(start_clock))); p_logger_->log(logger_type_, DEBUG, "Processing source file."); + while (std::getline(gcodeFile, line) && continue_processing) { lines_processed_++; - + // Check the first line of gcode and see if it = ;FLAVOR:UltiGCode +// This comment MUST be preserved as the first line for ultimakers, else things won't work + if (lines_processed_ == 1) + { + bool isUltiGCode = line == ";FLAVOR:UltiGCode"; + if (isUltiGCode) + { + write_gcode_to_file(line); + } + add_arcwelder_comment_to_target(); + if (isUltiGCode) + { + lines_with_no_commands++; + continue; + } + } cmd.clear(); if (verbose_logging_enabled_) { @@ -306,7 +317,7 @@ arc_welder_results results; if (current_arc_.is_shape() && waiting_for_arc_) { - p_logger_->log(logger_type_, DEBUG, "The target file opened successfully."); + p_logger_->log(logger_type_, DEBUG, "Processing the final line."); process_gcode(cmd, true, false); } p_logger_->log(logger_type_, DEBUG, "Writing all unwritten gcodes to the target file."); @@ -580,7 +591,6 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess } } - bool arc_generated = false; if (!arc_added && !(cmd.is_empty && cmd.comment.length() == 0)) { if (current_arc_.get_num_segments() < current_arc_.get_min_segments()) { @@ -606,7 +616,6 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess write_arc_gcodes(p_pre_pos->is_extruder_relative, p_pre_pos->f); // Now clear the arc and flag the processor as not waiting for an arc waiting_for_arc_ = false; - arc_generated = true; current_arc_.clear(); p_cur_pos = NULL; p_pre_pos = NULL; diff --git a/ArcWelder/segmented_arc.h b/ArcWelder/segmented_arc.h index 3515143..c67c071 100644 --- a/ArcWelder/segmented_arc.h +++ b/ArcWelder/segmented_arc.h @@ -62,7 +62,6 @@ private: bool try_add_point_internal_(printer_point p); std::string get_shape_gcode_(bool has_e, double e, double f) const; arc current_arc_; - int num_gcode; double max_radius_mm_; int min_arc_segments_; double mm_per_arc_segment_; diff --git a/ArcWelderTest/ArcWelderTest.cpp b/ArcWelderTest/ArcWelderTest.cpp index c8b26bd..237c2ac 100644 --- a/ArcWelderTest/ArcWelderTest.cpp +++ b/ArcWelderTest/ArcWelderTest.cpp @@ -292,7 +292,7 @@ static void TestAntiStutter(std::string filePath) //arc_welder arc_welder_obj(BENCHY_0_5_MM_NO_WIPE, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode", p_logger, max_resolution, false, 50, static_cast(on_progress)); //arc_welder arc_welder_obj(SIX_SPEED_TEST, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode", p_logger, max_resolution, false, 50, on_progress); arc_welder arc_welder_obj( - BARBARIAN, + BENCHY_DIFFICULT, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode", p_logger, max_resolution, diff --git a/GcodeProcessorLib/array_list.h b/GcodeProcessorLib/array_list.h index 90e0cb5..53ed43e 100644 --- a/GcodeProcessorLib/array_list.h +++ b/GcodeProcessorLib/array_list.h @@ -64,7 +64,7 @@ public: inline int get_index_position(int index) const { - int index_position = index + front_index_;// + max_size_; + int index_position = index + front_index_ + max_size_; while (index_position >= max_size_) { index_position = index_position - max_size_; -- cgit v1.2.3