diff options
author | bubnikv <bubnikv@gmail.com> | 2018-09-19 12:02:24 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-09-19 12:02:24 +0300 |
commit | 0558b53493a77bae44831cf87bb0f59359828ef5 (patch) | |
tree | c3e8dbdf7d91a051c12d9ebbf7606d41047fea96 /src/libslic3r/PrintRegion.cpp | |
parent | 3ddaccb6410478ad02d8c0e02d6d8e6eb1785b9f (diff) |
WIP: Moved sources int src/, separated most of the source code from Perl.
The XS was left only for the unit / integration tests, and it links
libslic3r only. No wxWidgets are allowed to be used from Perl starting
from now.
Diffstat (limited to 'src/libslic3r/PrintRegion.cpp')
-rw-r--r-- | src/libslic3r/PrintRegion.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/libslic3r/PrintRegion.cpp b/src/libslic3r/PrintRegion.cpp new file mode 100644 index 000000000..4ea777b4a --- /dev/null +++ b/src/libslic3r/PrintRegion.cpp @@ -0,0 +1,64 @@ +#include "Print.hpp" + +namespace Slic3r { + +Flow PrintRegion::flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, const PrintObject &object) const +{ + ConfigOptionFloatOrPercent config_width; + if (width != -1) { + // use the supplied custom width, if any + config_width.value = width; + config_width.percent = false; + } else { + // otherwise, get extrusion width from configuration + // (might be an absolute value, or a percent value, or zero for auto) + if (first_layer && m_print->config().first_layer_extrusion_width.value > 0) { + config_width = m_print->config().first_layer_extrusion_width; + } else if (role == frExternalPerimeter) { + config_width = m_config.external_perimeter_extrusion_width; + } else if (role == frPerimeter) { + config_width = m_config.perimeter_extrusion_width; + } else if (role == frInfill) { + config_width = m_config.infill_extrusion_width; + } else if (role == frSolidInfill) { + config_width = m_config.solid_infill_extrusion_width; + } else if (role == frTopSolidInfill) { + config_width = m_config.top_infill_extrusion_width; + } else { + throw std::invalid_argument("Unknown role"); + } + } + if (config_width.value == 0) { + config_width = object.config().extrusion_width; + } + + // get the configured nozzle_diameter for the extruder associated + // to the flow role requested + size_t extruder = 0; // 1-based + if (role == frPerimeter || role == frExternalPerimeter) { + extruder = m_config.perimeter_extruder; + } else if (role == frInfill) { + extruder = m_config.infill_extruder; + } else if (role == frSolidInfill || role == frTopSolidInfill) { + extruder = m_config.solid_infill_extruder; + } else { + throw std::invalid_argument("Unknown role"); + } + double nozzle_diameter = m_print->config().nozzle_diameter.get_at(extruder-1); + + return Flow::new_from_config_width(role, config_width, nozzle_diameter, layer_height, bridge ? (float)m_config.bridge_flow_ratio : 0.0); +} + +coordf_t PrintRegion::nozzle_dmr_avg(const PrintConfig &print_config) const +{ + return (print_config.nozzle_diameter.get_at(m_config.perimeter_extruder.value - 1) + + print_config.nozzle_diameter.get_at(m_config.infill_extruder.value - 1) + + print_config.nozzle_diameter.get_at(m_config.solid_infill_extruder.value - 1)) / 3.; +} + +coordf_t PrintRegion::bridging_height_avg(const PrintConfig &print_config) const +{ + return this->nozzle_dmr_avg(print_config) * sqrt(m_config.bridge_flow_ratio.value); +} + +} |