* Shorten the travel between extrusion paths
chain_and_reorder_extrusion_entities() builds the print order of the infill,
ironing and support paths of a region from the nozzle position. It took the
greedy chain, which leaves its longest joins for last; it now shortens it:
- Up to eight paths, chain_segments_exact() finds the shortest chain over
every order and allowed reversal, by dynamic programming over the subsets
of paths, with a fixed start and a free end.
- Longer chains are refined by local search: 2-opt, or-opt of up to three
paths, and moving a run of any length next to the nozzle to the front, each
tried only toward the 32 end points nearest a link, which come from a
uniform grid. A move is applied only if it shortens the chain, so the result
is never longer than the greedy one.
- A nearest-next chain is built too, and refined and used instead when it is
already shorter than the refined greedy chain, which happens when the greedy
chain sweeps away from the nozzle and has to come back with a long jump.
The shared greedy chaining also chains two to four segments exactly, which
covers the islands of a layer and the loops of a perimeter collection. Paths
that cannot reverse, such as Grid's, are only reordered, and collections that
keep their order are left alone. The overload without a start point keeps the
greedy chain.
Co-authored-by: Tobias Gloth <tobias.gloth@3dsystems.com>
* Order objects and islands along shorter tours
Objects under print_order Default, and the tour of islands across objects, are
visited in the same order on every layer, so chain_points_with_postprocessing()
orders them as a closed tour. Up to ten points, tsp_exact_cycle() finds the
shortest tour by dynamic programming over subsets, starting at the point
nearest the start point when one is given. Larger sets add or-opt to the
existing 2-opt and crossing removal: runs of up to three points move next to
one of the eight points nearest an end of the run, reversed or not, and
crossing removal runs last so no crossing is left. Snake ordering is
unchanged; Best of strategies gets the shorter Default tour as a candidate.
* Join infill lines into fewer paths
Every separate infill path costs a travel to it, so the fill generators now
leave fewer of them:
- connect_infill() pairs the line ends along each wall in the order that
joins the most lines: besides shortest arc first, it replays arcs of about
the same length taken along each contour, forwards and backwards, including
the last pass that joins neighboring open ends, and keeps the order that
joins the most. Regular patterns no longer leave loose ends where the
pairs along a wall fall out of step, and multiline copies print out and back.
- Ends whose anchors would meet are joined along the wall instead, up to two
anchors and a line width apart.
- An unpaired end anchors toward the nearest open end of another path, where
the next path usually starts, instead of the side with more free wall. With
multiline infill, an anchor toward a copy of the same line stops short of
the copy instead of printing over it.
- Last, sparse infill lines whose ends are at most two line spacings apart are
joined with a straight piece, shortest first, without closing a loop or
crossing a line; with anchors off this is the only joining. Copies of
neighboring multiline groups are joined at the same side, and lines that
cannot reverse only join end to start.
* Describe the travel optimization design
How the extrusion chains, the object and island tours and the infill line joining shorten the travel, and why each part is built the way it is.
---------
Co-authored-by: Tobias Gloth <tobias.gloth@3dsystems.com>