Skip to content

Improve ExtrusionLine::simplify, eliminating many very-short extrusion segments which led to blemishes in thin-wall models sliced with arachne#11811

Open
sethml wants to merge 9 commits intoprusa3d:masterfrom
sethml:bugfix/simplify
Open

Improve ExtrusionLine::simplify, eliminating many very-short extrusion segments which led to blemishes in thin-wall models sliced with arachne#11811
sethml wants to merge 9 commits intoprusa3d:masterfrom
sethml:bugfix/simplify

Conversation

@sethml
Copy link
Contributor

@sethml sethml commented Dec 1, 2023

This change makes ExtrusionLine::simplify() able to remove more very-short segments, which arachne seems to tend to produce frequently on thin-walled models with curvature. Interestingly, Cura does not seem to have this problem. From what I can see, when Arachne was ported over from Cura, a significant amount of logic was added to polyline simplification, but some of that logic was flawed. In particular, the simplification code in Cura seems to be in PolygonRef::simplify(), but during porting logic was added to avoid removing a point prior to a long segment and instead replace the two prior points with the intersection of the prior and next segments, but only if that intersection does not move the points too much. Unfortunately that test compared the intersection to the point at the other end of the long segment, thus the length test would always fail and the point would never be removed.

I made the following changes:

  • When considering replacing two points with the intersection of the adjoining segments, test the distance between the intersection and the two points prev and current, rather than prev and next. This change removes most extrusion blemishes around the perimeter.
  • For a closed polygon, allow removing the first/last point (which are the same). This can remove a single extrusion blemish per perimeter. In order to do so, we consider removing the last point, and pull the next and next_next points from the second and third points of the newly-filtered path.

While working with this code I noticed a few potential issues/future improvements:

  • As points are removed or replaced, their width is not updated. In most cases this probably results in negligible errors. However, I could imagine that if a point is removed between two nearly-collinear long segments and the segments have different widths, significant error could be introduced. Consider either not merging segments with significant width differences, and/or updating widths with a length-weighted average when merging segments.
  • Why is arachne generating so many nearly-zero-length segments in the first place? Consider changing it to no longer do so. Given that the nearly-zero-length segments seem to have a slightly different width than neighboring segments, I suspect that whatever heuristics arachne uses to determine width are generating these.
  • The logic is pretty complex and challenging to reason about. Perhaps going back to simpler simplification logic such as Cura uses would produce more consistent results.

I believe this fixes #11807. Here's a photo of the model from that issue with this change:
PXL_20231201_052558340

I think it probably also fixes #11573. I'll do a test in a moment.

@mfish38
Copy link

mfish38 commented Dec 16, 2023

I just did a test print using the dev build of OrcaSlicer/OrcaSlicer#3014 and can confirm that this change fixes #11573.

Downstream code contains assumptions that closed ExtrusionLines are not
degenerate. Open ExtrusionLines already are not reduced below 2 points by
ExtrusionLine::simplify().

Change copied from:
OrcaSlicer/OrcaSlicer@aa3cdc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thin walls with arachne have tiny moves causing blemishes Garbage G-Code segments causing printing artifacts

3 participants