Skip to content

Commit 0f48a25

Browse files
committed
Generate inwards moves according to the settings
CURA-12822
1 parent babbb7f commit 0f48a25

File tree

4 files changed

+66
-21
lines changed

4 files changed

+66
-21
lines changed

include/FffGcodeWriter.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,14 @@ class FffGcodeWriter : public NoCopy
419419
* \param part The part for which to create gcode.
420420
* \return Whether this function added anything to the layer plan.
421421
*/
422-
bool processMultiLayerInfill(LayerPlan& gcodeLayer, const SliceMeshStorage& mesh, const size_t extruder_nr, const MeshPathConfigs& mesh_config, const SliceLayerPart& part)
423-
const;
422+
bool processMultiLayerInfill(
423+
LayerPlan& gcodeLayer,
424+
const SliceMeshStorage& mesh,
425+
const size_t extruder_nr,
426+
const MeshPathConfigs& mesh_config,
427+
const SliceLayerPart& part,
428+
const coord_t move_inwards_start,
429+
const coord_t move_inwards_end) const;
424430

425431
/*!
426432
* \brief Add normal sparse infill for a given part in a layer.
@@ -438,7 +444,9 @@ class FffGcodeWriter : public NoCopy
438444
const SliceMeshStorage& mesh,
439445
const size_t extruder_nr,
440446
const MeshPathConfigs& mesh_config,
441-
const SliceLayerPart& part) const;
447+
const SliceLayerPart& part,
448+
const coord_t move_inwards_start,
449+
const coord_t move_inwards_end) const;
442450

443451
/*!
444452
* Generate the insets for the walls of a given layer part.

include/infill.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class Infill
5959
size_t zag_skip_count_{}; //!< (ZigZag) To skip one zag in every N if skip some zags is enabled
6060
coord_t pocket_size_{}; //!< The size of the pockets at the intersections of the fractal in the cross 3d pattern
6161
bool mirror_offset_{}; //!< Indication in which offset direction the extra infill lines are made
62+
coord_t move_inwards_start_{ 0 }; //!< Length of the inwards extrusion move to be added at infill start
63+
coord_t move_inwards_end_{ 0 }; //!< Length of the inwards extrusion move to be added at infill end
6264

6365
static constexpr auto one_over_sqrt_2 = 1.0 / std::numbers::sqrt2;
6466

@@ -163,7 +165,9 @@ class Infill
163165
bool use_endpieces,
164166
bool skip_some_zags,
165167
size_t zag_skip_count,
166-
coord_t pocket_size) noexcept
168+
coord_t pocket_size,
169+
const coord_t move_inwards_start = 0,
170+
const coord_t move_inwards_end = 0) noexcept
167171
: pattern_{ pattern }
168172
, zig_zaggify_{ zig_zaggify }
169173
, connect_polygons_{ connect_polygons }
@@ -188,6 +192,8 @@ class Infill
188192
, zag_skip_count_{ zag_skip_count }
189193
, pocket_size_{ pocket_size }
190194
, mirror_offset_{ zig_zaggify }
195+
, move_inwards_start_(move_inwards_start)
196+
, move_inwards_end_(move_inwards_end)
191197
{
192198
}
193199

src/FffGcodeWriter.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,8 +1917,12 @@ bool FffGcodeWriter::processInfill(
19171917
{
19181918
return false;
19191919
}
1920-
bool added_something = processMultiLayerInfill(gcode_layer, mesh, extruder_nr, mesh_config, part);
1921-
added_something = added_something | processSingleLayerInfill(storage, gcode_layer, mesh, extruder_nr, mesh_config, part);
1920+
1921+
const coord_t infill_move_inwards_start = mesh.settings.get<coord_t>("infill_move_inwards_start");
1922+
const coord_t infill_move_inwards_end = mesh.settings.get<coord_t>("infill_move_inwards_end");
1923+
1924+
bool added_something = processMultiLayerInfill(gcode_layer, mesh, extruder_nr, mesh_config, part, infill_move_inwards_start, infill_move_inwards_end);
1925+
added_something = added_something | processSingleLayerInfill(storage, gcode_layer, mesh, extruder_nr, mesh_config, part, infill_move_inwards_start, infill_move_inwards_end);
19221926
return added_something;
19231927
}
19241928

@@ -1927,7 +1931,9 @@ bool FffGcodeWriter::processMultiLayerInfill(
19271931
const SliceMeshStorage& mesh,
19281932
const size_t extruder_nr,
19291933
const MeshPathConfigs& mesh_config,
1930-
const SliceLayerPart& part) const
1934+
const SliceLayerPart& part,
1935+
const coord_t move_inwards_start,
1936+
const coord_t move_inwards_end) const
19311937
{
19321938
if (extruder_nr != mesh.settings.get<ExtruderTrain&>("infill_extruder_nr").extruder_nr_)
19331939
{
@@ -2010,7 +2016,9 @@ bool FffGcodeWriter::processMultiLayerInfill(
20102016
use_endpieces,
20112017
skip_some_zags,
20122018
zag_skip_count,
2013-
mesh.settings.get<coord_t>("cross_infill_pocket_size"));
2019+
mesh.settings.get<coord_t>("cross_infill_pocket_size"),
2020+
move_inwards_start,
2021+
move_inwards_end);
20142022
infill_comp.generate(
20152023
infill_paths,
20162024
infill_polygons,
@@ -2457,7 +2465,9 @@ bool FffGcodeWriter::processSingleLayerInfill(
24572465
const SliceMeshStorage& mesh,
24582466
const size_t extruder_nr,
24592467
const MeshPathConfigs& mesh_config,
2460-
const SliceLayerPart& part) const
2468+
const SliceLayerPart& part,
2469+
const coord_t move_inwards_start,
2470+
const coord_t move_inwards_end) const
24612471
{
24622472
if (extruder_nr != mesh.settings.get<ExtruderTrain&>("infill_extruder_nr").extruder_nr_)
24632473
{
@@ -2609,7 +2619,9 @@ bool FffGcodeWriter::processSingleLayerInfill(
26092619
use_endpieces,
26102620
skip_some_zags,
26112621
zag_skip_count,
2612-
pocket_size);
2622+
pocket_size,
2623+
move_inwards_start,
2624+
move_inwards_end);
26132625
infill_comp.generate(
26142626
wall_tool_paths.back(),
26152627
infill_polygons,
@@ -2674,7 +2686,9 @@ bool FffGcodeWriter::processSingleLayerInfill(
26742686
use_endpieces,
26752687
skip_some_zags,
26762688
zag_skip_count,
2677-
pocket_size);
2689+
pocket_size,
2690+
move_inwards_start,
2691+
move_inwards_end);
26782692
infill_comp.generate(
26792693
wall_tool_paths.back(),
26802694
infill_polygons,

src/infill.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,36 @@ void Infill::_generate(
343343
connectLines(result_lines);
344344
}
345345

346-
for (OpenPolyline& infill_line : result_lines)
346+
if (move_inwards_start_ != 0 || move_inwards_end_ != 0)
347347
{
348-
auto inner_contour_offset = inner_contour_.offset(-infill_line_width_ * 2);
349-
350-
auto last_point = infill_line.back();
351-
const auto last_point_polygon = PolygonUtils::moveInside2(inner_contour_offset, last_point);
352-
353-
infill_line.push_back(last_point_polygon.location_);
348+
// Add the start/end inwards moves
349+
const Shape offsetted_contour_start = move_inwards_start_ != 0 ? inner_contour_.offset(-move_inwards_start_) : Shape();
350+
Shape offsetted_contour_end;
351+
if (move_inwards_end_ == move_inwards_start_)
352+
{
353+
offsetted_contour_end = offsetted_contour_start;
354+
}
355+
else if (move_inwards_end_ != 0)
356+
{
357+
offsetted_contour_end = inner_contour_.offset(-move_inwards_end_);
358+
}
354359

360+
for (OpenPolyline& infill_line : result_lines)
361+
{
362+
if (! offsetted_contour_end.empty())
363+
{
364+
auto last_point = infill_line.back();
365+
const auto last_point_polygon = PolygonUtils::moveInside2(offsetted_contour_end, last_point);
366+
infill_line.push_back(last_point_polygon.location_);
367+
}
355368

356-
auto first_point = infill_line.front();
357-
const auto first_point_polygon = PolygonUtils::moveInside2(inner_contour_offset, first_point);
358-
infill_line.insert(infill_line.begin(), first_point_polygon.location_);
369+
if (! offsetted_contour_start.empty())
370+
{
371+
auto first_point = infill_line.front();
372+
const auto first_point_polygon = PolygonUtils::moveInside2(offsetted_contour_start, first_point);
373+
infill_line.insert(infill_line.begin(), first_point_polygon.location_);
374+
}
375+
}
359376
}
360377

361378
Simplify simplifier(max_resolution_, max_deviation_, 0);

0 commit comments

Comments
 (0)