135 lines
3.7 KiB
Markdown
135 lines
3.7 KiB
Markdown
# ViewDesignEngine API 参考手册
|
||
|
||
> v1.0.1 · 24 模块(13 内核 + 11 独立业务) · 完整 API 文档见 [Doxygen](api/html/index.html)
|
||
|
||
## 模块索引
|
||
|
||
| 模块 | 命名空间 | 核心类/函数 |
|
||
|------|---------|-----------|
|
||
| **foundation** | `vde::foundation` | `ToleranceConfig`, `import_gltf`, `import_dxf`, `import_stl`(工业格式见 `vde::io`) |
|
||
| **core** | `vde::core` | `Point3D`, `Vector3D`, `AABB3D`, `Matrix4D`, `ObjectPool<T>` |
|
||
| **compute** | `vde::compute` | `ComputeBackend`, `CpuSimdComputeBackend`, `CudaComputeBackend`(可选) |
|
||
| **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_2d`, `mesh_union` |
|
||
| **collision** | `vde::collision` | `gjk_intersect`, `ray_intersect_triangle` |
|
||
| **brep** | `vde::brep` | `BrepModel`, `make_box`, `brep_union`, `validate`, `import_step` |
|
||
| **sdf** | `vde::sdf` | `SdfNode`, `evaluate`, `sdf_to_mesh` |
|
||
| **sketch** | `vde::sketch` | `ConstraintSolver` |
|
||
| **cam** | `vde::cam` | `Tool`, `ToolLibrary`, `roughing_toolpath`, `FanucPost` |
|
||
| **capi** | C ABI(`extern "C"`,无 C++ 命名空间) | `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); // ValidationResult
|
||
|
||
// 直接建模
|
||
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);
|
||
```
|
||
|
||
## 曲线曲面 (`vde::curves`)
|
||
|
||
```cpp
|
||
// 求值
|
||
Point3D p = surf.evaluate(u, v);
|
||
Vector3D n = surf.normal(u, v);
|
||
|
||
// 分析
|
||
auto cmap = curvature_map(surf, 64, 64);
|
||
auto cont = surface_continuity(a, b, edge);
|
||
|
||
// 生成
|
||
auto swept = sweep_surface(profile, path);
|
||
auto lofted = loft_surface(sections);
|
||
auto netted = net_surface(u_curves, v_curves);
|
||
```
|
||
|
||
## 网格 (`vde::mesh`)
|
||
|
||
```cpp
|
||
// 简化
|
||
auto simplified = simplify_mesh(mesh); // 第二参数 SimplifyOptions{}(目标比例等)
|
||
|
||
// MC(等值面提取,返回 MCMesh)
|
||
auto mc = marching_cubes(f, 0.0, {-2,-2,-2}, {2,2,2}, 64);
|
||
|
||
// FEA
|
||
auto tets = tetrahedral_mesh(body, TetMeshParams{});
|
||
auto hex = mapped_hex_mesh(body, src, tgt);
|
||
```
|
||
|
||
## 格式 IO (`vde::foundation`)
|
||
|
||
```cpp
|
||
// STEP(vde::brep)
|
||
auto bodies = import_step("input.step"); // std::vector<BrepModel>
|
||
export_step_file("output.step", bodies);
|
||
|
||
// IGES
|
||
auto bodies = import_iges("input.igs");
|
||
|
||
// 工业格式(vde::io,industrial_formats.h)
|
||
auto body = io::import_parasolid_xt("model.x_t");
|
||
auto body = io::import_acis_sat("model.sat");
|
||
auto body = io::import_jt("model.jt");
|
||
```
|
||
|
||
## CAM (`vde::cam`)
|
||
|
||
```cpp
|
||
Tool tool{ToolType::ENDMILL, 10.0, 4, 50.0};
|
||
|
||
auto rough = roughing_toolpath(body, tool, {});
|
||
auto finish = finishing_toolpath(body, tool, {});
|
||
auto drill = drilling_toolpath(points, tool, DrillingCycle::G83);
|
||
|
||
FanucPost post;
|
||
auto gcode = post.post_process(toolpath);
|
||
```
|
||
|
||
---
|
||
|
||
> 完整 API 文档请查看 [Doxygen HTML](api/html/index.html)
|