OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Flow Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/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
void set_spacing (float spacing)
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
bool operator!= (const Flow &rhs) 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 Flow(), bridging_flow(), new_from_config_width(), operator!=(), operator<(), operator==(), with_cross_section(), with_flow_ratio(), with_height(), with_spacing(), 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
58 :
float height() const
Definition Flow.hpp:67
static float rounded_rectangle_extrusion_spacing(float width, float height)
Definition Flow.cpp:207
Flow()=default
float width() const
Definition Flow.hpp:63
float nozzle_diameter() const
Definition Flow.hpp:73

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

Here is the call graph for this function:

◆ Flow() [3/3]

Slic3r::Flow::Flow ( float width,
float height,
float spacing,
float nozzle_diameter,
bool bridge )
inlineprivate
130 :
132 {
133 // Gap fill violates this condition.
134 //assert(width >= height);
135 }
float m_width
Definition Flow.hpp:137
float spacing() const
Definition Flow.hpp:69
float m_nozzle_diameter
Definition Flow.hpp:140
bool bridge() const
Definition Flow.hpp:75
float m_spacing
Definition Flow.hpp:139
bool m_bridge
Definition Flow.hpp:141
float m_height
Definition Flow.hpp:138

References bridge(), height(), m_bridge, m_height, m_nozzle_diameter, m_spacing, m_width, nozzle_diameter(), spacing(), and width().

Here is the call graph for this function:

Member Function Documentation

◆ auto_extrusion_width()

float Slic3r::Flow::auto_extrusion_width ( FlowRole role,
float nozzle_diameter )
static
28{
29 switch (role) {
34 return nozzle_diameter;
35 default:
37 case frPerimeter:
38 case frSolidInfill:
39 case frInfill:
40 return 1.125f * nozzle_diameter;
41 }
42}
@ frTopSolidInfill
Definition Flow.hpp:23
@ frSupportMaterial
Definition Flow.hpp:24
@ frExternalPerimeter
Definition Flow.hpp:19
@ frPerimeter
Definition Flow.hpp:20
@ frSolidInfill
Definition Flow.hpp:22
@ frSupportMaterialInterface
Definition Flow.hpp:25
@ frSupportTransition
Definition Flow.hpp:26
@ frInfill
Definition Flow.hpp:21

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

Referenced by Slic3r::FillLightning::Generator::Generator(), Slic3r::FillLightning::Generator::Generator(), Slic3r::FillAdaptive::adaptive_fill_line_spacing(), extrusion_width(), Slic3r::CalibPressureAdvance::find_optimal_PA_speed(), Slic3r::CalibPressureAdvancePattern::flow_val(), Slic3r::TreeSupport::generate_toolpaths(), Slic3r::CalibPressureAdvancePattern::line_width(), Slic3r::CalibPressureAdvancePattern::line_width_first_layer(), new_from_config_width(), Slic3r::resolve_outer_wall_line_width(), Slic3r::PerimeterGenerator::split_top_surfaces(), and Slic3r::GUI::update_speed_parameter().

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

◆ bridge()

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

References m_bridge.

Referenced by Flow(), and Slic3r::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
221{
222 return dmr + BRIDGE_EXTRA_SPACING;
223}
#define BRIDGE_EXTRA_SPACING
Definition Flow.hpp:16

References BRIDGE_EXTRA_SPACING.

Referenced by bridging_flow().

Here is the caller graph for this function:

◆ bridging_flow()

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

References Flow(), bridge_extrusion_spacing(), and nozzle_diameter().

Referenced by Slic3r::SupportParameters::SupportParameters(), Slic3r::LayerRegion::bridging_flow(), Slic3r::ExtrusionPath::polygons_covered_by_spacing(), and Slic3r::support_transition_flow().

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
76{
77 assert(opt != nullptr);
78
79 auto opt_nozzle_diameters = config.option<ConfigOptionFloats>("nozzle_diameter");
80 if (opt_nozzle_diameters == nullptr)
81 throw_on_missing_variable(opt_key, "nozzle_diameter");
82 const float nozzle_diameter = float(opt_nozzle_diameters->get_at(first_printing_extruder));
83
84 if (opt_key == "bridge_line_width") {
85 if (opt->percent) {
86 const double bridge_width = opt->get_abs_value(nozzle_diameter);
87 if (bridge_width > 0.)
88 return bridge_width;
89 } else if (opt->value > 0.) {
90 return opt->value;
91 }
92
93 opt = config.option<ConfigOptionFloatOrPercent>("internal_solid_infill_line_width");
94 if (opt == nullptr)
95 throw_on_missing_variable(opt_key, "internal_solid_infill_line_width");
96 return extrusion_width("internal_solid_infill_line_width", opt, config, first_printing_extruder);
97 }
98
99#if 0
100// This is the logic used for skit / brim, but not for the rest of the 1st layer.
101 if (opt->value == 0. && first_layer) {
102 // The "initial_layer_line_width" was set to zero, try a substitute.
103 opt = config.option<ConfigOptionFloatOrPercent>("inner_wall_line_width");
104 if (opt == nullptr)
105 throw_on_missing_variable(opt_key, "inner_wall_line_width");
106 }
107#endif
108
109 if (opt->value == 0.) {
110 // The role specific extrusion width value was set to zero, try the role non-specific extrusion width.
111 opt = config.option<ConfigOptionFloatOrPercent>("line_width");
112 if (opt == nullptr)
113 throw_on_missing_variable(opt_key, "line_width");
114 }
115
116 if (opt->percent) {
117 return opt->get_abs_value(nozzle_diameter);
118 }
119
120 if (opt->value == 0.) {
121 // If user left option to 0, calculate a sane default width.
123 }
124
125 return opt->value;
126}
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:75
static float auto_extrusion_width(FlowRole role, float nozzle_diameter)
Definition Flow.cpp:27
static FlowRole opt_key_to_flow_role(const std::string &opt_key)
Definition Flow.cpp:46
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015
static void throw_on_missing_variable(const std::string &opt_key, const char *dependent_opt_key)
Definition Flow.cpp:68

References auto_extrusion_width(), extrusion_width(), nozzle_diameter(), Slic3r::opt_key_to_flow_role(), Slic3r::ConfigOptionResolver::option(), and Slic3r::throw_on_missing_variable().

Referenced by extrusion_width(), extrusion_width(), Slic3r::client::MyContext::scalar_variable_to_expr(), and Slic3r::client::MyContext::vector_element_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
130{
131 return extrusion_width(opt_key, config.option<ConfigOptionFloatOrPercent>(opt_key), config, first_printing_extruder);
132}

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
227{
228 float res = m_bridge ?
229 // Area of a circle with dmr of this->width.
230 float((m_width * m_width) * 0.25 * PI) :
231 // Rectangle with semicircles at the ends. ~ h (w - 0.215 h)
232 float(m_height * (m_width - m_height * (1. - 0.25 * PI)));
233 //assert(res > 0.);
234 if (res <= 0.)
235 throw FlowErrorNegativeFlow();
236 return res;
237}
static constexpr double PI
Definition libslic3r.h:81

References m_bridge, m_height, m_width, and PI.

Referenced by Slic3r::_make_loops(), Slic3r::Print::_make_skirt(), Slic3r::GUI::CalibUtils::calib_flowrate(), Slic3r::GUI::CalibUtils::calib_max_vol_speed(), Slic3r::GUI::Plater::calib_max_vol_speed(), Slic3r::CalibPressureAdvance::e_per_mm(), Slic3r::fill_expolygon_generate_paths(), Slic3r::fill_expolygon_generate_paths(), Slic3r::fill_expolygons_with_sheath_generate_paths(), Slic3r::Fill::fill_surface_extrusion(), Slic3r::FillLockedZag::fill_surface_extrusion(), Slic3r::CalibPressureAdvance::find_optimal_PA_speed(), Slic3r::CalibPressureAdvancePattern::flow_val(), Slic3r::LoopInterfaceProcessor::generate(), Slic3r::generate_extra_perimeters_over_overhangs(), Slic3r::GCode::generate_skirt(), Slic3r::TreeSupport::generate_toolpaths(), Slic3r::get_outer_wall_volumetric_speed(), Slic3r::modulate_extrusion_by_overlapping_layers(), Slic3r::GUI::VFA_Test_Dlg::on_start(), operator<(), Slic3r::thick_polyline_to_extrusion_paths_2(), Slic3r::thick_polyline_to_multi_path(), Slic3r::tree_supports_generate_paths(), Slic3r::GUI::update_speed_parameter(), 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
137{
138 if (height <= 0)
139 throw Slic3r::InvalidArgument("Invalid flow height supplied to new_from_config_width().");
140
141 float w;
142 if (!width.percent && width.value <= 0.) {
143 // If user left option to 0, calculate a sane default width.
145 } else {
146 // If user set a manual value, use it.
147 w = float(width.get_abs_value(nozzle_diameter));
148 }
149
151}

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

Referenced by Slic3r::Print::brim_flow(), Slic3r::PrintRegion::flow(), Slic3r::group_fills(), 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
73{ return m_nozzle_diameter; }

References m_nozzle_diameter.

Referenced by Flow(), Flow(), auto_extrusion_width(), bridging_flow(), extrusion_width(), Slic3r::generate_support_toolpaths(), new_from_config_width(), and Slic3r::SeamPlacerImpl::process_perimeter_polygon().

Here is the caller graph for this function:

◆ operator!=()

bool Slic3r::Flow::operator!= ( const Flow & rhs) const
inline
87 {
88 return m_width != rhs.m_width || m_height != rhs.m_height || m_nozzle_diameter != rhs.m_nozzle_diameter || m_bridge != rhs.m_bridge;
89 }

References Flow(), m_bridge, m_height, m_nozzle_diameter, and m_width.

Here is the call graph for this function:

◆ operator<()

bool Slic3r::Flow::operator< ( const Flow & rhs) const
inline
91 {
92 return this->mm3_per_mm() < rhs.mm3_per_mm();
93 }
double mm3_per_mm() const
Definition Flow.cpp:226

References Flow(), and mm3_per_mm().

Here is the call graph for this function:

◆ operator==()

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

References Flow(), m_bridge, m_height, m_nozzle_diameter, and m_width.

Here is the call graph for this function:

◆ rounded_rectangle_extrusion_spacing()

float Slic3r::Flow::rounded_rectangle_extrusion_spacing ( float width,
float height )
static
208{
209 auto out = width - height * float(1. - 0.25 * PI);
210 if (out <= 0.f)
211 throw FlowErrorNegativeSpacing();
212 return out;
213}

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

Referenced by Flow(), new_from_config_width(), Slic3r::segmentation_top_and_bottom_layers(), 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
216{
217 return float(spacing + height * (1. - 0.25 * PI));
218}

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

Referenced by Slic3r::Arachne::WallToolPaths::generate(), Slic3r::Layer::make_ironing(), 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
83{ return coord_t(0.5f * float(this->scaled_width() + 0.6f * this->scaled_spacing())); }
coord_t scaled_width() const
Definition Flow.hpp:64
coord_t scaled_spacing() const
Definition Flow.hpp:71
int64_t coord_t
Definition libslic3r.h:48

References scaled_spacing(), and scaled_width().

Here is the call graph for this function:

◆ scaled_spacing()

◆ scaled_width()

◆ set_spacing()

void Slic3r::Flow::set_spacing ( float spacing)
inline
70{ m_spacing = spacing; }

References m_spacing, and spacing().

Here is the call graph for this function:

◆ spacing()

float Slic3r::Flow::spacing ( ) const
inline
69{ return m_spacing; }

References m_spacing.

Referenced by Flow(), Slic3r::Print::_make_skirt(), Slic3r::elephant_foot_compensation(), Slic3r::TreeSupport3D::generate_support_infill_lines(), Slic3r::generate_support_toolpaths(), Slic3r::TreeSupport::generate_toolpaths(), Slic3r::group_fills(), rounded_rectangle_extrusion_width_from_spacing(), and set_spacing().

Here is the caller graph for this function:

◆ width()

◆ with_cross_section()

Flow Slic3r::Flow::with_cross_section ( float area) const
175{
176 assert(! m_bridge);
177 assert(m_width >= m_height);
178
179 // Adjust for bridge_flow, maintain the extrusion spacing.
180 float area = this->mm3_per_mm();
181 if (area_new > area + EPSILON) {
182 // Increasing the flow rate.
183 float new_full_spacing = area_new / m_height;
184 if (new_full_spacing > m_spacing) {
185 // Filling up the spacing without an air gap. Grow the extrusion in height.
186 float height = area_new / m_spacing;
188 } else {
190 }
191 } else if (area_new < area - EPSILON) {
192 // Decreasing the flow rate.
193 float width_new = m_width - (area - area_new) / m_height;
194 assert(width_new > 0);
195 if (width_new > m_height) {
196 // Shrink the extrusion width.
197 return this->with_width(width_new);
198 } else {
199 // Create a rounded extrusion.
200 auto dmr = float(sqrt(area_new / M_PI));
201 return Flow(dmr, dmr, m_spacing, m_nozzle_diameter, false);
202 }
203 } else
204 return *this;
205}
#define EPSILON
Definition ColorUtils.cpp:64
#define M_PI
Definition ExtrusionSimulator.cpp:31
static float rounded_rectangle_extrusion_width_from_spacing(float spacing, float height)
Definition Flow.cpp:215
Flow with_width(float width) const
Definition Flow.hpp:94
double area(const ExPolygon &poly)
Definition ExPolygon.hpp:511

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(), and with_width().

Referenced by Slic3r::belt_brim_band_paths(), and 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
106{ return this->with_cross_section(this->mm3_per_mm() * ratio); }
Flow with_cross_section(float area) const
Definition Flow.cpp:174

References Flow(), mm3_per_mm(), and with_cross_section().

Referenced by 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::LoopInterfaceProcessor::generate(), and Slic3r::GCode::generate_skirt().

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
155{
156 Flow out = *this;
157 if (m_bridge) {
158 // Diameter of the rounded extrusion.
159 assert(m_width == m_height);
160 float gap = m_spacing - m_width;
161 auto new_diameter = new_spacing - gap;
162 out.m_width = out.m_height = new_diameter;
163 } else {
164 assert(m_width >= m_height);
165 out.m_width += new_spacing - m_spacing;
166 if (out.m_width < out.m_height)
167 throw Slic3r::InvalidArgument(L("Invalid spacing supplied to Flow::with_spacing(), check your layer height and extrusion width."));
168 }
169 out.m_spacing = new_spacing;
170 return out;
171}
#define L(s)
Definition ExtrusionEntity.cpp:25

References Flow(), L, m_bridge, m_height, m_spacing, and m_width.

Referenced by Slic3r::Fill::fill_surface_extrusion(), Slic3r::FillConcentricInternal::fill_surface_extrusion(), and Slic3r::FillLockedZag::fill_surface_extrusion().

Here is the call graph for this function:
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::thick_polyline_to_extrusion_paths_2(), Slic3r::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:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Flow.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/Flow.cpp