From fdc057f2d99da820f5dd803a5fffffd37fe1eb40 Mon Sep 17 00:00:00 2001 From: hm-thinkbook14p Date: Tue, 15 Sep 2026 13:34:59 +0800 Subject: [PATCH] =?UTF-8?q?perf(heal):=20Orient=20=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E7=BD=91=E6=A0=BC=20deflection=20=E6=8C=89=20bbox=20=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E5=8C=96=E2=80=94=E2=80=94=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=BB=95=E5=90=91=E4=BF=AE=E5=A4=8D=2046h=E2=86=92=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=E7=BA=A7=EF=BC=88VDE-1193=20=C2=A79.11.12=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit heal_shell_orientation 的网格仅用于"共享边传播绕向 + 分量有符号体积 定号"(纯拓扑决策),却按固定 0.05mm 网格化整机——Trike(23,651 面/ 249MB)trimmed 面 interior res=1/deflection 打满 200×200 上限,实测 ~7s/面 = 46h。 修复:bbox 对角线 >100mm 时 deflection = max(调用值, diag/1000)。 小零件(≤100mm)行为完全不变;大模型面内点数随 (diag/1000/0.05)² 下降,绕向传播结果不变(传播只依赖网格流形性与分量结构)。 效果:Trike 推进速率 3.6→7 面/分(project_chain/CDT 为剩余主导); test_brep_heal 41 + test_trimmed_surface 30 + test_measure 33 全过。 --- src/brep/brep_heal.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/brep/brep_heal.cpp b/src/brep/brep_heal.cpp index 20b68cc10..293e328b1 100644 --- a/src/brep/brep_heal.cpp +++ b/src/brep/brep_heal.cpp @@ -500,6 +500,32 @@ int heal_orientation(BrepModel& body) { int heal_shell_orientation(BrepModel& body, double deflection) { if (body.faces_.empty()) return 0; + // VDE-1193 §9.11.12:Orient 网格仅用于"共享边传播绕向 + 分量有符号 + // 体积定号"——纯拓扑决策,不需要几何精度。大模型(飞机整机)按 + // 0.05mm 网格化会产生海量三角形(Trike 23,651 面 × ~7s/面 ≈ 46h: + // trimmed 面 interior res=1/deflection 打满 200×200 上限所致)。 + // deflection 按 bbox 对角线相对化(diag/1000),下限保持调用值 + // (≤100mm 零件行为完全不变);面内点数随之下降 ~10⁴ 倍,绕向 + // 传播结果不变(传播只依赖网格流形性与分量结构)。 + { + double mnr[3] = {1e300, 1e300, 1e300}; + double mxr[3] = {-1e300, -1e300, -1e300}; + for (int vi = 0; vi < body.num_vertices(); ++vi) { + const auto& p = body.vertex(vi).point; + const double c[3] = {p.x(), p.y(), p.z()}; + for (int k = 0; k < 3; ++k) { + mnr[k] = std::min(mnr[k], c[k]); + mxr[k] = std::max(mxr[k], c[k]); + } + } + const double diag = std::sqrt( + (mxr[0] - mnr[0]) * (mxr[0] - mnr[0]) + + (mxr[1] - mnr[1]) * (mxr[1] - mnr[1]) + + (mxr[2] - mnr[2]) * (mxr[2] - mnr[2])); + if (diag > 100.0) + deflection = std::max(deflection, diag / 1000.0); + } + // 仅对"闭合壳"内的面做修复:开放壳没有内外之分,绕向保持原状。 std::vector in_closed(body.faces_.size(), 0); bool any_closed = false;