fix: clip pockets and triangulation to boundary in plots — no visual crossovers

This commit is contained in:
2026-02-17 12:42:52 +00:00
parent 39a3420a8e
commit 732e41ec3a
2 changed files with 72 additions and 5 deletions

View File

@@ -224,8 +224,20 @@ def generate_triangulation(geometry, params, max_refinement_passes=3):
cx = np.mean(all_pts[t, 0])
cy = np.mean(all_pts[t, 1])
centroid = Point(cx, cy)
# Keep if centroid is inside plate frame and outside keepouts
if inner_plate.contains(centroid) and not keepout_union.contains(centroid):
# Keep if centroid is inside plate frame and outside keepouts,
# AND all 3 vertices are inside the plate boundary (no crossovers)
if not inner_plate.contains(centroid):
continue
if keepout_union.contains(centroid):
continue
all_inside = True
for vi in t:
if not plate_poly.contains(Point(all_pts[vi])):
# Allow small tolerance (vertex on boundary is OK)
if not plate_poly.buffer(0.5).contains(Point(all_pts[vi])):
all_inside = False
break
if all_inside:
keep.append(i)
triangles = triangles[keep] if keep else np.empty((0, 3), dtype=int)