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

#include <src/libslic3r/Flow.hpp>

Public Member Functions

 Flow ()=default
 
 Flow (float width, float height, float nozzle_diameter)
 
float width () const
 
coord_t scaled_width () const
 
float height () const
 
float spacing () const
 
coord_t scaled_spacing () const
 
float nozzle_diameter () const
 
bool bridge () const
 
double mm3_per_mm () const
 
coord_t scaled_elephant_foot_spacing () const
 
bool operator== (const Flow &rhs) const
 
Flow with_width (float width) const
 
Flow with_height (float height) const
 
Flow with_spacing (float spacing) const
 
Flow with_cross_section (float area) const
 
Flow with_flow_ratio (double ratio) const
 

Static Public Member Functions

static Flow bridging_flow (float dmr, float nozzle_diameter)
 
static Flow new_from_config_width (FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height)
 
static float rounded_rectangle_extrusion_spacing (float width, float height)
 
static float rounded_rectangle_extrusion_width_from_spacing (float spacing, float height)
 
static float bridge_extrusion_spacing (float dmr)
 
static float auto_extrusion_width (FlowRole role, float nozzle_diameter)
 
static double extrusion_width (const std::string &opt_key, const ConfigOptionFloatOrPercent *opt, const ConfigOptionResolver &config, const unsigned int first_printing_extruder=0)
 
static double extrusion_width (const std::string &opt_key, const ConfigOptionResolver &config, const unsigned int first_printing_extruder=0)
 

Private Member Functions

 Flow (float width, float height, float spacing, float nozzle_diameter, bool bridge)
 

Private Attributes

float m_width { 0 }
 
float m_height { 0 }
 
float m_spacing { 0 }
 
float m_nozzle_diameter { 0 }
 
bool m_bridge { false }
 

Detailed Description

Constructor & Destructor Documentation

◆ Flow() [1/3]

Slic3r::Flow::Flow ( )
default

Referenced by new_from_config_width(), with_cross_section(), with_height(), and with_width().

+ Here is the caller graph for this function:

◆ Flow() [2/3]

Slic3r::Flow::Flow ( float  width,
float  height,
float  nozzle_diameter 
)
inline
55 :
float height() const
Definition Flow.hpp:64
static float rounded_rectangle_extrusion_spacing(float width, float height)
Definition Flow.cpp:186
Flow()=default
float width() const
Definition Flow.hpp:60
float nozzle_diameter() const
Definition Flow.hpp:69

◆ Flow() [3/3]

Slic3r::Flow::Flow ( float  width,
float  height,
float  spacing,
float  nozzle_diameter,
bool  bridge 
)
inlineprivate
119 :
121 {
122 // Gap fill violates this condition.
123 //assert(width >= height);
124 }
float m_width
Definition Flow.hpp:126
float spacing() const
Definition Flow.hpp:66
float m_nozzle_diameter
Definition Flow.hpp:129
bool bridge() const
Definition Flow.hpp:71
float m_spacing
Definition Flow.hpp:128
bool m_bridge
Definition Flow.hpp:130
float m_height
Definition Flow.hpp:127

Member Function Documentation

◆ auto_extrusion_width()

float Slic3r::Flow::auto_extrusion_width ( FlowRole  role,
float  nozzle_diameter 
)
static
19{
20 switch (role) {
24 return nozzle_diameter;
25 default:
27 case frPerimeter:
28 case frSolidInfill:
29 case frInfill:
30 return 1.125f * nozzle_diameter;
31 }
32}
@ frTopSolidInfill
Definition Flow.hpp:21
@ frSupportMaterial
Definition Flow.hpp:22
@ frExternalPerimeter
Definition Flow.hpp:17
@ frPerimeter
Definition Flow.hpp:18
@ frSolidInfill
Definition Flow.hpp:20
@ frSupportMaterialInterface
Definition Flow.hpp:23
@ frInfill
Definition Flow.hpp:19

References Slic3r::frExternalPerimeter, Slic3r::frInfill, Slic3r::frPerimeter, Slic3r::frSolidInfill, Slic3r::frSupportMaterial, Slic3r::frSupportMaterialInterface, Slic3r::frTopSolidInfill, and nozzle_diameter().

Referenced by Slic3r::FillLightning::Generator::Generator(), Slic3r::FillAdaptive::adaptive_fill_line_spacing(), extrusion_width(), and new_from_config_width().

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

◆ bridge()

bool Slic3r::Flow::bridge ( ) const
inline
71{ return m_bridge; }

References m_bridge.

Referenced by Slic3r::PerimeterGenerator::thick_polyline_to_multi_path().

+ Here is the caller graph for this function:

◆ bridge_extrusion_spacing()

float Slic3r::Flow::bridge_extrusion_spacing ( float  dmr)
static
200{
201 return dmr + BRIDGE_EXTRA_SPACING;
202}
#define BRIDGE_EXTRA_SPACING
Definition Flow.hpp:14

References BRIDGE_EXTRA_SPACING.

Referenced by bridging_flow().

+ Here is the caller graph for this function:

◆ bridging_flow()

static Flow Slic3r::Flow::bridging_flow ( float  dmr,
float  nozzle_diameter 
)
inlinestatic
97{ return Flow { dmr, dmr, bridge_extrusion_spacing(dmr), nozzle_diameter, true }; }
static float bridge_extrusion_spacing(float dmr)
Definition Flow.cpp:199

References bridge_extrusion_spacing(), and nozzle_diameter().

Referenced by Slic3r::FFFSupport::SupportParameters::SupportParameters(), Slic3r::LayerRegion::bridging_flow(), Slic3r::PresetHints::maximum_volumetric_flow_description(), and Slic3r::ExtrusionPath::polygons_covered_by_spacing().

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

◆ extrusion_width() [1/2]

double Slic3r::Flow::extrusion_width ( const std::string &  opt_key,
const ConfigOptionFloatOrPercent opt,
const ConfigOptionResolver config,
const unsigned int  first_printing_extruder = 0 
)
static
63{
64 assert(opt != nullptr);
65
66 bool first_layer = boost::starts_with(opt_key, "first_layer_");
67
68#if 0
69// This is the logic used for skit / brim, but not for the rest of the 1st layer.
70 if (opt->value == 0. && first_layer) {
71 // The "first_layer_extrusion_width" was set to zero, try a substitute.
72 opt = config.option<ConfigOptionFloatOrPercent>("perimeter_extrusion_width");
73 if (opt == nullptr)
74 throw_on_missing_variable(opt_key, "perimeter_extrusion_width");
75 }
76#endif
77
78 if (opt->value == 0.) {
79 // The role specific extrusion width value was set to zero, try the role non-specific extrusion width.
80 opt = config.option<ConfigOptionFloatOrPercent>("extrusion_width");
81 if (opt == nullptr)
82 throw_on_missing_variable(opt_key, "extrusion_width");
83 // Use the "layer_height" instead of "first_layer_height".
84 first_layer = false;
85 }
86
87 if (opt->percent) {
88 auto opt_key_layer_height = first_layer ? "first_layer_height" : "layer_height";
89 auto opt_layer_height = config.option(opt_key_layer_height);
90 if (opt_layer_height == nullptr)
91 throw_on_missing_variable(opt_key, opt_key_layer_height);
92 assert(! first_layer || ! static_cast<const ConfigOptionFloatOrPercent*>(opt_layer_height)->percent);
93 return opt->get_abs_value(opt_layer_height->getFloat());
94 }
95
96 if (opt->value == 0.) {
97 // If user left option to 0, calculate a sane default width.
98 auto opt_nozzle_diameters = config.option<ConfigOptionFloats>("nozzle_diameter");
99 if (opt_nozzle_diameters == nullptr)
100 throw_on_missing_variable(opt_key, "nozzle_diameter");
101 return auto_extrusion_width(opt_key_to_flow_role(opt_key), float(opt_nozzle_diameters->get_at(first_printing_extruder)));
102 }
103
104 return opt->value;
105}
static float auto_extrusion_width(FlowRole role, float nozzle_diameter)
Definition Flow.cpp:18
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:716
static FlowRole opt_key_to_flow_role(const std::string &opt_key)
Definition Flow.cpp:36
static void throw_on_missing_variable(const std::string &opt_key, const char *dependent_opt_key)
Definition Flow.cpp:56

References auto_extrusion_width(), Slic3r::ConfigOptionFloatOrPercent::get_abs_value(), Slic3r::opt_key_to_flow_role(), Slic3r::ConfigOptionResolver::option(), Slic3r::ConfigOptionFloatOrPercent::percent, Slic3r::throw_on_missing_variable(), and Slic3r::ConfigOptionSingle< T >::value.

Referenced by extrusion_width(), and Slic3r::client::MyContext::scalar_variable_to_expr().

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

◆ extrusion_width() [2/2]

double Slic3r::Flow::extrusion_width ( const std::string &  opt_key,
const ConfigOptionResolver config,
const unsigned int  first_printing_extruder = 0 
)
static
109{
110 return extrusion_width(opt_key, config.option<ConfigOptionFloatOrPercent>(opt_key), config, first_printing_extruder);
111}
static double extrusion_width(const std::string &opt_key, const ConfigOptionFloatOrPercent *opt, const ConfigOptionResolver &config, const unsigned int first_printing_extruder=0)
Definition Flow.cpp:62

References extrusion_width(), and Slic3r::ConfigOptionResolver::option().

+ Here is the call graph for this function:

◆ height()

◆ mm3_per_mm()

double Slic3r::Flow::mm3_per_mm ( ) const
206{
207 float res = m_bridge ?
208 // Area of a circle with dmr of this->width.
209 float((m_width * m_width) * 0.25 * PI) :
210 // Rectangle with semicircles at the ends. ~ h (w - 0.215 h)
211 float(m_height * (m_width - m_height * (1. - 0.25 * PI)));
212 //assert(res > 0.);
213 if (res <= 0.)
214 throw FlowErrorNegativeFlow();
215 return res;
216}
static constexpr double PI
Definition libslic3r.h:58

References m_bridge, m_height, m_width, and PI.

Referenced by Slic3r::Print::_make_skirt(), Slic3r::FFFSupport::fill_expolygon_generate_paths(), Slic3r::FFFSupport::fill_expolygons_with_sheath_generate_paths(), Slic3r::FFFSupport::LoopInterfaceProcessor::generate(), Slic3r::generate_extra_perimeters_over_overhangs(), Slic3r::Layer::make_fills(), Slic3r::PresetHints::maximum_volumetric_flow_description(), Slic3r::FFFSupport::modulate_extrusion_by_overlapping_layers(), Slic3r::GCode::process_layer(), Slic3r::PerimeterGenerator::thick_polyline_to_multi_path(), Slic3r::FFFSupport::tree_supports_generate_paths(), with_cross_section(), and with_flow_ratio().

+ Here is the caller graph for this function:

◆ new_from_config_width()

Flow Slic3r::Flow::new_from_config_width ( FlowRole  role,
const ConfigOptionFloatOrPercent width,
float  nozzle_diameter,
float  height 
)
static
116{
117 if (height <= 0)
118 throw Slic3r::InvalidArgument("Invalid flow height supplied to new_from_config_width()");
119
120 float w;
121 if (! width.percent && width.value == 0.) {
122 // If user left option to 0, calculate a sane default width.
124 } else {
125 // If user set a manual value, use it.
126 w = float(width.get_abs_value(height));
127 }
128
130}

References Flow(), auto_extrusion_width(), height(), nozzle_diameter(), rounded_rectangle_extrusion_spacing(), and width().

Referenced by Slic3r::Print::brim_flow(), Slic3r::PrintRegion::flow(), Slic3r::PresetHints::maximum_volumetric_flow_description(), Slic3r::PresetHints::recommended_thin_wall_thickness(), Slic3r::Print::skirt_flow(), Slic3r::support_material_1st_layer_flow(), Slic3r::support_material_flow(), and Slic3r::support_material_interface_flow().

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

◆ nozzle_diameter()

float Slic3r::Flow::nozzle_diameter ( ) const
inline

◆ operator==()

bool Slic3r::Flow::operator== ( const Flow rhs) const
inline
81{ return m_width == rhs.m_width && m_height == rhs.m_height && m_nozzle_diameter == rhs.m_nozzle_diameter && m_bridge == rhs.m_bridge; }

References m_bridge, m_height, m_nozzle_diameter, and m_width.

◆ rounded_rectangle_extrusion_spacing()

float Slic3r::Flow::rounded_rectangle_extrusion_spacing ( float  width,
float  height 
)
static
187{
188 auto out = width - height * float(1. - 0.25 * PI);
189 if (out <= 0.f)
190 throw FlowErrorNegativeSpacing();
191 return out;
192}

References height(), PI, and width().

Referenced by new_from_config_width(), with_height(), and with_width().

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

◆ rounded_rectangle_extrusion_width_from_spacing()

float Slic3r::Flow::rounded_rectangle_extrusion_width_from_spacing ( float  spacing,
float  height 
)
static
195{
196 return float(spacing + height * (1. - 0.25 * PI));
197}

References height(), PI, and spacing().

Referenced by Slic3r::Arachne::WallToolPaths::generate(), and with_cross_section().

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

◆ scaled_elephant_foot_spacing()

coord_t Slic3r::Flow::scaled_elephant_foot_spacing ( ) const
inline
79{ return coord_t(0.5f * float(this->scaled_width() + 0.6f * this->scaled_spacing())); }
coord_t scaled_width() const
Definition Flow.hpp:61
coord_t scaled_spacing() const
Definition Flow.hpp:67
int32_t coord_t
Definition libslic3r.h:39

References scaled_spacing(), and scaled_width().

+ Here is the call graph for this function:

◆ scaled_spacing()

◆ scaled_width()

◆ spacing()

◆ width()

◆ with_cross_section()

Flow Slic3r::Flow::with_cross_section ( float  area) const
154{
155 assert(! m_bridge);
156 assert(m_width >= m_height);
157
158 // Adjust for bridge_flow_ratio, maintain the extrusion spacing.
159 float area = this->mm3_per_mm();
160 if (area_new > area + EPSILON) {
161 // Increasing the flow rate.
162 float new_full_spacing = area_new / m_height;
163 if (new_full_spacing > m_spacing) {
164 // Filling up the spacing without an air gap. Grow the extrusion in height.
165 float height = area_new / m_spacing;
167 } else {
169 }
170 } else if (area_new < area - EPSILON) {
171 // Decreasing the flow rate.
172 float width_new = m_width - (area - area_new) / m_height;
173 assert(width_new > 0);
174 if (width_new > m_height) {
175 // Shrink the extrusion width.
176 return this->with_width(width_new);
177 } else {
178 // Create a rounded extrusion.
179 auto dmr = 2.0 * float(sqrt(area_new / M_PI));
180 return Flow(dmr, dmr, m_spacing, m_nozzle_diameter, false);
181 }
182 } else
183 return *this;
184}
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition ArrayCwiseUnaryOps.h:152
#define M_PI
Definition ExtrusionSimulator.cpp:20
static float rounded_rectangle_extrusion_width_from_spacing(float spacing, float height)
Definition Flow.cpp:194
Flow with_width(float width) const
Definition Flow.hpp:83
double mm3_per_mm() const
Definition Flow.cpp:205
static constexpr double EPSILON
Definition libslic3r.h:51
double area(const ExPolygon &poly)
Definition ExPolygon.hpp:467

References Flow(), Slic3r::area(), EPSILON, height(), m_bridge, m_height, m_nozzle_diameter, M_PI, m_spacing, m_width, mm3_per_mm(), rounded_rectangle_extrusion_width_from_spacing(), sqrt(), and with_width().

Referenced by with_flow_ratio().

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

◆ with_flow_ratio()

Flow Slic3r::Flow::with_flow_ratio ( double  ratio) const
inline
95{ return this->with_cross_section(this->mm3_per_mm() * ratio); }
Flow with_cross_section(float area) const
Definition Flow.cpp:153

References mm3_per_mm(), and with_cross_section().

Referenced by Slic3r::FFFSupport::SupportParameters::SupportParameters(), and Slic3r::LayerRegion::bridging_flow().

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

◆ with_height()

Flow Slic3r::Flow::with_height ( float  height) const
inline

References Flow(), height(), m_bridge, m_nozzle_diameter, m_width, and rounded_rectangle_extrusion_spacing().

Referenced by Slic3r::FFFSupport::LoopInterfaceProcessor::generate(), and Slic3r::GCode::process_layer().

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

◆ with_spacing()

Flow Slic3r::Flow::with_spacing ( float  spacing) const
134{
135 Flow out = *this;
136 if (m_bridge) {
137 // Diameter of the rounded extrusion.
138 assert(m_width == m_height);
139 float gap = m_spacing - m_width;
140 auto new_diameter = new_spacing - gap;
141 out.m_width = out.m_height = new_diameter;
142 } else {
143 assert(m_width >= m_height);
144 out.m_width += new_spacing - m_spacing;
145 if (out.m_width < out.m_height)
146 throw Slic3r::InvalidArgument("Invalid spacing supplied to Flow::with_spacing()");
147 }
148 out.m_spacing = new_spacing;
149 return out;
150}

References m_bridge, m_height, m_spacing, and m_width.

Referenced by Slic3r::Layer::make_fills().

+ Here is the caller graph for this function:

◆ with_width()

Flow Slic3r::Flow::with_width ( float  width) const
inline

References Flow(), m_bridge, m_height, m_nozzle_diameter, rounded_rectangle_extrusion_spacing(), and width().

Referenced by Slic3r::PerimeterGenerator::thick_polyline_to_multi_path(), and with_cross_section().

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

Member Data Documentation

◆ m_bridge

bool Slic3r::Flow::m_bridge { false }
private

◆ m_height

float Slic3r::Flow::m_height { 0 }
private

◆ m_nozzle_diameter

float Slic3r::Flow::m_nozzle_diameter { 0 }
private

◆ m_spacing

float Slic3r::Flow::m_spacing { 0 }
private

◆ m_width

float Slic3r::Flow::m_width { 0 }
private

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