恢复首页(项目介绍)
+181
-30
@@ -1,53 +1,204 @@
|
|||||||
# ViewDesignEngine API 参考
|
# ViewDesignEngine — 高性能 CAD 计算几何引擎
|
||||||
> v3.2.0 | 76 个头文件 | 11 个模块
|
|
||||||
|
|
||||||
## 模块索引
|
C++17 全栈计算几何引擎。从底层数学工具到 B-Rep 拓扑建模、SDF 隐式建模、可微分几何、工业格式互操作,一条龙覆盖。
|
||||||
|
|
||||||
- [基础模块](foundation-api) — `vde::foundation`
|
> **版本**: v3.2.0 | **测试**: 500+ 全过 | **许可证**: Apache 2.0
|
||||||
- [核心几何](core-api) — `vde::core`
|
|
||||||
- [曲线曲面](curves-api) — `vde::curves`
|
|
||||||
- [网格处理](mesh-api) — `vde::mesh`
|
|
||||||
- [空间索引](spatial-api) — `vde::spatial`
|
|
||||||
- [布尔运算](boolean-api) — `vde::boolean`
|
|
||||||
- [碰撞检测](collision-api) — `vde::collision`
|
|
||||||
- [B-Rep 建模](brep-api) — `vde::brep`
|
|
||||||
- [SDF 隐式建模](sdf-api) — `vde::sdf`
|
|
||||||
- [草图约束](sketch-api) — `vde::sketch`
|
|
||||||
- [C API](capi-api) — `vde::capi`
|
|
||||||
|
|
||||||
## 安装
|
---
|
||||||
|
|
||||||
|
## 项目概述
|
||||||
|
|
||||||
|
ViewDesignEngine 是一个面向 CAD/CAM/CAE 场景的高性能 C++ 几何库,提供:
|
||||||
|
|
||||||
|
- **参数曲线曲面**: Bézier / B-Spline / NURBS,支持求值、求导、自适应细分
|
||||||
|
- **网格处理**: 半边数据结构、Delaunay 2D/3D、QEM 简化、拉普拉斯平滑、Marching Cubes
|
||||||
|
- **空间索引**: BVH (SAH)、Octree、KD-Tree、R-Tree (STR bulk-loading)
|
||||||
|
- **布尔运算**: 2D Sutherland-Hodgman 裁剪、3D 网格布尔、B-Rep 布尔
|
||||||
|
- **碰撞检测**: GJK/EPA、SAT、Möller-Trumbore 射线-三角形
|
||||||
|
- **B-Rep 建模**: 边界表示、STEP/IGES 导入导出、fillet/chamfer/shell
|
||||||
|
- **SDF 隐式建模**: 15+ 图元、CSG 表达式树、自动微分、梯度优化、SDF→Mesh
|
||||||
|
- **格式支持**: STEP、IGES、glTF/GLB、STL、OBJ、PLY、3MF
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 克隆仓库
|
||||||
git clone http://git.hdtime.space:3000/hm/ViewDesignEngine.git
|
git clone http://git.hdtime.space:3000/hm/ViewDesignEngine.git
|
||||||
cd ViewDesignEngine
|
cd ViewDesignEngine
|
||||||
cmake -B build && cmake --build build -j$(nproc)
|
|
||||||
|
# 构建
|
||||||
|
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build -j$(nproc)
|
||||||
|
|
||||||
|
# 运行全部测试
|
||||||
|
cd build && ctest --output-on-failure
|
||||||
|
|
||||||
|
# 运行示例
|
||||||
|
./examples/07_pipeline/pipeline_demo # SDF → GLB 全流程
|
||||||
|
./examples/09_brep_fab/demo_brep_fab # B-Rep → STEP + GLB
|
||||||
|
./examples/08_3d_print/demo_3d_print # SDF → STL 打印
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**依赖**: CMake ≥ 3.16, C++17 编译器, Eigen 3 (自动下载)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 架构
|
||||||
|
|
||||||
|
```
|
||||||
|
ViewDesignEngine/
|
||||||
|
├── include/vde/
|
||||||
|
│ ├── foundation/ 数学类型、公差、I/O、序列化
|
||||||
|
│ ├── core/ 点/线/面、变换、多边形、凸包、Voronoi、ICP
|
||||||
|
│ ├── curves/ NURBS 曲线曲面、细分、操作
|
||||||
|
│ ├── mesh/ 半边网格、三角剖分、简化、平滑、Marching Cubes
|
||||||
|
│ ├── spatial/ BVH、Octree、KD-Tree、R-Tree
|
||||||
|
│ ├── boolean/ 2D/3D 布尔、多边形偏移
|
||||||
|
│ ├── collision/ GJK、SAT、射线、三角交线
|
||||||
|
│ ├── brep/ B-Rep 建模、STEP/IGES、布尔、验证、装配体
|
||||||
|
│ ├── sdf/ 隐式图元、CSG 树、自动微分、优化、Torch
|
||||||
|
│ ├── sketch/ 2D 约束求解
|
||||||
|
│ └── capi/ C API 绑定
|
||||||
|
├── src/ 实现文件
|
||||||
|
├── tests/ 500+ 测试用例
|
||||||
|
├── examples/ 9 个完整示例
|
||||||
|
├── bench/ 5 套性能基准
|
||||||
|
└── docs/ API 手册、开发计划、性能报告
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 模块总览
|
||||||
|
|
||||||
|
| 模块 | 命名空间 | 关键能力 |
|
||||||
|
|------|---------|----------|
|
||||||
|
| [基础模块](foundation-api) | `vde::foundation` | 数学类型、公差、精确谓词、STL/OBJ/PLY/GLTF/3MF I/O |
|
||||||
|
| [核心几何](core-api) | `vde::core` | 多边形、Voronoi、凸包、ICP、距离计算 |
|
||||||
|
| [曲线曲面](curves-api) | `vde::curves` | Bézier / B-Spline / NURBS 曲线曲面、自适应细分 |
|
||||||
|
| [网格处理](mesh-api) | `vde::mesh` | 半边网格、Delaunay 2D/3D、QEM 简化、平滑、Marching Cubes |
|
||||||
|
| [空间索引](spatial-api) | `vde::spatial` | BVH (SAH)、Octree、KD-Tree、R-Tree (STR) |
|
||||||
|
| [布尔运算](boolean-api) | `vde::boolean` | 2D Sutherland-Hodgman、3D 网格布尔、多边形偏移 |
|
||||||
|
| [碰撞检测](collision-api) | `vde::collision` | GJK/EPA、SAT、射线-三角形、三角交线 |
|
||||||
|
| [B-Rep 建模](brep-api) | `vde::brep` | 边界表示、STEP/IGES、布尔、验证、装配体 |
|
||||||
|
| [SDF 隐式建模](sdf-api) | `vde::sdf` | 15+ 图元、CSG 树、自动微分、梯度优化 |
|
||||||
|
| [草图约束](sketch-api) | `vde::sketch` | 2D 草图约束求解 |
|
||||||
|
| [C API](capi-api) | `vde::capi` | C 接口,跨语言互操作 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 代码示例
|
## 代码示例
|
||||||
|
|
||||||
### SDF 隐式建模
|
### SDF 隐式建模
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#include <vde/sdf/sdf_primitives.h>
|
#include <vde/sdf/sdf_primitives.h>
|
||||||
#include <vde/sdf/sdf_operations.h>
|
#include <vde/sdf/sdf_operations.h>
|
||||||
|
|
||||||
auto shape = vde::sdf::SdfNode::smooth_union(
|
// 光滑并集:球 + 盒子
|
||||||
vde::sdf::SdfNode::sphere(1.5),
|
using vde::core::Point3D;
|
||||||
vde::sdf::SdfNode::box(vde::core::Point3D(1,1,1)), 0.3);
|
auto f = [](double x, double y, double z) {
|
||||||
double d = vde::sdf::evaluate(shape, vde::core::Point3D(0,0,0));
|
double d1 = vde::sdf::sphere(Point3D(x,y,z), 1.5);
|
||||||
|
double d2 = vde::sdf::box(Point3D(x,y,z), Point3D(1,1,1));
|
||||||
|
return vde::sdf::op_smooth_union(d1, d2, 0.3);
|
||||||
|
};
|
||||||
|
double val = f(0, 0, 0); // SDF 值:负=内部,正=外部
|
||||||
```
|
```
|
||||||
|
|
||||||
### B-Rep 建模
|
### B-Rep 建模 + 导出
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#include <vde/brep/modeling.h>
|
#include <vde/brep/modeling.h>
|
||||||
|
|
||||||
auto box = vde::brep::make_box(2.0, 2.0, 2.0);
|
|
||||||
auto shelled = vde::brep::shell(box, -1, 0.15);
|
|
||||||
auto result = vde::brep::fillet(shelled, 0, 0.3);
|
|
||||||
```
|
|
||||||
|
|
||||||
### 格式导出
|
|
||||||
```cpp
|
|
||||||
#include <vde/brep/step_export.h>
|
#include <vde/brep/step_export.h>
|
||||||
|
|
||||||
vde::brep::export_step_file("output.stp", {model});
|
auto box = vde::brep::make_box(100, 50, 30); // 100×50×30 mm
|
||||||
|
auto shelled = vde::brep::shell(box, -1, 2.0); // 2mm 抽壳
|
||||||
|
auto result = vde::brep::fillet(shelled, 0, 0.5); // R0.5 倒圆
|
||||||
|
vde::brep::export_step_file("part.stp", {result}); // STEP 导出
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Marching Cubes → STL 打印
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <vde/mesh/marching_cubes.h>
|
||||||
|
#include <vde/mesh/halfedge_mesh.h>
|
||||||
|
|
||||||
|
auto f = [](double x, double y, double z) {
|
||||||
|
return std::sqrt(x*x + y*y + z*z) - 1.0; // 球面 SDF
|
||||||
|
};
|
||||||
|
auto mc = vde::mesh::marching_cubes(f, 0.0,
|
||||||
|
Point3D(-2,-2,-2), Point3D(2,2,2), 30);
|
||||||
|
// mc.vertices + mc.triangles → 三角网格
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 性能基准
|
||||||
|
|
||||||
|
| 操作 | 规模 | 耗时 | 吞吐 |
|
||||||
|
|------|------|------|------|
|
||||||
|
| Bézier 求值 | 100K | 2.64 ms | 38M evals/s |
|
||||||
|
| B-Spline 求值 | 100K | 7.14 ms | 14M evals/s |
|
||||||
|
| BVH 构建 | 500 tris | 73.9 µs | 6.8M tris/s |
|
||||||
|
| Delaunay 2D | 1000 pts | 3.97 ms | 253K pts/s |
|
||||||
|
| R-Tree 构建 | 1000 | 35.7 µs | 28.2M items/s |
|
||||||
|
| 网格布尔 Union | ~500 面 | 9.69 ms | 104 ops/s |
|
||||||
|
|
||||||
|
[完整性能报告 →](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/docs/benchmark-report.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 测试覆盖
|
||||||
|
|
||||||
|
| 类别 | 测试数 |
|
||||||
|
|------|--------|
|
||||||
|
| 核心 + 曲线 + 网格 + 空间 + 碰撞 | ~120 |
|
||||||
|
| B-Rep 建模 + 布尔 + 验证 | ~85 |
|
||||||
|
| STEP 导入/导出 | 31 |
|
||||||
|
| IGES 导入/导出 | 39 |
|
||||||
|
| SDF 隐式建模 (6 模块) | 195 |
|
||||||
|
| NURBS 操作 | 16 |
|
||||||
|
| GLTF/GLB + 3MF | 15 |
|
||||||
|
| 草图约束 | ~10 |
|
||||||
|
| 装配体 | 4 |
|
||||||
|
| **合计** | **~500** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 格式支持
|
||||||
|
|
||||||
|
| 格式 | 导入 | 导出 | 用途 |
|
||||||
|
|------|:--:|:--:|------|
|
||||||
|
| STEP AP203/214 | ✅ | ✅ | 工业 CAD 交换 |
|
||||||
|
| IGES 5.3 | ✅ | ✅ | 传统制造 |
|
||||||
|
| glTF 2.0 / GLB | — | ✅ | 实时 3D / Web |
|
||||||
|
| STL (bin+ASCII) | — | ✅ | 3D 打印 |
|
||||||
|
| 3MF | ✅ | ✅ | 现代 3D 打印 |
|
||||||
|
| OBJ | — | ✅ | 通用网格 |
|
||||||
|
| PLY | ✅ | ✅ | 点云 / 网格 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 文档导航
|
||||||
|
|
||||||
|
- [API 参考手册](Home) — 本 Wiki
|
||||||
|
- [开发计划](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/docs/00-开发计划.md)
|
||||||
|
- [v3.2 计划](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/docs/11-v3.2-开发计划.md)
|
||||||
|
- [性能基准报告](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/docs/benchmark-report.md)
|
||||||
|
- [构建指南](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/docs/06-部署维护/01-构建指南.md)
|
||||||
|
- [更新日志](https://git.hdtime.space/hm/ViewDesignEngine/src/branch/main/CHANGELOG.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 版本历史
|
||||||
|
|
||||||
|
| 版本 | 日期 | 里程碑 |
|
||||||
|
|------|------|--------|
|
||||||
|
| v1.0.0 | 2026-07 | 核心引擎(曲线+网格+空间+碰撞) |
|
||||||
|
| v2.0.0 | 2026-07 | B-Rep + STEP 导入/导出 |
|
||||||
|
| v2.5.0 | 2026-07 | SDF 隐式建模 |
|
||||||
|
| v2.8.0 | 2026-07 | 可微分几何 + Torch 集成 |
|
||||||
|
| v3.0.0 | 2026-07 | IGES + 全线 bugfix (476+ 测试) |
|
||||||
|
| v3.1.0 | 2026-07 | 示例 + NURBS 操作 + MC 修复 |
|
||||||
|
| v3.2.0 | 2026-07 | CI/CD + Python + 3MF + 装配体 |
|
||||||
|
|||||||
Reference in New Issue
Block a user