# ViewDesignEngine API 参考文档 > **版本**: 1.0.1 | **分支**: main | **语言**: C++20 ## 📚 文档索引 | 模块 | 文档 | 说明 | |------|------|------| | **总览** | [README.md](README.md) | 本文档,模块索引总览 | | **core** | [api-reference-core.md](api-reference-core.md) | 核心几何模块:矩阵、变换、基础图元、表达式求解、CAM、平台抽象 | | **brep** | [api-reference-brep.md](api-reference-brep.md) | B-Rep 边界表示模块(60+头文件):建模、阵列、约束、剖面、标注、HLR、视口、捕捉、结构型材 | | **curves** | [api-reference-curves.md](api-reference-curves.md) | 曲线曲面模块:NURBS 曲线/曲面、曲面工具、continuity、offset 等 | | **foundation** | [api-reference-foundation.md](api-reference-foundation.md) | 基础 IO 模块:22 种格式的导入导出(glTF/DXF/DWG/STL/JT/Parasolid/ACIS/IFC 等) | | **mesh** | [api-reference-mesh.md](api-reference-mesh.md) | 网格模块:mesh→曲线转换、点云(E57/LAS)、重建与处理 | | **spatial** | [api-reference-spatial.md](api-reference-spatial.md) | 空间索引模块:BVH 加速结构、射线查询、KNN、范围查询 | | **C API** | [api-reference-capi.md](api-reference-capi.md) | C 语言边界接口:跨语言 FFI(Python/Rust/C#/JS) | | **格式支持** | [format-support.md](format-support.md) | 22 种 CAD 格式支持表:版本、导入/导出状态、备注 | | **变更日志** | [changelog.md](changelog.md) | 近期 API 新增、修改和废弃记录 | --- ## 🏗️ 项目架构 ``` ViewDesignEngine (vde) ├── core/ 核心几何与计算 │ ├── 基础数学: Matrix4D, Transform3D, Point, Vector, Plane, Line, Ray │ ├── 几何图元: AABB, Triangle, Polygon2D, ConvexHull │ └── 空间计算: Distance, ClosestPoint, ICP, Voronoi ├── brep/ B-Rep 边界表示 │ ├── 核心数据: BrepModel (顶点/边/面/壳/体) │ ├── 建模: extrude, revolve, sweep, loft, fillet, chamfer, shell │ ├── 基本体: make_box, cylinder, sphere, cone, torus │ ├── 齿轮/弹簧: make_spur_gear, helical_gear, spring │ ├── 型材: I-beam, C-channel, angle, tube, weld_bead │ ├── 阵列/镜像: linear_pattern, circular_pattern, mirror_body_pattern │ ├── 布尔: brep_union, intersect, subtract, assembly_boolean │ ├── 截面/裁剪: section_plane, clip_body, cross_section_extents │ ├── HLR/标注: hlr_edges, linear_dimension, angular_dimension, radial_dimension │ ├── 约束: constraint_solver (3D 装配), assembly_constraints │ └── PMI/MBD: PMI 产品制造信息标注 ├── curves/ 曲线曲面 │ ├── NURBS: NurbsCurve, NurbsSurface (工厂方法: line/circle/arc/helix/plane/box) │ ├── Bézier: BezierCurve, BezierSurface │ ├── B-Spline: BSplineCurve, BSplineSurface │ ├── 曲面工具: thicken_surface, sew_surfaces, boundary_surface, fill_surface │ └── 连续性/延伸/编辑: surface_continuity, surface_extension, surface_editing ├── foundation/ IO 格式 │ ├── 网格格式: STL, OBJ, PLY, glTF/GLB, 3MF, VRML, AMF, COLLADA │ ├── CAD 格式: STEP, IGES, DXF, DWG(plugin), Parasolid XT, ACIS SAT, JT │ ├── BIM 格式: IFC │ ├── 点云格式: E57, LAS/LAZ (via PointCloud) │ └── PDF 3D, STEP AP242 (PMI) ├── mesh/ 网格处理 │ ├── HalfedgeMesh (半边数据结构) │ ├── mesh→curve 桥接: mesh_boundary_to_curve, mesh_contour_to_curves │ ├── 重建/展开: delaunay_2d, flattening, geodesic_distance │ ├── 点云: PointCloud (E57/LAS/PLY/PTX 加载,降采样,法线估计) │ └── 处理: simplify, smooth, repair, parameterize, boolean, marching_cubes ├── spatial/ 空间索引 │ ├── BVH: 包围盒层次结构 (SAH 构建,射线/范围/KNN 查询) │ ├── Octree, KDTree, RTree │ └── B-Rep 级空间查询: ray_cast_multi, face_adjacency, spatial_index ├── capi/ C 语言接口 │ └── vde_capi.h: 上下文、网格、曲线、约束求解、B-Rep、SDF、Assembly ├── collision/ 碰撞检测 │ └── GJK, SAT, Ray-Intersect, Triangle-Intersect ├── boolean/ 二维布尔 │ └── boolean_2d, polygon_offset ├── sketch/ 草图约束 │ └── constraint_solver (2D 草图) ├── sdf/ 有符号距离场 │ └── sdf_primitives, sdf_operations, sdf_to_mesh, sdf_gradient ├── compute/ 计算后端 (vde::compute) │ └── ComputeBackend, CpuSimdComputeBackend, CudaComputeBackend (可选,未启用时回退 CPU SIMD) └── 独立业务模块(非几何职责,从内核拆分) ├── cam/ CAM 加工 (vde::cam): Toolpath, Contour, Pocket, Roughing, Finishing, 5-Axis ├── expression/ 表达式 (vde::expression): evaluate_expression (参数化设计) ├── platform/ 平台抽象 (vde::platform): load_library, find_symbol, make_temp_file ├── ui/ 视口/交互 (vde::ui): viewport_api, gizmo_api, selection_manager ├── render/ 渲染 (vde::render) ├── event/ 更新通知 (vde::event) ├── drafting/ 制图标准 (vde::drafting) ├── mechanism/ 机构运动 (vde::mechanism) ├── pdm/ BOM/物料 (vde::pdm) ├── param/ 参数管理 (vde::param) ├── license/ 许可证 (vde::license) └── infra/ 基础设施 (vde::infra) ``` --- ## 🚀 快速开始 ### 基础几何操作 ```cpp #include #include #include using namespace vde::core; // 矩阵变换 auto T = Matrix4D::Translation(10, 0, 0); auto R = Matrix4D::RotationZ(M_PI / 4); auto S = Matrix4D::Scale(2, 2, 2); Point3D p(1, 2, 3); Point3D tp = (T * R * S).transform_point(p); ``` ### B-Rep 建模 ```cpp #include using namespace vde::brep; auto box = make_box(10, 5, 3); auto cylinder = make_cylinder(2, 10); auto gear = make_spur_gear(2.5, 20, 10, 20.0); auto spring = make_spring(20, 3, 10, 80, SpringType::Compression); ``` ### 文件导入导出 ```cpp #include #include // glTF 导入 auto result = foundation::import_gltf("model.glb"); // DXF 导入 auto doc = foundation::import_dxf("drawing.dxf"); ``` --- ## 📝 约定 - **命名空间**: `vde::core`, `vde::brep`, `vde::curves`, `vde::foundation`, `vde::mesh`, `vde::spatial`, `vde::boolean`, `vde::collision`, `vde::sdf`, `vde::compute`, `vde::io`, `vde::cam`, `vde::expression`, `vde::platform`, `vde::ui`, `vde::render` 等(`vde::sketch` 已移出公共 API 面,见 VDE-1201) - **值语义**: 所有建模函数返回新对象,不修改输入 - **坐标系统**: 右手坐标系,Z 轴向上(默认) - **角度**: 弧度制(除特殊标注外) - **容差**: 默认 `1e-6` - **返回约定**: 无异常时返回有效值,失败时通过 `std::optional` 或空对象表示