Closed majroy closed 3 months ago
@leoxiaoyuan Your function for detecting this condition doesn't correctly identify the issue:
def is_self_intersecting(contour_points):
"""
Check if a given contour is self-intersecting.
Params:
contour_points: list of tuples representing (x, y) points.
Returns:
bool: True if the contour is self-intersecting
"""
line = LineString(contour_points[:-1])
return not line.is_simple
The function returns False for all slices. Changing the LineString definition to line = LineString(contour_points)
, it does start to discriminate; for the slice in question, it returns True, but so does slice 11 and 24 which don't have any observable self-intersections. It also returns true for other slices that do have very subtle self-intersections. Holding the issue open, remedies are to use the alpha shape outline mod; I am retaining the function to flag to the user at the command line that there might be self-intersections.
Can not reproduce 'The function returns False for all slices'. At my end, slice 23 could be detected correctly and only that slice could be detected.
Solved with "ContourLoopExtractor" - see JavaScript implmentation here: https://kitware.github.io/vtk-js/examples/ContourLoopExtraction.html. Now rolled into *post2.
Version 0.3post2 now has removed the agglomerating filter to pick up 'sub slices'.
See below for issue seen on slice 23 of the Stanford Bunny when slicing with a 4 mm average height, will likely need an exception for self-intersecting outlines: