feat: 完善参数化编辑和孔修改稳定性

This commit is contained in:
2026-07-28 18:30:58 +08:00
parent 7c263d1e96
commit 720c2dc970
13 changed files with 2190 additions and 690 deletions
+16 -5
View File
@@ -197,7 +197,7 @@ def _shape_quality_info(label: str, shape: TopoDS_Shape, expect_solid: bool) ->
elif expect_solid and solids > 1:
warnings.append(
f"检测到 {solids} 个Solid。"
"如果这不是有意的多实体零件,导出后可能看起来像多个体叠在一起或彼此分离。"
"如果这不是有意的多实体特征,导出后可能看起来像多个体叠在一起或彼此分离。"
)
geometry_info = _shape_volume_info(shape)
@@ -560,7 +560,8 @@ def _axis_aligned_edge_candidates(
def _finalize_boolean_result(op, operation_name: str) -> TopoDS_Shape:
op.SetNonDestructive(True)
if hasattr(op, "SetGlue"):
use_glue = "cut" not in operation_name.lower()
if use_glue and hasattr(op, "SetGlue"):
try:
op.SetGlue(BOPAlgo_GlueFull)
except Exception:
@@ -764,7 +765,14 @@ def _cylinder_resize_readiness(
else:
diameter_delta = abs(new_diameter - current_diameter)
delta_ratio = diameter_delta / max(current_diameter, 1e-9)
if delta_ratio > 1.0:
if new_diameter > current_diameter * 2.0:
status = "blocked"
risk = "blocked"
blockers.append(
"目标直径超过当前直径的 2 倍;当前受限 B-Rep 孔径编辑会直接阻止这种极端放大,"
"否则很容易出现布尔返回成功但孔壁没有真正变成目标直径。"
)
elif delta_ratio > 1.0:
risk = _max_risk(risk, "high")
warnings.append("目标直径变化超过当前直径的 100%,很可能导致大范围误切或布尔失败。")
elif delta_ratio > 0.35:
@@ -772,8 +780,11 @@ def _cylinder_resize_readiness(
warnings.append("目标直径变化超过当前直径的 35%,请确认预览范围。")
if height_estimate > 0 and new_diameter > height_estimate * 2.0:
risk = _max_risk(risk, "high")
warnings.append("目标直径超过圆柱面估算高度的 2 倍,几何比例异常。")
status = "blocked"
risk = "blocked"
blockers.append(
"目标直径超过圆柱面估算高度的 2 倍;当前版本无法稳定判断周边材料余量,已阻止。"
)
elif height_estimate > 0 and new_diameter > height_estimate:
risk = _max_risk(risk, "medium")
warnings.append("目标直径超过圆柱面估算高度,可能不是常规孔径修改。")