Files
hm dcfc716b3e refactor(brep/arch)!: 修复反馈 D 组 d1 VDE-1201 — 内嵌 2D 约束求解器移出公共 API 面与 C ABI
背景:VDE 内嵌的 2D 草图约束求解器违反"几何内核不含求解器"的分层共识
(Parasolid 不调用 DCM),与宿主侧专职求解器 VDCS 并存造成词表裂缝
(VDE-1199 根因)、行为分裂、双状态机与长期维护负担。按反馈方案 A 处理:
从公共 API 面与 C ABI 移除,代码保留为内部/测试实现。

变更:
- 头文件移出公共面:include/vde/sketch/constraint_solver.h 经 git mv 迁至
  src/sketch/constraint_solver.h(保留历史),顶部加注为内部实现;目录
  include/vde/sketch/ 不再存在。
- C ABI 移除:src/capi/vde_capi.cpp 删除 vde_solver_* 全部 9 个实现;
  include/vde/capi/vde_capi.h 删除 VdeSolverHandle typedef、句柄对照表行
  与"约束求解器(二维草图)"整节;include/vde/vde.h 删除同名前向声明与
  "// ── 约束求解 ──" 整节。
- 构建图降级:聚合目标 vde 不再 INTERFACE vde_sketch;vde_capi 不再链接
  vde_sketch;vde_sketch 的 include 目录改 PRIVATE 并标注为内部模块。
- 测试迁移:tests/sketch 两个测试改为直取私有头并显式链接 vde_sketch;
  tests/capi 移除 SolverCreateAndAddPoint / FreeSolverNullSafe / CreateSolver。
- 顺带修复既有缺陷:vde_load_mesh 对不存在路径/不支持格式/解析异常/0 顶点
  不再返回非空"空网格句柄"(假成功),改为返回 NULL 并写 last_error——
  修复 tests/capi/test_vde_capi.cpp LoadMeshInvalidPath 长期失败。
- 文档同步:feedback/VDE-1201 标记 fixed;guides/reference 中 sketch 模块
  的公共面描述改为内部模块说明。

验证:test_constraint_solver 30/30、test_sketch_ops 11/11、
test_vde_capi 6/6、test_capi_extended 10/10;全量构建 360/360 目标成功,
无 error / undefined reference。

BREAKING CHANGE: vde_solver_* C ABI 与 VdeSolverHandle 已移除,
vde::sketch 不再属公共 API 面。宿主侧约束求解请统一使用 VDCS;
FeatureBuilderTools::sketchAdd* 的 VDE backend 分支需宿主自行迁移(宿主侧工作)。
2026-09-11 00:26:33 +08:00

135 lines
3.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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`~~ | 已移出公共 API 面(VDE-1201),转内部实现 |
| **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)