feedback: VDE-142 -- modeling.cpp gear/spring compilation errors (missing include + wrong NurbsCurve constructor + invalid knot vector)
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# VDE-142: modeling.cpp gear/spring compilation errors
|
||||
|
||||
**日期**: 2026-07-31
|
||||
**状态**: 已提交
|
||||
**严重度**: P0 (阻断编译)
|
||||
**模块**: `vde/brep/modeling.cpp`
|
||||
**VDE Commit**: `1b511da` ("fix(VDE-137): gear/spring implementations")
|
||||
|
||||
## 问题描述
|
||||
|
||||
最新 VDE commit `1b511da` 在 `modeling.cpp` 中引入了齿轮 (`make_spur_gear`, `make_helical_gear`) 和弹簧 (`make_spring`) 实现,但代码无法编译,存在以下 4 个错误:
|
||||
|
||||
### 1. 缺少 `#include "vde/curves/nurbs_curve.h"`
|
||||
|
||||
`NurbsCurve` 在约 1351、1382、1394 行使用,但未包含对应头文件。
|
||||
|
||||
### 2. 缺少 `curves::` 命名空间前缀
|
||||
|
||||
在 `namespace vde::brep {}` 内部使用 `NurbsCurve` 时缺少 `curves::` 前缀(约 1351、1382、1394 行)。应使用 `curves::NurbsCurve`(与第 19 行使用 `curves::NurbsSurface` 一致)。
|
||||
|
||||
### 3. NurbsCurve 构造函数签名错误
|
||||
|
||||
代码使用了不存在的 3 参数构造函数 `NurbsCurve(std::vector<Point3D>, std::vector<double>, int)`。实际构造函数为 4 参数:
|
||||
|
||||
```cpp
|
||||
NurbsCurve(std::vector<Point3D> control_points, std::vector<double> knots,
|
||||
std::vector<double> weights, int degree);
|
||||
```
|
||||
|
||||
weights 为第 3 个参数,当前代码缺少该参数。
|
||||
|
||||
### 4. 无效的节点向量大小(约 1354 行)
|
||||
|
||||
```cpp
|
||||
std::vector<double> params(profile.size());
|
||||
for (size_t i = 0; i < profile.size(); ++i) params[i] = static_cast<double>(i);
|
||||
```
|
||||
|
||||
对于具有 N 个控制点和阶次 D 的 NURBS 曲线,节点向量必须包含 N+D+1 个元素。当前代码创建了 N 个元素,对于任何 degree > 1 都不够。
|
||||
|
||||
## 影响行数
|
||||
|
||||
| 行号 | 问题 |
|
||||
|------|------|
|
||||
| ~1351 | `NurbsCurve curve;` — 缺少 `curves::` 前缀 |
|
||||
| ~1354-1356 | 构造函数签名错误(3参 → 需4参)+ 节点计数无效 |
|
||||
| ~1382 | `NurbsCurve spine(pts, {}, 3);` — 构造函数签名错误 |
|
||||
| ~1394 | `NurbsCurve spine(spine_pts, {}, 3);` — 构造函数签名错误 |
|
||||
|
||||
## 影响范围
|
||||
|
||||
ViewDesign 的 `FeatureBuilder::makeSpurGearVde()`、`makeHelicalGearVde()` 和 `makeSpringVde()` 均以 stub 形式实现(标注 `// FIXME(VDE): not yet implemented in VDE`)。这些 stub 已准备就绪,但被此编译问题阻断。
|
||||
|
||||
## 建议修复
|
||||
|
||||
1. 添加 `#include "vde/curves/nurbs_curve.h"`
|
||||
2. 使用 `curves::NurbsCurve` 限定名
|
||||
3. 使用正确的 4 参数构造函数,传入 weights 向量
|
||||
4. 为给定阶次生成 N+D+1 个元素的节点向量
|
||||
|
||||
## 复现步骤
|
||||
|
||||
```bash
|
||||
cd third_party/ViewDesignEngine
|
||||
git checkout 1b511da
|
||||
# 构建将失败
|
||||
```
|
||||
|
||||
## 相关代码
|
||||
|
||||
- `FeatureBuilder::makeSpurGearVde()` 位于 `feature_builder.cpp:10024`
|
||||
- `FeatureBuilder::makeHelicalGearVde()` 位于 `feature_builder.cpp:10036`
|
||||
- `FeatureBuilder::makeSpringVde()` 位于 `feature_builder.cpp:10048`
|
||||
Reference in New Issue
Block a user