Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite perimeter fuzzification functions to properly follow perimeter shape #13593

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jarno-de-Wit
Copy link

The previous implementation of the fuzzy_polygon (classic perimeter generator) and fuzzy_extrusion_line (Arachne perimeter generator) did not work well at larger values for Fuzzy skin point distance. At higher values, the generator would start cutting corners, and overshooting at corners leading to incorrect overhangs being generated. The latter of these issues was reported in #7744.

This PR is a complete rewrite of the fuzzification algorithm to work well with both small and large values for Fuzzy skin point distance. The table below shows a comparison between the old and new fuzzy skin generation algorithm between the old fuzzification algorithm (left), and the new fuzzification algorithm (right) at various Fuzzy skin point distance values. (Note: the top infill has been hidden to better show the difference between the algorithms.)

Fuzzy skin point distance Old fuzzification algorithm New fuzzification algorithm
0.8 mm Old_0 8 New_0 8
2.0 mm Old_2 0 New_2 0
5.0 mm Old_5 0 New_5 0
50.0 mm Old_50 0 New_50 0
5.0 mm (Top down view) Old_5 0_top New_5 0_top

A brief summary of how the new algorithm works:

while not at the end:
    choose new segment length
    for each original corner point on this segment:
        place this corner point at the appropriate offset (magnitude determined using linear interpolation over current segment)
    place the end point of the segment

Since a new point is placed at x-locations where a corner point existed in the original line, the corner cutting that was visible in the original algorithm is avoided.
By cleverly picking the lengths of each of the segments (i.e. taking into account the remaining perimeter length), the outline can be closed with every segment length being in the acceptable range, thus not suffering from the overshoot present in the original algorithm

@Jarno-de-Wit Jarno-de-Wit changed the title Rewrite perimeter fuzzification functions Rewrite perimeter fuzzification functions to properly follow perimeter shape Nov 15, 2024
@Jarno-de-Wit
Copy link
Author

While the 2.9 update fixed the overshoot issue in the Fuzzy Skin generator, in doing so a new problem was introduced where the external fuzzy perimeter would be stopped too early. This leads to the perimeter not always being properly closed, and in extreme cases even being completely missing in case the Fuzzy skin point distance is set larger than the perimeter's length. Additionally, the corner cutting behaviour that existed in 2.8.1 (and is visible in the screenshots above) still exists in 2.9.0-alpha1. Both of these issues are fixed in the new fuzzification functions implemented in this PR.

As the fuzzy skin generation code was moved to a different file in 2.9.0-alpha1, I have updated the linked branch of this PR (fuzzy-skin-fix) to be up to date with the public master branch again.

@Jarno-de-Wit
Copy link
Author

Another side by side to highlight the improvements of the new / fixed algorithm over the one currently in 2.9.0-alpha1. The shape is the same as the one used above. In the first two rows, a cylindrical modifier is added at one of the corners which has a different point distance from the main shape. This causes the perimeter to no longer consist of closed loops for the bottom half of the shape, triggering some of the issues mentioned above (i.e. too short perimeter extrusion).

Notes:

  • In the first row, the shape is not properly closed near the seams. The corner cutting of the old algorithm is also visible.
  • In the second row, it can be seen how for short perimeters, the fuzzification isn't always applied. This might be related to the check in the original to ensure the length >= 3. This check is not needed anymore, especially now that singular line segments can be fuzzy instead of full perimeters only, thus this check is not present in the new / fixed fuzzification function.
  • In the third row, it can be seen that certain perimeters are completely absent in case the point distance is set too large.
Scenario 2.9.0-alpha1 algorithm New fuzzification algorithm
Point distance: 10 mm - Modifier point distance: 1 mm V2 9-Seams New-Seams
Point distance: 10 mm - Modifier point distance: 15 mm V2 9-Short New-Short
Point distance: 75 mm - No modifier V2 9-75 0 New-75 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant