feat(review): 几何干涉检查 find_collisions(BVH 粗筛 + 容器过滤)
C++(cad_mcp_plugins):
- 新增 bvh.h:header-only 2D BVH(质心中位分割,叶<=4,SelfPairs 交叉对枚举)
- 新增 find_collisions.cpp:粗筛 AABB 相交实体对,附重叠盒 + 逐轴重叠比 ratio
(= 逐轴重叠长/较短长 之积,退化轴取 1.0),按 ratio 降序 + 分页;
narrow=true 只对返回页跑 intersectWith 细筛(附 exact)
- 容器过滤(关键):图框块/分区边界会与一切相交,用重叠【度】判定
deg >= max(exclude_container_deg=8, exclude_container_frac=0.25 * 其他实体数),
与图幅/缩放无关;被剔除者在 excluded_containers 里如实报告
(初版用面积判据对多图框并排失效:3 框只占并集 27/13/7% 全部漏过,
全模型 163 对噪声;改度判据后图框 deg=35/25/23 vs 其余 deg<=3,分离干净)
- cmakelists.txt + 两个 mcp_config.json 注册(28 工具)
agent 侧(Python):
- cad_tools.READ_ONLY_TOOLS += find_collisions(受控子循环可调用)
- checks.check_collisions + run_deterministic_checks(受 CHECK_COLLISIONS 开关,默认关)
- config += CHECK_COLLISIONS=False / COLLISION_MIN_OVERLAP=0.5
- checklist.py / review_checklist.json += 「干涉/碰撞」类别(high)+ 提示词协议
(先 find_collisions 拿候选 → inspect_region 目视确认;AABB 相交 != 真干涉)
验证:
- verify_collisions.py 17/17 PASS:全模型候选 163→80(全部 ratio=0.000),
min_overlap=0.5 → 0 对;逐图框 0 对;narrow top-5 中 4 条 exact=true;
--inject 注入深重叠矩形报出 ratio=0.902 并清理 2/2
- pytest 355 passed(新增 12 项)
- 端到端:LLM 主动调用 find_collisions{min_overlap:0.2,narrow:true,window:<图框>},未误报
This commit is contained in:
1 parent
a77a090281
commit
d4a9442e30
20 files changed
+1152
-13
No files matched your search
@@ -77,6 +77,8 @@ def test_credibility_constants_have_expected_types():
|
||||
assert isinstance(config.ZERO_LENGTH_TOLERANCE, float)
|
||||
assert isinstance(config.DUP_TOLERANCE, float)
|
||||
assert isinstance(config.DUP_GROUP_LIMIT, int)
|
||||
assert isinstance(config.CHECK_COLLISIONS, bool)
|
||||
assert isinstance(config.COLLISION_MIN_OVERLAP, float)
|
||||
|
||||
|
||||
def test_tiling_constants_have_expected_types():
|
||||
@@ -132,6 +134,13 @@ def test_credibility_defaults_are_on():
|
||||
assert config.CHECK_UNCLOSED_POLYLINES is True
|
||||
|
||||
|
||||
def test_collision_defaults_are_sane():
|
||||
# 干涉粗筛默认关闭(AABB 相交噪声大,改由 LLM 按需调用);
|
||||
# 阈值须落在 [0,1](重叠比是乘积,可能为 0)
|
||||
assert config.CHECK_COLLISIONS is False
|
||||
assert 0.0 <= config.COLLISION_MIN_OVERLAP <= 1.0
|
||||
|
||||
|
||||
def test_checklist_path_resolves_relative_to_root():
|
||||
assert config.CHECKLIST_PATH.name == "review_checklist.json"
|
||||
assert config.CHECKLIST_PATH.parent == config.PROJECT_ROOT
|
||||
|
||||
Reference in new issue
Block a user