Refactored the cooling buffer: Removed ElapsedTime.

This commit is contained in:
bubnikv 2017-06-30 20:01:32 +02:00
parent bf9027ff2d
commit 0ad4e9d51f
5 changed files with 19 additions and 105 deletions

View file

@ -10,54 +10,6 @@ namespace Slic3r {
class GCode;
class Layer;
struct ElapsedTime
{
ElapsedTime(unsigned int extruder_id = 0) : extruder_id(extruder_id) { this->reset(); }
void reset() {
total = bridges = external_perimeters = travel = other = 0.f;
max_stretch_time_total = max_stretch_time_no_ext_perimetes = 0.f;
}
ElapsedTime& operator+=(const ElapsedTime &rhs) {
this->total += rhs.total;
this->bridges += rhs.bridges;
this->external_perimeters += rhs.external_perimeters;
this->travel += rhs.travel;
this->other += rhs.other;
this->max_stretch_time_total += rhs.max_stretch_time_total;
this->max_stretch_time_no_ext_perimetes += rhs.max_stretch_time_no_ext_perimetes;
return *this;
}
// Potion of the total time, which cannot be stretched to heed the minimum layer print time.
float non_stretchable(bool stretch_external_perimeters = true) const
{ return this->bridges + this->travel + this->other + (stretch_external_perimeters ? 0.f : this->external_perimeters); }
// Potion of the total time, which could be stretched to heed the minimum layer print time.
float stretchable(bool stretch_external_perimeters = true) const
{ return this->total - this->non_stretchable(stretch_external_perimeters); }
// For which extruder ID has this statistics been collected?
unsigned int extruder_id;
// Total time.
float total;
// Per feature time slices.
float bridges;
float external_perimeters;
float travel;
float other;
// Per feature maximum time, to which the extrusion could be stretched to respect the extruder specific min_print_speed.
// Maximum stretch time, to which the time this->stretchable() could be extended.
float max_stretch_time_total;
// Maximum stretch time, to which the time (this->stretchable() - external_perimeters) could be extended.
float max_stretch_time_no_ext_perimetes;
};
// Sort ElapsedTime objects by the extruder id by default.
inline bool operator==(const ElapsedTime &e1, const ElapsedTime &e2) { return e1.extruder_id == e2.extruder_id; }
inline bool operator!=(const ElapsedTime &e1, const ElapsedTime &e2) { return e1.extruder_id != e2.extruder_id; }
inline bool operator< (const ElapsedTime &e1, const ElapsedTime &e2) { return e1.extruder_id < e2.extruder_id; }
inline bool operator> (const ElapsedTime &e1, const ElapsedTime &e2) { return e1.extruder_id > e2.extruder_id; }
/*
A standalone G-code filter, to control cooling of the print.
The G-code is processed per layer. Once a layer is collected, fan start / stop commands are edited