fix: clip pockets and triangulation to boundary in plots — no visual crossovers
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user