Files

56 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

# VDE-021: extrude/revolve/sweep/loft 需要 NURBS 曲线输入,缺少 mesh→profile 便捷 API
- **ID**: VDE-021
- **Date**: 2026-07-28
- **Status**: Fixed
- **Severity**: High
- **Category**: API Gap
- **Source**: ViewDesign feat/viewdesign-engine branch
## Issue
VDE 的扫掠特征 API 全部以 `NurbsCurve` 为输入:
```cpp
BrepModel extrude(const NurbsCurve& profile, const Vector3D& dir);
BrepModel revolve(const NurbsCurve& profile, ...);
BrepModel sweep(const NurbsCurve& profile, const NurbsCurve& path);
BrepModel loft(const std::vector<NurbsCurve>& profiles);
```
但 ViewDesign 的 `FeatureBuilder``Shape`mesh 数据)作为 profile 输入(用户通过二维草图生成的封闭轮廓):
```cpp
Shape extrude(const Shape& profileWire, double dirX, dirY, dirZ, double length);
```
从 mesh Shape 中提取 NURBS 曲线轮廓是一个复杂的拟合问题(需要边界检测 + 曲线拟合),VDE 没有提供这样的便捷 API。
## Impact
ViewDesign 中 `extrude`/`revolve`/`sweep`/`loft` 保持 OCCT-onlyVDE 后端下返回空 Shape。这四个特征是机械 CAD 最常用的建模操作。
## Suggested Fix
**方案一(推荐)**:为 VDE 添加从 mesh 提取轮廓的 API
```cpp
// 从闭合 mesh 边界提取轮廓曲线
std::vector<NurbsCurve> extract_profiles_from_mesh(
const HalfedgeMesh& mesh,
const Vector3D& projectionAxis = Vector3D(0, 0, 1));
```
**方案二**:为建模 API 添加 mesh 输入重载
```cpp
BrepModel extrude(const HalfedgeMesh& profileMesh, const Vector3D& dir);
BrepModel revolve(const HalfedgeMesh& profileMesh, const Vector3D& axis, double angle);
```
**方案三**:提供 mesh→NurbsCurve 转换工具
```cpp
NurbsCurve mesh_boundary_to_curve(const HalfedgeMesh& mesh);
```