Skip to content

Commit

Permalink
Change behavior of infill overlap to match expected behavior
Browse files Browse the repository at this point in the history
The infill overlap previously worked by extending the whole infill area
and filling it. However, infill areas sometimes have inner walls, and in
this case we would expand the walls, but the pattern generated inside
would not overlap the walls, which is actually what we want to achieve
in order to ensure that the sparser inner pattern properly sticks to
what is outside it, whenever this is an infill wall or a skin wall.
  • Loading branch information
wawanbreton committed Jun 21, 2024
1 parent 3f65f44 commit 9163541
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
13 changes: 4 additions & 9 deletions include/infill.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class Infill
Shape inner_contour_{}; //!< The part of the contour that will get filled with an infill pattern. Equals outer_contour minus the extra infill walls.
coord_t infill_line_width_{}; //!< The line width of the infill lines to generate
coord_t line_distance_{}; //!< The distance between two infill lines / polygons
coord_t infill_overlap_{}; //!< the distance by which to overlap with the actual area within which to generate infill
coord_t pattern_overlap_{ 0 }; //!< The distance by which to overlap the inner infill pattern with the infill walls
coord_t infill_overlap_{}; //!< The distance by which to overlap the inner infill pattern with the infill walls
size_t infill_multiplier_{}; //!< the number of infill lines next to each other
AngleDegrees fill_angle_{}; //!< for linear infill types: the angle of the infill lines (or the angle of the grid)
coord_t z_{}; //!< height of the layer for which we generate infill
Expand Down Expand Up @@ -164,8 +163,7 @@ class Infill
bool use_endpieces,
bool skip_some_zags,
size_t zag_skip_count,
coord_t pocket_size,
coord_t pattern_overlap = 0) noexcept
coord_t pocket_size) noexcept
: pattern_{ pattern }
, zig_zaggify_{ zig_zaggify }
, connect_polygons_{ connect_polygons }
Expand All @@ -190,7 +188,6 @@ class Infill
, zag_skip_count_{ zag_skip_count }
, pocket_size_{ pocket_size }
, mirror_offset_{ zig_zaggify }
, pattern_overlap_{ pattern_overlap }
{
}

Expand Down Expand Up @@ -222,19 +219,17 @@ class Infill
* This function is called within the generate() function but can also be called stand-alone
*
* \param toolpaths [out] The generated toolpaths. Binned by inset_idx.
* \param outer_contour [in,out] the outer contour, this is offsetted with the infill overlap
* \param outer_contour [in] the outer contour
* \param wall_line_count [in] The number of walls that needs to be generated
* \param line_width [in] The optimum wall line width of the walls
* \param infill_overlap [in] The overlap of the infill
* \param settings [in] A settings storage to use for generating variable-width walls.
* \return The inner contour of the wall toolpaths
*/
static Shape generateWallToolPaths(
std::vector<VariableWidthLines>& toolpaths,
Shape& outer_contour,
const Shape& outer_contour,
const size_t wall_line_count,
const coord_t line_width,
const coord_t infill_overlap,
const Settings& settings,
int layer_idx,
SectionType section_type);
Expand Down
22 changes: 8 additions & 14 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
const size_t wall_line_count = base_settings.get<size_t>("raft_base_wall_count");
const coord_t small_area_width = 0; // A raft never has a small region due to the large horizontal expansion.
const coord_t line_spacing = base_settings.get<coord_t>("raft_base_line_spacing");
constexpr coord_t infill_overlap = 0;
const coord_t pattern_overlap = base_settings.get<coord_t>("raft_base_infill_overlap_mm");
const coord_t infill_overlap = base_settings.get<coord_t>("raft_base_infill_overlap_mm");
const coord_t line_spacing_prime_tower = base_settings.get<coord_t>("prime_tower_raft_base_line_spacing");
const Point2LL& infill_origin = Point2LL();
constexpr bool skip_stitching = false;
Expand Down Expand Up @@ -685,8 +684,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
use_endpieces,
skip_some_zags,
zag_skip_count,
pocket_size,
pattern_overlap);
pocket_size);
std::vector<VariableWidthLines> raft_paths;
infill_comp.generate(raft_paths, raft_polygons, raft_lines, base_settings, layer_nr, SectionType::ADHESION);
if (! raft_paths.empty())
Expand Down Expand Up @@ -755,8 +753,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
const coord_t interface_line_spacing = interface_settings.get<coord_t>("raft_interface_line_spacing");
const Ratio interface_fan_speed = interface_settings.get<Ratio>("raft_interface_fan_speed");
const coord_t interface_line_width = interface_settings.get<coord_t>("raft_interface_line_width");
constexpr coord_t interface_infill_overlap = 0;
const coord_t interface_pattern_overlap = interface_settings.get<coord_t>("raft_interface_infill_overlap_mm");
const coord_t interface_infill_overlap = interface_settings.get<coord_t>("raft_interface_infill_overlap_mm");
const coord_t interface_avoid_distance = interface_settings.get<coord_t>("travel_avoid_distance");
const coord_t interface_max_resolution = interface_settings.get<coord_t>("meshfix_maximum_resolution");
const coord_t interface_max_deviation = interface_settings.get<coord_t>("meshfix_maximum_deviation");
Expand Down Expand Up @@ -846,8 +843,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
use_endpieces,
skip_some_zags,
zag_skip_count,
pocket_size,
interface_pattern_overlap);
pocket_size);
std::vector<VariableWidthLines> raft_paths;
infill_comp.generate(raft_paths, raft_polygons, raft_lines, interface_settings, layer_nr, SectionType::ADHESION);
if (! raft_paths.empty())
Expand Down Expand Up @@ -917,8 +913,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
const coord_t surface_max_resolution = surface_settings.get<coord_t>("meshfix_maximum_resolution");
const coord_t surface_max_deviation = surface_settings.get<coord_t>("meshfix_maximum_deviation");
const coord_t surface_line_width = surface_settings.get<coord_t>("raft_surface_line_width");
constexpr coord_t surface_infill_overlap = 0;
const coord_t surface_pattern_overlap = surface_settings.get<coord_t>("raft_surface_infill_overlap_mm");
const coord_t surface_infill_overlap = surface_settings.get<coord_t>("raft_surface_infill_overlap_mm");
const coord_t surface_avoid_distance = surface_settings.get<coord_t>("travel_avoid_distance");
const Ratio surface_fan_speed = surface_settings.get<Ratio>("raft_surface_fan_speed");
const bool surface_monotonic = surface_settings.get<bool>("raft_surface_monotonic");
Expand Down Expand Up @@ -1014,8 +1009,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
use_endpieces,
skip_some_zags,
zag_skip_count,
pocket_size,
surface_pattern_overlap);
pocket_size);

std::vector<VariableWidthLines> raft_paths;
infill_comp.generate(raft_paths, raft_polygons, raft_lines, surface_settings, layer_nr, SectionType::ADHESION);
Expand Down Expand Up @@ -1933,7 +1927,7 @@ bool FffGcodeWriter::processMultiLayerInfill(

constexpr size_t wall_line_count = 0; // wall toolpaths are when gradual infill areas are determined
const coord_t small_area_width = 0;
constexpr coord_t infill_overlap = 0; // Overlap is handled when the wall toolpaths are generated
const coord_t infill_overlap = mesh.settings.get<coord_t>("infill_overlap_mm");
constexpr bool skip_stitching = false;
constexpr bool connected_zigzags = false;
constexpr bool use_endpieces = true;
Expand Down Expand Up @@ -2214,7 +2208,7 @@ bool FffGcodeWriter::processSingleLayerInfill(

constexpr size_t wall_line_count_here = 0; // Wall toolpaths were generated in generateGradualInfill for the sparsest density, denser parts don't have walls by default
const coord_t small_area_width = 0;
constexpr coord_t overlap = 0; // overlap is already applied for the sparsest density in the generateGradualInfill
const coord_t overlap = mesh.settings.get<coord_t>("infill_overlap_mm");

wall_tool_paths.emplace_back();
Infill infill_comp(
Expand Down
10 changes: 3 additions & 7 deletions src/infill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,13 @@ namespace cura

Shape Infill::generateWallToolPaths(
std::vector<VariableWidthLines>& toolpaths,
Shape& outer_contour,
const Shape& outer_contour,
const size_t wall_line_count,
const coord_t line_width,
const coord_t infill_overlap,
const Settings& settings,
int layer_idx,
SectionType section_type)
{
outer_contour = outer_contour.offset(infill_overlap);
scripta::log("infill_outer_contour", outer_contour, section_type, layer_idx, scripta::CellVDI{ "infill_overlap", infill_overlap });

Shape inner_contour;
if (wall_line_count > 0)
{
Expand Down Expand Up @@ -100,10 +96,10 @@ void Infill::generate(
return;
}

inner_contour_ = generateWallToolPaths(toolpaths, outer_contour_, wall_line_count_, infill_line_width_, infill_overlap_, settings, layer_idx, section_type);
inner_contour_ = generateWallToolPaths(toolpaths, outer_contour_, wall_line_count_, infill_line_width_, settings, layer_idx, section_type);
scripta::log("infill_inner_contour_0", inner_contour_, section_type, layer_idx);

inner_contour_ = inner_contour_.offset(pattern_overlap_);
inner_contour_ = inner_contour_.offset(infill_overlap_);

// It does not make sense to print a pattern in a small region. So the infill region
// is split into a small region that will be filled with walls and the normal region
Expand Down
2 changes: 0 additions & 2 deletions src/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh)

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");
const auto is_connected = mesh.settings.get<bool>("zig_zaggify_infill") || mesh.settings.get<EFillMethod>("infill_pattern") == EFillMethod::ZIG_ZAG;
for (LayerIndex layer_idx = 0; layer_idx < static_cast<LayerIndex>(mesh.layers.size()); layer_idx++)
{ // loop also over layers which don't contain infill cause of bottom_ and top_layer to initialize their infill_area_per_combine_per_density
Expand All @@ -485,7 +484,6 @@ void SkinInfillAreaComputation::generateGradualInfill(SliceMeshStorage& mesh)
part.getOwnInfillArea(),
infill_wall_count,
infill_wall_width,
infill_overlap,
mesh.settings,
layer_idx,
SectionType::SKIN);
Expand Down
1 change: 0 additions & 1 deletion src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ void AreaSupport::generateGradualSupport(SliceDataStorage& storage)
original_area,
support_infill_part.inset_count_to_generate_,
wall_width,
0,
infill_extruder.settings_,
layer_nr,
SectionType::SUPPORT);
Expand Down

0 comments on commit 9163541

Please sign in to comment.