Removed G2/3 R option, it does not work correctly

This commit is contained in:
Lukas Matena 2023-10-17 09:31:51 +02:00
parent e6c4522143
commit 30861c81d2
6 changed files with 10 additions and 67 deletions

View File

@ -3071,7 +3071,6 @@ std::string GCodeGenerator::_extrude(
Vec2d prev = GCodeFormatter::quantize(prev_exact); Vec2d prev = GCodeFormatter::quantize(prev_exact);
auto it = path.begin(); auto it = path.begin();
auto end = path.end(); auto end = path.end();
const bool emit_radius = m_config.arc_fitting == ArcFittingType::EmitRadius;
for (++ it; it != end; ++ it) { for (++ it; it != end; ++ it) {
Vec2d p_exact = this->point_to_gcode(it->point); Vec2d p_exact = this->point_to_gcode(it->point);
Vec2d p = GCodeFormatter::quantize(p_exact); Vec2d p = GCodeFormatter::quantize(p_exact);
@ -3082,14 +3081,9 @@ std::string GCodeGenerator::_extrude(
Vec2d ij; Vec2d ij;
if (it->radius != 0) { if (it->radius != 0) {
// Extrude an arc. // Extrude an arc.
assert(m_config.arc_fitting == ArcFittingType::EmitCenter || assert(m_config.arc_fitting == ArcFittingType::EmitCenter);
m_config.arc_fitting == ArcFittingType::EmitRadius);
radius = unscaled<double>(it->radius); radius = unscaled<double>(it->radius);
if (emit_radius) { {
// Only quantize radius if emitting it directly into G-code. Otherwise use the exact radius for calculating the IJ values.
//FIXME rather re-fit the arc to improve accuracy!
radius = GCodeFormatter::quantize_xyzf(radius);
} else {
// Calculate quantized IJ circle center offset. // Calculate quantized IJ circle center offset.
ij = GCodeFormatter::quantize(Vec2d( ij = GCodeFormatter::quantize(Vec2d(
Geometry::ArcWelder::arc_center(prev_exact.cast<double>(), p_exact.cast<double>(), double(radius), it->ccw()) Geometry::ArcWelder::arc_center(prev_exact.cast<double>(), p_exact.cast<double>(), double(radius), it->ccw())
@ -3112,9 +3106,7 @@ std::string GCodeGenerator::_extrude(
path_length += line_length; path_length += line_length;
const double dE = e_per_mm * line_length; const double dE = e_per_mm * line_length;
assert(dE > 0); assert(dE > 0);
gcode += emit_radius ? gcode += m_writer.extrude_to_xy_G2G3IJ(p, ij, it->ccw(), dE, comment);
m_writer.extrude_to_xy_G2G3R(p, radius, it->ccw(), dE, comment) :
m_writer.extrude_to_xy_G2G3IJ(p, ij, it->ccw(), dE, comment);
} }
prev = p; prev = p;
prev_exact = p_exact; prev_exact = p_exact;

View File

@ -302,22 +302,6 @@ std::string GCodeWriter::travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij
return w.string(); return w.string();
} }
std::string GCodeWriter::travel_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, const std::string_view comment)
{
assert(std::abs(point.x()) < 1200.);
assert(std::abs(point.y()) < 1200.);
assert(std::abs(radius) >= 0.001);
assert(std::abs(radius) < 1800.);
m_pos.head<2>() = point.head<2>();
GCodeG2G3Formatter w(ccw);
w.emit_xy(point);
w.emit_radius(radius);
w.emit_comment(this->config.gcode_comments, comment);
return w.string();
}
std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string_view comment) std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string_view comment)
{ {
// FIXME: This function was not being used when travel_speed_z was separated (bd6badf). // FIXME: This function was not being used when travel_speed_z was separated (bd6badf).
@ -431,25 +415,6 @@ std::string GCodeWriter::extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &i
return w.string(); return w.string();
} }
std::string GCodeWriter::extrude_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, double dE, const std::string_view comment)
{
assert(dE != 0);
assert(std::abs(dE) < 1000.0);
assert(std::abs(point.x()) < 1200.);
assert(std::abs(point.y()) < 1200.);
assert(std::abs(radius) >= 0.001);
assert(std::abs(radius) < 1800.);
m_pos.head<2>() = point.head<2>();
GCodeG2G3Formatter w(ccw);
w.emit_xy(point);
w.emit_radius(radius);
w.emit_e(m_extrusion_axis, m_extruder->extrude(dE).second);
w.emit_comment(this->config.gcode_comments, comment);
return w.string();
}
#if 0 #if 0
std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment) std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment)
{ {

View File

@ -69,13 +69,11 @@ public:
std::string set_speed(double F, const std::string_view comment = {}, const std::string_view cooling_marker = {}) const; std::string set_speed(double F, const std::string_view comment = {}, const std::string_view cooling_marker = {}) const;
std::string travel_to_xy(const Vec2d &point, const std::string_view comment = {}); std::string travel_to_xy(const Vec2d &point, const std::string_view comment = {});
std::string travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, const std::string_view comment = {}); std::string travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, const std::string_view comment = {});
std::string travel_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, const std::string_view comment = {});
std::string travel_to_xyz(const Vec3d &point, const std::string_view comment = {}); std::string travel_to_xyz(const Vec3d &point, const std::string_view comment = {});
std::string travel_to_z(double z, const std::string_view comment = {}); std::string travel_to_z(double z, const std::string_view comment = {});
bool will_move_z(double z) const; bool will_move_z(double z) const;
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {}); std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
std::string extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, double dE, const std::string_view comment); std::string extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, double dE, const std::string_view comment);
std::string extrude_to_xy_G2G3R(const Vec2d &point, const double radius, const bool ccw, double dE, const std::string_view comment);
// std::string extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment = {}); // std::string extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment = {});
std::string retract(bool before_wipe = false); std::string retract(bool before_wipe = false);
std::string retract_for_toolchange(bool before_wipe = false); std::string retract_for_toolchange(bool before_wipe = false);
@ -195,12 +193,6 @@ public:
this->emit_axis('J', point.y(), XYZF_EXPORT_DIGITS); this->emit_axis('J', point.y(), XYZF_EXPORT_DIGITS);
} }
// Positive radius means a smaller arc,
// negative radius means a larger arc.
void emit_radius(const double radius) {
this->emit_axis('R', radius, XYZF_EXPORT_DIGITS);
}
void emit_e(const std::string_view axis, double v) { void emit_e(const std::string_view axis, double v) {
if (! axis.empty()) { if (! axis.empty()) {
// not gcfNoExtrusion // not gcfNoExtrusion

View File

@ -116,16 +116,15 @@ std::string Wipe::wipe(GCodeGenerator &gcodegen, bool toolchange)
retract_length -= dE; retract_length -= dE;
return done; return done;
}; };
const bool emit_radius = gcodegen.config().arc_fitting == ArcFittingType::EmitRadius; auto wipe_arc = [&gcode, &gcodegen, &retract_length, xy_to_e, &wipe_linear](
auto wipe_arc = [&gcode, &gcodegen, &retract_length, xy_to_e, emit_radius, &wipe_linear](
const Vec2d &prev_quantized, Vec2d &p, double radius_in, const bool ccw) { const Vec2d &prev_quantized, Vec2d &p, double radius_in, const bool ccw) {
Vec2d p_quantized = GCodeFormatter::quantize(p); Vec2d p_quantized = GCodeFormatter::quantize(p);
if (p_quantized == prev_quantized) { if (p_quantized == prev_quantized) {
p = p_quantized; p = p_quantized;
return false; return false;
} }
// Only quantize radius if emitting it directly into G-code. Otherwise use the exact radius for calculating the IJ values. // Use the exact radius for calculating the IJ values, no quantization.
double radius = emit_radius ? GCodeFormatter::quantize_xyzf(radius_in) : radius_in; double radius = radius_in;
if (radius == 0) if (radius == 0)
// Degenerated arc after quantization. Process it as if it was a line segment. // Degenerated arc after quantization. Process it as if it was a line segment.
return wipe_linear(prev_quantized, p); return wipe_linear(prev_quantized, p);
@ -151,9 +150,7 @@ std::string Wipe::wipe(GCodeGenerator &gcodegen, bool toolchange)
} else } else
p = p_quantized; p = p_quantized;
assert(dE > 0); assert(dE > 0);
if (emit_radius) { {
gcode += gcodegen.writer().extrude_to_xy_G2G3R(p, radius, ccw, -dE, wipe_retract_comment);
} else {
// Calculate quantized IJ circle center offset. // Calculate quantized IJ circle center offset.
Vec2d ij = GCodeFormatter::quantize(Vec2d(center - prev_quantized)); Vec2d ij = GCodeFormatter::quantize(Vec2d(center - prev_quantized));
if (ij == Vec2d::Zero()) if (ij == Vec2d::Zero())

View File

@ -59,8 +59,7 @@ static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values &
static const t_config_enum_values s_keys_map_ArcFittingType { static const t_config_enum_values s_keys_map_ArcFittingType {
{ "disabled", int(ArcFittingType::Disabled) }, { "disabled", int(ArcFittingType::Disabled) },
{ "emit_center", int(ArcFittingType::EmitCenter) }, { "emit_center", int(ArcFittingType::EmitCenter) }
{ "emit_radius", int(ArcFittingType::EmitRadius) }
}; };
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ArcFittingType) CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ArcFittingType)
@ -441,8 +440,7 @@ void PrintConfigDef::init_fff_params()
"G-code resolution will be used as the fitting tolerance."); "G-code resolution will be used as the fitting tolerance.");
def->set_enum<ArcFittingType>({ def->set_enum<ArcFittingType>({
{ "disabled", "Disabled" }, { "disabled", "Disabled" },
{ "emit_center", "Enabled: G2/3 I J" }, { "emit_center", "Enabled: G2/3 I J" }
{ "emit_radius", "Enabled: G2/3 R" }
}); });
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<ArcFittingType>(ArcFittingType::Disabled)); def->set_default_value(new ConfigOptionEnum<ArcFittingType>(ArcFittingType::Disabled));

View File

@ -49,8 +49,7 @@ namespace Slic3r {
enum class ArcFittingType { enum class ArcFittingType {
Disabled, Disabled,
EmitCenter, EmitCenter
EmitRadius,
}; };
enum GCodeFlavor : unsigned char { enum GCodeFlavor : unsigned char {