﻿# Mechanical Diagnostic Tools Usage

鏈枃妗ｈ鏄?`tools` 鐩綍涓満姊拌璁℃煡閿欑浉鍏充唬鐮佺殑浣滅敤銆佹帹鑽愪娇鐢ㄦ祦绋嬨€佽緭鍏ヨ緭鍑哄拰褰撳墠閬楃暀杈圭晫銆?
## 鎬讳綋鐩爣

鏌ラ敊閮ㄥ垎鐨勭洰鏍囦笉鏄洿鎺ョ敤浠ｇ爜纭垽鎵€鏈夎璁￠敊璇紝鑰屾槸鎶?SolidWorks 妯″瀷杞崲鎴?AI 鍜岃鍒欑郴缁熷彲浣跨敤鐨勮瘉鎹寘锛?
```text
SolidWorks 妯″瀷
  -> B-rep/鎺ヨЕ/鐗瑰緛/鍥剧墖璇佹嵁鍖?  -> AI 鐢熸垚鏈烘璇箟鍥?  -> AI 鎷嗗垎灞€閮ㄨ涔夊崟鍏?  -> 妫€绱㈡満姊拌璁＄蹇岀煡璇嗗簱
  -> 鎸夎鍒欓獙璇?  -> 杈撳嚭 pass/problem/needs_review
```

褰撳墠鏈€閲嶈鐨勫師鍒欙細

- 瑁呴厤浣撹緭鍏ユ椂锛孊-rep 淇℃伅鍙粠瑁呴厤浣撲腑鎻愬彇銆?- 姣忎釜缁勪欢鐨?B-rep銆佺壒寰併€佹帴瑙﹀叧绯诲繀椤绘寜缁勪欢鍒嗗寘锛屼笉鑳芥贩鍦ㄤ竴璧枫€?- 闈炴爣浠剁殑鍥剧墖鍙互浠庨浂浠舵枃浠跺鍑猴紝浣嗗嚑浣曚簨瀹炰粛鐒朵娇鐢ㄨ閰嶄綋涓缁勪欢鐨?B-rep 瀛愰泦銆?- 瑁呴厤浣撳厛璇婃柇瑁呴厤绾ч棶棰橈紝鍐嶈瘖鏂潪鏍囦欢鐨勯浂浠惰璁￠棶棰樸€?- 鏍囧噯浠?澶栬喘浠跺彧浣滀负瑁呴厤涓婁笅鏂囷紝闄ら潪瑙勫垯鏈韩鏄爣鍑嗕欢閫夊瀷鎴栨牎鏍搞€?
## 鐩綍瑙掕壊

### `SectionBrepExtractor`

鏍稿績妯″瀷璇佹嵁鎻愬彇宸ュ叿銆?
涓昏浣滅敤锛?
- 鎵撳紑 `.SLDASM` 鎴?`.SLDPRT`銆?- 鎻愬彇 B-rep 闈€佸渾鏌遍潰銆佸钩闈€佸寘鍥寸洅銆佽酱绾裤€佹帴瑙﹀€欓€夈€侀厤鍚堥潰瑙掕壊绛夈€?- 瀵煎嚭鏍囧噯瑙嗗浘鍥剧墖锛氬墠銆佸悗銆佷笂銆佷笅銆佸乏銆佸彸銆佽酱娴嬨€?- 鏍规嵁 B-rep 淇℃伅瑙勫垝鍓栬鍥撅紝骞跺鍑哄墫闈㈠浘鐗囥€?- 杈撳嚭 `FeatureGraph`锛屾妸鍘熷闈㈠垵姝ョ粍鍚堟垚瀛旂粍銆佸渾鏌遍潰缁勩€佸钩闈?鍙伴樁鍊欓€夈€佽閰嶆帴瑙︾壒寰佺瓑銆?- 杈撳嚭 `SemanticFusionContract`锛岃瀹?AI 濡備綍鎶?B-rep 鍜屽浘鐗囪瀺鍚堟垚鏈烘璇箟銆?- 瀵硅閰嶄綋杈撳嚭 `AssemblyComponents`銆乣ComponentEvidencePackages`銆乣PartImagePlan`锛岀敤浜庨伩鍏嶇粍浠惰瘉鎹贩鏀俱€?
鎺ㄨ崘鍛戒护锛?
```powershell
dotnet run --project tools\model-diagnostics\SectionBrepExtractor\SectionBrepExtractor.csproj -c Release -- "D:\path\model.SLDASM" --output-dir runtime\section_brep\trial1 --export-images --export-section-images
```

涓昏杈撳嚭锛?
- `section_brep_report.json`
- `section_brep_report.md`
- `model_images\*.jpg`

涓嬫父璇婃柇搴斾紭鍏堣鍙?`section_brep_report.json`銆?
### `BrepFaultProbe`

鏌ラ敊娴佺▼璋冭瘯鍏ュ彛锛屼笉鏄渶缁堜骇鍝佸悗绔€?
涓昏浣滅敤锛?
- 璋冪敤 `SectionBrepExtractor` 鍋氭ā鍨嬭瘉鎹彁鍙栥€?- 鐢熸垚 B-rep/鍥剧墖鍒版満姊拌涔変箣闂寸殑妗ユ帴鍖呫€?- 杩愯绗?18 绔犱袱涓凡楠岃瘉瑙勫垯鐨勯樁娈垫€у疄楠屾祦绋嬨€?- 淇濈暀濂楃瓛鎷嗗嵏瑙勫垯鐨?legacy 鍥炲綊鏍蜂緥銆?
鍙敤鍛戒护锛?
```powershell
dotnet run --project tools\model-diagnostics\BrepFaultProbe\BrepFaultProbe.csproj -c Release -- model "D:\path\model.SLDASM"
dotnet run --project tools\model-diagnostics\BrepFaultProbe\BrepFaultProbe.csproj -c Release -- bridge "D:\path\model.SLDASM" runtime\brep_semantic_bridge\trial1 --no-ai
dotnet run --project tools\model-diagnostics\BrepFaultProbe\BrepFaultProbe.csproj -c Release -- diagnose-ch18 "D:\path\model.SLDASM" runtime\knowledge_diagnosis_ch18\trial1 --no-ai
```

淇濈暀浣嗕笉鎺ㄨ崘浣滀负姝ｅ紡涓绘祦绋嬬殑鍛戒护锛?
- `judge-local`
- `model-and-judge`

杩欎袱涓懡浠ゅ彧鐢ㄤ簬濂楃瓛鎷嗗嵏涓撻」瑙勫垯鐨勫巻鍙插洖褰掗獙璇併€?
宸插垹闄ょ殑鏃у叆鍙ｏ細

- `image`
- `judge`
- `suite`

杩欎簺鍏ュ彛鍘熸潵渚濊禆 `tmp` 涓嬬殑鏃у疄楠岄」鐩紝涓嶅啀灞炰簬姝ｅ紡宸ュ叿閾俱€?
### `RuleTemplateGenerator`

瑙勫垯妯℃澘鐢熸垚宸ュ叿銆?
涓昏浣滅敤锛?
- 闈㈠悜鈥滀粠鏁欐潗鍥剧墖/鏂囧瓧鐢熸垚瑙勫垯鍖呪€濈殑鏂瑰悜銆?- 瀹氫箟瑙勫垯鍖呯粨鏋勶細瑙﹀彂鏉′欢銆侀敊璇弿杩般€佸彲璇佹槑閫氳繃鐨勮瘉鎹€佸浘鐗囦晶缁撴瀯妯℃澘绛夈€?- 褰撳墠浠嶅亸瀹為獙鍜屾牱渚嬶紝鏈€鎴愮啛鐨勬槸濂楃瓛鎷嗗嵏鏍蜂緥銆?
绀轰緥鍛戒护锛?
```powershell
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- sample-sleeve runtime\rule_templates\tight_fit_sleeve_requires_disassembly_access.json
dotnet run --project tools\model-diagnostics\RuleTemplateGenerator\RuleTemplateGenerator.csproj -c Release -- validate runtime\rule_templates\tight_fit_sleeve_requires_disassembly_access.json
```

娉ㄦ剰锛?
- 瀹冧笉鎵撳紑 SolidWorks 妯″瀷銆?- 瀹冧笉鍒ゆ柇妯″瀷鏄惁鏈夐敊銆?- 鏈潵濡傛灉鎺ュ叆鐪熸鐨?AI 璇嗗浘鐢熸垚瑙勫垯锛屽簲杈撳嚭鍚屾牱鐨勮鍒欏寘缁撴瀯銆?
### `ModelDiagnosticVerifier`

瑙勫垯楠岃瘉鍣ㄣ€?
涓昏浣滅敤锛?
- 杈撳叆妯″瀷璇佹嵁鎴?SolidWorks 妯″瀷璺緞銆?- 杈撳叆瑙勫垯鍖呫€?- 璋冪敤妯″瀷璇佹嵁鎻愬彇宸ュ叿骞跺綊涓€鍖栬瘉鎹€?- 鏍规嵁瑙勫垯鍖呴獙璇佹ā鍨嬫槸鍚?`not_applicable`銆乣pass`銆乣problem` 鎴?`needs_review`銆?
绀轰緥鍛戒护锛?
```powershell
dotnet run --project tools\model-diagnostics\ModelDiagnosticVerifier\ModelDiagnosticVerifier.csproj -c Release -- verify --model "D:\path\assembly.SLDASM" --rules runtime\rule_templates\tight_fit_sleeve_requires_disassembly_access.json --out runtime\diagnostics\sleeve_check
```

褰撳墠瀹氫綅锛?
- 閫傚悎楠岃瘉缁撴瀯鍖栬鍒欏寘銆?- 杩樹笉鏄畬鏁寸殑鈥滅煡璇嗗簱妫€绱?+ 澶氳鍒欒瘖鏂€濆悗绔€?- 鏈€缁堝悗绔簲鍦ㄦ绱㈠埌鍊欓€夎鍒欏悗锛屽啀璋冪敤鎴栧鐢ㄨ繖閲岀殑楠岃瘉閫昏緫銆?
### `StructuralFaultProbe`

鏃╂湡缁撴瀯鏌ラ敊杈呭姪宸ュ叿銆?
涓昏浣滅敤锛?
- 鎻愬彇瑁呴厤浣撲腑鐨勮酱鍚戞帴瑙︺€佽酱鎵块檺浣嶃€佸浐瀹氫俊鎭瓑缁撴瀯浜嬪疄銆?- 鏃╂湡鐢ㄤ簬濂楃瓛銆佽酱鎵裤€佽酱鍚戝畾浣嶇浉鍏冲疄楠屻€?
褰撳墠鐘舵€侊細

- 鍙綔涓鸿ˉ鍏呰瘉鎹潵婧愩€?- 涓嶅缓璁綔涓烘柊娴佺▼涓诲叆鍙ｃ€?- agent3 鐗堟湰涓粛淇濈暀鏃ф牱渚嬮粯璁よ矾寰勶紝姝ｅ紡浣跨敤鏃跺簲鏄惧紡浼犲叆妯″瀷璺緞銆?
绀轰緥鍛戒护锛?
```powershell
dotnet run --project tools\model-diagnostics\StructuralFaultProbe\StructuralFaultProbe.csproj -c Release -- "D:\path\assembly.SLDASM"
```

## 鐭ヨ瘑搴撲綅缃?
鏈烘璁捐绂佸繉鐭ヨ瘑搴撲綅浜庯細

```text
鏈烘璁捐绂佸繉1000渚媉鐭ヨ瘑搴撴彁鍙?```

璇婃柇妫€绱富瑕佷娇鐢細

```text
鏈烘璁捐绂佸繉1000渚媉鐭ヨ瘑搴撴彁鍙朶diagnostic_index
```

鍏抽敭鏂囦欢锛?
- `taboo_taxonomy_v1.json`锛氭煡閿欑煡璇嗗垎绫汇€?- `taboo_rule_index_v1.json`锛氶€氱敤瑙勫垯妫€绱㈢储寮曘€?- `taboo_rule_store_v1.json`锛氶€氱敤瑙勫垯璇︾粏鍐呭銆?- `chapter18_rule_index_v1.json`锛氱 18 绔犻樁娈垫€ф绱㈢储寮曘€?- `chapter18_rule_store_v1.json`锛氱 18 绔犻樁娈垫€ц鍒欏簱銆?- `chapter18_verified_all.json`锛氱 18 绔犺緝瀹屾暣鐨勪汉宸?鍗婁汉宸ラ獙璇佺粨鏋溿€?- `RULE_CARD_SCHEMA_V1.md`锛氳鍒欏崱缁撴瀯璇存槑銆?
鎺ㄨ崘鏂瑰悜鏄細

```text
妯″瀷灞€閮ㄨ涔夊崟鍏?retrieval_sentence
  -> 妫€绱?taboo_rule_index_v1.json
  -> 鍔犺浇 taboo_rule_store_v1.json 涓搴旇鍒?  -> 楠岃瘉 required_model_facts
```

## 鎺ㄨ崘寮€鍙戞祦绋?
### 1. 鍙湅妯″瀷璇佹嵁鏄惁鎻愬彇瀹屾暣

```powershell
dotnet run --project tools\model-diagnostics\SectionBrepExtractor\SectionBrepExtractor.csproj -c Release -- "D:\path\model.SLDASM" --output-dir runtime\section_brep\trial1 --export-images --export-section-images
```

妫€鏌ワ細

- `AssemblyComponents` 鏄惁鏈夌湡瀹?SolidWorks 缁勪欢鍚嶃€?- `ComponentEvidencePackages` 鏄惁鎸夌粍浠跺垎寮€銆?- `PartImagePlan` 鏄惁鍙寘鍚潪鏍囦欢銆?- `AssemblyFaceContacts` 鏄惁鑳藉弽鏄犲叧閿閰嶆帴瑙︺€?- `FeatureGraph` 鏄惁鍖呭惈瀛斻€佸渾鏌遍潰銆佸钩闈?鍙伴樁銆佽閰嶆帴瑙︾瓑鍊欓€夈€?
### 2. 鐢熸垚 AI 鏈烘璇箟杈撳叆鍖?
```powershell
dotnet run --project tools\model-diagnostics\BrepFaultProbe\BrepFaultProbe.csproj -c Release -- bridge "D:\path\model.SLDASM" runtime\brep_semantic_bridge\trial1 --no-ai
```

妫€鏌ワ細

- `semantic_bridge_package.json`
- `structure_graph.json`
- `prompt.md`
- `self_evolution_audit.json`

濡傛灉鍚敤 AI锛岄渶瑕佽缃細

```powershell
$env:OPENAI_API_KEY = "<your-api-key>"
$env:OPENAI_MODEL = "qwen-vl-max"
$env:OPENAI_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
$env:OPENAI_API_MODE = "chat_completions"
```

### 3. 闃舵鎬ч獙璇佺 18 绔犳祦绋?
```powershell
dotnet run --project tools\model-diagnostics\BrepFaultProbe\BrepFaultProbe.csproj -c Release -- diagnose-ch18 "D:\path\model.SLDASM" runtime\knowledge_diagnosis_ch18\trial1 --no-ai
```

杩欎釜娴佺▼鐩墠鍙€傚悎楠岃瘉绗?18 绔犲凡澶勭悊瑙勫垯锛屼笉浠ｈ〃瀹屾暣鐭ヨ瘑搴撹瘖鏂€?
### 4. 楠岃瘉瑙勫垯鍖?
```powershell
dotnet run --project tools\model-diagnostics\ModelDiagnosticVerifier\ModelDiagnosticVerifier.csproj -c Release -- verify --model "D:\path\model.SLDASM" --rules runtime\rule_templates\rule.json --out runtime\diagnostics\trial1
```

閫傚悎娴嬭瘯鍗曟潯缁撴瀯鍖栬鍒欍€?
## 鍚庣闆嗘垚寤鸿

姝ｅ紡鍚庣涓嶅缓璁洿鎺ユ妸 `BrepFaultProbe` 褰撲綔鍞竴鍏ュ彛銆傛洿鍚堢悊鐨勫悗绔紪鎺掓槸锛?
```text
1. 璋冪敤 SectionBrepExtractor锛岀敓鎴愭ā鍨嬭瘉鎹寘鍜屽浘鐗囥€?2. AI 鍩轰簬璇佹嵁鍖呯敓鎴愬叏灞€鏈烘璇箟鍥俱€?3. AI 灏嗗叏灞€鏈烘璇箟鍥炬媶鍒嗘垚灞€閮ㄨ涔夊崟鍏冦€?4. 鐢ㄥ眬閮ㄨ涔夊崟鍏冪殑涓€鍙ヨ瘽妫€绱㈠厓妫€绱㈢煡璇嗗簱銆?5. 鍔犺浇鍊欓€夎鍒欒缁嗗唴瀹广€?6. 璋冪敤瑙勫垯楠岃瘉閫昏緫锛岃緭鍑烘渶缁堥棶棰樺垪琛ㄣ€?7. 鑻ョ己灏戝彲鎻愬彇浜嬪疄锛岃Е鍙戜簩娆″墫瑙嗗浘鎴栬ˉ鍏?B-rep 妫€鏌ャ€?```

`BrepFaultProbe` 鍙互浣滀负寮€鍙戣皟璇曞彴锛岀敤浜庨獙璇佷腑闂存枃浠跺拰瀹為獙娴佺▼銆?
## 闇€瑕侀伩鍏嶇殑璇敤

- 涓嶈鎶?`SectionBrepExtractor` 杈撳嚭鐨?`FeatureGraph` 褰撴垚鏈€缁堟満姊拌涔夛紝瀹冨彧鏄瘉鎹垎缁勩€?- 涓嶈鍙牴鎹浘鐗囧垽鏂敊璇紱鍥剧墖鍜?B-rep 蹇呴』浜掔浉鏍￠獙銆?- 涓嶈鎶婃爣鍑嗕欢褰撲綔闈炴爣闆朵欢鍘绘鏌ュ眬閮ㄧ粨鏋勭蹇屻€?- 涓嶈瀵归浂浠堕噸鏂版彁鍙?B-rep 鍚庡啀娣峰叆瑁呴厤浣?B-rep锛涜閰嶄綋鍔熻兘闈㈡剰涔変細涓㈠け銆?- 涓嶈鍦ㄦā鍨嬬鐢熸垚甯﹁鍒欑紪鍙锋垨鈥滆繚鍙?閿欒/搴旇鈥濈瓑缁撹鎬х殑妫€绱㈠彞锛涙绱㈠墠鐨勫眬閮ㄨ涔夊簲淇濇寔涓€т簨瀹炴弿杩般€?
## 褰撳墠閬楃暀浜嬮」

- `BrepFaultProbe diagnose-ch18` 浠嶆槸绗?18 绔犻樁娈垫€у疄楠屾祦绋嬨€?- `judge-local` 鍜?`model-and-judge` 鏄绛掓媶鍗歌鍒?legacy 鍥炲綊鏍蜂緥銆?- `StructuralFaultProbe` 鏄棭鏈熺粨鏋勪簨瀹炴彁鍙栧伐鍏凤紝鍚庣画搴旈€愭灏嗘湁鐢ㄨ兘鍔涘苟鍏ユ寮忚瘉鎹彁鍙?楠岃瘉娴佺▼銆?- 瀹屾暣鐨勨€滃叏鐭ヨ瘑搴撴绱?+ 澶氳鍒欓獙璇?+ 鍚庣 API鈥濊繕闇€瑕佺户缁皝瑁呫€?
