2014-04-07 23:42:29 +00:00
|
|
|
#ifndef slic3r_Extruder_hpp_
|
|
|
|
#define slic3r_Extruder_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2014-04-07 23:42:29 +00:00
|
|
|
#include "Point.hpp"
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2020-03-04 08:24:13 +00:00
|
|
|
class GCodeConfig;
|
|
|
|
|
2014-04-07 23:42:29 +00:00
|
|
|
class Extruder
|
|
|
|
{
|
2017-05-03 16:28:22 +00:00
|
|
|
public:
|
2015-11-04 19:48:44 +00:00
|
|
|
Extruder(unsigned int id, GCodeConfig *config);
|
2014-04-07 23:42:29 +00:00
|
|
|
virtual ~Extruder() {}
|
2017-05-03 16:28:22 +00:00
|
|
|
|
2017-05-19 17:24:21 +00:00
|
|
|
void reset() {
|
2017-06-22 13:18:37 +00:00
|
|
|
m_E = 0;
|
|
|
|
m_absolute_E = 0;
|
|
|
|
m_retracted = 0;
|
|
|
|
m_restart_extra = 0;
|
2017-05-19 17:24:21 +00:00
|
|
|
}
|
|
|
|
|
2017-06-22 10:59:23 +00:00
|
|
|
unsigned int id() const { return m_id; }
|
|
|
|
|
2014-04-07 23:42:29 +00:00
|
|
|
double extrude(double dE);
|
2014-10-21 18:16:45 +00:00
|
|
|
double retract(double length, double restart_extra);
|
|
|
|
double unretract();
|
2017-06-22 13:18:37 +00:00
|
|
|
double E() const { return m_E; }
|
|
|
|
void reset_E() { m_E = 0.; }
|
|
|
|
double e_per_mm(double mm3_per_mm) const { return mm3_per_mm * m_e_per_mm3; }
|
2017-06-22 10:59:23 +00:00
|
|
|
double e_per_mm3() const { return m_e_per_mm3; }
|
2017-06-22 13:18:37 +00:00
|
|
|
// Used filament volume in mm^3.
|
2014-10-21 18:36:52 +00:00
|
|
|
double extruded_volume() const;
|
2017-06-22 13:18:37 +00:00
|
|
|
// Used filament length in mm.
|
2014-10-21 18:36:52 +00:00
|
|
|
double used_filament() const;
|
2014-04-28 20:02:34 +00:00
|
|
|
|
2014-04-27 21:49:05 +00:00
|
|
|
double filament_diameter() const;
|
2017-06-22 13:18:37 +00:00
|
|
|
double filament_crossection() const { return this->filament_diameter() * this->filament_diameter() * 0.25 * PI; }
|
2017-01-16 05:56:01 +00:00
|
|
|
double filament_density() const;
|
|
|
|
double filament_cost() const;
|
2014-04-27 21:49:05 +00:00
|
|
|
double extrusion_multiplier() const;
|
2017-05-19 17:24:21 +00:00
|
|
|
double retract_before_wipe() const;
|
2014-04-27 21:49:05 +00:00
|
|
|
double retract_length() const;
|
|
|
|
double retract_lift() const;
|
2017-05-03 16:28:22 +00:00
|
|
|
int retract_speed() const;
|
2017-05-19 17:24:21 +00:00
|
|
|
int deretract_speed() const;
|
2014-04-27 21:49:05 +00:00
|
|
|
double retract_restart_extra() const;
|
|
|
|
double retract_length_toolchange() const;
|
|
|
|
double retract_restart_extra_toolchange() const;
|
2017-05-03 16:28:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Private constructor to create a key for a search in std::set.
|
2017-06-22 10:59:23 +00:00
|
|
|
Extruder(unsigned int id) : m_id(id) {}
|
2017-05-03 16:28:22 +00:00
|
|
|
|
2017-06-22 13:18:37 +00:00
|
|
|
// Reference to GCodeWriter instance owned by GCodeWriter.
|
2017-05-03 16:28:22 +00:00
|
|
|
GCodeConfig *m_config;
|
2017-06-22 13:18:37 +00:00
|
|
|
// Print-wide global ID of this extruder.
|
2017-06-22 10:59:23 +00:00
|
|
|
unsigned int m_id;
|
2017-06-22 13:18:37 +00:00
|
|
|
// Current state of the extruder axis, may be resetted if use_relative_e_distances.
|
|
|
|
double m_E;
|
|
|
|
// Current state of the extruder tachometer, used to output the extruded_volume() and used_filament() statistics.
|
|
|
|
double m_absolute_E;
|
|
|
|
// Current positive amount of retraction.
|
|
|
|
double m_retracted;
|
|
|
|
// When retracted, this value stores the extra amount of priming on deretraction.
|
|
|
|
double m_restart_extra;
|
2017-06-22 10:59:23 +00:00
|
|
|
double m_e_per_mm3;
|
2014-04-07 23:42:29 +00:00
|
|
|
};
|
|
|
|
|
2017-05-03 16:28:22 +00:00
|
|
|
// Sort Extruder objects by the extruder id by default.
|
2017-06-22 10:59:23 +00:00
|
|
|
inline bool operator==(const Extruder &e1, const Extruder &e2) { return e1.id() == e2.id(); }
|
|
|
|
inline bool operator!=(const Extruder &e1, const Extruder &e2) { return e1.id() != e2.id(); }
|
|
|
|
inline bool operator< (const Extruder &e1, const Extruder &e2) { return e1.id() < e2.id(); }
|
|
|
|
inline bool operator> (const Extruder &e1, const Extruder &e2) { return e1.id() > e2.id(); }
|
2017-05-03 16:28:22 +00:00
|
|
|
|
2014-04-07 23:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|