feat(cadfs): 扩展重建引擎能力并固化代表性模型回归

- 扩展 CDSL engine 的 shell、sweep、loft、reference plane、pattern 等运行时能力,
  支持新的实体结果模式、双向拉伸、曲线扫掠、镜像/圆周阵列及相关 selector 解析。
- 完善 Build123d 适配层的拓扑快照、Compound/ShapeList 兼容处理和旋转曲面识别,
  兼容 Python 3.12 / 当前 Build123d 缺少 axis_of_rotation 的合法曲面场景。
- 扩展 CDSL schema、profile schema、capability analysis、semantic validation 和
  sketch solver,使新增建模操作能够被校验、执行并保留可诊断的部分结果。
- 完善 CADFS FeatureScript lowering:
  支持 shell、sweep、surface/实体 loft、圆周阵列副本、镜像副本、删除阵列实例、
  新 body 操作、更多拉伸终止条件和 reference plane 变体。
- 补齐椭圆、B-spline、环形区域、imprint、SWEPT_FACE、CAP_FACE、OFFSET_FACE 等
  草图和拓扑引用的转换逻辑,改善后续特征的工作平面、轴线和 profile 定位精度。
- 改进 selector binding:支持 pattern 前缀复合 B-rep 快照、交集顶点引用、
  多面 match_mode=all、圆柱轴线/半径和面积下限等稳定匹配条件。
- 修复 MID_PLANE 法向统一后交线方向未同步的问题,恢复 00287955 基准面的正确位置;
  修复 00542223 sweep 路径反转后的切线契约和 00423838 的拓扑面数不稳定测试假设。
- 修正 CADFS 比较模块 import 路径,补充重建报告、批量重建脚本、目标文档和 README。
- 新增并扩展 engine、lowering、parser、selector binding、reports、integration 和
  Onshape pipeline 回归测试,覆盖代表性 CADFS 特征链及运行时兼容性。
This commit is contained in:
2026-09-08 11:47:10 +08:00
parent e7dc521ece
commit 738934416e
28 changed files with 5532 additions and 339 deletions
+30 -7
View File
@@ -63,21 +63,44 @@ class Parser:
return left
def statements(self) -> list[Call]:
found: list[Call] = []; environment: dict[str, Any] = {}
found: list[Call] = []; scopes: list[dict[str, Any]] = [{}]
def environment() -> dict[str, Any]:
resolved: dict[str, Any] = {}
for scope in scopes: resolved.update(scope)
return resolved
def assignment_scope(name: str) -> dict[str, Any]:
return next((scope for scope in reversed(scopes) if name in scope), scopes[-1])
while self.peek().kind != "eof":
if self.accept("{"):
scopes.append({}); continue
if self.accept("}"):
if len(scopes) > 1: scopes.pop()
continue
if self.peek().value == "var":
self.pop()
if self.peek().kind == "ident":
name = self.pop().value
if self.accept("="):
scopes[-1][name] = _resolve(self.expression(), environment())
else: scopes[-1][name] = name
if isinstance(scopes[-1][name], Call) and scopes[-1][name].name == "newSketch":
found.append(scopes[-1][name])
continue
if self.peek().kind == "ident" and self.i + 1 < len(self.tokens) and self.tokens[self.i + 1].value == "=":
name = self.pop().value; self.pop()
try:
environment[name] = self.expression()
if isinstance(environment[name], Call) and environment[name].name == "newSketch":
value = environment[name]
value.args = [_resolve(arg, environment) for arg in value.args]
scope = assignment_scope(name); scope[name] = _resolve(self.expression(), environment())
if isinstance(scope[name], Call) and scope[name].name == "newSketch":
value = scope[name]
found.append(value)
except Exception: pass
elif self.peek().kind == "ident" and self.i + 1 < len(self.tokens) and self.tokens[self.i + 1].value == "(":
value = self.expression()
if isinstance(value, Call):
value.args = [_resolve(arg, environment) for arg in value.args]
value.args = [_resolve(arg, environment()) for arg in value.args]
found.append(value)
else: self.i += 1
return found
@@ -119,7 +142,7 @@ def parse_featurescript(source: str, sample_id: str = "unknown") -> ModelIR:
if model.sketches:
args = _arg_map(call); eid = str(call.args[1]) if len(call.args) > 1 else f"E{len(model.sketches[-1].entities)}"
model.sketches[-1].entities.append(FeatureIR(eid, call.name, args, line_start=call.line, raw_source=call.name))
elif call.name in {"extrude", "revolve", "fillet", "chamfer", "hole", "linearPattern", "mirror", "cPlane", "referenceAxis", "shell", "loft", "sweep", "circularPattern", "booleanBodies", "transform"}:
elif call.name in {"extrude", "revolve", "fillet", "chamfer", "hole", "linearPattern", "mirror", "cPlane", "referenceAxis", "shell", "loft", "sweep", "circularPattern", "booleanBodies", "deleteBodies", "transform", "draft", "thicken", "split", "moveFace", "replaceFace", "deleteFace", "derive"}:
fid = symbolic_string(call.args[1]) if len(call.args) > 1 else f"feature_{len(model.features)}"
feature_ir = FeatureIR(fid, call.name, _arg_map(call), line_start=call.line, raw_source=call.name)
model.features.append(feature_ir); model.steps.append(feature_ir)