Fix: skip pockets crossing sandbox boundary
profile_assembly.py now checks each pocket's polyline against the plate boundary using Shapely contains(). Pockets extending outside are dropped. Sandbox 1: 1 pocket removed (was crossing corner near x=150, y=-20).
This commit is contained in:
@@ -88,13 +88,26 @@ def profile_to_json(ribbed_plate, pockets, geometry, params):
|
||||
else:
|
||||
outer = [list(p) for p in outer]
|
||||
|
||||
# Structured pocket data (lines + arcs)
|
||||
# Structured pocket data (lines + arcs) — only include pockets fully inside boundary
|
||||
plate = Polygon(outer)
|
||||
pocket_data = []
|
||||
skipped = 0
|
||||
for p in pockets:
|
||||
# Use polyline to check containment
|
||||
polyline = p.get('polyline', [])
|
||||
if polyline:
|
||||
pocket_poly = Polygon(polyline)
|
||||
if pocket_poly.is_valid and not pocket_poly.is_empty:
|
||||
if not plate.contains(pocket_poly):
|
||||
skipped += 1
|
||||
continue
|
||||
pocket_data.append({
|
||||
'lines': p['lines'],
|
||||
'arcs': p['arcs'],
|
||||
})
|
||||
if skipped > 0:
|
||||
import sys
|
||||
print(f"[profile_assembly] Skipped {skipped} pockets outside boundary", file=sys.stderr)
|
||||
|
||||
# Hole data for NX (circles)
|
||||
hole_data = []
|
||||
|
||||
Reference in New Issue
Block a user