diff options
author | remi durand <remi-j.durand@thalesgroup.com> | 2022-01-12 10:49:19 +0300 |
---|---|---|
committer | remi durand <remi-j.durand@thalesgroup.com> | 2022-01-12 10:49:19 +0300 |
commit | 6e0017ff8fc82ce66e65bcddd2285d48c1b6fb1c (patch) | |
tree | 07fa4bca6aa5dfb8fb3dcdeb8c5d691e443247dc /src/libslic3r/GCode/WipeTower.hpp | |
parent | 42db5ca0d12e9a54b8c378dbf8ec12671566a9ec (diff) | |
parent | 215e845c31889f92f78e8be1d9ee52f6209a8082 (diff) |
Merge remote-tracking branch 'remotes/prusa/master' 2.4 into dev 2.3.58
still need much tests (& bugfixes) and finish some merging things.
Diffstat (limited to 'src/libslic3r/GCode/WipeTower.hpp')
-rw-r--r-- | src/libslic3r/GCode/WipeTower.hpp | 107 |
1 files changed, 55 insertions, 52 deletions
diff --git a/src/libslic3r/GCode/WipeTower.hpp b/src/libslic3r/GCode/WipeTower.hpp index f63f71618..812ea8023 100644 --- a/src/libslic3r/GCode/WipeTower.hpp +++ b/src/libslic3r/GCode/WipeTower.hpp @@ -85,6 +85,37 @@ public: } }; + struct box_coordinates + { + box_coordinates(float left, float bottom, float width, float height) : + ld(left , bottom ), + lu(left , bottom + height), + rd(left + width, bottom ), + ru(left + width, bottom + height) {} + box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {} + void translate(const Vec2f &shift) { + ld += shift; lu += shift; + rd += shift; ru += shift; + } + void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); } + void expand(const float offset) { + ld += Vec2f(- offset, - offset); + lu += Vec2f(- offset, offset); + rd += Vec2f( offset, - offset); + ru += Vec2f( offset, offset); + } + void expand(const float offset_x, const float offset_y) { + ld += Vec2f(- offset_x, - offset_y); + lu += Vec2f(- offset_x, offset_y); + rd += Vec2f( offset_x, - offset_y); + ru += Vec2f( offset_x, offset_y); + } + Vec2f ld; // left down + Vec2f lu; // left upper + Vec2f rd; // right lower + Vec2f ru; // right upper + }; + // Construct ToolChangeResult from current state of WipeTower and WipeTowerWriter. // WipeTowerWriter is moved from ! ToolChangeResult construct_tcr(WipeTowerWriter& writer, @@ -102,13 +133,13 @@ public: // Appends into internal structure m_plan containing info about the future wipe tower // to be used before building begins. The entries must be added ordered in z. - void plan_toolchange(float z_par, float layer_height_par, uint16_t old_tool, uint16_t new_tool, bool brim, float wipe_volume = 0.f); + void plan_toolchange(float z_par, float layer_height_par, uint16_t old_tool, uint16_t new_tool, float wipe_volume = 0.f); // Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result" void generate(std::vector<std::vector<ToolChangeResult>> &result); float get_depth() const { return m_wipe_tower_depth; } - float get_brim_width() const { return m_wipe_tower_brim_width; } + float get_brim_width() const { return m_wipe_tower_brim_width_real; } @@ -129,15 +160,13 @@ public: { m_z_pos = print_z; m_layer_height = layer_height; - m_is_first_layer = is_first_layer; - m_print_brim = is_first_layer; m_depth_traversed = 0.f; + m_current_layer_finished = false; m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; if (is_first_layer) { - this->m_num_layer_changes = 0; - this->m_num_tool_changes = 0; - } - else + m_num_layer_changes = 0; + m_num_tool_changes = 0; + } else ++ m_num_layer_changes; // Calculate extrusion flow from desired line width, nozzle diameter, filament diameter and layer_height: @@ -177,7 +206,7 @@ public: // Is the current layer finished? bool layer_finished() const { - return ( (m_is_first_layer ? m_wipe_tower_depth - m_perimeter_width : m_layer_info->depth) - WT_EPSILON < m_depth_traversed); + return m_current_layer_finished; } std::vector<float> get_used_filament() const { return m_used_filament_length; } @@ -185,6 +214,7 @@ public: struct FilamentParameters { std::string material = "PLA"; + bool is_soluble = false; int temperature = 0; int first_layer_temperature = 0; float loading_speed = 0.f; @@ -223,7 +253,6 @@ private: SHAPE_REVERSED = -1 }; - const bool m_peters_wipe_tower = false; // sparse wipe tower inspired by Peter's post processor - not finished yet const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust const float WT_EPSILON = 1e-3f; float filament_area() const { @@ -236,15 +265,18 @@ private: Vec2f m_wipe_tower_pos; // Left front corner of the wipe tower in mm. float m_wipe_tower_width; // Width of the wipe tower. float m_wipe_tower_depth = 0.f; // Depth of the wipe tower - float m_wipe_tower_brim_width = 0.f; // Width of brim (mm) + float m_wipe_tower_brim_width = 0.f; // Width of brim (mm) from config + float m_wipe_tower_brim_width_real = 0.f; // Width of brim (mm) after generation float m_wipe_tower_rotation_angle = 0.f; // Wipe tower rotation angle in degrees (with respect to x axis) float m_internal_rotation = 0.f; float m_y_shift = 0.f; // y shift passed to writer float m_z_pos = 0.f; // Current Z position. float m_layer_height = 0.f; // Current layer height. size_t m_max_color_changes = 0; // Maximum number of color changes per layer. - bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower. int m_old_temperature = -1; // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary) + float m_travel_speed = 0.f; + float m_first_layer_speed = 0.f; + size_t m_first_layer_idx = size_t(-1); // G-code generator parameters. float m_cooling_tube_retraction = 0.f; @@ -260,7 +292,8 @@ private: // Bed properties enum { RectangularBed, - CircularBed + CircularBed, + CustomBed } m_bed_shape; float m_bed_width; // width of the bed bounding box Vec2f m_bed_bottom_left; // bottom-left corner coordinates (for rectangular beds) @@ -284,9 +317,12 @@ private: const std::vector<std::vector<float>> wipe_volumes; float m_depth_traversed = 0.f; // Current y position at the wipe tower. + bool m_current_layer_finished = false; bool m_left_to_right = true; float m_extra_spacing = 1.f; + bool is_first_layer() const { return size_t(m_layer_info - m_plan.begin()) == m_first_layer_idx; } + // Calculates extrusion flow needed to produce required line width for given layer height float extrusion_flow(float layer_height = -1.f) const // negative layer_height - return current m_extrusion_flow { @@ -310,39 +346,7 @@ private: void save_on_last_wipe(); - struct box_coordinates - { - box_coordinates(float left, float bottom, float width, float height) : - ld(left , bottom ), - lu(left , bottom + height), - rd(left + width, bottom ), - ru(left + width, bottom + height) {} - box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {} - void translate(const Vec2f &shift) { - ld += shift; lu += shift; - rd += shift; ru += shift; - } - void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); } - void expand(const float offset) { - ld += Vec2f(- offset, - offset); - lu += Vec2f(- offset, offset); - rd += Vec2f( offset, - offset); - ru += Vec2f( offset, offset); - } - void expand(const float offset_x, const float offset_y) { - ld += Vec2f(- offset_x, - offset_y); - lu += Vec2f(- offset_x, offset_y); - rd += Vec2f( offset_x, - offset_y); - ru += Vec2f( offset_x, offset_y); - } - Vec2f ld; // left down - Vec2f lu; // left upper - Vec2f rd; // right lower - Vec2f ru; // right upper - }; - - - // to store information about tool changes for a given layer + // to store information about tool changes for a given layer struct WipeTowerInfo{ struct ToolChange { size_t old_tool; @@ -372,11 +376,10 @@ private: // Stores information about used filament length per extruder: std::vector<float> m_used_filament_length; - - // Returns gcode for wipe tower brim - // sideOnly -- set to false -- experimental, draw brim on sides of wipe tower - // offset -- set to 0 -- experimental, offset to replace brim in front / rear of wipe tower - ToolChangeResult toolchange_Brim(bool sideOnly = false, float y_offset = 0.f); + // Return index of first toolchange that switches to non-soluble extruder + // ot -1 if there is no such toolchange. + int first_toolchange_to_nonsoluble( + const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const; void toolchange_Unload( WipeTowerWriter &writer, @@ -401,6 +404,6 @@ private: -}; // namespace Slic3r +} // namespace Slic3r #endif // WipeTowerPrusaMM_hpp_ |