Skip to content

Commit

Permalink
Remove narrow areas from --and simplify-- gradual infill areas.
Browse files Browse the repository at this point in the history
Narrow or small areas can lead to double printing of lines, as a polygon is filled out that can be narrower than the line-width. Also observed what might be micro-segments in the connecting zags (if there are any), so simplify those out as well.

part of CURA-11597
  • Loading branch information
rburema committed Apr 3, 2024
1 parent 51daa75 commit 042745e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "sliceDataStorage.h"
#include "utils/math.h"
#include "utils/polygonUtils.h"
#include "utils/Simplify.h"

#define MIN_AREA_SIZE (0.4 * 0.4)

Expand Down Expand Up @@ -465,6 +466,8 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh)
const LayerIndex mesh_min_layer = mesh.settings.get<size_t>("initial_bottom_layers");
const LayerIndex mesh_max_layer = mesh.layers.size() - 1 - mesh.settings.get<size_t>("top_layers");

const Simplify simplifier(mesh.settings.get<ExtruderTrain&>("infill_extruder_nr").settings_);

const auto infill_wall_count = mesh.settings.get<size_t>("infill_wall_line_count");
const auto infill_wall_width = mesh.settings.get<coord_t>("infill_line_width");
const auto infill_overlap = mesh.settings.get<coord_t>("infill_overlap_mm");
Expand Down Expand Up @@ -527,12 +530,12 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh)
part.infill_area_per_combine_per_density.emplace_back();
std::vector<Polygons>& infill_area_per_combine_current_density = part.infill_area_per_combine_per_density.back();
const Polygons more_dense_infill = infill_area.difference(less_dense_infill);
infill_area_per_combine_current_density.push_back(more_dense_infill.difference(sum_more_dense));
infill_area_per_combine_current_density.push_back(simplifier.polygon(more_dense_infill.difference(sum_more_dense).offset(-infill_wall_width).offset(infill_wall_width)));
sum_more_dense = sum_more_dense.unionPolygons(more_dense_infill);
}
part.infill_area_per_combine_per_density.emplace_back();
std::vector<Polygons>& infill_area_per_combine_current_density = part.infill_area_per_combine_per_density.back();
infill_area_per_combine_current_density.push_back(infill_area.difference(sum_more_dense));
infill_area_per_combine_current_density.push_back(simplifier.polygon(infill_area.difference(sum_more_dense).offset(-infill_wall_width).offset(infill_wall_width)));
part.infill_area_own = std::nullopt; // clear infill_area_own, it's not needed any more.
assert(! part.infill_area_per_combine_per_density.empty() && "infill_area_per_combine_per_density is now initialized");
}
Expand Down
5 changes: 3 additions & 2 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void AreaSupport::generateGradualSupport(SliceDataStorage& storage)
const size_t max_density_steps = infill_extruder.settings_.get<size_t>("gradual_support_infill_steps");

const coord_t wall_width = infill_extruder.settings_.get<coord_t>("support_line_width");
const Simplify simplifier(infill_extruder.settings_);

// no early-out for this function; it needs to initialize the [infill_area_per_combine_per_density]
double layer_skip_count{ 8.0 }; // skip every so many layers as to ignore small gaps in the model making computation more easy
Expand Down Expand Up @@ -293,13 +294,13 @@ void AreaSupport::generateGradualSupport(SliceDataStorage& storage)
support_infill_part.infill_area_per_combine_per_density_.emplace_back();
std::vector<Polygons>& support_area_current_density = support_infill_part.infill_area_per_combine_per_density_.back();
const Polygons more_dense_support = infill_area.difference(less_dense_support);
support_area_current_density.push_back(more_dense_support.difference(sum_more_dense));
support_area_current_density.push_back(simplifier.polygon(more_dense_support.difference(sum_more_dense).offset(-wall_width).offset(wall_width)));
sum_more_dense = sum_more_dense.unionPolygons(more_dense_support);
}

support_infill_part.infill_area_per_combine_per_density_.emplace_back();
std::vector<Polygons>& support_area_current_density = support_infill_part.infill_area_per_combine_per_density_.back();
support_area_current_density.push_back(infill_area.difference(sum_more_dense));
support_area_current_density.push_back(simplifier.polygon(infill_area.difference(sum_more_dense).offset(-wall_width).offset(wall_width)));

assert(support_infill_part.infill_area_per_combine_per_density_.size() != 0 && "support_infill_part.infill_area_per_combine_per_density should now be initialized");
#ifdef DEBUG
Expand Down

0 comments on commit 042745e

Please sign in to comment.