From 9a838679c1ae3cdbfd0a3eedade6bf94ebb79409 Mon Sep 17 00:00:00 2001 From: FormerLurker Date: Sat, 3 Jul 2021 13:42:58 -0500 Subject: Alpha travel move conversion support. --- ArcWelder/arc_welder.cpp | 20 +++++++++++++------- ArcWelder/arc_welder.h | 22 +++++++++++++--------- ArcWelder/segmented_arc.cpp | 15 +++++++++++++++ ArcWelder/segmented_shape.cpp | 8 ++++---- ArcWelderConsole/ArcWelderConsole.cpp | 20 +++++++++++++++----- ArcWelderTest/ArcWelderTest.cpp | 6 ++++-- ArcWelderTest/ArcWelderTest.h | 1 + GcodeProcessorLib/position.h | 2 +- GcodeProcessorLib/utilities.cpp | 9 ++++++--- GcodeProcessorLib/utilities.h | 3 ++- PyArcWelder/py_arc_welder.cpp | 2 +- PyArcWelder/py_arc_welder.h | 5 ++++- PyArcWelder/py_arc_welder_extension.cpp | 13 ++++++++++++- PyArcWelder/py_arc_welder_extension.h | 4 ++++ 14 files changed, 95 insertions(+), 35 deletions(-) diff --git a/ArcWelder/arc_welder.cpp b/ArcWelder/arc_welder.cpp index 95fbcda..b45f9e9 100644 --- a/ArcWelder/arc_welder.cpp +++ b/ArcWelder/arc_welder.cpp @@ -47,6 +47,7 @@ arc_welder::arc_welder( double mm_per_arc_segment, bool g90_g91_influences_extruder, bool allow_3d_arcs, + bool allow_travel_arcs, bool allow_dynamic_precision, unsigned char default_xyz_precision, unsigned char default_e_precision, @@ -84,6 +85,7 @@ arc_welder::arc_welder( target_path_ = target_path; gcode_position_args_ = get_args_(g90_g91_influences_extruder, buffer_size); allow_3d_arcs_ = allow_3d_arcs; + allow_travel_arcs_ = allow_travel_arcs; allow_dynamic_precision_ = allow_dynamic_precision; extrusion_rate_variance_percent_ = extrusion_rate_variance_percent; notification_period_seconds = 1; @@ -204,12 +206,15 @@ arc_welder_results results; stream << std::fixed << std::setprecision(2); stream << "arc_welder::process - Parameters received: source_file_path: '" << source_path_ << "', target_file_path:'" << target_path_ << "', resolution_mm:" << - resolution_mm_ << "mm (+-" << current_arc_.get_resolution_mm() << "mm), path_tolerance_percent: " << current_arc_.get_path_tolerance_percent() - << ", max_radius_mm:" << current_arc_.get_max_radius() + resolution_mm_ << "mm (+-" << current_arc_.get_resolution_mm() + << "mm), path_tolerance_percent: " << current_arc_.get_path_tolerance_percent() + << "%, extrusion_rate_variance_percent: " << extrusion_rate_variance_percent_ + << "%, max_radius_mm:" << current_arc_.get_max_radius() << ", min_arc_segments:" << std::setprecision(0) <get_g90_91_influences_extruder() ? "True" : "False") << ", allow_3d_arcs: " << (allow_3d_arcs_ ? "True" : "False") + << ", allow_travel_arcs: " << (allow_travel_arcs_ ? "True" : "False") << ", allow_dynamic_precision: " << (allow_dynamic_precision_ ? "True" : "False") << ", default_xyz_precision: " << std::setprecision(0) << static_cast(current_arc_.get_xyz_precision()) << ", default_e_precision: " << std::setprecision(0) << static_cast(current_arc_.get_e_precision()); @@ -424,7 +429,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess double movement_length_mm = 0; bool has_e_changed = extruder_current.is_extruding || extruder_current.is_retracting; // Update the source file statistics - if (p_cur_pos->has_xy_position_changed && (has_e_changed)) + if (p_cur_pos->has_xy_position_changed) { if (allow_3d_arcs_) { movement_length_mm = utilities::get_cartesian_distance(p_pre_pos->x, p_pre_pos->y, p_pre_pos->z, p_cur_pos->x, p_cur_pos->y, p_cur_pos->z); @@ -444,7 +449,8 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess double mm_extruded_per_mm_travel = 0; double extrusion_rate_change_percent = 0; bool aborted_by_flow_rate = false; - if (movement_length_mm > 0) + // TODO: MAKE SURE THIS WORKS FOR TRANSITIONS FROM TRAVEL TO NON TRAVEL MOVES + if (movement_length_mm > 0 && has_e_changed) { mm_extruded_per_mm_travel = extruder_current.e_relative / movement_length_mm; if (previous_extrusion_rate_ > 0) @@ -497,7 +503,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess !waiting_for_arc_ || extruder_current.is_extruding || // Test for travel conversion - + (allow_travel_arcs_ && p_cur_pos->is_travel()) || //(previous_extruder.is_extruding && extruder_current.is_extruding) || // Test to see if // we can get more arcs. (previous_extruder.is_retracting && extruder_current.is_retracting) @@ -874,7 +880,7 @@ void arc_welder::add_arcwelder_comment_to_target() stream << "; Copyright(C) 2020 - Brad Hochgesang\n"; stream << "; Version: " << GIT_TAGGED_VERSION << ", Branch: " << GIT_BRANCH << ", BuildDate: " << BUILD_DATE << "\n"; stream << "; resolution=" << std::setprecision(2) << resolution_mm_ << "mm\n"; - stream << "; path_tolerance=" << std::setprecision(0) << (current_arc_.get_path_tolerance_percent() * 100.0) << "%\n"; + stream << "; path_tolerance=" << std::setprecision(1) << (current_arc_.get_path_tolerance_percent() * 100.0) << "%\n"; stream << "; max_radius=" << std::setprecision(2) << (current_arc_.get_max_radius()) << "mm\n"; if (gcode_position_args_.g90_influences_extruder) { @@ -897,7 +903,7 @@ void arc_welder::add_arcwelder_comment_to_target() } stream << "; default_xyz_precision=" << std::setprecision(0) << static_cast(current_arc_.get_xyz_precision()) << "\n"; stream << "; default_e_precision=" << std::setprecision(0) << static_cast(current_arc_.get_e_precision()) << "\n"; - stream << "; extrusion_rate_variance_percent=" << std::setprecision(3) << static_cast(extrusion_rate_variance_percent_) << "%\n\n"; + stream << "; extrusion_rate_variance_percent=" << std::setprecision(1) << (extrusion_rate_variance_percent_ * 100.0) << "%\n\n"; output_file_ << stream.str(); diff --git a/ArcWelder/arc_welder.h b/ArcWelder/arc_welder.h index a4fdded..98564ec 100644 --- a/ArcWelder/arc_welder.h +++ b/ArcWelder/arc_welder.h @@ -418,7 +418,9 @@ struct arc_welder_results { #define DEFAULT_GCODE_BUFFER_SIZE 10 #define DEFAULT_G90_G91_INFLUENCES_EXTRUDER false #define DEFAULT_ALLOW_DYNAMIC_PRECISION false -#define DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT 5 +#define DEFAULT_ALLOW_TRAVEL_ARCS false +#define DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT 0.05 +#define DEFAULT_CONVERT_TRAVEL_MOVES false class arc_welder { public: @@ -431,14 +433,15 @@ public: double max_radius, int min_arc_segments, double mm_per_arc_segment, - bool g90_g91_influences_extruder = DEFAULT_G90_G91_INFLUENCES_EXTRUDER, - bool allow_3d_arcs = DEFAULT_ALLOW_3D_ARCS, - bool allow_dynamic_precision = DEFAULT_ALLOW_DYNAMIC_PRECISION, - unsigned char default_xyz_precision = DEFAULT_XYZ_PRECISION, - unsigned char default_e_precision = DEFAULT_E_PRECISION, - double extrusion_rate_variance_percent = DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT, - int buffer_size = DEFAULT_GCODE_BUFFER_SIZE, - progress_callback callback = NULL); + bool g90_g91_influences_extruder, + bool allow_3d_arcs, + bool allow_travel_arcs, + bool allow_dynamic_precision, + unsigned char default_xyz_precision, + unsigned char default_e_precision, + double extrusion_rate_variance_percent, + int buffer_size, + progress_callback callback); void set_logger_type(int logger_type); virtual ~arc_welder(); arc_welder_results process(); @@ -465,6 +468,7 @@ private: gcode_position_args gcode_position_args_; bool allow_dynamic_precision_; bool allow_3d_arcs_; + bool allow_travel_arcs_; long file_size_; int lines_processed_; int gcodes_processed_; diff --git a/ArcWelder/segmented_arc.cpp b/ArcWelder/segmented_arc.cpp index 62593d7..51ef57e 100644 --- a/ArcWelder/segmented_arc.cpp +++ b/ArcWelder/segmented_arc.cpp @@ -142,6 +142,21 @@ bool segmented_arc::try_add_point(printer_point p) return false; } + // Need to separate travel moves from moves with extrusion + if (points_.count() > 2) + { + // We already have at least an initial point and a second point. Make cure the current point and the previous are either both + // travel moves, or both extrusion + if (!( + (p1.e_relative != 0 && p.e_relative != 0) // Extrusions + || (p1.e_relative == 0 && p.e_relative == 0) // Travel + ) + ) + { + return false; + } + } + if (utilities::is_zero(p.distance)) { // there must be some distance between the points diff --git a/ArcWelder/segmented_shape.cpp b/ArcWelder/segmented_shape.cpp index ec0611e..4e17d3c 100644 --- a/ArcWelder/segmented_shape.cpp +++ b/ArcWelder/segmented_shape.cpp @@ -447,8 +447,8 @@ bool arc::try_create_arc( } } // Calculate the percent difference of the original path - double difference = (arc_length - approximate_length) / approximate_length; - if (!utilities::is_zero(difference, path_tolerance_percent)) + double path_difference_percent = utilities::get_percent_change(arc_length, approximate_length); + if (!utilities::is_zero(path_difference_percent, path_tolerance_percent)) { // So it's possible our vector calculation above got the direction wrong. // This can happen if there is a crazy arrangement of points @@ -468,8 +468,8 @@ bool arc::try_create_arc( test_arc_length = utilities::hypot(test_arc_length, end_point.z - start_point.z); } } - difference = (test_arc_length - approximate_length) / approximate_length; - if (!utilities::is_zero(difference, path_tolerance_percent)) + path_difference_percent = utilities::get_percent_change(test_arc_length,approximate_length); + if (!utilities::is_zero(path_difference_percent, path_tolerance_percent)) { return false; } diff --git a/ArcWelderConsole/ArcWelderConsole.cpp b/ArcWelderConsole/ArcWelderConsole.cpp index 691f155..16a6923 100644 --- a/ArcWelderConsole/ArcWelderConsole.cpp +++ b/ArcWelderConsole/ArcWelderConsole.cpp @@ -46,7 +46,8 @@ int main(int argc, char* argv[]) bool g90_g91_influences_extruder; bool hide_progress; bool overwrite_source_file = false; - bool allow_3d_arcs = false; + bool allow_3d_arcs = DEFAULT_ALLOW_3D_ARCS; + bool allow_travel_arcs = DEFAULT_ALLOW_TRAVEL_ARCS; bool allow_dynamic_precision = DEFAULT_ALLOW_DYNAMIC_PRECISION; unsigned char default_xyz_precision = DEFAULT_XYZ_PRECISION; unsigned char default_e_precision = DEFAULT_E_PRECISION; @@ -123,6 +124,12 @@ int main(int argc, char* argv[]) arg_description_stream << "(experimental) - If supplied, 3D arcs will be allowed (supports spiral vase mode). Not all firmware supports this. Default Value: " << DEFAULT_ALLOW_3D_ARCS; TCLAP::SwitchArg allow_3d_arcs_arg("z", "allow-3d-arcs", arg_description_stream.str(), DEFAULT_ALLOW_3D_ARCS); + // -y --allow-travel-arcs + arg_description_stream.clear(); + arg_description_stream.str(""); + arg_description_stream << "(experimental) - If supplied, travel arcs will be allowed. Default Value: " << DEFAULT_ALLOW_TRAVEL_ARCS; + TCLAP::SwitchArg allow_travel_arcs_arg("y", "allow-travel-arcs", arg_description_stream.str(), DEFAULT_ALLOW_TRAVEL_ARCS); + // -d --allow-dynamic-precision arg_description_stream.clear(); arg_description_stream.str(""); @@ -144,7 +151,7 @@ int main(int argc, char* argv[]) // -v --extrusion-rate-variance arg_description_stream.clear(); arg_description_stream.str(""); - arg_description_stream << "The allowed variance in extrusion rate by percent. Default Value: " << DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT; + arg_description_stream << "(experimental) - The allowed variance in extrusion rate by percent. Default Value: " << DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT; TCLAP::ValueArg extrusion_rate_variance_percent_arg("v", "extrusion-rate-variance-percent", arg_description_stream.str(), false, DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT, "double"); @@ -176,6 +183,7 @@ int main(int argc, char* argv[]) cmd.add(min_arc_segments_arg); cmd.add(mm_per_arc_segment_arg); cmd.add(allow_3d_arcs_arg); + cmd.add(allow_travel_arcs_arg); cmd.add(allow_dynamic_precision_arg); cmd.add(default_xyz_precision_arg); cmd.add(default_e_precision_arg); @@ -202,6 +210,7 @@ int main(int argc, char* argv[]) mm_per_arc_segment = mm_per_arc_segment_arg.getValue(); path_tolerance_percent = path_tolerance_percent_arg.getValue(); allow_3d_arcs = allow_3d_arcs_arg.getValue(); + allow_travel_arcs = allow_travel_arcs_arg.getValue(); g90_g91_influences_extruder = g90_arg.getValue(); allow_dynamic_precision = allow_dynamic_precision_arg.getValue(); default_xyz_precision = default_xyz_precision_arg.getValue(); @@ -367,10 +376,11 @@ int main(int argc, char* argv[]) log_messages << "\tMin Arc Segments : " << std::setprecision(0) << min_arc_segments << "\n"; log_messages << "\tMM Per Arc Segment : " << std::setprecision(3) << mm_per_arc_segment << "\n"; log_messages << "\tAllow 3D Arcs : " << (allow_3d_arcs ? "True" : "False") << "\n"; + log_messages << "\tAllow Travel Arcs : " << (allow_travel_arcs ? "True" : "False") << "\n"; log_messages << "\tAllow Dynamic Precision : " << (allow_dynamic_precision ? "True" : "False") << "\n"; log_messages << "\tDefault XYZ Precision : " << std::setprecision(0) << static_cast(default_xyz_precision) << "\n"; log_messages << "\tDefault E Precision : " << std::setprecision(0) << static_cast(default_e_precision) << "\n"; - log_messages << "\tExtrusion Rate Variance % : " << std::setprecision(3) << extrusion_rate_variance_percent << "%\n"; + log_messages << "\tExtrusion Rate Variance % : " << std::setprecision(3) << extrusion_rate_variance_percent*100.0 << "%\n"; log_messages << "\tG90/G91 Influences Extruder : " << (g90_g91_influences_extruder ? "True" : "False") << "\n"; log_messages << "\tLog Level : " << log_level_string << "\n"; log_messages << "\tHide Progress Updates : " << (hide_progress ? "True" : "False"); @@ -382,9 +392,9 @@ int main(int argc, char* argv[]) target_file_path = temp_file_path; } if (!hide_progress) - p_arc_welder = new arc_welder(source_file_path, target_file_path, p_logger, resolution_mm, path_tolerance_percent, max_radius_mm, min_arc_segments, mm_per_arc_segment, g90_g91_influences_extruder, allow_3d_arcs, allow_dynamic_precision, default_xyz_precision, default_e_precision, extrusion_rate_variance_percent, DEFAULT_GCODE_BUFFER_SIZE, on_progress); + p_arc_welder = new arc_welder(source_file_path, target_file_path, p_logger, resolution_mm, path_tolerance_percent, max_radius_mm, min_arc_segments, mm_per_arc_segment, g90_g91_influences_extruder, allow_3d_arcs, allow_travel_arcs, allow_dynamic_precision, default_xyz_precision, default_e_precision, extrusion_rate_variance_percent, DEFAULT_GCODE_BUFFER_SIZE, on_progress); else - p_arc_welder = new arc_welder(source_file_path, target_file_path, p_logger, resolution_mm, path_tolerance_percent, max_radius_mm, min_arc_segments, mm_per_arc_segment, g90_g91_influences_extruder, allow_3d_arcs, allow_dynamic_precision, default_xyz_precision, default_e_precision, extrusion_rate_variance_percent, DEFAULT_GCODE_BUFFER_SIZE, suppress_progress); + p_arc_welder = new arc_welder(source_file_path, target_file_path, p_logger, resolution_mm, path_tolerance_percent, max_radius_mm, min_arc_segments, mm_per_arc_segment, g90_g91_influences_extruder, allow_3d_arcs, allow_travel_arcs, allow_dynamic_precision, default_xyz_precision, default_e_precision, extrusion_rate_variance_percent, DEFAULT_GCODE_BUFFER_SIZE, suppress_progress); arc_welder_results results = p_arc_welder->process(); if (results.success) diff --git a/ArcWelderTest/ArcWelderTest.cpp b/ArcWelderTest/ArcWelderTest.cpp index 9f3aa2f..95aebc5 100644 --- a/ArcWelderTest/ArcWelderTest.cpp +++ b/ArcWelderTest/ArcWelderTest.cpp @@ -294,7 +294,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( - METALTEST, + BENCHY_DIFFICULT, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode", p_logger, max_resolution, @@ -304,10 +304,12 @@ static void TestAntiStutter(std::string filePath) mm_per_arc_segment, true, true, + true, //DEFAULT_ALLOW_TRAVEL_ARCS, DEFAULT_ALLOW_DYNAMIC_PRECISION, DEFAULT_XYZ_PRECISION, DEFAULT_E_PRECISION, - DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT, + //DEFAULT_EXTRUSION_RATE_VARIANCE_PERCENT, + 1000000, DEFAULT_GCODE_BUFFER_SIZE, on_progress); //FIRMWARE_COMPENSATION_TEST_1 diff --git a/ArcWelderTest/ArcWelderTest.h b/ArcWelderTest/ArcWelderTest.h index 13f4940..b4331e9 100644 --- a/ArcWelderTest/ArcWelderTest.h +++ b/ArcWelderTest/ArcWelderTest.h @@ -82,6 +82,7 @@ static std::string ISSUE_PRICKLYPEAR_LAYER_0_114 = "C:\\Users\\Brad\\Documents\\ // Sanity tests static std::string COLINEAR_TEST_1 = "C:\\Users\\Brad\\Documents\\AntiStutter\\Sanity Checks\\G2_colinear_test.gcode"; static std::string SPIRAL_TEST = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\smoothietest\\SPIRAL_TEST.gcode"; +static std::string SPIRAL_TRAVEL_TEST = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\smoothietest\\SPIRAL_TRAVEL_TEST.gcode"; static std::string SPIRAL_TEST_PRECISION = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\smoothietest\\SPIRAL_TEST_precision.gcode"; static std::string SPIRAL_VASE_TEST_DOUBLE_SPIRAL = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\SpiralVaseTest\\SpiralVaseTest_DOUBLE_SPIRAL.gcode"; diff --git a/GcodeProcessorLib/position.h b/GcodeProcessorLib/position.h index 5059d5f..7470ae9 100644 --- a/GcodeProcessorLib/position.h +++ b/GcodeProcessorLib/position.h @@ -102,6 +102,6 @@ struct position void set_e_axis_mode(const std::string& e_axis_default_mode); void set_units_default(const std::string& units_default); bool can_take_snapshot(); - bool is_travel() + bool is_travel(); }; #endif \ No newline at end of file diff --git a/GcodeProcessorLib/utilities.cpp b/GcodeProcessorLib/utilities.cpp index b5a09a6..a723cdf 100644 --- a/GcodeProcessorLib/utilities.cpp +++ b/GcodeProcessorLib/utilities.cpp @@ -176,7 +176,7 @@ double utilities::get_percent_change(double v1, double v2) { if (v1 != 0) { - return ((v2 - v1) / v1) * 100.0; + return ((v2 - v1) / v1); } return 0; } @@ -322,7 +322,7 @@ std::string utilities::dtos(double x, unsigned char precision) */ return buffer; } - +/* bool utilities::case_insensitive_compare_char(char& c1, char& c2) { if (c1 == c2) @@ -331,10 +331,13 @@ bool utilities::case_insensitive_compare_char(char& c1, char& c2) return true; return false; } + /* * Case Insensitive String Comparision - */ + bool utilities::case_insensitive_compare(std::string& str1, std::string& str2) { return ((str1.size() == str2.size()) && std::equal(str1.begin(), str1.end(), str2.begin(), &utilities::case_insensitive_compare_char)); } + +*/ \ No newline at end of file diff --git a/GcodeProcessorLib/utilities.h b/GcodeProcessorLib/utilities.h index 33afd51..acbea6c 100644 --- a/GcodeProcessorLib/utilities.h +++ b/GcodeProcessorLib/utilities.h @@ -41,9 +41,10 @@ public: static double get_cartesian_distance(double x1, double y1, double x2, double y2); static double get_cartesian_distance(double x1, double y1, double z1, double x2, double y2, double z2); - + /* Todo: Implement for gcode comment processor static bool case_insensitive_compare_char(char& c1, char& c2); static bool case_insensitive_compare(std::string& str1, std::string& str2); + */ static std::string to_string(double value); static std::string to_string(int value); static std::string ltrim(const std::string& s); diff --git a/PyArcWelder/py_arc_welder.cpp b/PyArcWelder/py_arc_welder.cpp index f811e6d..7fdf9bd 100644 --- a/PyArcWelder/py_arc_welder.cpp +++ b/PyArcWelder/py_arc_welder.cpp @@ -32,7 +32,7 @@ PyObject* py_arc_welder::build_py_progress(const arc_welder_progress& progress, if (pyMessage == NULL) return NULL; double total_count_reduction_percent = progress.segment_statistics.get_total_count_reduction_percent(); - PyObject* py_progress = Py_BuildValue("{s:d,s:d,s:d,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:f,s:f,s:f,s:f,s:i,s:i,s:f}", + PyObject* py_progress = Py_BuildValue("{s:d,s:d,s:d,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:f,s:f,s:f,s:f,s:i,s:i,s:f}", "percent_complete", progress.percent_complete, //1 "seconds_elapsed", diff --git a/PyArcWelder/py_arc_welder.h b/PyArcWelder/py_arc_welder.h index 6813c34..40a9cab 100644 --- a/PyArcWelder/py_arc_welder.h +++ b/PyArcWelder/py_arc_welder.h @@ -46,6 +46,7 @@ public: double mm_per_arc_segment, bool g90_g91_influences_extruder, bool allow_3d_arcs, + bool allow_travel_arcs, bool allow_dynamic_precision, unsigned char default_xyz_precision, unsigned char default_e_precision, @@ -63,11 +64,13 @@ public: mm_per_arc_segment, g90_g91_influences_extruder, allow_3d_arcs, + allow_travel_arcs, allow_dynamic_precision, default_xyz_precision, default_e_precision, extrusion_rate_variance_percent, - buffer_size + buffer_size, + NULL ){ guid_ = guid; py_progress_callback_ = py_progress_callback; diff --git a/PyArcWelder/py_arc_welder_extension.cpp b/PyArcWelder/py_arc_welder_extension.cpp index 71c3855..19a2274 100644 --- a/PyArcWelder/py_arc_welder_extension.cpp +++ b/PyArcWelder/py_arc_welder_extension.cpp @@ -206,7 +206,8 @@ extern "C" args.min_arc_segments, args.mm_per_arc_segment, args.g90_g91_influences_extruder, - args.allow_3d_arcs, + args.allow_3d_arcs, + args.allow_travel_arcs, args.allow_dynamic_precision, args.default_xyz_precision, args.default_e_precision, @@ -423,6 +424,16 @@ static bool ParseArgs(PyObject* py_args, py_gcode_arc_args& args, PyObject** py_ } args.allow_3d_arcs = PyLong_AsLong(py_allow_3d_arcs) > 0; + // extract allow_travel_arcs + PyObject* py_allow_travel_arcs = PyDict_GetItemString(py_args, "allow_travel_arcs"); + if (py_allow_travel_arcs == NULL) + { + std::string message = "ParseArgs - Unable to retrieve allow_travel_arcs from the args."; + p_py_logger->log_exception(GCODE_CONVERSION, message); + return false; + } + args.allow_travel_arcs = PyLong_AsLong(py_allow_travel_arcs) > 0; + // Extract G90/G91 influences extruder // g90_influences_extruder PyObject* py_g90_g91_influences_extruder = PyDict_GetItemString(py_args, "g90_g91_influences_extruder"); diff --git a/PyArcWelder/py_arc_welder_extension.h b/PyArcWelder/py_arc_welder_extension.h index 9b979fe..2212748 100644 --- a/PyArcWelder/py_arc_welder_extension.h +++ b/PyArcWelder/py_arc_welder_extension.h @@ -53,6 +53,7 @@ struct py_gcode_arc_args { mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT; g90_g91_influences_extruder = DEFAULT_G90_G91_INFLUENCES_EXTREUDER; allow_3d_arcs = DEFAULT_ALLOW_3D_ARCS; + allow_travel_arcs = DEFAULT_ALLOW_TRAVEL_ARCS; log_level = 0; } py_gcode_arc_args( @@ -66,6 +67,7 @@ struct py_gcode_arc_args { double mm_per_arc_segment_, bool g90_g91_influences_extruder_, bool allow_3d_arcs_, + bool allow_travel_arcs_, bool allow_dynamic_precision_, unsigned char default_xyz_precision_, unsigned char default_e_precision_, @@ -81,6 +83,7 @@ struct py_gcode_arc_args { min_arc_segments = min_arc_segments_; mm_per_arc_segment = mm_per_arc_segment_; allow_3d_arcs = allow_3d_arcs_; + allow_travel_arcs = allow_travel_arcs_; allow_dynamic_precision = allow_dynamic_precision_; default_xyz_precision = default_xyz_precision_; default_e_precision = default_e_precision_; @@ -94,6 +97,7 @@ struct py_gcode_arc_args { double resolution_mm; double path_tolerance_percent; bool allow_3d_arcs; + bool allow_travel_arcs; bool allow_dynamic_precision; unsigned char default_xyz_precision; unsigned char default_e_precision; -- cgit v1.2.3