Files
ViewDesignEngine/docs/reference/API-REFERENCE.md
T

133 lines
3.2 KiB
Markdown
Raw Normal View History

# ViewDesignEngine API 参考手册
2026-07-27 15:00:57 +08:00
> v1.0.0-rc.1 · 11 模块 · 完整 API 文档见 [Doxygen](api/html/index.html)
## 模块索引
| 模块 | 命名空间 | 核心类/函数 |
|------|---------|-----------|
| **foundation** | `vde::foundation` | `ToleranceConfig`, `import_step_file`, `export_step_file` |
| **core** | `vde::core` | `Point3D`, `Vector3D`, `AABB3D`, `Tool`, `ObjectPool<T>` |
| **curves** | `vde::curves` | `NurbsCurve`, `NurbsSurface`, `sweep_surface`, `loft_surface` |
| **mesh** | `vde::mesh` | `HalfedgeMesh`, `marching_cubes`, `tetrahedral_mesh` |
| **spatial** | `vde::spatial` | `BVH`, `Octree`, `KDTree`, `RTree` |
| **boolean** | `vde::boolean` | `boolean_union_2d`, `mesh_union` |
| **collision** | `vde::collision` | `gjk_intersect`, `ray_intersect_triangle` |
| **brep** | `vde::brep` | `BrepModel`, `make_box`, `brep_union`, `validate` |
| **sdf** | `vde::sdf` | `SdfNode`, `evaluate`, `sdf_to_mesh` |
| **sketch** | `vde::sketch` | `ConstraintSolver` |
| **capi** | `vde::capi` | C API `vde_*` 函数 |
## 基础类型 (`vde::core`)
```cpp
// 3D 点
Point3D p(1.0, 2.0, 3.0);
double x = p.x(), y = p.y(), z = p.z();
// 3D 向量
Vector3D v = p2 - p1;
double len = v.norm();
Vector3D n = v.normalized();
double dot = a.dot(b);
Vector3D cross = a.cross(b);
// 包围盒
AABB3D box(p_min, p_max);
box.expand(point);
bool hit = box.intersects(other);
auto center = box.center();
```
## B-Rep 建模 (`vde::brep`)
```cpp
// 创建
auto box = make_box(2, 3, 4);
auto cyl = make_cylinder(1.5, 6, 32);
auto sphere = make_sphere(2, 32, 16);
// 布尔
auto result = brep_union(a, b);
auto result = brep_intersection(a, b);
auto result = brep_difference(a, b);
// 修复
heal_topology(body);
auto report = validate(body); // ValidationReport
// 直接建模
push_pull(body, face_id, 5.0);
tweak_face(body, face_id, 2.0);
// 转换
auto mesh = body.to_mesh(0.01); // HalfedgeMesh
auto bb = body.bounds(); // AABB3D
size_t n = body.num_faces();
const auto& f = body.face(id);
```
2026-07-27 15:00:57 +08:00
## 曲线曲面 (`vde::curves`)
2026-07-27 15:00:57 +08:00
```cpp
// 求值
Point3D p = surf.evaluate(u, v);
Vector3D n = surf.normal(u, v);
2026-07-27 15:00:57 +08:00
// 分析
auto cmap = curvature_map(surf, 64, 64);
auto cont = surface_continuity(a, b, edge);
2026-07-27 15:00:57 +08:00
// 生成
auto swept = sweep_surface(profile, path);
auto lofted = loft_surface(sections);
auto netted = net_surface(u_curves, v_curves);
```
2026-07-27 15:00:57 +08:00
## 网格 (`vde::mesh`)
2026-07-27 15:00:57 +08:00
```cpp
// 简化
auto simplified = simplify_mesh(mesh, 0.5);
2026-07-27 15:00:57 +08:00
// MC
auto mesh = marching_cubes(sdf, bounds, 64);
2026-07-27 15:00:57 +08:00
// FEA
auto tets = tetrahedral_mesh(body, TetraParams{});
auto hex = mapped_hex_mesh(body, src, tgt);
```
2026-07-27 15:00:57 +08:00
## 格式 IO (`vde::foundation`)
2026-07-27 15:00:57 +08:00
```cpp
// STEP
auto body = import_step_file("input.step");
export_step_file(body, "output.step");
2026-07-27 15:00:57 +08:00
// IGES
auto body = import_iges_file("input.igs");
2026-07-27 15:00:57 +08:00
// 工业格式
auto body = import_parasolid_xt("model.x_t");
auto body = import_acis_sat("model.sat");
auto body = import_jt("model.jt");
```
2026-07-27 15:00:57 +08:00
## CAM (`vde::core`)
2026-07-27 15:00:57 +08:00
```cpp
Tool tool{ToolType::ENDMILL, 10.0, 4, 50.0};
2026-07-27 15:00:57 +08:00
auto rough = roughing_toolpath(body, tool, {});
auto finish = finishing_toolpath(body, tool, {});
auto drill = drilling_toolpath(points, tool, {5, 10});
2026-07-27 15:00:57 +08:00
FanucPost post;
auto gcode = post.generate(toolpath);
```
2026-07-27 15:00:57 +08:00
---
2026-07-27 15:00:57 +08:00
> 完整 API 文档请查看 [Doxygen HTML](api/html/index.html)