diff --git a/xs/src/libslic3r/Flow.cpp b/xs/src/libslic3r/Flow.cpp index 42caf9f1a..cc87ec0bb 100644 --- a/xs/src/libslic3r/Flow.cpp +++ b/xs/src/libslic3r/Flow.cpp @@ -120,11 +120,11 @@ Flow::_width_from_spacing(float spacing, float nozzle_diameter, float height, bo return spacing + OVERLAP_FACTOR * height * (1 - PI/4.0); } -// Calculate a new spacing to fill width with possibly integer number of lines, -// the first and last line being centered at the interval ends. -// This function possibly increases the spacing, never decreases, -// and for a narrow width the increase in spacing may become severe, -// therefore the adjustment is limited to 20% increase. +/// Calculate a new spacing to fill width with possibly integer number of lines, +/// the first and last line being centered at the interval ends. +/// This function possibly increases the spacing, never decreases, +/// and for a narrow width the increase in spacing may become severe, +/// therefore the adjustment is limited to 20% increase. template T Flow::solid_spacing(const T total_width, const T spacing) diff --git a/xs/src/libslic3r/Flow.hpp b/xs/src/libslic3r/Flow.hpp index 7149df6b4..8be103a86 100644 --- a/xs/src/libslic3r/Flow.hpp +++ b/xs/src/libslic3r/Flow.hpp @@ -10,7 +10,8 @@ namespace Slic3r { constexpr auto BRIDGE_EXTRA_SPACING = 0.05; constexpr auto OVERLAP_FACTOR = 1.0; -enum FlowRole { +/// Enumeration for different flow roles +enum FlowRole frExternalPerimeter, frPerimeter, frInfill, @@ -20,6 +21,8 @@ enum FlowRole { frSupportMaterialInterface, }; + +/// Represents material flow; provides methods to predict material spacing. class Flow { public: @@ -28,7 +31,13 @@ class Flow Flow(float _w, float _h, float _nd, bool _bridge = false) : width(_w), height(_h), nozzle_diameter(_nd), bridge(_bridge) {}; + + /// Return the centerline spacing between two adjacent extrusions that have the same properties (width, etc). + /// Models as a rectangle with semicircles at the ends. float spacing() const; + + /// Return the centerline spacing between two Flow objects (current and some other flow). + /// \remark this->spacing(other) == other.spacing(this) float spacing(const Flow &other) const; void set_spacing(float spacing); void set_solid_spacing(const coord_t total_width) { @@ -48,12 +57,18 @@ class Flow return scale_(this->spacing(other)); }; + + /// Static method to build a Flow object from an extrusion width config setting and some other context properties static Flow new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio); + + /// Static method to build a Flow object from a specified centerline spacing (center-to-center). static Flow new_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge); template static T solid_spacing(const T total_width, const T spacing); private: static float _bridge_width(float nozzle_diameter, float bridge_flow_ratio); + /// Calculate a relatively sane extrusion width, based on height and nozzle diameter. + /// Algorithm used does not play nice with layer heights < 0.1mm. static float _auto_width(FlowRole role, float nozzle_diameter, float height); static float _width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge); };