Open logiclrd opened 3 years ago
In general this is very hard to solve, even when long travel moves are allowed. Getting the optimal order in which to print these lines is an extension of the Traveling Salesman problem for which there is no known polynomial-time algorithm (and an exponential-time algorithm would take too long to compute). So we have to use a heuristic. Currently the heuristic for skin is as follows:
It seems that for the raft, the first part is not implemented. It is implemented for the skin to prevent a long travel move that creates a scar on the surface. It was never considered a problem since the raft doesn't need to be pretty. For the sake of improving adhesion, we can consider implementing that.
Thanks for the detailed response. Yes, I can see that finding a truly optimal path is a trickier problem, though for most models (yes, there are pathological cases), the total number of different segments is such that an exhaustive search of different orders could be completed in microseconds. But, it isn't the order of separate sections that was concerning me, but the fact that it splits single contiguous segments unnecessarily -- and, in practice it appears that travel with early raft layers often causes minor collisions with the print head because the raft line is so thick it rises up higher than the bottom of the nozzle, so if you have to travel, then fine, but if it's completely unnecessary, it feels like it actually has the potential to negatively impact or maybe even fail a print (though I haven't in practice observed this).
Yes, I can see that finding a truly optimal path is a trickier problem, though for most models (yes, there are pathological cases), the total number of different segments is such that an exhaustive search of different orders could be completed in microseconds.
Well, be careful with that. Your own model seems to have about 6 line segments per cm in the X direction from your screenshot, and is about 24cm long in the X direction, which would result in 144 lines, each of which can be printed in two directions. There are about 1.24*10^293 ways in which to print 144 lines. If every atom in the universe would calculate the travel lengths of 1 million of these options every microsecond, it would take about 6.5*10^193 years to slice a single layer. Those thought experiments are fun :P
But indeed, it appears to split a single contiguous segment here. Although of course in some cases you're going to need to have a split, like when printing something in the shape of an X. But at least one of these splits can be prevented, which is what we're doing with the skin like I explained before. We could apply that to the raft lines too, and I think that's what you're looking for.
Application version 4.7.1
Platform Windows x64
Printer Custom build
Reproduction steps
The resulting G code draws a perimeter around the first layer, and then almost always, in my experience, starts drawing the raft's lines partway into the first layer, so that when it reaches the far side of the model it has to return to the start.
Obviously many models will require travel to take place, because some places have multiple different lines at the same X value (assuming the first layer is angled perpendicular to X axis). Travel cannot in general be avoided. But, sometimes really unnecessary travel is generated, which is slow and results in the head dragging across all of the raft lines printed so far.
Screenshot(s) (Image showing the problem, perhaps before/after images.)![image](https://user-images.githubusercontent.com/2349379/96569709-15c83e00-128f-11eb-8fca-aa6962dac4b7.png)
The part highlighted in red requires the head to travel all the way back along the model to complete the printing of the first raft layer.
Actual results In some cases extreme amounts of unnecessary travel when printing the raft, because the surface is split unnecessarily into two parts, each of which prints from the middle outward.
Expected results In simple cases, these are not split and print consecutively. This takes less time and avoids travel where the print head may actually collide with each already-printed line of the raft (since the raft is compensating for bed imperfections and has an extremely high flow rate, the lines can end up higher than the nozzle).