Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Extruder Class Reference

#include <src/libslic3r/Extruder.hpp>

Public Member Functions

 Extruder (unsigned int id, GCodeConfig *config)
 
 ~Extruder ()=default
 
unsigned int id () const
 
std::pair< double, double > extrude (double dE)
 
std::pair< double, double > retract (double retract_length, double restart_extra)
 
std::pair< double, double > unretract ()
 
double retract_to_go (double retract_length) const
 
bool reset_E ()
 
double e_per_mm (double mm3_per_mm) const
 
double e_per_mm3 () const
 
double extruded_volume () const
 
double used_filament () const
 
double position () const
 
double retracted () const
 
double restart_extra () const
 
void set_position (double e)
 
void set_retracted (double retracted, double restart_extra)
 
double filament_diameter () const
 
double filament_crossection () const
 
double filament_density () const
 
double filament_cost () const
 
double extrusion_multiplier () const
 
double retract_before_wipe () const
 
double retract_length () const
 
double retract_lift () const
 
int retract_speed () const
 
int deretract_speed () const
 
double retract_restart_extra () const
 
double retract_length_toolchange () const
 
double retract_restart_extra_toolchange () const
 

Private Member Functions

 Extruder (unsigned int id)
 

Private Attributes

GCodeConfig * m_config
 
unsigned int m_id
 
double m_E { 0 }
 
double m_absolute_E { 0 }
 
double m_retracted { 0 }
 
double m_restart_extra { 0 }
 
double m_e_per_mm3
 

Detailed Description

Constructor & Destructor Documentation

◆ Extruder() [1/2]

Slic3r::Extruder::Extruder ( unsigned int  id,
GCodeConfig *  config 
)
7 :
8 m_id(id),
9 m_config(config)
10{
11 // cache values that are going to be called often
13 if (! m_config->use_volumetric_e)
15}
double m_e_per_mm3
Definition Extruder.hpp:85
double filament_crossection() const
Definition Extruder.hpp:54
unsigned int m_id
Definition Extruder.hpp:74
GCodeConfig * m_config
Definition Extruder.hpp:72
double extrusion_multiplier() const
Definition Extruder.cpp:117

References extrusion_multiplier(), filament_crossection(), m_config, and m_e_per_mm3.

+ Here is the call graph for this function:

◆ ~Extruder()

Slic3r::Extruder::~Extruder ( )
default

◆ Extruder() [2/2]

Slic3r::Extruder::Extruder ( unsigned int  id)
inlineprivate
69: m_id(id) {}

Member Function Documentation

◆ deretract_speed()

int Slic3r::Extruder::deretract_speed ( ) const
144{
145 int speed = int(floor(m_config->deretract_speed.get_at(m_id)+0.5));
146 return (speed > 0) ? speed : this->retract_speed();
147}
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
Definition ArrayCwiseUnaryOps.h:388
int retract_speed() const
Definition Extruder.cpp:138

References floor(), m_config, m_id, and retract_speed().

Referenced by Slic3r::GCodeWriter::unretract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ e_per_mm()

double Slic3r::Extruder::e_per_mm ( double  mm3_per_mm) const
inline
33{ return mm3_per_mm * m_e_per_mm3; }

References m_e_per_mm3.

Referenced by Slic3r::Print::_make_skirt().

+ Here is the caller graph for this function:

◆ e_per_mm3()

double Slic3r::Extruder::e_per_mm3 ( ) const
inline
34{ return m_e_per_mm3; }

References m_e_per_mm3.

Referenced by Slic3r::GCode::_extrude().

+ Here is the caller graph for this function:

◆ extrude()

std::pair< double, double > Slic3r::Extruder::extrude ( double  dE)
18{
19 // in case of relative E distances we always reset to 0 before any output
20 if (m_config->use_relative_e_distances)
21 m_E = 0.;
22 // Quantize extruder delta to G-code resolution.
24 m_E += dE;
25 m_absolute_E += dE;
26 if (dE < 0.)
27 m_retracted -= dE;
28 return std::make_pair(dE, m_E);
29}
double m_E
Definition Extruder.hpp:78
double m_retracted
Definition Extruder.hpp:82
double m_absolute_E
Definition Extruder.hpp:80
static double quantize_e(double v)
Definition GCodeWriter.hpp:154

References m_absolute_E, m_config, m_E, m_retracted, and Slic3r::GCodeFormatter::quantize_e().

Referenced by Slic3r::GCodeWriter::extrude_to_xy(), and unretract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extruded_volume()

double Slic3r::Extruder::extruded_volume ( ) const
88{
89 return m_config->use_volumetric_e ?
91 this->used_filament() * this->filament_crossection();
92}
double used_filament() const
Definition Extruder.cpp:95

References filament_crossection(), m_absolute_E, m_config, m_retracted, and used_filament().

Referenced by used_filament().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extrusion_multiplier()

double Slic3r::Extruder::extrusion_multiplier ( ) const
118{
119 return m_config->extrusion_multiplier.get_at(m_id);
120}

References m_config, and m_id.

Referenced by Extruder().

+ Here is the caller graph for this function:

◆ filament_cost()

double Slic3r::Extruder::filament_cost ( ) const
113{
114 return m_config->filament_cost.get_at(m_id);
115}

References m_config, and m_id.

◆ filament_crossection()

double Slic3r::Extruder::filament_crossection ( ) const
inline
54{ return this->filament_diameter() * this->filament_diameter() * 0.25 * PI; }
double filament_diameter() const
Definition Extruder.cpp:102
static constexpr double PI
Definition libslic3r.h:58

References filament_diameter(), and PI.

Referenced by Extruder(), extruded_volume(), and used_filament().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filament_density()

double Slic3r::Extruder::filament_density ( ) const
108{
109 return m_config->filament_density.get_at(m_id);
110}

References m_config, and m_id.

◆ filament_diameter()

double Slic3r::Extruder::filament_diameter ( ) const
103{
104 return m_config->filament_diameter.get_at(m_id);
105}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::_retract(), and filament_crossection().

+ Here is the caller graph for this function:

◆ id()

unsigned int Slic3r::Extruder::id ( ) const
inline

◆ position()

double Slic3r::Extruder::position ( ) const
inline
42{ return m_E; }

References m_E.

◆ reset_E()

bool Slic3r::Extruder::reset_E ( )
inline
32{ bool modified = m_E != 0; m_E = 0.; return modified; }

References m_E.

Referenced by Slic3r::GCodeWriter::reset_e().

+ Here is the caller graph for this function:

◆ restart_extra()

double Slic3r::Extruder::restart_extra ( ) const
inline
46{ return m_restart_extra; }
double m_restart_extra
Definition Extruder.hpp:84

References m_restart_extra.

Referenced by retract(), and set_retracted().

+ Here is the caller graph for this function:

◆ retract()

std::pair< double, double > Slic3r::Extruder::retract ( double  retract_length,
double  restart_extra 
)
39{
40 assert(restart_extra >= 0);
41 // in case of relative E distances we always reset to 0 before any output
42 if (m_config->use_relative_e_distances)
43 m_E = 0.;
44 // Quantize extruder delta to G-code resolution.
45 double to_retract = this->retract_to_go(retract_length);
46 if (to_retract > 0.) {
47 m_E -= to_retract;
48 m_absolute_E -= to_retract;
49 m_retracted += to_retract;
51 }
52 return std::make_pair(to_retract, m_E);
53}
double restart_extra() const
Definition Extruder.hpp:46
double retract_length() const
Definition Extruder.cpp:128
double retract_to_go(double retract_length) const
Definition Extruder.cpp:55

References m_absolute_E, m_config, m_E, m_restart_extra, m_retracted, restart_extra(), and retract_to_go().

Referenced by Slic3r::GCodeWriter::_retract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retract_before_wipe()

double Slic3r::Extruder::retract_before_wipe ( ) const
124{
125 return std::min(1., std::max(0., m_config->retract_before_wipe.get_at(m_id) * 0.01));
126}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::retract(), and Slic3r::GCodeWriter::retract_for_toolchange().

+ Here is the caller graph for this function:

◆ retract_length()

double Slic3r::Extruder::retract_length ( ) const
129{
130 return m_config->retract_length.get_at(m_id);
131}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::retract(), Slic3r::GCode::retract(), retract_to_go(), and Slic3r::Wipe::wipe().

+ Here is the caller graph for this function:

◆ retract_length_toolchange()

double Slic3r::Extruder::retract_length_toolchange ( ) const
155{
156 return m_config->retract_length_toolchange.get_at(m_id);
157}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::retract_for_toolchange(), and Slic3r::Wipe::wipe().

+ Here is the caller graph for this function:

◆ retract_lift()

double Slic3r::Extruder::retract_lift ( ) const
134{
135 return m_config->retract_lift.get_at(m_id);
136}

References m_config, and m_id.

◆ retract_restart_extra()

double Slic3r::Extruder::retract_restart_extra ( ) const
150{
151 return m_config->retract_restart_extra.get_at(m_id);
152}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::retract().

+ Here is the caller graph for this function:

◆ retract_restart_extra_toolchange()

double Slic3r::Extruder::retract_restart_extra_toolchange ( ) const
160{
161 return m_config->retract_restart_extra_toolchange.get_at(m_id);
162}

References m_config, and m_id.

Referenced by Slic3r::GCodeWriter::retract_for_toolchange().

+ Here is the caller graph for this function:

◆ retract_speed()

int Slic3r::Extruder::retract_speed ( ) const
139{
140 return int(floor(m_config->retract_speed.get_at(m_id)+0.5));
141}

References floor(), m_config, and m_id.

Referenced by Slic3r::GCodeWriter::_retract(), deretract_speed(), and Slic3r::Wipe::wipe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retract_to_go()

double Slic3r::Extruder::retract_to_go ( double  retract_length) const
56{
58}

References m_retracted, Slic3r::GCodeFormatter::quantize_e(), and retract_length().

Referenced by retract(), and Slic3r::Wipe::wipe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retracted()

double Slic3r::Extruder::retracted ( ) const
inline
44{ return m_retracted; }

References m_retracted.

Referenced by set_retracted().

+ Here is the caller graph for this function:

◆ set_position()

void Slic3r::Extruder::set_position ( double  e)
inline
49{ m_E = e; }

References m_E.

◆ set_retracted()

void Slic3r::Extruder::set_retracted ( double  retracted,
double  restart_extra 
)
71{
72 if (retracted < - EPSILON)
73 throw Slic3r::RuntimeError("Custom G-code reports negative z_retracted.");
74 if (restart_extra < - EPSILON)
75 throw Slic3r::RuntimeError("Custom G-code reports negative z_restart_extra.");
76
77 if (retracted > EPSILON) {
80 } else {
81 m_retracted = 0;
83 }
84}
double retracted() const
Definition Extruder.hpp:44
static constexpr double EPSILON
Definition libslic3r.h:51

References EPSILON, m_restart_extra, m_retracted, restart_extra(), and retracted().

Referenced by Slic3r::GCode::placeholder_parser_process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unretract()

std::pair< double, double > Slic3r::Extruder::unretract ( )
61{
62 auto [dE, emitE] = this->extrude(m_retracted + m_restart_extra);
63 m_retracted = 0.;
64 m_restart_extra = 0.;
65 return std::make_pair(dE, emitE);
66}
std::pair< double, double > extrude(double dE)
Definition Extruder.cpp:17

References extrude(), m_restart_extra, and m_retracted.

Referenced by Slic3r::GCodeWriter::unretract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ used_filament()

double Slic3r::Extruder::used_filament ( ) const
96{
97 return m_config->use_volumetric_e ?
98 this->extruded_volume() / this->filament_crossection() :
100}
double extruded_volume() const
Definition Extruder.cpp:87

References extruded_volume(), filament_crossection(), m_absolute_E, m_config, and m_retracted.

Referenced by extruded_volume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_absolute_E

double Slic3r::Extruder::m_absolute_E { 0 }
private

◆ m_config

◆ m_E

double Slic3r::Extruder::m_E { 0 }
private

◆ m_e_per_mm3

double Slic3r::Extruder::m_e_per_mm3
private

Referenced by Extruder(), e_per_mm(), and e_per_mm3().

◆ m_id

◆ m_restart_extra

double Slic3r::Extruder::m_restart_extra { 0 }
private

◆ m_retracted

double Slic3r::Extruder::m_retracted { 0 }
private

The documentation for this class was generated from the following files: