mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 06:11:02 +00:00
* Add Missing Includes Across src/libslic3r Every libslic3r source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, with libslic3r headers spelled libslic3r/... so they resolve outside the library's private include paths. MultiMaterialSegmentation.hpp, Support/SupportParameters.hpp and Format/STEP.hpp are made self-contained by hand. * Make the libslic3r Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Left out: I18N.hpp, which errors on purpose when included from GUI code, and VoxelizeCSGMesh.hpp and SLA/bicubic.h, which nothing includes and which no longer compile at all. * Add the Includes Missing From the Hand-Fixed libslic3r Headers clang-tidy would not edit these headers while they failed to compile on their own, so the first pass skipped them. With the headers now self-contained, a second pass adds the rest. * Keep Windows Setup Ahead of the Added libslic3r Includes Print.cpp and Thread.cpp open with a _WIN32 block that has to come first; without the precompiled header, Print.cpp otherwise reaches windows.h through OCCT with NONLS defined and boost/regex fails. OpenVDBUtils.cpp and SLA/SupportTreeBuilder.cpp had includes inside #ifndef NOMINMAX, which libslic3r defines on Windows, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory. * Re-Add libslic3r Includes After the Clipper2 2.0.1 Migration Rebasing onto main took main's version of the files the Clipper2 migration rewrote, so their added includes are restored here, along with includes for main's new code. Clipper2's individual headers are now ignored by clang-tidy: they only build the Z variant through clipper2_z.hpp, which defines USINGZ first, so including clipper.core.h and the like directly broke ClipperZUtils.cpp.
104 lines
3.4 KiB
C++
104 lines
3.4 KiB
C++
#ifndef slic3r_GCode_FanMover_hpp_
|
|
#define slic3r_GCode_FanMover_hpp_
|
|
|
|
|
|
#include "../libslic3r.h"
|
|
#include "../PrintConfig.hpp"
|
|
#include "../ExtrusionEntity.hpp"
|
|
|
|
#include "../Point.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_ */
|