feat: 完善 Face 一级关系编辑和稳定性校验

This commit is contained in:
2026-08-04 18:15:29 +08:00
parent 5799d5d813
commit a76282d7dd
28 changed files with 6872 additions and 270 deletions
@@ -51,6 +51,36 @@ def _assert_push_pull_keeps_single_solid(path: Path, distance: float) -> str:
stats = model.stats()
if stats.solids != 1:
raise SystemExit(f"holed planar Face push/pull should keep one solid: {stats}")
if "inner_wires=" not in result:
raise SystemExit(f"holed planar Face push/pull should report inner-wire verification: {result}")
target_position = plan.get("target_plane_position")
direction = plan.get("plane_direction") or plan.get("outward_direction")
if not isinstance(target_position, (int, float)) or not isinstance(direction, tuple) or len(direction) != 3:
raise SystemExit(f"holed planar Face push/pull plan should expose a target plane position: {plan}")
best: tuple[float, int, dict[str, object]] | None = None
for candidate_id in range(len(model.faces)):
info = model.face_info(candidate_id)
if info.get("surface") != "plane":
continue
origin = info.get("plane_origin")
if not isinstance(origin, tuple) or len(origin) != 3:
continue
actual_position = (
float(origin[0]) * float(direction[0])
+ float(origin[1]) * float(direction[1])
+ float(origin[2]) * float(direction[2])
)
error = abs(actual_position - float(target_position))
if best is None or error < best[0]:
best = (error, candidate_id, info)
if best is None:
raise SystemExit("holed planar Face push/pull should leave a measurable target plane")
_error, matched_face_id, matched_info = best
if int(matched_info.get("inner_boundary_wires") or 0) < 1:
raise SystemExit(
"holed planar Face push/pull should preserve the target Face inner boundary: "
f"matched_face={matched_face_id}, info={matched_info}, result={result}"
)
return result