majroy / d3dslic3r

Slic3s and dic3s!
Other
0 stars 1 forks source link

Infill paths not correctly re-orienting with rotational offset on some outlines #5

Closed majroy closed 3 months ago

majroy commented 3 months ago

See issue here: image Confirmed that still occurs with 'Path outline' enabled, and on outlines that have been processed by an alpha shape, see settings above to replicate.

leoxiaoyuan commented 3 months ago

Tried to reproduce the issue while keeping generated paths not transformed back, found there were no intersections on the bottom contour.

Screenshot 2024-08-04 at 18 31 58

Tried to give yrange a larger range. (change yrange = [limits[2]1.2,limits[3]1.2] to yrange = [limits[2]1.2-100,limits[3]1.2+100]) Problem solved.

Screenshot 2024-08-04 at 18 37 25

Any reason why to choose this range? Is that OK to just give it a very big range?

majroy commented 3 months ago

Main issue attributed to simultaneous move to centroid and rotation for path calculation. A two-stage move, first to the centroid and then rotated by the target theta value seems to fix the main issue noted for most values of theta Leaving open as there is still a problem: image

leoxiaoyuan commented 3 months ago
Screenshot 2024-08-05 at 09 32 48

Problem location: As shown in the figure, the intersection points of that line are marked with "o", the starting points of that contour is marked with 🌟. Because the starting point f the contour is in the middle, which would cause problem of the intersection points order. Therefore, if the 'pack up/pair intersections for line paths' is used, it will cause this problem.

Solution: reorder the contour to make sure the starting point always has the largest y value: X = do_transform(outline,trans)

Find the index of the point with the maximum y value

max_y_index = np.argmax(X[:, 1])
# Reorder the contour points to start from the point with the maximum y value
reordered_contour = np.concatenate((X[max_y_index:-1], X[:max_y_index]), axis=0)
# Add the starting point to the end to close the contour
X = np.vstack([reordered_contour, reordered_contour[0]])
Screenshot 2024-08-05 at 10 15 13
leoxiaoyuan commented 3 months ago

Previous method did not solve the problem indeed, it will cause: image

So, instead, reorder the intersection points directly with: intersections = intersections[np.lexsort((intersections[:, 1], intersections[:, 0]))]

image image

Seems working for both cases.