mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-13 10:51:12 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
101 lines
3.3 KiB
C++
101 lines
3.3 KiB
C++
#ifndef slic3r_GCode_FanMover_hpp_
|
|
#define slic3r_GCode_FanMover_hpp_
|
|
|
|
|
|
#include "../ExtrusionEntity.hpp"
|
|
|
|
#include "../GCodeReader.hpp"
|
|
#include "../GCodeWriter.hpp"
|
|
#include <cstdint>
|
|
#include <list>
|
|
#include <algorithm>
|
|
#include <regex>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace Slic3r {
|
|
|
|
class BufferData {
|
|
public:
|
|
std::string raw;
|
|
float time;
|
|
int16_t fan_speed;
|
|
bool is_kickstart;
|
|
float x = 0, y = 0, z = 0, e = 0;
|
|
float dx = 0, dy = 0, dz = 0, de = 0;
|
|
BufferData(std::string line, float time = 0, int16_t fan_speed = 0, float is_kickstart = false) : raw(line), time(time), fan_speed(fan_speed), is_kickstart(is_kickstart){
|
|
//avoid double \n
|
|
if(!line.empty() && line.back() == '\n') line.pop_back();
|
|
}
|
|
};
|
|
|
|
class FanMover
|
|
{
|
|
private:
|
|
const std::regex regex_fan_speed;
|
|
const float nb_seconds_delay;
|
|
// Set from fan_speedup_time at the call site, but nothing here reads it.
|
|
[[maybe_unused]] const bool with_D_option;
|
|
const bool relative_e;
|
|
const bool only_overhangs;
|
|
const float kickstart;
|
|
|
|
GCodeReader m_parser{};
|
|
const GCodeWriter& m_writer;
|
|
|
|
//current value (at the back of the buffer), when parsing a new line
|
|
ExtrusionRole current_role = ExtrusionRole::erCustom;
|
|
// in unit/second
|
|
double m_current_speed = 1000 / 60.0;
|
|
bool m_is_custom_gcode = false;
|
|
uint16_t m_currrent_extruder = 0;
|
|
|
|
// variable for when you add a line (front of the buffer)
|
|
int m_front_buffer_fan_speed = 0;
|
|
int m_back_buffer_fan_speed = 0;
|
|
BufferData m_current_kickstart{"",-1,0};
|
|
|
|
//buffer
|
|
std::list<BufferData> m_buffer;
|
|
double m_buffer_time_size = 0;
|
|
|
|
// The output of process_layer()
|
|
std::string m_process_output;
|
|
|
|
public:
|
|
FanMover(const GCodeWriter& writer, const float nb_seconds_delay, const bool with_D_option, const bool relative_e,
|
|
const bool only_overhangs, const float kickstart)
|
|
: regex_fan_speed("S[0-9]+"),
|
|
nb_seconds_delay(nb_seconds_delay>0 ? std::max(0.01f,nb_seconds_delay) : 0),
|
|
with_D_option(with_D_option)
|
|
, relative_e(relative_e), only_overhangs(only_overhangs), kickstart(kickstart), m_writer(writer){
|
|
m_parser.apply_config(writer.config);
|
|
}
|
|
|
|
// Adds the gcode contained in the given string to the analysis and returns it after removing the workcodes
|
|
const std::string& process_gcode(const std::string& gcode, bool flush);
|
|
|
|
private:
|
|
BufferData& put_in_buffer(BufferData&& data) {
|
|
m_buffer_time_size += data.time;
|
|
m_buffer.emplace_back(data);
|
|
return m_buffer.back();
|
|
}
|
|
std::list<BufferData>::iterator remove_from_buffer(std::list<BufferData>::iterator data) {
|
|
m_buffer_time_size -= data->time;
|
|
return m_buffer.erase(data);
|
|
}
|
|
// Processes the given gcode line
|
|
void _process_gcode_line(GCodeReader& reader, const GCodeReader::GCodeLine& line);
|
|
void _process_T(const std::string_view command);
|
|
void _put_in_middle_G1(std::list<BufferData>::iterator item_to_split, float nb_sec, BufferData&& line_to_write);
|
|
void _print_in_middle_G1(BufferData& line_to_split, float nb_sec, const std::string& line_to_write);
|
|
void _remove_slow_fan(int16_t min_speed, float past_sec);
|
|
std::string _set_fan(int16_t speed);
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
#endif /* slic3r_GCode_FanMover_hpp_ */
|