Skip to content

Commit 4379cbf

Browse files
committed
Use different minimum layer time when layer has an overhang
CURA-12352
1 parent 71c8e14 commit 4379cbf

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

include/FanSpeedLayerTime.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//Copyright (c) 2020 Ultimaker B.V.
2-
//CuraEngine is released under the terms of the AGPLv3 or higher.
1+
// Copyright (c) 2020 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
33

44
#ifndef FAN_SPEED_LAYER_TIME_H
55
#define FAN_SPEED_LAYER_TIME_H
@@ -8,7 +8,7 @@
88
#include "settings/types/LayerIndex.h"
99
#include "settings/types/Velocity.h"
1010

11-
namespace cura
11+
namespace cura
1212
{
1313

1414
/*!
@@ -19,7 +19,7 @@ namespace cura
1919
* store these settings over and over again for each part, even though the
2020
* settings may be different for each part on a layer.
2121
*/
22-
struct FanSpeedLayerTimeSettings
22+
struct FanSpeedLayerTimeSettings
2323
{
2424
public:
2525
/*!
@@ -28,6 +28,11 @@ struct FanSpeedLayerTimeSettings
2828
*/
2929
Duration cool_min_layer_time;
3030

31+
/*!
32+
* Similar to Minimum layer time, but to be applied for layers that contain overhanging extrusion.
33+
*/
34+
Duration cool_min_layer_time_overhang;
35+
3136
/*!
3237
* "Regular/Maximum Fan Speed Threshold". If the layers take longer to print
3338
* than this, they'll use the regular fan speed. If they take shorter, we'll

include/LayerPlan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class LayerPlan : public NoCopy
124124
std::vector<OverhangMask> overhang_masks_; //!< The regions of a layer part where the walls overhang, calculated for multiple overhang angles. The latter is the most
125125
//!< overhanging. For a visual explanation of the result, see doc/gradual_overhang_speed.svg
126126
Shape seam_overhang_mask_; //!< The regions of a layer part where the walls overhang, specifically as defined for the seam
127+
bool contains_overhang_{ false }; //!< Indicates whether this plan contains any overhanging extrusion
127128
Shape roofing_mask_; //!< The regions of a layer part where the walls are exposed to the air
128129

129130
bool min_layer_time_used = false; //!< Wether or not the minimum layer time (cool_min_layer_time) was actually used in this layerplan.

src/FffGcodeWriter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ void FffGcodeWriter::setConfigFanSpeedLayerTime()
318318
fan_speed_layer_time_settings_per_extruder.emplace_back();
319319
FanSpeedLayerTimeSettings& fan_speed_layer_time_settings = fan_speed_layer_time_settings_per_extruder.back();
320320
fan_speed_layer_time_settings.cool_min_layer_time = train.settings_.get<Duration>("cool_min_layer_time");
321+
fan_speed_layer_time_settings.cool_min_layer_time_overhang = train.settings_.get<Duration>("cool_min_layer_time_overhang");
321322
fan_speed_layer_time_settings.cool_min_layer_time_fan_speed_max = train.settings_.get<Duration>("cool_min_layer_time_fan_speed_max");
322323
fan_speed_layer_time_settings.cool_fan_speed_0 = train.settings_.get<Ratio>("cool_fan_speed_0") * 100.0;
323324
fan_speed_layer_time_settings.cool_fan_speed_min = train.settings_.get<Ratio>("cool_fan_speed_min") * 100.0;

src/LayerPlan.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,13 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang(
569569
const double fan_speed,
570570
const bool travel_to_z)
571571
{
572-
const auto add_extrusion_move = [&](const Point3LL& target, const Ratio& overhang_speed_factor = 1.0_r)
572+
const auto add_extrusion_move = [&](const Point3LL& target, const std::optional<size_t> speed_region_index = std::nullopt)
573573
{
574+
const Ratio overhang_speed_factor = speed_region_index.has_value() ? overhang_masks_[speed_region_index.value()].speed_ratio : 1.0_r;
575+
if (speed_region_index.has_value() && speed_region_index.value() > 0)
576+
{
577+
contains_overhang_ = true;
578+
}
574579
addExtrusionMove(target, config, space_fill_type, flow, width_factor, spiralize, speed_factor * overhang_speed_factor, fan_speed, travel_to_z);
575580
};
576581

@@ -659,7 +664,7 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang(
659664

660665
// Move to intersection at current region speed
661666
const Point2LL split_position = start + vector * intersection_parameter;
662-
add_extrusion_move(split_position, overhang_masks_[actual_speed_region_index].speed_ratio);
667+
add_extrusion_move(split_position, actual_speed_region_index);
663668

664669
// Prepare for next move in different region
665670
actual_speed_region_index = next_speed_region_index;
@@ -668,7 +673,7 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang(
668673
else
669674
{
670675
// We cross no border, which means we can reach the end of the segment within the current speed region, so we are done
671-
add_extrusion_move(p, overhang_masks_[actual_speed_region_index].speed_ratio);
676+
add_extrusion_move(p, actual_speed_region_index);
672677
return;
673678
}
674679
}
@@ -2562,7 +2567,9 @@ void LayerPlan::processFanSpeedAndMinimalLayerTime(Point2LL starting_position)
25622567
{
25632568
other_extr_plan_time += extruder_plan.estimates_.getTotalTime();
25642569
}
2565-
maximum_cool_min_layer_time = std::max(maximum_cool_min_layer_time, extruder_plan.fan_speed_layer_time_settings_.cool_min_layer_time);
2570+
2571+
const FanSpeedLayerTimeSettings& settings = extruder_plan.fan_speed_layer_time_settings_;
2572+
maximum_cool_min_layer_time = std::max(maximum_cool_min_layer_time, contains_overhang_ ? settings.cool_min_layer_time_overhang : settings.cool_min_layer_time);
25662573

25672574
// Modify fan speeds for the first layer(s)
25682575
extruder_plan.processFanSpeedForFirstLayers();

0 commit comments

Comments
 (0)