@@ -37,6 +37,7 @@ namespace cura
3737class Comb ;
3838class SliceDataStorage ;
3939class LayerPlanBuffer ;
40+ class STHalfEdge ;
4041
4142template <typename PathType>
4243class PathAdapter ;
@@ -525,9 +526,30 @@ class LayerPlan : public NoCopy
525526 bool reverse_order = false,
526527 const std::optional<Point2LL> start_near_location = std::optional<Point2LL>(),
527528 bool scarf_seam = false,
528- bool smooth_acceleration = false,
529+ bool smooth_speed = false,
529530 const std::shared_ptr<TextureDataProvider>& texture_data_provider = nullptr);
530531
532+ /* !
533+ * Adds infill polygons to the gcode with optimized order.
534+ *
535+ * In case we need to generate extra inwards moves for the infill, we cannot treat them as polygons anymore, since the lines will be un-closed. Thus, the resulting open
536+ * polylines are returned in \p remaining_lines and should be re-added to the gcode, e.g. by using addLinesByOptimizer().
537+ *
538+ * @param polygons The infill polygons to be added
539+ * @param[out] remaining_lines The list to be filled with generates open polylines. The given list may be non-empty, only new lines will be appended. * @param config The
540+ * config with which to print the polygon lines
541+ * @param settings The current settings to retrieve values from
542+ * @param add_extra_inwards_move Indicates whether extra start/end inwards extrusion moves will be generated
543+ * @param near_start_location Optional: Location near where to add the first line. If not provided the last position is used.
544+ */
545+ void addInfillPolygonsByOptimizer (
546+ const Shape& polygons,
547+ OpenLinesSet& remaining_lines,
548+ const GCodePathConfig& config,
549+ const Settings& settings,
550+ const bool add_extra_inwards_move = false ,
551+ const std::optional<Point2LL>& near_start_location = std::optional<Point2LL>());
552+
531553 /* !
532554 * Add a single line that is part of a wall to the gcode.
533555 * \param p0 The start vertex of the line.
@@ -687,6 +709,9 @@ class LayerPlan : public NoCopy
687709 * \param fan_speed optional fan speed override for this path
688710 * \param reverse_print_direction Whether to reverse the optimized order and their printing direction.
689711 * \param order_requirements Pairs where first needs to be printed before second. Pointers are pointing to elements of \p lines
712+ * \param extra_inwards_start_move_length The length of the extra inwards moves to be added at the start of each infill line
713+ * \param extra_inwards_end_move_length The length of the extra inwards moves to be added at the end of each infill line
714+ * \param extra_inwards_move_contour The contour to be considered in order to add the inwards moves
690715 */
691716 template <class LineType >
692717 void addLinesByOptimizer (
@@ -699,7 +724,10 @@ class LayerPlan : public NoCopy
699724 const std::optional<Point2LL> near_start_location = std::optional<Point2LL>(),
700725 const double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT,
701726 const bool reverse_print_direction = false,
702- const std::unordered_multimap<const Polyline*, const Polyline*>& order_requirements = PathOrderOptimizer<const Polyline*>::no_order_requirements_);
727+ const std::unordered_multimap<const Polyline*, const Polyline*>& order_requirements = PathOrderOptimizer<const Polyline*>::no_order_requirements_,
728+ const coord_t extra_inwards_start_move_length = 0,
729+ const coord_t extra_inwards_end_move_length = 0,
730+ const Shape& extra_inwards_move_contour = Shape());
703731
704732 /* !
705733 * Add lines to the gcode with optimized order.
@@ -870,14 +898,55 @@ class LayerPlan : public NoCopy
870898 * \param wipe_dist (optional) the distance wiped without extruding after laying down a line.
871899 * \param flow_ratio The ratio with which to multiply the extrusion amount
872900 * \param fan_speed optional fan speed override for this path
901+ * \param extra_inwards_start_move_length The length of the extra inwards moves to be added at the start of each infill line
902+ * \param extra_inwards_end_move_length The length of the extra inwards moves to be added at the end of each infill line
903+ * \param extra_inwards_move_contour The contour to be considered in order to add the inwards moves
873904 */
874905 void addLinesInGivenOrder (
875906 const std::vector<PathOrdering<const Polyline*>>& lines,
876907 const GCodePathConfig& config,
877908 const SpaceFillType space_fill_type,
878909 const coord_t wipe_dist,
879910 const Ratio flow_ratio,
880- const double fan_speed);
911+ const double fan_speed,
912+ const coord_t extra_inwards_start_move_length = 0 ,
913+ const coord_t extra_inwards_end_move_length = 0 ,
914+ const Shape& extra_inwards_move_contour = Shape());
915+
916+ /* !
917+ * Add order optimized polygons to the gcode.
918+ * Add polygons to the gcode with optimized order.
919+ *
920+ * \param polygons The polygons.
921+ * \param config The config with which to print the polygon lines.
922+ * for each given segment (optionally nullptr).
923+ * \param settings The settings which should apply to these polygons added to the layer plan
924+ * \param z_seam_config Optional configuration for z-seam.
925+ * \param wall_0_wipe_dist The distance to travel along each polygon after
926+ * it has been laid down, in order to wipe the start and end of the wall
927+ * together.
928+ * \param spiralize Whether to gradually increase the z height from the
929+ * normal layer height to the height of the next layer over each polygon
930+ * printed.
931+ * \param flow_ratio The ratio with which to multiply the extrusion amount.
932+ * \param always_retract Whether to force a retraction when moving to the
933+ * start of the polygon (used for outer walls).
934+ * \param reverse_order Adds polygons in reverse order.
935+ * \param scarf_seam Indicates whether we may use a scarf seam for the path
936+ * \param smooth_speed Indicates whether we may use a speed gradient for the path
937+ */
938+ void addPolygonsInGivenOrder (
939+ const std::vector<PathOrdering<const Polygon*>>& polygons,
940+ const GCodePathConfig& config,
941+ const Settings& settings,
942+ const ZSeamConfig& z_seam_config = ZSeamConfig(),
943+ coord_t wall_0_wipe_dist = 0,
944+ bool spiralize = false,
945+ const Ratio flow_ratio = 1.0_r,
946+ bool always_retract = false,
947+ bool reverse_order = false,
948+ bool scarf_seam = false,
949+ bool smooth_speed = false);
881950
882951 /* !
883952 * @brief Send a GCodePath line to the communication object, applying proper Z offsets
@@ -1150,6 +1219,16 @@ class LayerPlan : public NoCopy
11501219 const std::optional<TravelAntiOozing>& priming_amounts,
11511220 const Velocity& speed,
11521221 const size_t point_index);
1222+
1223+ /* !
1224+ * Generates an extrusion move that goes as inwards as possible given a skeletized contour, starting from the given point
1225+ * @param trapezoidal_edges The edges of the skeletal trapezoidation for the contour
1226+ * @param start_point The point to start generating the move from
1227+ * @param move_inwards_length The length of the move to be generated
1228+ * @return Extrusion path to be started from the given start point, going further inwards. It may be empty if not possible or if the start point is
1229+ * already inwards the contour enough.
1230+ */
1231+ static OpenPolyline makeInwardsMove (const std::list<STHalfEdge>& trapezoidal_edges, const Point2LL& start_point, const coord_t move_inwards_length);
11531232};
11541233
11551234} // namespace cura
0 commit comments