diff options
author | FormerLurker <hochgebe@gmail.com> | 2020-11-24 03:18:31 +0300 |
---|---|---|
committer | FormerLurker <hochgebe@gmail.com> | 2020-11-24 03:18:31 +0300 |
commit | 359b6e92bf252a9ab6485179aee7f3148108aa86 (patch) | |
tree | 59d9c44a29177b08e249e88e04ed65621693d378 /ArcWelder | |
parent | f2b52d935ebc81a2eb12cfd7a1c4b924cfc5ea68 (diff) |
Rename allow_z_axis_changes to allow_3d_arcs.
Diffstat (limited to 'ArcWelder')
-rw-r--r-- | ArcWelder/arc_welder.cpp | 16 | ||||
-rw-r--r-- | ArcWelder/arc_welder.h | 4 | ||||
-rw-r--r-- | ArcWelder/segmented_arc.cpp | 16 | ||||
-rw-r--r-- | ArcWelder/segmented_arc.h | 4 | ||||
-rw-r--r-- | ArcWelder/segmented_shape.cpp | 28 | ||||
-rw-r--r-- | ArcWelder/segmented_shape.h | 12 |
6 files changed, 40 insertions, 40 deletions
diff --git a/ArcWelder/arc_welder.cpp b/ArcWelder/arc_welder.cpp index 5fb9c82..981eeec 100644 --- a/ArcWelder/arc_welder.cpp +++ b/ArcWelder/arc_welder.cpp @@ -45,7 +45,7 @@ arc_welder::arc_welder( int min_arc_segments, double mm_per_arc_segment, bool g90_g91_influences_extruder, - bool allow_z_axis_changes, + bool allow_3d_arcs, int buffer_size, progress_callback callback) : current_arc_( DEFAULT_MIN_SEGMENTS, @@ -55,7 +55,7 @@ arc_welder::arc_welder( max_radius, min_arc_segments, mm_per_arc_segment, - allow_z_axis_changes + allow_3d_arcs ), segment_statistics_( segment_statistic_lengths, @@ -76,7 +76,7 @@ arc_welder::arc_welder( source_path_ = source_path; target_path_ = target_path; gcode_position_args_ = get_args_(g90_g91_influences_extruder, buffer_size); - allow_z_axis_changes_ = allow_z_axis_changes; + allow_3d_arcs_ = allow_3d_arcs; notification_period_seconds = 1; lines_processed_ = 0; gcodes_processed_ = 0; @@ -195,7 +195,7 @@ arc_welder_results results; << ", min_arc_segments:" << std::setprecision(0) <<current_arc_.get_min_arc_segments() << ", mm_per_arc_segment:" << std::setprecision(0) << current_arc_.get_mm_per_arc_segment() << ", g90_91_influences_extruder: " << (p_source_position_->get_g90_91_influences_extruder() ? "True" : "False") - << ", allow_z_axis_changes: " << (allow_z_axis_changes_ ? "True" : "False"); + << ", allow_3d_arcs: " << (allow_3d_arcs_ ? "True" : "False"); p_logger_->log(logger_type_, INFO, stream.str()); @@ -389,7 +389,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess { double movement_length_mm; - if (allow_z_axis_changes_) { + 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); } else { @@ -423,7 +423,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess } } - bool z_axis_ok = allow_z_axis_changes_ || + bool z_axis_ok = allow_3d_arcs_ || utilities::is_equal(p_cur_pos->z, p_pre_pos->z); if ( @@ -500,7 +500,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess { p_logger_->log(logger_type_, DEBUG, "Command '"+ cmd.command + "' is not G0/G1, skipping. Gcode:" + cmd.gcode); } - else if (!allow_z_axis_changes_ && !utilities::is_equal(p_cur_pos->z, p_pre_pos->z)) + else if (!allow_3d_arcs_ && !utilities::is_equal(p_cur_pos->z, p_pre_pos->z)) { p_logger_->log(logger_type_, DEBUG, "Z axis position changed, cannot convert:" + cmd.gcode); } @@ -695,7 +695,7 @@ int arc_welder::process_gcode(parsed_command cmd, bool is_end, bool is_reprocess { position* prev_pos = p_source_position_->get_previous_position_ptr(); length = 0; - if (allow_z_axis_changes_) + if (allow_3d_arcs_) { length = utilities::get_cartesian_distance(cur_pos->x, cur_pos->y, cur_pos->z, prev_pos->x, prev_pos->y, prev_pos->z); } diff --git a/ArcWelder/arc_welder.h b/ArcWelder/arc_welder.h index 79b7712..22cf4b6 100644 --- a/ArcWelder/arc_welder.h +++ b/ArcWelder/arc_welder.h @@ -422,7 +422,7 @@ public: int min_arc_segments, double mm_per_arc_segment, bool g90_g91_influences_extruder = DEFAULT_G90_G91_INFLUENCES_EXTRUDER, - bool allow_z_axis_changes = DEFAULT_ALLOW_Z_AXIS_CHANGES, + bool allow_3d_arcs = DEFAULT_allow_3d_arcs, int buffer_size = DEFAULT_GCODE_BUFFER_SIZE, progress_callback callback = NULL); void set_logger_type(int logger_type); @@ -448,7 +448,7 @@ private: std::string target_path_; double resolution_mm_; gcode_position_args gcode_position_args_; - bool allow_z_axis_changes_; + bool allow_3d_arcs_; long file_size_; int lines_processed_; int gcodes_processed_; diff --git a/ArcWelder/segmented_arc.cpp b/ArcWelder/segmented_arc.cpp index 8ee8adb..bd4b964 100644 --- a/ArcWelder/segmented_arc.cpp +++ b/ArcWelder/segmented_arc.cpp @@ -35,7 +35,7 @@ segmented_arc::segmented_arc() : segmented_shape(DEFAULT_MIN_SEGMENTS, DEFAULT_M { max_radius_mm_ = DEFAULT_MAX_RADIUS_MM; min_arc_segments_ = DEFAULT_MIN_ARC_SEGMENTS, - allow_z_axis_changes_ = DEFAULT_ALLOW_Z_AXIS_CHANGES; + allow_3d_arcs_ = DEFAULT_allow_3d_arcs; } segmented_arc::segmented_arc( @@ -46,7 +46,7 @@ segmented_arc::segmented_arc( double max_radius_mm, int min_arc_segments, double mm_per_arc_segment, - bool allow_z_axis_changes + bool allow_3d_arcs ) : segmented_shape(min_segments, max_segments, resolution_mm, path_tolerance_percent) { max_radius_mm_ = max_radius_mm; @@ -63,7 +63,7 @@ segmented_arc::segmented_arc( { min_arc_segments_ = 0; } - allow_z_axis_changes_ = allow_z_axis_changes; + allow_3d_arcs_ = allow_3d_arcs; } segmented_arc::~segmented_arc() @@ -122,7 +122,7 @@ bool segmented_arc::try_add_point(point p, double e_relative) if (points_.count() > 0) { point p1 = points_[points_.count() - 1]; - if (allow_z_axis_changes_) { + if (allow_3d_arcs_) { // If we can draw arcs in 3 space, add in the distance of the z axis changes distance = utilities::get_cartesian_distance(p1.x, p1.y, p1.z, p.x, p.y, p.z); } @@ -151,7 +151,7 @@ bool segmented_arc::try_add_point(point p, double e_relative) original_shape_length_ += distance; if (points_.count() == get_min_segments()) { - if (!arc::try_create_arc(points_, current_arc_, original_shape_length_, max_radius_mm_, resolution_mm_, path_tolerance_percent_, min_arc_segments_, mm_per_arc_segment_, xyz_precision_, allow_z_axis_changes_)) + if (!arc::try_create_arc(points_, current_arc_, original_shape_length_, max_radius_mm_, resolution_mm_, path_tolerance_percent_, min_arc_segments_, mm_per_arc_segment_, xyz_precision_, allow_3d_arcs_)) { point_added = false; points_.pop_back(); @@ -183,7 +183,7 @@ bool segmented_arc::try_add_point(point p, double e_relative) // We have to remove the distance and e relative value // accumulated between the old arc start point and the new point new_initial_point = points_[0]; - if (allow_z_axis_changes_) { + if (allow_3d_arcs_) { original_shape_length_ -= utilities::get_cartesian_distance(old_initial_point.x, old_initial_point.y, old_initial_point.z, new_initial_point.x, new_initial_point.y, new_initial_point.z); } else { @@ -212,7 +212,7 @@ bool segmented_arc::try_add_point_internal_(point p, double pd) double previous_shape_length = original_shape_length_; original_shape_length_ += pd; - if (arc::try_create_arc(points_, current_arc_, original_shape_length_, max_radius_mm_, resolution_mm_, path_tolerance_percent_, min_arc_segments_, mm_per_arc_segment_, xyz_precision_, allow_z_axis_changes_)) + if (arc::try_create_arc(points_, current_arc_, original_shape_length_, max_radius_mm_, resolution_mm_, path_tolerance_percent_, min_arc_segments_, mm_per_arc_segment_, xyz_precision_, allow_3d_arcs_)) { if (!is_shape()) { @@ -266,7 +266,7 @@ std::string segmented_arc::get_shape_gcode_(bool has_e, double e, double f) cons gcode += " Y"; gcode += utilities::to_string(current_arc_.end_point.y, xyz_precision_, buf, false); - if (allow_z_axis_changes_) + if (allow_3d_arcs_) { // We may need to add a z coordinate double z_initial = current_arc_.start_point.z; diff --git a/ArcWelder/segmented_arc.h b/ArcWelder/segmented_arc.h index 6705e2e..10ad7f0 100644 --- a/ArcWelder/segmented_arc.h +++ b/ArcWelder/segmented_arc.h @@ -43,7 +43,7 @@ public: double max_radius_mm = DEFAULT_MAX_RADIUS_MM, int min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS, double mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT, - bool allow_z_axis_changes = DEFAULT_ALLOW_Z_AXIS_CHANGES + bool allow_3d_arcs = DEFAULT_allow_3d_arcs ); virtual ~segmented_arc(); virtual bool try_add_point(point p, double e_relative); @@ -67,6 +67,6 @@ private: double max_radius_mm_; int min_arc_segments_; double mm_per_arc_segment_; - bool allow_z_axis_changes_; + bool allow_3d_arcs_; }; diff --git a/ArcWelder/segmented_shape.cpp b/ArcWelder/segmented_shape.cpp index 7a7f8c2..945c912 100644 --- a/ArcWelder/segmented_shape.cpp +++ b/ArcWelder/segmented_shape.cpp @@ -198,7 +198,7 @@ bool circle::try_create_circle(const point& p1, const point& p2, const point& p3 return true; } -bool circle::try_create_circle(const array_list<point>& points, const double max_radius, const double resolution_mm, const int xyz_precision, bool allow_z_axis_changes, bool check_middle_only, circle& new_circle) +bool circle::try_create_circle(const array_list<point>& points, const double max_radius, const double resolution_mm, const int xyz_precision, bool allow_3d_arcs, bool check_middle_only, circle& new_circle) { int middle_index = points.count() / 2; int check_index; @@ -210,7 +210,7 @@ bool circle::try_create_circle(const array_list<point>& points, const double max // Check the index if (circle::try_create_circle(points[0], points[check_index], points[points.count() - 1], max_radius, new_circle)) { - if (!new_circle.is_over_deviation(points, resolution_mm, xyz_precision, allow_z_axis_changes)) + if (!new_circle.is_over_deviation(points, resolution_mm, xyz_precision, allow_3d_arcs)) { return true; } @@ -269,19 +269,19 @@ point circle::get_closest_point(const point& p) const return point(px, py, pz, 0); } -bool circle::is_over_deviation(const array_list<point>& points, const double resolution_mm, const int xyz_precision, const bool allow_z_axis_changes) +bool circle::is_over_deviation(const array_list<point>& points, const double resolution_mm, const int xyz_precision, const bool allow_3d_arcs) { // We need to ensure that the Z steps are constand per linear travel unit double z_step_per_distance = 0; // Skip the first and last points since they will fit perfectly. // UNLESS allow z changes is set to true, then we need to do some different stuff - int final_index = points.count() - 1 + (allow_z_axis_changes ? 1 : 0); + int final_index = points.count() - 1 + (allow_3d_arcs ? 1 : 0); for (int index = 1; index < points.count() - 1; index++) { // Make sure the length from the center of our circle to the test point is // at or below our max distance. double distance = distance = utilities::get_cartesian_distance(points[index].x, points[index].y, center.x, center.y); - if (allow_z_axis_changes) { + if (allow_3d_arcs) { double z1 = points[index - 1].z; double z2 = points[index].z; @@ -334,7 +334,7 @@ bool arc::try_create_arc( double path_tolerance_percent, int min_arc_segments, double mm_per_arc_segment, - bool allow_z_axis_changes) + bool allow_3d_arcs) { double polar_start_theta = c.get_polar_radians(start_point); double polar_mid_theta = c.get_polar_radians(mid_point); @@ -385,7 +385,7 @@ bool arc::try_create_arc( // got the direction wrong double arc_length = c.radius * angle_radians; - if (allow_z_axis_changes) + if (allow_3d_arcs) { // We may be traveling in 3 space, calculate the arc_length of the spiral if (start_point.z != end_point.z) @@ -407,7 +407,7 @@ bool arc::try_create_arc( double test_radians = std::abs(angle_radians - 2 * PI_DOUBLE); // Calculate the length of that arc double test_arc_length = c.radius * test_radians; - if (allow_z_axis_changes) + if (allow_3d_arcs) { // We may be traveling in 3 space, calculate the arc_length of the spiral if (start_point.z != end_point.z) @@ -425,7 +425,7 @@ bool arc::try_create_arc( direction = direction == 1 ? 2 : 1; } - if (allow_z_axis_changes) + if (allow_3d_arcs) { // Ensure the perimeter of the arc is less than that of a full circle double perimeter = utilities::hypot(c.radius * 2.0 * PI_DOUBLE, end_point.z - start_point.z); @@ -477,10 +477,10 @@ bool arc::try_create_arc( double path_tolerance_percent, int min_arc_segments, double mm_per_arc_segment, - bool allow_z_axis_changes) + bool allow_3d_arcs) { int mid_point_index = ((points.count() - 2) / 2) + 1; - return arc::try_create_arc(c, points[0], points[mid_point_index], points[points.count() - 1], target_arc, approximate_length, resolution, path_tolerance_percent, min_arc_segments, mm_per_arc_segment, allow_z_axis_changes); + return arc::try_create_arc(c, points[0], points[mid_point_index], points[points.count() - 1], target_arc, approximate_length, resolution, path_tolerance_percent, min_arc_segments, mm_per_arc_segment, allow_3d_arcs); } bool arc::try_create_arc( const array_list<point>& points, @@ -492,13 +492,13 @@ bool arc::try_create_arc( int min_arc_segments, double mm_per_arc_segment, int xyz_precision, - bool allow_z_axis_changes) + bool allow_3d_arcs) { circle test_circle; - if (circle::try_create_circle(points, max_radius_mm, resolution_mm, xyz_precision, allow_z_axis_changes, false, test_circle)) + if (circle::try_create_circle(points, max_radius_mm, resolution_mm, xyz_precision, allow_3d_arcs, false, test_circle)) { int mid_point_index = ((points.count() - 2) / 2) + 1; - return arc::try_create_arc(test_circle, points[0], points[mid_point_index], points[points.count() - 1], target_arc, approximate_length, resolution_mm, path_tolerance_percent, min_arc_segments, mm_per_arc_segment, allow_z_axis_changes); + return arc::try_create_arc(test_circle, points[0], points[mid_point_index], points[points.count() - 1], target_arc, approximate_length, resolution_mm, path_tolerance_percent, min_arc_segments, mm_per_arc_segment, allow_3d_arcs); } return false; } diff --git a/ArcWelder/segmented_shape.h b/ArcWelder/segmented_shape.h index af7d8be..7e57c54 100644 --- a/ArcWelder/segmented_shape.h +++ b/ArcWelder/segmented_shape.h @@ -109,7 +109,7 @@ struct circle { static bool try_create_circle(const point &p1, const point &p2, const point &p3, const double max_radius, circle& new_circle); - static bool try_create_circle(const array_list<point>& points, const double max_radius, const double resolutino_mm, const int xyz_precision, bool allow_z_axis_changes, bool check_middle_only, circle& new_circle); + static bool try_create_circle(const array_list<point>& points, const double max_radius, const double resolutino_mm, const int xyz_precision, bool allow_3d_arcs, bool check_middle_only, circle& new_circle); double get_radians(const point& p1, const point& p2) const; @@ -117,11 +117,11 @@ struct circle { point get_closest_point(const point& p) const; - bool is_over_deviation(const array_list<point>& points, const double resolution_mm, const int xyz_precision, const bool allow_z_axis_changes); + bool is_over_deviation(const array_list<point>& points, const double resolution_mm, const int xyz_precision, const bool allow_3d_arcs); }; #define DEFAULT_RESOLUTION_MM 0.05 -#define DEFAULT_ALLOW_Z_AXIS_CHANGES false +#define DEFAULT_allow_3d_arcs false #define DEFAULT_MIN_ARC_SEGMENTS 0 #define DEFAULT_MM_PER_ARC_SEGMENT 0 struct arc : circle @@ -165,7 +165,7 @@ struct arc : circle double path_tolerance_percent = ARC_LENGTH_PERCENT_TOLERANCE_DEFAULT, int min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS, double mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT, - bool allow_z_axis_changes = DEFAULT_ALLOW_Z_AXIS_CHANGES); + bool allow_3d_arcs = DEFAULT_allow_3d_arcs); static bool try_create_arc( const circle& c, const array_list<point>& points, @@ -175,7 +175,7 @@ struct arc : circle double path_tolerance_percent = ARC_LENGTH_PERCENT_TOLERANCE_DEFAULT, int min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS, double mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT, - bool allow_z_axis_changes = DEFAULT_ALLOW_Z_AXIS_CHANGES); + bool allow_3d_arcs = DEFAULT_allow_3d_arcs); static bool try_create_arc( const array_list<point>& points, arc& target_arc, @@ -186,7 +186,7 @@ struct arc : circle int min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS, double mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT, int xyz_precision = DEFAULT_XYZ_PRECISION, - bool allow_z_axis_changes = DEFAULT_ALLOW_Z_AXIS_CHANGES); + bool allow_3d_arcs = DEFAULT_allow_3d_arcs); }; double distance_from_segment(segment s, point p); |