From f3b36cb535a242ae11aef3fa631716dbf1214fcb Mon Sep 17 00:00:00 2001 From: hm-thinkbook16p Date: Thu, 1 Oct 2026 22:12:36 +0800 Subject: [PATCH] docs: feedback from ViewDesign integration (VDE-892.md) --- docs/feedback/VDE-892.md | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 docs/feedback/VDE-892.md diff --git a/docs/feedback/VDE-892.md b/docs/feedback/VDE-892.md new file mode 100644 index 000000000..10fe5a4b0 --- /dev/null +++ b/docs/feedback/VDE-892.md @@ -0,0 +1,79 @@ +# VDE-892: NurbsCurve::interpolate 应为真·全局插值(现实现把输入点当 poles,仅逼近) + +**Status**: open +**来源**: ViewDesign 集成(草图样条拉伸轮廓 / 单曲线精确回路) +**优先级**: High (P2) — 样条建模保真的基础 +**日期**: 2026-10-01 + +## 背景 + +`NurbsCurve::interpolate(points, degree)` +(src/curves/nurbs_curve.cpp:377-408,VDE-476 工厂)名为插值, +实际是**逼近**:chord-length 参数化与 averaging 内节点都算好了, +但最后一步 + +```cpp +// Use points as control points (approximate interpolation) // L405 +std::vector weights(points.size(), 1.0); +return NurbsCurve(points, knots, weights, degree); // L407 +``` + +直接把输入点当 poles——曲线**只保证过首尾点**(clamped 端点性质), +中间拟合点全部偏离。节点向量与参数化结果没有被用来解方程组。 + +## 复现(语义层面) + +对 4 点 (0,0,0) (10,20,0) (20,-5,0) (30,10,0) 调 interpolate: +在 t=1/3、t=2/3 处求值不过 (10,20,0)、(20,-5,0)(de Boor 对 +非插值节点结构的必然结果)。 + +## 影响(ViewDesign 侧) + +- `src/vd_shell/main_window.cpp:13636` 一带:草图样条 → 3D 拉伸轮廓 + 用 `NurbsCurve::interpolate(pts3d, deg)`,用户画的拟合点在拉伸 + 轮廓上**不落线**,形状系统性偏差; +- `loadSketchExactLoop`(单曲线精确回路旁路):lone spline 回路 + 同样依赖该工厂,「精确回路」名不副实; +- 2D 侧(vd_shell Catmull-Rom)与 3D 侧(VDE 逼近)行为不一致, + 同一拟合点列在草图面与拉伸体上形状不同。 + +## 期望行为 + +标准 NURBS 全局插值(PIG L/The NURBS Book Chp.9.2): + +1. 保持 chord-length 参数化 + averaging knots(现有代码已正确); +2. **解带状线性方程组** (degree+1 带) 求 poles,使 + C(params[i]) = points[i] 对全部 i 成立(首尾 pole = 首尾点); +3. 端条件可选:natural(端二阶导 = 0)或 clamped 端切矢——建议 + 提供: + ```cpp + static NurbsCurve interpolate(const std::vector& points, + int degree = 3); // 保持签名,行为改为真插值 + static NurbsCurve interpolate(const std::vector& points, + int degree, + const std::optional& tangentStart, + const std::optional& tangentEnd); // 端切矢重载 + ``` +4. 退化输入(共线点、点数 ≤ degree+1)现行為可保留。 + +若不便改默认行为(兼容顾虑),请提供 +`interpolateExact(...)` 并在头文件注明 interpolate 是逼近。 + +## 实际行为 + +输入点被直接当 poles;中间点不落线(源码 L405 注释自认 +"approximate interpolation")。 + +## 排查建议 + +- 带状方程组规模 = 点数,degree=3 时带宽 4,LU 分解 O(n)—— + 性能无忧; +- 解出 poles 后可加断言/自检:max |C(params[i]) − points[i]| < 1e-9; +- 建议补回归用例:插值后逐点回代误差 + 首/尾切向与端切矢输入一致。 + +## 关联 + +- ViewDesign 消费点:`src/vd_shell/main_window.cpp` 样条拉伸轮廓 + (NurbsCurve::interpolate 调用)与 loadSketchExactLoop +- 相关 VDCS 侧:VDCS-007(等曲率 G2 约束)——与本需求共同构成 + ViewDesign 样条对齐 SolidWorks 的子模块侧前提