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
@@ -220,12 +220,65 @@ def _verify_missing_first_level_neighbor_blocks_plan() -> None:
)
def _verify_result_check_rejects_degraded_first_level_topology() -> None:
with tempfile.TemporaryDirectory(prefix="geom_param_cyl_topology_result_guard_") as temp_dir:
model_path = Path(temp_dir) / "through_hole.step"
_write_through_hole_model(model_path)
model = StepModel.load(model_path)
face_id = _first_hole_face(model, blind=False)
plan = model.cylindrical_resize_plan(face_id, 8.0)
healthy = model._attach_cylindrical_first_level_result_check( # noqa: SLF001
{"matched": True, "face_id": face_id},
plan,
)
_assert(
healthy.get("first_level_topology_matched") is True,
f"healthy result topology should pass: {healthy}",
)
minimums = dict(healthy.get("first_level_topology_minimums") or {})
_assert(
int(minimums.get("adjacent_face_count", 0) or 0) >= 2,
f"through-hole result guard should derive a direct-neighbor minimum: {healthy}",
)
original_topology = model.cylindrical_feature_first_level_topology
def degraded_topology(target_face_id: int) -> dict[str, object]:
topology = dict(original_topology(target_face_id))
topology["cylindrical_feature_adjacent_face_ids"] = tuple(
tuple(topology.get("cylindrical_feature_adjacent_face_ids", ()) or ())[:1]
)
topology["cylindrical_feature_adjacent_face_count"] = 1
return topology
model.cylindrical_feature_first_level_topology = degraded_topology # type: ignore[method-assign]
degraded = model._attach_cylindrical_first_level_result_check( # noqa: SLF001
{"matched": True, "face_id": face_id},
plan,
)
_assert(
degraded.get("matched") is False,
f"result topology with too few direct adjacent Faces should fail: {degraded}",
)
_assert(
degraded.get("first_level_topology_matched") is False,
f"degraded result should mark first-level topology mismatch: {degraded}",
)
detail = str(degraded.get("detail") or "")
_assert(
"first-level topology" in detail and "adjacent_face_count" in detail,
f"degraded result should explain the weaker first-level topology: {degraded}",
)
def main() -> int:
_verify_through_hole()
_verify_blind_hole()
_verify_half_round_slot()
_verify_obround_slot_length_plan()
_verify_missing_first_level_neighbor_blocks_plan()
_verify_result_check_rejects_degraded_first_level_topology()
print("cylindrical first-level topology verification passed")
return 0