mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-25 06:47:48 -05:00
Refuse a Filament Flow Ratio of 0 Instead of Writing NaN Extrusion (#16719)
A used filament with a flow ratio of 0 sliced in the GUI and wrote E-92233720368547.758 on every extrusion move: GCode::_extrude multiplied the flow by the ratio and divided by it again, giving 0 * 0 / 0 = NaN. The CLI already rejected the value through the config check, but Print::validate never looked at it. Print::validate now stops the slice with an error naming the filament when a used filament's flow ratio is 0 or nil, and _extrude converts the flow to extrusion length with the bare filament cross-section, so the ratio is applied once without a divide.
This commit is contained in:
1 parent
258ddc15e8
commit
ca51cba597
4 files changed
+67
-4
No files matched your search
@@ -140,6 +140,28 @@ TEST_CASE("The exclude object tolerance defaults to the former fixed 0.1 mm", "[
|
||||
Catch::Matchers::WithinAbs(0.1, 1e-9));
|
||||
}
|
||||
|
||||
TEST_CASE("The filament flow ratio scales the extruded length once", "[GCode]")
|
||||
{
|
||||
// Retraction off, so every positive relative E move is extrusion and scales with the ratio.
|
||||
auto extruded_length = [](double flow_ratio) {
|
||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||
config.set_deserialize_strict({ { "use_relative_e_distances", "1" }, { "retraction_length", "0" }, { "wipe", "0" } });
|
||||
config.set_key_value("filament_flow_ratio", new ConfigOptionFloatsNullable{ flow_ratio });
|
||||
double total = 0.;
|
||||
GCodeReader reader;
|
||||
reader.parse_buffer(Test::slice({ Test::cube(20) }, config),
|
||||
[&](GCodeReader &, const GCodeReader::GCodeLine &line) {
|
||||
if ((line.cmd_is("G1") || line.cmd_is("G2") || line.cmd_is("G3")) && line.has_e() && line.e() > 0.f)
|
||||
total += line.e();
|
||||
});
|
||||
return total;
|
||||
};
|
||||
|
||||
const double full = extruded_length(1.);
|
||||
REQUIRE(full > 0.);
|
||||
CHECK_THAT(extruded_length(0.9) / full, Catch::Matchers::WithinRel(0.9, 1e-3));
|
||||
}
|
||||
|
||||
// Firmwares read the compatibility header lines (Anycubic's GoKlipper heats the bed with
|
||||
// first_layer_bed_temperature), so they must describe the filament the plate prints, not filament 1.
|
||||
TEST_CASE("The G-code header names the first layer temperatures of the filament the plate prints", "[GCode]")
|
||||
|
||||
Reference in new issue
Block a user