mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Fix retraction issues
This commit is contained in:
parent
2d849fec6c
commit
df0a49a73d
4 changed files with 12 additions and 7 deletions
|
@ -22,9 +22,8 @@ public:
|
||||||
} else {
|
} else {
|
||||||
m_E = 0;
|
m_E = 0;
|
||||||
m_retracted = 0;
|
m_retracted = 0;
|
||||||
m_restart_extra = 0;
|
|
||||||
}
|
}
|
||||||
|
m_restart_extra = 0;
|
||||||
m_absolute_E = 0;
|
m_absolute_E = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ public:
|
||||||
double retract(double length, double restart_extra);
|
double retract(double length, double restart_extra);
|
||||||
double unretract();
|
double unretract();
|
||||||
double E() const { return m_share_extruder ? m_share_E : m_E; }
|
double E() const { return m_share_extruder ? m_share_E : m_E; }
|
||||||
void reset_E() { m_E = 0.; m_share_E = 0.; }
|
void reset_E() { reset(); }
|
||||||
double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; }
|
double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; }
|
||||||
double e_per_mm3() const { return m_e_per_mm3; }
|
double e_per_mm3() const { return m_e_per_mm3; }
|
||||||
// Used filament volume in mm^3.
|
// Used filament volume in mm^3.
|
||||||
|
|
|
@ -213,7 +213,7 @@ public:
|
||||||
|
|
||||||
std::string travel_to(const Point& point, ExtrusionRole role, std::string comment);
|
std::string travel_to(const Point& point, ExtrusionRole role, std::string comment);
|
||||||
bool needs_retraction(const Polyline& travel, ExtrusionRole role, LiftType& lift_type);
|
bool needs_retraction(const Polyline& travel, ExtrusionRole role, LiftType& lift_type);
|
||||||
std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::SpiralLift);
|
std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::NormalLift);
|
||||||
std::string unretract() { return m_writer.unlift() + m_writer.unretract(); }
|
std::string unretract() { return m_writer.unlift() + m_writer.unretract(); }
|
||||||
std::string set_extruder(unsigned int extruder_id, double print_z);
|
std::string set_extruder(unsigned int extruder_id, double print_z);
|
||||||
bool is_BBL_Printer();
|
bool is_BBL_Printer();
|
||||||
|
|
|
@ -320,7 +320,7 @@ std::string GCodeWriter::reset_e(bool force)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (m_extruder != nullptr) {
|
if (m_extruder != nullptr) {
|
||||||
if (m_extruder->E() == 0. && ! force)
|
if (is_zero(m_extruder->E()) && ! force)
|
||||||
return "";
|
return "";
|
||||||
m_extruder->reset_E();
|
m_extruder->reset_E();
|
||||||
}
|
}
|
||||||
|
@ -709,7 +709,7 @@ std::string GCodeWriter::_retract(double length, double restart_extra, const std
|
||||||
length = 1;
|
length = 1;
|
||||||
|
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
if (double dE = m_extruder->retract(length, restart_extra); dE != 0) {
|
if (double dE = m_extruder->retract(length, restart_extra); !is_zero(dE)) {
|
||||||
if (this->config.use_firmware_retraction) {
|
if (this->config.use_firmware_retraction) {
|
||||||
gcode = FLAVOR_IS(gcfMachinekit) ? "G22 ; retract\n" : "G10 ; retract\n";
|
gcode = FLAVOR_IS(gcfMachinekit) ? "G22 ; retract\n" : "G10 ; retract\n";
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,7 @@ std::string GCodeWriter::unretract()
|
||||||
if (FLAVOR_IS(gcfMakerWare))
|
if (FLAVOR_IS(gcfMakerWare))
|
||||||
gcode = "M101 ; extruder on\n";
|
gcode = "M101 ; extruder on\n";
|
||||||
|
|
||||||
if (double dE = m_extruder->unretract(); dE != 0) {
|
if (double dE = m_extruder->unretract(); !is_zero(dE)) {
|
||||||
if (this->config.use_firmware_retraction) {
|
if (this->config.use_firmware_retraction) {
|
||||||
gcode += FLAVOR_IS(gcfMachinekit) ? "G23 ; unretract\n" : "G11 ; unretract\n";
|
gcode += FLAVOR_IS(gcfMachinekit) ? "G23 ; unretract\n" : "G11 ; unretract\n";
|
||||||
gcode += this->reset_e();
|
gcode += this->reset_e();
|
||||||
|
|
|
@ -278,6 +278,12 @@ constexpr inline T sqr(T x)
|
||||||
return x * x;
|
return x * x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Number> constexpr
|
||||||
|
inline bool is_zero(Number value)
|
||||||
|
{
|
||||||
|
return std::fabs(double(value)) < 1e-6;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, typename Number>
|
template <typename T, typename Number>
|
||||||
constexpr inline T lerp(const T& a, const T& b, Number t)
|
constexpr inline T lerp(const T& a, const T& b, Number t)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue