feat: 完善 Face 一级编辑与隔离计算

This commit is contained in:
2026-08-05 15:08:16 +08:00
parent a76282d7dd
commit ed1faf51d8
28 changed files with 3740 additions and 876 deletions
+80
View File
@@ -8,6 +8,19 @@ from pathlib import Path
from .model import StepModel
def _optional_int(value: object) -> int | None:
if value is None or value == "":
return None
return int(value)
def _point3(value: object, operation: str) -> tuple[float, float, float]:
point = list(value) if isinstance(value, (list, tuple)) else []
if len(point) != 3:
raise ValueError(f"{operation} requires a 3D target center.")
return (float(point[0]), float(point[1]), float(point[2]))
def _execute(model: StepModel, operation: str, args: list[object]) -> str:
if operation == "push_pull_face":
return model.push_pull_face(int(args[0]), float(args[1]))
@@ -47,6 +60,73 @@ def _execute(model: StepModel, operation: str, args: list[object]) -> str:
return model.resize_spherical_radius(int(args[0]), float(args[1]))
if operation == "resize_torus_radius":
return model.resize_toroidal_radius(int(args[0]), float(args[1]), str(args[2]))
if operation == "resize_cylindrical_hole":
return model.resize_cylindrical_hole(int(args[0]), float(args[1]))
if operation == "resize_cylindrical_owning_scale":
return model.resize_cylindrical_owning_scale(int(args[0]), float(args[1]))
if operation == "move_cylindrical_hole_axis":
return model.move_cylindrical_hole_axis(int(args[0]), _point3(args[1], operation))
if operation == "suppress_cylindrical_hole":
return model.suppress_cylindrical_hole(int(args[0]))
if operation == "resize_cylindrical_depth":
bottom_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_depth(int(args[0]), float(args[1]), bottom_face_id=bottom_face_id)
if operation == "resize_cylindrical_depth_owning_scale":
bottom_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_depth_owning_scale(int(args[0]), float(args[1]), bottom_face_id=bottom_face_id)
if operation == "move_cylindrical_slot_axis":
return model.move_cylindrical_slot_axis(int(args[0]), _point3(args[1], operation))
if operation == "resize_cylindrical_slot_width":
pair_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_slot_width(int(args[0]), float(args[1]), pair_face_id=pair_face_id)
if operation == "resize_cylindrical_slot_depth":
pair_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_slot_depth(int(args[0]), float(args[1]), pair_face_id=pair_face_id)
if operation == "resize_cylindrical_slot_arc_length":
pair_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_slot_arc_length(int(args[0]), float(args[1]), pair_face_id=pair_face_id)
if operation == "resize_cylindrical_slot_angular_span":
return model.resize_cylindrical_slot_angular_span(int(args[0]), float(args[1]))
if operation == "resize_cylindrical_slot_total_length":
pair_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_slot_total_length(int(args[0]), float(args[1]), pair_face_id=pair_face_id)
if operation == "resize_cylindrical_slot_center_distance":
pair_face_id = _optional_int(args[2]) if len(args) > 2 else None
return model.resize_cylindrical_slot_center_distance(
int(args[0]),
float(args[1]),
pair_face_id=pair_face_id,
)
if operation == "resize_general_edge_length":
anchor_mode = str(args[2]) if len(args) > 2 else "auto"
strategy_mode = str(args[3]) if len(args) > 3 else "auto"
return model.resize_general_edge_length(
int(args[0]),
float(args[1]),
anchor_mode=anchor_mode,
strategy_mode=strategy_mode,
)
if operation == "move_edge_endpoint":
return model.move_edge_endpoint(int(args[0]), str(args[1]), _point3(args[2], operation))
if operation == "move_edge_center":
return model.move_edge_center(int(args[0]), _point3(args[1], operation))
if operation == "move_circular_edge_axis_center":
return model.move_circular_edge_axis_center(int(args[0]), _point3(args[1], operation))
if operation == "resize_ellipse_edge_axis_radius":
axis_kind = str(args[2]) if len(args) > 2 else "major"
return model.resize_ellipse_edge_axis_radius(int(args[0]), float(args[1]), axis_kind=axis_kind)
if operation == "resize_existing_fillet":
return model.resize_existing_fillet(int(args[0]), float(args[1]))
if operation == "fillet_edge":
return model.fillet_edge(int(args[0]), float(args[1]))
if operation == "chamfer_edge":
return model.chamfer_edge(int(args[0]), float(args[1]))
if operation == "chamfer_edge_asymmetric":
reference_face_id = _optional_int(args[3]) if len(args) > 3 else None
return model.chamfer_edge_asymmetric(int(args[0]), float(args[1]), float(args[2]), reference_face_id)
if operation == "chamfer_edge_distance_angle":
reference_face_id = _optional_int(args[3]) if len(args) > 3 else None
return model.chamfer_edge_distance_angle(int(args[0]), float(args[1]), float(args[2]), reference_face_id)
raise ValueError(f"Unsupported isolated edit operation: {operation}")