Skip to content

Commit

Permalink
Use different minimum layer time when layer has an overhang
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Dec 16, 2024
1 parent 71c8e14 commit 4379cbf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
13 changes: 9 additions & 4 deletions include/FanSpeedLayerTime.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,7 +8,7 @@
#include "settings/types/LayerIndex.h"
#include "settings/types/Velocity.h"

namespace cura
namespace cura
{

/*!
Expand All @@ -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:
/*!
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class LayerPlan : public NoCopy
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
//!< 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.
Expand Down
1 change: 1 addition & 0 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Duration>("cool_min_layer_time");
fan_speed_layer_time_settings.cool_min_layer_time_overhang = train.settings_.get<Duration>("cool_min_layer_time_overhang");
fan_speed_layer_time_settings.cool_min_layer_time_fan_speed_max = train.settings_.get<Duration>("cool_min_layer_time_fan_speed_max");
fan_speed_layer_time_settings.cool_fan_speed_0 = train.settings_.get<Ratio>("cool_fan_speed_0") * 100.0;
fan_speed_layer_time_settings.cool_fan_speed_min = train.settings_.get<Ratio>("cool_fan_speed_min") * 100.0;
Expand Down
15 changes: 11 additions & 4 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t> 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);
};

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4379cbf

Please sign in to comment.