refactored for clarity
    Fix of SPE-1109 / #7285 (spiral vase+sequential printing)
    This was broken with ae7d6db, between 2.4.0-alpha1 and alpha2.
This commit is contained in:
Vojtech Bubnik 2021-11-29 10:26:53 +01:00
parent bcc02172f9
commit 87b6073575

View File

@ -1544,67 +1544,37 @@ void GCode::process_layers(
const size_t single_object_idx, const size_t single_object_idx,
GCodeOutputStream &output_stream) GCodeOutputStream &output_stream)
{ {
// FIXME: Following condition is probably not necessary, spiral vase should be applied the same way it // The pipeline is variable: The vase mode filter is optional.
// is done in nonsequential print case. The reason it is done this way is that spiral vase and sequential
// print was broken recently, and LukasM is trying to do the safest fix possible before 2.4.0-beta2, so
// he copied the first block and only planted the spiral vase to the copy. This should be unified
// after 2.4.0 final.
if (! m_spiral_vase) {
// The pipeline is fixed: Neither wipe tower nor vase mode are implemented for sequential print.
size_t layer_to_print_idx = 0; size_t layer_to_print_idx = 0;
tbb::parallel_pipeline(12, const auto generator = tbb::make_filter<void, GCode::LayerResult>(tbb::filter::serial_in_order,
tbb::make_filter<void, GCode::LayerResult>( [this, &print, &tool_ordering, &layers_to_print, &layer_to_print_idx, single_object_idx](tbb::flow_control& fc) -> GCode::LayerResult {
tbb::filter::serial_in_order, if (layer_to_print_idx == layers_to_print.size()) {
[this, &print, &tool_ordering, &layers_to_print, &layer_to_print_idx, single_object_idx](tbb::flow_control& fc) -> GCode::LayerResult { fc.stop();
if (layer_to_print_idx == layers_to_print.size()) { return {};
fc.stop(); } else {
return {}; LayerToPrint &layer = layers_to_print[layer_to_print_idx ++];
} else { print.throw_if_canceled();
LayerToPrint &layer = layers_to_print[layer_to_print_idx ++]; return this->process_layer(print, { std::move(layer) }, tool_ordering.tools_for_layer(layer.print_z()), &layer == &layers_to_print.back(), nullptr, single_object_idx);
print.throw_if_canceled(); }
return this->process_layer(print, { std::move(layer) }, tool_ordering.tools_for_layer(layer.print_z()), &layer == &layers_to_print.back(), nullptr, single_object_idx); });
} const auto spiral_vase = tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter::serial_in_order,
}) & [&spiral_vase = *this->m_spiral_vase.get()](GCode::LayerResult in)->GCode::LayerResult {
tbb::make_filter<GCode::LayerResult, std::string>( spiral_vase.enable(in.spiral_vase_enable);
tbb::filter::serial_in_order, return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
[&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in) -> std::string { });
return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush); const auto cooling = tbb::make_filter<GCode::LayerResult, std::string>(tbb::filter::serial_in_order,
}) & [&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in)->std::string {
tbb::make_filter<std::string, void>( return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
tbb::filter::serial_in_order, });
[&output_stream](std::string s) { output_stream.write(s); } const auto output = tbb::make_filter<std::string, void>(tbb::filter::serial_in_order,
)); [&output_stream](std::string s) { output_stream.write(s); }
} );
else {
size_t layer_to_print_idx = 0; // The pipeline elements are joined using const references, thus no copying is performed.
tbb::parallel_pipeline(12, if (m_spiral_vase)
tbb::make_filter<void, GCode::LayerResult>( tbb::parallel_pipeline(12, generator & spiral_vase & cooling & output);
tbb::filter::serial_in_order, else
[this, &print, &tool_ordering, &layers_to_print, &layer_to_print_idx, single_object_idx](tbb::flow_control& fc) -> GCode::LayerResult { tbb::parallel_pipeline(12, generator & cooling & output);
if (layer_to_print_idx == layers_to_print.size()) {
fc.stop();
return {};
} else {
LayerToPrint &layer = layers_to_print[layer_to_print_idx ++];
print.throw_if_canceled();
return this->process_layer(print, { std::move(layer) }, tool_ordering.tools_for_layer(layer.print_z()), &layer == &layers_to_print.back(), nullptr, single_object_idx);
}
}) &
tbb::make_filter<GCode::LayerResult, GCode::LayerResult>(tbb::filter::serial_in_order,
[&spiral_vase = *this->m_spiral_vase.get()](GCode::LayerResult in)->GCode::LayerResult {
spiral_vase.enable(in.spiral_vase_enable);
return { spiral_vase.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush };
}) &
tbb::make_filter<GCode::LayerResult, std::string>(
tbb::filter::serial_in_order,
[&cooling_buffer = *this->m_cooling_buffer.get()](GCode::LayerResult in)->std::string {
return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush);
}) &
tbb::make_filter<std::string, void>(
tbb::filter::serial_in_order,
[&output_stream](std::string s) { output_stream.write(s); }
));
}
} }
std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override) std::string GCode::placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override)