Skip to content

Commit

Permalink
Fan speed up from SS (with Fix GCodeReader::update_coordinates for G2…
Browse files Browse the repository at this point in the history
… & G3)
  • Loading branch information
vovodroid committed Apr 23, 2024
1 parent 3b5f4bb commit 291a6a5
Show file tree
Hide file tree
Showing 10 changed files with 653 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/libslic3r/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ set(SLIC3R_SOURCES
GCode/CoolingBuffer.hpp
GCode/ExtrusionProcessor.cpp
GCode/ExtrusionProcessor.hpp
GCode/FanMover.cpp
GCode/FindReplace.cpp
GCode/FindReplace.hpp
GCode/LabelObjects.cpp
Expand Down
42 changes: 40 additions & 2 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
m_last_mm3_per_mm = 0.;
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
m_fan_mover.release();

// How many times will be change_layer() called?gcode.cpp
// change_layer() in turn increments the progress bar status.
Expand Down Expand Up @@ -1628,14 +1629,32 @@ void GCodeGenerator::process_layers(
const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order,
[&output_stream](std::string s) { output_stream.write(s); }
);
const auto fan_mover = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&fan_mover = this->m_fan_mover, &config = this->config(), &writer = this->m_writer](std::string in)->std::string {

int extr_id = writer.extruder()->id();
float fan_speedup_time = writer.config.fan_speedup_time.get_at(extr_id);
if (fan_speedup_time != 0 /*|| config.fan_kickstart.value > 0*/) {
if (fan_mover.get() == nullptr)
fan_mover.reset(new Slic3r::FanMover(
writer,
fan_speedup_time,
config.use_relative_e_distances.value,
false,//config.fan_speedup_overhangs_only.value,
0.));//(float)config.fan_kickstart.value));
//flush as it's a whole layer
return fan_mover->process_gcode(in, true);
}
return in;
});

tbb::filter<void, LayerResult> pipeline_to_layerresult = smooth_path_interpolator & generator;
if (m_spiral_vase)
pipeline_to_layerresult = pipeline_to_layerresult & spiral_vase;
if (m_pressure_equalizer)
pipeline_to_layerresult = pipeline_to_layerresult & pressure_equalizer;

tbb::filter<LayerResult, std::string> pipeline_to_string = cooling;
tbb::filter<LayerResult, std::string> pipeline_to_string = cooling & fan_mover;
if (m_find_replace)
pipeline_to_string = pipeline_to_string & find_replace;

Expand Down Expand Up @@ -1721,14 +1740,33 @@ void GCodeGenerator::process_layers(
const auto output = tbb::make_filter<std::string, void>(slic3r_tbb_filtermode::serial_in_order,
[&output_stream](std::string s) { output_stream.write(s); }
);

const auto fan_mover = tbb::make_filter<std::string, std::string>(slic3r_tbb_filtermode::serial_in_order,
[&fan_mover = this->m_fan_mover, &config = this->config(), &writer = this->m_writer](std::string in)->std::string {

int extr_id = writer.extruder()->id();
float fan_speedup_time = writer.config.fan_speedup_time.get_at(extr_id);
if (fan_speedup_time != 0 /*|| config.fan_kickstart.value > 0*/) {
if (fan_mover.get() == nullptr)
fan_mover.reset(new Slic3r::FanMover(
writer,
fan_speedup_time,
config.use_relative_e_distances.value,
false,//config.fan_speedup_overhangs_only.value,
0.));//(float)config.fan_kickstart.value));
//flush as it's a whole layer
return fan_mover->process_gcode(in, true);
}
return in;
});

tbb::filter<void, LayerResult> pipeline_to_layerresult = smooth_path_interpolator & generator;
if (m_spiral_vase)
pipeline_to_layerresult = pipeline_to_layerresult & spiral_vase;
if (m_pressure_equalizer)
pipeline_to_layerresult = pipeline_to_layerresult & pressure_equalizer;

tbb::filter<LayerResult, std::string> pipeline_to_string = cooling;
tbb::filter<LayerResult, std::string> pipeline_to_string = cooling & fan_mover;
if (m_find_replace)
pipeline_to_string = pipeline_to_string & find_replace;

Expand Down
4 changes: 4 additions & 0 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Geometry/ArcWelder.hpp"
#include "GCode/AvoidCrossingPerimeters.hpp"
#include "GCode/CoolingBuffer.hpp"
#include "GCode/FanMover.hpp"
#include "GCode/FindReplace.hpp"
#include "GCode/GCodeWriter.hpp"
#include "GCode/LabelObjects.hpp"
Expand Down Expand Up @@ -467,6 +468,9 @@ class GCodeGenerator {
// Processor
GCodeProcessor m_processor;

//some post-processing on the file, with their data class
std::unique_ptr<FanMover> m_fan_mover;

// Back-pointer to Print (const).
const Print* m_print;

Expand Down
Loading

0 comments on commit 291a6a5

Please sign in to comment.