diff --git a/include/FanSpeedLayerTime.h b/include/FanSpeedLayerTime.h index bc6c00fc73..05554a886d 100644 --- a/include/FanSpeedLayerTime.h +++ b/include/FanSpeedLayerTime.h @@ -1,5 +1,5 @@ -//Copyright (c) 2020 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2020 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef FAN_SPEED_LAYER_TIME_H #define FAN_SPEED_LAYER_TIME_H @@ -8,7 +8,7 @@ #include "settings/types/LayerIndex.h" #include "settings/types/Velocity.h" -namespace cura +namespace cura { /*! @@ -19,7 +19,7 @@ namespace cura * store these settings over and over again for each part, even though the * settings may be different for each part on a layer. */ -struct FanSpeedLayerTimeSettings +struct FanSpeedLayerTimeSettings { public: /*! @@ -28,6 +28,11 @@ struct FanSpeedLayerTimeSettings */ Duration cool_min_layer_time; + /*! + * Similar to Minimum layer time, but to be applied for layers that contain overhanging extrusion. + */ + Duration cool_min_layer_time_overhang; + /*! * "Regular/Maximum Fan Speed Threshold". If the layers take longer to print * than this, they'll use the regular fan speed. If they take shorter, we'll diff --git a/include/LayerPlan.h b/include/LayerPlan.h index 149138e9cb..449a3a3127 100644 --- a/include/LayerPlan.h +++ b/include/LayerPlan.h @@ -124,6 +124,7 @@ class LayerPlan : public NoCopy std::vector overhang_masks_; //!< The regions of a layer part where the walls overhang, calculated for multiple overhang angles. The latter is the most //!< overhanging. For a visual explanation of the result, see doc/gradual_overhang_speed.svg Shape seam_overhang_mask_; //!< The regions of a layer part where the walls overhang, specifically as defined for the seam + bool contains_overhang_{ false }; //!< Indicates whether this plan contains any overhanging extrusion Shape roofing_mask_; //!< The regions of a layer part where the walls are exposed to the air bool min_layer_time_used = false; //!< Wether or not the minimum layer time (cool_min_layer_time) was actually used in this layerplan. diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 26a1995cfc..469d5f4854 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -318,6 +318,7 @@ void FffGcodeWriter::setConfigFanSpeedLayerTime() fan_speed_layer_time_settings_per_extruder.emplace_back(); FanSpeedLayerTimeSettings& fan_speed_layer_time_settings = fan_speed_layer_time_settings_per_extruder.back(); fan_speed_layer_time_settings.cool_min_layer_time = train.settings_.get("cool_min_layer_time"); + fan_speed_layer_time_settings.cool_min_layer_time_overhang = train.settings_.get("cool_min_layer_time_overhang"); fan_speed_layer_time_settings.cool_min_layer_time_fan_speed_max = train.settings_.get("cool_min_layer_time_fan_speed_max"); fan_speed_layer_time_settings.cool_fan_speed_0 = train.settings_.get("cool_fan_speed_0") * 100.0; fan_speed_layer_time_settings.cool_fan_speed_min = train.settings_.get("cool_fan_speed_min") * 100.0; diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 690f789139..dcc92a4f40 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -569,8 +569,13 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang( const double fan_speed, const bool travel_to_z) { - const auto add_extrusion_move = [&](const Point3LL& target, const Ratio& overhang_speed_factor = 1.0_r) + const auto add_extrusion_move = [&](const Point3LL& target, const std::optional speed_region_index = std::nullopt) { + const Ratio overhang_speed_factor = speed_region_index.has_value() ? overhang_masks_[speed_region_index.value()].speed_ratio : 1.0_r; + if (speed_region_index.has_value() && speed_region_index.value() > 0) + { + contains_overhang_ = true; + } addExtrusionMove(target, config, space_fill_type, flow, width_factor, spiralize, speed_factor * overhang_speed_factor, fan_speed, travel_to_z); }; @@ -659,7 +664,7 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang( // Move to intersection at current region speed const Point2LL split_position = start + vector * intersection_parameter; - add_extrusion_move(split_position, overhang_masks_[actual_speed_region_index].speed_ratio); + add_extrusion_move(split_position, actual_speed_region_index); // Prepare for next move in different region actual_speed_region_index = next_speed_region_index; @@ -668,7 +673,7 @@ void LayerPlan::addExtrusionMoveWithGradualOverhang( else { // We cross no border, which means we can reach the end of the segment within the current speed region, so we are done - add_extrusion_move(p, overhang_masks_[actual_speed_region_index].speed_ratio); + add_extrusion_move(p, actual_speed_region_index); return; } } @@ -2562,7 +2567,9 @@ void LayerPlan::processFanSpeedAndMinimalLayerTime(Point2LL starting_position) { other_extr_plan_time += extruder_plan.estimates_.getTotalTime(); } - maximum_cool_min_layer_time = std::max(maximum_cool_min_layer_time, extruder_plan.fan_speed_layer_time_settings_.cool_min_layer_time); + + const FanSpeedLayerTimeSettings& settings = extruder_plan.fan_speed_layer_time_settings_; + 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); // Modify fan speeds for the first layer(s) extruder_plan.processFanSpeedForFirstLayers();