Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cura 12275 retract before outer wall only works on the initial layer #2172

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/ExtruderPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class ExtruderPlan
*/
void applyBackPressureCompensation(const Ratio back_pressure_compensation);

/*!
* Gets the mesh being printed first on this plan
*/
std::shared_ptr<const SliceMeshStorage> findFirstPrintedMesh() const;

private:
LayerIndex layer_nr_{ 0 }; //!< The layer number at which we are currently printing.
bool is_initial_layer_{ false }; //!< Whether this extruder plan is printed on the very first layer (which might be raft)
Expand Down
5 changes: 5 additions & 0 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,11 @@ class LayerPlan : public NoCopy
*/
void applyGradualFlow();

/*!
* Gets the mesh being printed first on this layer
*/
std::shared_ptr<const SliceMeshStorage> findFirstPrintedMesh() const;

private:
/*!
* \brief Compute the preferred or minimum combing boundary
Expand Down
14 changes: 14 additions & 0 deletions src/ExtruderPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@ void ExtruderPlan::applyBackPressureCompensation(const Ratio back_pressure_compe
path.speed_back_pressure_factor = std::max(epsilon_speed_factor, 1.0 + (nominal_width_for_path / line_width_for_path - 1.0) * back_pressure_compensation);
}
}

std::shared_ptr<const SliceMeshStorage> ExtruderPlan::findFirstPrintedMesh() const
{
for (const GCodePath& path : paths_)
{
if (path.mesh)
{
return path.mesh;
}
}

return nullptr;
}

} // namespace cura
13 changes: 13 additions & 0 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,19 @@ void LayerPlan::applyGradualFlow()
}
}

std::shared_ptr<const SliceMeshStorage> LayerPlan::findFirstPrintedMesh() const
{
for (const ExtruderPlan& extruder_plan : extruder_plans_)
{
if (std::shared_ptr<const SliceMeshStorage> mesh = extruder_plan.findFirstPrintedMesh())
{
return mesh;
}
}

return nullptr;
}

LayerIndex LayerPlan::getLayerNr() const
{
return layer_nr_;
Expand Down
19 changes: 15 additions & 4 deletions src/LayerPlanBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,21 @@ void LayerPlanBuffer::addConnectingTravelMove(LayerPlan* prev_layer, const Layer
const Settings& mesh_group_settings = Application::getInstance().current_slice_->scene.current_mesh_group->settings;
const Settings& extruder_settings = Application::getInstance().current_slice_->scene.extruders[prev_layer->extruder_plans_.back().extruder_nr_].settings_;
prev_layer->setIsInside(new_layer_destination_state->second);
const bool force_retract = extruder_settings.get<bool>("retract_at_layer_change")
|| (mesh_group_settings.get<bool>("travel_retract_before_outer_wall")
&& (mesh_group_settings.get<InsetDirection>("inset_direction") == InsetDirection::OUTSIDE_IN
|| mesh_group_settings.get<size_t>("wall_line_count") == 1)); // Moving towards an outer wall.

const bool travel_retract_before_outer_wall = mesh_group_settings.get<bool>("travel_retract_before_outer_wall");
const bool retract_at_layer_change = extruder_settings.get<bool>("retract_at_layer_change");
bool next_mesh_retract_before_outer_wall = false;
std::shared_ptr<const SliceMeshStorage> first_printed_mesh = newest_layer->findFirstPrintedMesh();
if (! retract_at_layer_change && first_printed_mesh && travel_retract_before_outer_wall)
{
// Check whether we are moving toving towards an outer wall and it should be retracted
const Settings& mesh_settings = first_printed_mesh->settings;
const InsetDirection inset_direction = mesh_settings.get<InsetDirection>("inset_direction");
const size_t wall_line_count = mesh_settings.get<size_t>("wall_line_count");

next_mesh_retract_before_outer_wall = inset_direction == InsetDirection::OUTSIDE_IN || wall_line_count == 1;
}
const bool force_retract = retract_at_layer_change || next_mesh_retract_before_outer_wall;
prev_layer->final_travel_z_ = newest_layer->z_;
GCodePath& path = prev_layer->addTravel(first_location_new_layer, force_retract);
if (force_retract && ! path.retract)
Expand Down
Loading