Cura icon indicating copy to clipboard operation
Cura copied to clipboard

Slicing optimization idea to consider

Open dgnuff opened this issue 1 year ago • 0 comments

Is your feature request related to a problem?

This is not specifically related to a problem, it's a suggestion for an idea to try during slicing, to see if it can trim anything from the final model print time.

Describe the solution you'd like

First, let me note down some thoughts on the issue I'm looking at. During slicing, movement of the head is split into two types. Firstly there is movement while extruding, and secondly movement with the filament retracted to get to the next extrusion point. The first of these obviously can't be optimized, but the second can. However, optimizing that section of head movement is a variation on the classic "Traveling salesman" problem, and therefore finding the absolute best solution is NP complete, i.e. it will require exponential time, based on the size of the problem. Therefore the best that can be done is to use a simpler solution, and accept that it won't be perfect. This is what I believe that Cura currently does. I also recognize that when printing a layer, it's broken into multiple groups, and each group is completely printed before the next starts. By observation, it appears that it's "support first, then walls/skin of the model, and lastly infill. Even if my optimization were applied, that ordering should still remain. The optimization itself is fairly simple. Again, this description is just by observation, but I think that currently, Cura keeps a list of candidate unprinted sections within the current group, and selects the section that can be reached with the minimum head travel distance, checking both ends of each segment, and choosing the one with the smallest travel distance. My suggestion is to change that slightly, and rather than considering the distance to each end of a segment in isolation, only compute one distance which is the sum of the distances to both ends of each candidate segment. What is the specific problem I'm trying to solve with this change? I have observed this several times when printing a model that is a flat surface, with a number of small "drill holes" through it. When printing the wall, it will go to a region where there are several holes in close proximity, print some of them, but before printing all of them, it will instead select a long section of the outer wall, and move elsewhere in the model. It then has to backtrack later to print the outline of the drill holes that were missed earlier. The intention of this optimization is to make the selection process favor candidate segments that keep the head in the same area of the model, thus allowing it to finish all the drill holes in an area before moving elsewhere.

Describe alternatives you've considered

One alternative I considered is instead of taking the sum of the two distances to the two endpoints, the product is used. That has the advantage of slightly heavier favoring of segments that are close by, but it has a hidden risk. During the printing of infill, there will be cases where there are two or more candidate printable segments all of which have one end at the current head location. In a situation like that, the sum will allow those specific segments to be ordered correctly, while the product will assign all of them a value of zero and without some special case logic it will be unable to choose the best of those segments.

Affected users and/or printers

All users of Cura

Additional information & file uploads

No response

dgnuff avatar Feb 19 '24 04:02 dgnuff