2026-07-24 09:57:31 +00:00
|
|
|
|
# ViewDesignEngine — 高性能 CAD 计算几何引擎
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
C++17 全栈计算几何引擎。从底层数学工具到 B-Rep 拓扑建模、SDF 隐式建模、可微分几何、工业格式互操作,一条龙覆盖。
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 11:33:09 +00:00
|
|
|
|
[](https://git.hdtime.space/ViewDesignEngine/ViewDesignEngine/actions)
|
2026-07-24 09:57:31 +00:00
|
|
|
|
[](tests/)
|
2026-07-24 11:33:09 +00:00
|
|
|
|
[](CHANGELOG.md)
|
2026-07-24 03:08:13 +00:00
|
|
|
|
[](CMakeLists.txt)
|
2026-07-24 11:33:09 +00:00
|
|
|
|
[](pyproject.toml)
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
|
|
|
|
|
## 快速开始
|
|
|
|
|
|
|
2026-07-24 11:33:09 +00:00
|
|
|
|
### C++ 构建
|
|
|
|
|
|
|
2026-07-23 05:27:51 +00:00
|
|
|
|
```bash
|
2026-07-24 09:57:31 +00:00
|
|
|
|
# Docker 构建环境(推荐)
|
|
|
|
|
|
docker exec vde-builder bash -c "cd /ws/ViewDesignEngine && cmake -B build && cmake --build build -j\$(nproc)"
|
|
|
|
|
|
|
|
|
|
|
|
# 本地构建
|
2026-07-23 05:27:51 +00:00
|
|
|
|
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
|
|
|
|
|
cmake --build build -j$(nproc)
|
2026-07-24 09:57:31 +00:00
|
|
|
|
|
|
|
|
|
|
# 运行测试
|
2026-07-23 05:27:51 +00:00
|
|
|
|
cd build && ctest --output-on-failure
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
# 运行示例
|
|
|
|
|
|
./build/examples/07_pipeline/pipeline_demo # SDF → GLB 全流程
|
2026-07-23 05:27:51 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
**依赖**: CMake ≥ 3.16, C++17, Eigen 3, GoogleTest(自动下载)
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 11:33:09 +00:00
|
|
|
|
### Python 安装
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# 从源码安装(推荐)
|
|
|
|
|
|
pip install .
|
|
|
|
|
|
|
|
|
|
|
|
# 开发模式(可编辑安装)
|
|
|
|
|
|
pip install -e .
|
|
|
|
|
|
|
|
|
|
|
|
# 仅 CMake 构建(不安装到 site-packages)
|
|
|
|
|
|
cmake -B build_py -DVDE_BUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=Release
|
|
|
|
|
|
cmake --build build_py -j$(nproc)
|
|
|
|
|
|
|
|
|
|
|
|
# 测试导入
|
|
|
|
|
|
PYTHONPATH=build_py/python python3 -c "import vde; print(vde.__version__)"
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**Python 依赖**: CMake ≥ 3.16, C++17, Eigen 3(自动下载), pybind11 ≥ 2.10
|
|
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
## 模块总览
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
| 模块 | 命名空间 | 关键能力 |
|
|
|
|
|
|
|------|---------|----------|
|
|
|
|
|
|
| `foundation` | `vde::foundation` | 数学类型、公差、精确谓词、STL/OBJ/PLY/GLTF(F/GLB) 读写 |
|
|
|
|
|
|
| `core` | `vde::core` | 多边形、Voronoi、凸包、ICP、距离计算 |
|
|
|
|
|
|
| `curves` | `vde::curves` | Bézier / B-Spline / NURBS 曲线曲面、自适应细分 |
|
|
|
|
|
|
| `mesh` | `vde::mesh` | 半边网格、Delaunay 2D/3D、QEM 简化、平滑、Marching Cubes、测地线、网格布尔 |
|
|
|
|
|
|
| `spatial` | `vde::spatial` | BVH (SAH)、Octree、KD-Tree、R-Tree (STR) |
|
|
|
|
|
|
| `boolean` | `vde::boolean` | 2D Sutherland-Hodgman、3D 网格布尔、多边形偏移 |
|
|
|
|
|
|
| `collision` | `vde::collision` | GJK/EPA、SAT、射线-三角形、三角交线 |
|
|
|
|
|
|
| `brep` | `vde::brep` | 边界表示 (B-Rep) 拓扑建模、布尔运算、验证 |
|
|
|
|
|
|
| `sdf` | `vde::sdf` | 15+ 隐式图元、CSG 树、自动微分、梯度优化、SDF → Mesh |
|
|
|
|
|
|
| `sketch` | `vde::sketch` | 2D 草图约束求解器 |
|
|
|
|
|
|
| `capi` | `vde::capi` | C API,跨语言互操作 |
|
|
|
|
|
|
|
|
|
|
|
|
## 格式支持
|
|
|
|
|
|
|
|
|
|
|
|
| 格式 | 导入 | 导出 | 说明 |
|
|
|
|
|
|
|------|------|------|------|
|
|
|
|
|
|
| STEP (AP203/214) | ✅ | ✅ | 工业 CAD 交换标准 |
|
|
|
|
|
|
| IGES (5.3) | ✅ | ✅ | 传统制造业格式 |
|
|
|
|
|
|
| glTF 2.0 / GLB | — | ✅ | 实时 3D / Web 查看 |
|
|
|
|
|
|
| STL | — | ✅ | 3D 打印 |
|
|
|
|
|
|
| OBJ | — | ✅ | 通用网格 |
|
|
|
|
|
|
| PLY | — | ✅ | 点云/网格 |
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
## 特色功能
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
### 🔮 SDF 隐式建模
|
2026-07-24 03:08:13 +00:00
|
|
|
|
```cpp
|
2026-07-24 09:57:31 +00:00
|
|
|
|
#include <vde/sdf/sdf_primitives.h>
|
|
|
|
|
|
#include <vde/sdf/sdf_operations.h>
|
|
|
|
|
|
#include <vde/sdf/sdf_tree.h>
|
|
|
|
|
|
|
|
|
|
|
|
// 光滑并集
|
|
|
|
|
|
auto shape = SdfNode::smooth_union(
|
|
|
|
|
|
SdfNode::sphere(1.5),
|
|
|
|
|
|
SdfNode::box(Point3D(1, 1, 1)),
|
|
|
|
|
|
0.3
|
|
|
|
|
|
);
|
|
|
|
|
|
double d = evaluate(shape, Point3D(0, 0, 0)); // SDF 值
|
2026-07-24 03:08:13 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
### ⚡ 可微分几何 + torch 集成
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
#include <vde/sdf/sdf_gradient.h>
|
|
|
|
|
|
#include <vde/sdf/sdf_optimize.h>
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
// 拟合 SDF 到点云
|
|
|
|
|
|
auto sphere = SdfNode::sphere(1.0);
|
|
|
|
|
|
auto result = fit_to_point_cloud(sphere, point_cloud, 0.01, 100);
|
|
|
|
|
|
// result.optimized_shape → 优化后的形状
|
|
|
|
|
|
```
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
### 🔧 B-Rep 工业建模
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
#include <vde/brep/modeling.h>
|
|
|
|
|
|
#include <vde/brep/brep_boolean.h>
|
|
|
|
|
|
|
|
|
|
|
|
auto box = make_box(2, 2, 2);
|
|
|
|
|
|
auto shelled = shell(box, -1, 0.15); // 抽壳
|
|
|
|
|
|
auto filleted = fillet(box, 0, 0.3); // 倒圆
|
|
|
|
|
|
auto result = brep_union(a, b); // 布尔并
|
|
|
|
|
|
```
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
## 代码示例
|
|
|
|
|
|
|
|
|
|
|
|
完整示例见 [`examples/`](examples/):
|
|
|
|
|
|
- `01_hello_triangle` — 基础几何
|
|
|
|
|
|
- `02_bezier` — 曲线求值
|
|
|
|
|
|
- `03_mesh` — 网格操作
|
|
|
|
|
|
- `04_delaunay` — 三角剖分
|
|
|
|
|
|
- `05_boolean` — 布尔运算
|
|
|
|
|
|
- `06_collision` — 碰撞检测
|
|
|
|
|
|
- `07_pipeline` — **SDF → Mesh → GLB 完整管线**
|
|
|
|
|
|
|
|
|
|
|
|
## 测试
|
|
|
|
|
|
|
|
|
|
|
|
| 类别 | 测试数 | 状态 |
|
|
|
|
|
|
|------|--------|------|
|
|
|
|
|
|
| 核心 + 曲线 + 网格 + 空间 + 碰撞 | ~120 | ✅ |
|
|
|
|
|
|
| B-Rep 建模 + 验证 | ~70 | ✅ |
|
|
|
|
|
|
| STEP 导入/导出 | 31 | ✅ |
|
|
|
|
|
|
| IGES 导入/导出 | 39 | ✅ |
|
|
|
|
|
|
| SDF 隐式建模 | 189 | ✅ |
|
|
|
|
|
|
| 可微分几何 | 76 | ✅ |
|
|
|
|
|
|
| GLTF/GLB 导出 | 6 | ✅ |
|
|
|
|
|
|
| 草图约束 | — | ✅ |
|
|
|
|
|
|
| **合计** | **~476** | **100%** |
|
2026-07-24 03:08:13 +00:00
|
|
|
|
|
|
|
|
|
|
## 工程指标
|
|
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
- **语言**: C++17,零外部运行时依赖(仅 header-only Eigen + GTest)
|
|
|
|
|
|
- **测试**: 476+ 用例,100% 通过
|
|
|
|
|
|
- **编译**: GCC 11+ / Clang 16+,零错误零警告
|
|
|
|
|
|
- **格式支持**: STEP、IGES、glTF/GLB、STL、OBJ、PLY
|
2026-07-23 05:27:51 +00:00
|
|
|
|
|
|
|
|
|
|
## 文档
|
|
|
|
|
|
|
2026-07-24 09:57:31 +00:00
|
|
|
|
- [开发计划](docs/00-开发计划.md) — 版本规划 + Sprint 划分
|
|
|
|
|
|
- [v3.1 计划](docs/10-v3.1-开发计划.md) — 下一阶段路线图
|
|
|
|
|
|
- [CHANGELOG](CHANGELOG.md) — 版本历史
|
2026-07-24 03:08:13 +00:00
|
|
|
|
- [构建指南](docs/06-部署维护/01-构建指南.md)
|
|
|
|
|
|
|
|
|
|
|
|
## 许可证
|
|
|
|
|
|
|
|
|
|
|
|
Apache License 2.0 — 详见 [LICENSE](LICENSE)
|