Skip to content

Commit

Permalink
Merge branch 'main' into CURA-12352_different-minimum-layer-time-for-…
Browse files Browse the repository at this point in the history
…layers-that-contain-overhangs
  • Loading branch information
HellAholic authored Jan 17, 2025
2 parents a98e7d0 + a7e6fa0 commit c468d03
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
29 changes: 13 additions & 16 deletions include/PathOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,29 +738,26 @@ class PathOrderOptimizer

BestElementFinder::WeighedCriterion main_criterion;

if (path.force_start_index_.has_value()) // Actually handles EZSeamType::USER_SPECIFIED
if (path.force_start_index_.has_value()) // Handles EZSeamType::USER_SPECIFIED with "seam_on_vertex" disabled
{
// Use a much smaller distance divider because we want points around the forced points to be filtered out very easily
constexpr double distance_divider = 1.0;
constexpr auto distance_type = DistanceScoringCriterion::DistanceType::Euclidian;
main_criterion.criterion = std::make_shared<DistanceScoringCriterion>(points, points.at(path.force_start_index_.value()), distance_type, distance_divider);
}
else
else if (path.seam_config_.type_ == EZSeamType::SHORTEST || path.seam_config_.type_ == EZSeamType::USER_SPECIFIED)
{
if (path.seam_config_.type_ == EZSeamType::SHORTEST)
{
main_criterion.criterion = std::make_shared<DistanceScoringCriterion>(points, target_pos);
}
else if (
path.seam_config_.type_ == EZSeamType::SHARPEST_CORNER
&& (path.seam_config_.corner_pref_ != EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE && path.seam_config_.corner_pref_ != EZSeamCornerPrefType::PLUGIN))
{
main_criterion.criterion = std::make_shared<CornerScoringCriterion>(points, path.seam_config_.corner_pref_);
}
else if (path.seam_config_.type_ == EZSeamType::RANDOM)
{
main_criterion.criterion = std::make_shared<RandomScoringCriterion>();
}
main_criterion.criterion = std::make_shared<DistanceScoringCriterion>(points, target_pos);
}
else if (
path.seam_config_.type_ == EZSeamType::SHARPEST_CORNER
&& (path.seam_config_.corner_pref_ != EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE && path.seam_config_.corner_pref_ != EZSeamCornerPrefType::PLUGIN))
{
main_criterion.criterion = std::make_shared<CornerScoringCriterion>(points, path.seam_config_.corner_pref_);
}
else if (path.seam_config_.type_ == EZSeamType::RANDOM)
{
main_criterion.criterion = std::make_shared<RandomScoringCriterion>();
}

if (main_criterion.criterion)
Expand Down
4 changes: 3 additions & 1 deletion src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS

const Scene& scene = Application::getInstance().current_slice_->scene;

coord_t comb_offset_from_outlines = 0;
coord_t avoid_distance = 0; // minimal avoid distance is zero
const std::vector<bool> extruder_is_used = storage.getExtrudersUsed();
for (size_t extruder_nr = 0; extruder_nr < scene.extruders.size(); extruder_nr++)
Expand All @@ -1184,6 +1185,8 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS
{
avoid_distance = std::max(avoid_distance, extruder.settings_.get<coord_t>("travel_avoid_distance"));
}

comb_offset_from_outlines = std::max(comb_offset_from_outlines, extruder.settings_.get<coord_t>("retraction_combing_avoid_distance"));
}
}

Expand All @@ -1199,7 +1202,6 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS
}
max_inner_wall_width = std::max(max_inner_wall_width, mesh_inner_wall_width);
}
const coord_t comb_offset_from_outlines = max_inner_wall_width * 2;

const size_t first_extruder = findUsedExtruderIndex(storage, layer_nr, false);

Expand Down
26 changes: 21 additions & 5 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ Shape LayerPlan::computeCombBoundary(const CombBoundary boundary_type)
switch (boundary_type)
{
case CombBoundary::MINIMUM:
offset = -mesh.settings.get<coord_t>("machine_nozzle_size") / 2 - mesh.settings.get<coord_t>("wall_line_width_0") / 2 - extra_offset;
offset = -(mesh.settings.get<coord_t>("machine_nozzle_size") / 2 + mesh.settings.get<coord_t>("wall_line_width_0") / 2 + extra_offset);
break;
case CombBoundary::PREFERRED:
offset = -mesh.settings.get<coord_t>("machine_nozzle_size") * 3 / 2 - mesh.settings.get<coord_t>("wall_line_width_0") / 2 - extra_offset;
offset = -(mesh.settings.get<coord_t>("retraction_combing_avoid_distance") + mesh.settings.get<coord_t>("wall_line_width_0") / 2 + extra_offset);
break;
default:
offset = 0;
Expand Down Expand Up @@ -2676,8 +2676,24 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
{
ExtruderPlan& extruder_plan = extruder_plans_[extruder_plan_idx];

const RetractionAndWipeConfig* retraction_config
= current_mesh ? &current_mesh->retraction_wipe_config : &storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_];
auto get_retraction_config = [&extruder_nr, this](std::shared_ptr<const SliceMeshStorage>& mesh) -> std::optional<const RetractionAndWipeConfig*>
{
if (mesh)
{
if (extruder_nr == mesh->settings.get<size_t>("extruder_nr")) [[likely]]
{
return &mesh->retraction_wipe_config;
}

// We are printing a part of a mesh with a different extruder, use this extruder settings instead (mesh-specific settings will be ignored)
return &storage_.retraction_wipe_config_per_extruder[extruder_nr];
}

// We have no mesh yet, a more global config should be used
return std::nullopt;
};

const RetractionAndWipeConfig* retraction_config = get_retraction_config(current_mesh).value_or(&storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_]);
coord_t z_hop_height = retraction_config->retraction_config.zHop;

if (extruder_nr != extruder_plan.extruder_nr_)
Expand Down Expand Up @@ -2861,7 +2877,7 @@ void LayerPlan::writeGCode(GCodeExport& gcode)

if (path.retract)
{
retraction_config = path.mesh ? &path.mesh->retraction_wipe_config : retraction_config;
retraction_config = get_retraction_config(path.mesh).value_or(retraction_config);
gcode.writeRetraction(retraction_config->retraction_config);
if (path.retract_for_nozzle_switch)
{
Expand Down

0 comments on commit c468d03

Please sign in to comment.