feat: 增强一级关系识别与保持关系策略

This commit is contained in:
2026-08-10 14:56:50 +08:00
parent 12250603dd
commit 83c44265ba
24 changed files with 3460 additions and 241 deletions
+57
View File
@@ -25,10 +25,14 @@ from verify_edge_round_chamfer import (
_cylindrical_faces_near_radius,
_first_adjacent_reference_face,
_first_editable_line_edge,
_first_existing_chamfer_face,
_first_existing_fillet_face,
_verify_chamfer_topology,
_write_box_model,
_write_chamfered_box_model,
_write_chained_filleted_box_model,
_write_filleted_box_model,
_existing_chamfer_faces_near_distance,
)
from verify_ellipse_edge_resize import _ellipse_edge_ids, _write_ellipse_face_model
from verify_hole_resize import (
@@ -267,6 +271,57 @@ def _verify_existing_fillet_isolated(temp_dir: Path) -> None:
print(f"isolated existing fillet ok: face={face_id}, matches={matches[:3]}")
def _verify_existing_fillet_chain_isolated(temp_dir: Path) -> None:
input_path = temp_dir / "existing_fillet_chain.step"
output_path = temp_dir / "existing_fillet_chain_out.step"
request_path = temp_dir / "existing_fillet_chain_request.json"
source_radius = 1.0
target_radius = 1.5
_write_chained_filleted_box_model(input_path, source_radius)
model = StepModel.load(input_path)
face_id = _first_existing_fillet_face(model, source_radius, 2e-4)
feature = model.feature_info(face_id)
chain_face_ids = tuple(feature.get("feature_existing_fillet_chain_face_ids") or ())
if len(chain_face_ids) < 2:
raise SystemExit(f"isolated existing fillet chain source did not expose a chain: {feature}")
_write_request(request_path, input_path, output_path, "resize_existing_fillet", [face_id, target_radius])
response = _run_worker(request_path)
result_model = _load_worker_output(output_path, response)
matches = _cylindrical_faces_near_radius(result_model, target_radius, 2e-4)
old_matches = _cylindrical_faces_near_radius(result_model, source_radius, 2e-4)
if len(matches) < len(chain_face_ids) or old_matches:
raise SystemExit(
"isolated existing fillet chain failed: "
f"matches={matches}, old_matches={old_matches}, chain={chain_face_ids}, response={response}"
)
_assert_one_solid(result_model, "isolated existing fillet chain")
print(f"isolated existing fillet chain ok: face={face_id}, chain={chain_face_ids}, matches={matches[:4]}")
def _verify_existing_chamfer_isolated(temp_dir: Path) -> None:
input_path = temp_dir / "existing_chamfer.step"
output_path = temp_dir / "existing_chamfer_out.step"
request_path = temp_dir / "existing_chamfer_request.json"
source_distance = 1.5
target_distance = 2.0
_write_chamfered_box_model(input_path, source_distance)
model = StepModel.load(input_path)
face_id = _first_existing_chamfer_face(model, source_distance, 2e-4)
_write_request(request_path, input_path, output_path, "resize_existing_chamfer", [face_id, target_distance])
response = _run_worker(request_path)
result_model = _load_worker_output(output_path, response)
matches = _existing_chamfer_faces_near_distance(result_model, target_distance, target_distance * 0.03)
old_matches = _existing_chamfer_faces_near_distance(result_model, source_distance, source_distance * 0.02)
if not matches or old_matches:
raise SystemExit(
f"isolated existing chamfer failed: matches={matches}, old_matches={old_matches}, response={response}"
)
_assert_one_solid(result_model, "isolated existing chamfer")
print(f"isolated existing chamfer ok: face={face_id}, matches={matches[:3]}")
def main() -> int:
with tempfile.TemporaryDirectory(prefix="geom_param_edge_isolated_") as temp:
temp_dir = Path(temp)
@@ -278,6 +333,8 @@ def main() -> int:
_verify_edge_fillet_isolated(temp_dir)
_verify_edge_chamfers_isolated(temp_dir)
_verify_existing_fillet_isolated(temp_dir)
_verify_existing_fillet_chain_isolated(temp_dir)
_verify_existing_chamfer_isolated(temp_dir)
print("Edge isolated edit suite passed.")
return 0