feat(cadfs): 补齐核心建模能力并建立代表性回归

- 新增 loft、双向切除、through-all/up-to-next 等 CADFS lowering 与 engine 支持
- 支持多种 reference plane、B-spline profile 和 circular pattern replay
- 保留 transform 历史,并烘焙安全的单源平移/旋转变换
- 改进 selector 绑定、拓扑快照和 pattern 变换处理
- 建立 17 个代表样本的转换、重建与比较回归工具链
- 补充 schema、author guidance、运行时和几何回归测试
This commit is contained in:
2026-09-07 18:21:07 +08:00
parent 4ad890b7b4
commit 038d38ed98
31 changed files with 2498 additions and 85 deletions
+23 -2
View File
@@ -4,6 +4,7 @@ import argparse, json
from pathlib import Path
from .describe import describe_samples
from .pipeline import load_samples, run_stage, scan, select_samples
from .regression import regression_sample_ids, summarize_regression, write_regression_manifest
from .reports import generate_markdown_report, generate_reports, read_json
DEFAULT_INPUT = Path("data/cadfs-sample/CADFS_test")
@@ -13,11 +14,21 @@ DEFAULT_OUTPUT = Path("cadfs_to_cdsl/output")
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Convert CADFS FeatureScript to CDSL and validate against STEP")
commands = parser.add_subparsers(dest="command", required=True)
for name in ("scan", "convert", "rebuild", "compare", "report", "pipeline", "describe"):
for name in ("scan", "convert", "rebuild", "compare", "report", "pipeline", "describe", "regression-select", "regression"):
command = commands.add_parser(name)
command.add_argument("--input", type=Path, default=DEFAULT_INPUT)
command.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
if name == "describe":
if name == "regression-select":
command.add_argument("--manifest", type=Path, default=Path("cadfs_to_cdsl/regression/manifest.json"))
elif name == "regression":
command.add_argument("--manifest", type=Path, default=Path("cadfs_to_cdsl/regression/manifest.json"))
command.add_argument("--tier", choices=("engine", "conversion", "all"), default="engine")
command.add_argument("--stage", choices=("convert", "rebuild", "compare", "pipeline"), default="rebuild")
command.add_argument("--workers", type=int, default=1)
command.add_argument("--compare-mode", choices=("rp", "strict"), default="rp")
command.add_argument("--timeout-seconds", type=float, default=30.0, help="per-model OCC timeout (default: 30)")
command.add_argument("--resume", action="store_true", help="reuse cached per-sample stage results instead of rerunning them")
elif name == "describe":
command.add_argument("--shard", help="input shard directory to describe, for example 0005")
command.add_argument("--sample-id", action="append")
command.add_argument("--offset", type=int, default=0)
@@ -46,6 +57,16 @@ def main(argv: list[str] | None = None) -> int:
args.output.mkdir(parents=True, exist_ok=True)
if args.command == "scan":
records = scan(args.input, args.output); result = {"sample_count": len(records), "output": str(args.output / "dataset_index.json")}
elif args.command == "regression-select":
manifest = write_regression_manifest(args.output, args.manifest)
result = {"manifest": str(args.manifest), "selected_sample_count": manifest["selected_sample_count"], "engine_sample_count": manifest["engine_sample_count"]}
elif args.command == "regression":
if not 1 <= args.workers <= 8: raise ValueError("--workers must be between 1 and 8")
if args.timeout_seconds <= 0: raise ValueError("--timeout-seconds must be positive")
sample_ids = regression_sample_ids(args.manifest, args.tier)
samples = select_samples(load_samples(args.input, args.output), sample_ids=sample_ids)
records = run_stage(args.stage, samples, args.output, force=not args.resume, compare_mode=args.compare_mode, timeout_seconds=args.timeout_seconds, workers=args.workers)
result = {"tier": args.tier, "stage": args.stage, "manifest": str(args.manifest), **summarize_regression(records)}
elif args.command == "describe":
records, result = describe_samples(
args.input,