2-opt Travel Optimization
Nearest-neighbor ordering refined with 2-opt segment swapping, for shorter travel paths with fewer crossings.
Starting Position
preFlight orders islands and infill from where the nozzle actually is. When there is no previous position to continue from, the first island on a layer or the hole pass of a perimeter group, it starts from the region's centroid instead of the bed origin.
2-opt Optimization Algorithm
The 2-opt algorithm iteratively improves travel paths by swapping segments until no further improvement can be found. This is the same class of algorithm used to solve traveling salesman problems, applied here to minimize wasted movement between extrusions.
Region-Aware Infill Ordering
The same ordering applies to infill, region by region, and on multi-island layers it cuts travel distance 30 to 50 percent against the naive order. Shorter travel is less time off the part and fewer chances to string.