Files
ViewDesignEngine/docs/reference
茂之钳 99d38e2453
Build & Test / build-and-test (push) Has been cancelled
VDE Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
fix: P0 stubs — 4 files rewritten from shells to real implementations
exact_offset.cpp (269 lines): NURBS sampling + normal offset + least-squares fit
flexible_assembly.cpp (161 lines): joint transforms via direct_modeling
fastener_library.cpp (346 lines): bolt/nut/washer + threaded_hole via boolean
defeature.cpp (334 lines): face deletion + hole filling + fillet removal

Total: 1110 lines, 0 compile errors
2026-08-02 15:55:32 +08:00
..

ViewDesignEngine API 参考文档

版本: 1.0.1 | 分支: docs/api-refresh | 语言: C++17

📚 文档索引

模块 文档 说明
总览 README.md 本文档,模块索引总览
core api-reference-core.md 核心几何模块:矩阵、变换、基础图元、表达式求解、CAM、平台抽象
brep api-reference-brep.md B-Rep 边界表示模块(60+头文件):建模、阵列、约束、剖面、标注、HLR、视口、捕捉、结构型材
curves api-reference-curves.md 曲线曲面模块:NURBS 曲线/曲面、曲面工具、continuity、offset 等
foundation api-reference-foundation.md 基础 IO 模块:25+种格式的导入导出(glTF/DXF/DWG/STL/JT/Parasolid/ACIS/IFC 等)
mesh api-reference-mesh.md 网格模块:mesh→曲线转换、点云(E57/LAS)、网格曲面混合
spatial api-reference-spatial.md 空间索引模块:BVH 加速结构、射线查询、KNN、范围查询
C API api-reference-capi.md C 语言边界接口:跨语言 FFI(Python/Rust/C#/JS)
格式支持 format-support.md 22 种 CAD 格式支持表:版本、导入/导出状态、备注
变更日志 changelog.md 近期 API 新增、修改和废弃记录

🏗️ 项目架构

ViewDesignEngine (vde)
├── core/          核心几何与CAM
│   ├── 基础数学: Matrix4D, Transform3D, Point, Vector, Plane, Line, Ray
│   ├── 几何图元: AABB, Triangle, Polygon2D, ConvexHull
│   ├── 空间计算: Distance, ClosestPoint, ICP, Voronoi
│   ├── CAM 加工: Toolpath, Contour, Pocket, Roughing, Finishing, 5-Axis
│   ├── 表达式: evaluate_expression (参数化设计)
│   └── 平台: load_library, find_symbol, make_temp_file
├── 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
│   ├── 视口/渲染: camera_matrix, bounding_sphere, frustum_cull, hlr_edges
│   ├── 标注: linear_dimension, angular_dimension, radial_dimension
│   ├── 约束: constraint_solver, 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
│   ├── 曲面混合: fillet, chamfer, shell, draft (mesh_blend)
│   ├── 点云: 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
└── sdf/           有符号距离场
    ├── sdf_primitives, sdf_operations, sdf_to_mesh, sdf_gradient

🚀 快速开始

基础几何操作

#include <vde/core/point.h>
#include <vde/core/matrix4d.h>
#include <vde/core/transform.h>

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 建模

#include <vde/brep/modeling.h>

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);

文件导入导出

#include <vde/foundation/io_gltf.h>
#include <vde/foundation/io_dxf.h>

// 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::io
  • 值语义: 所有建模函数返回新对象,不修改输入
  • 坐标系统: 右手坐标系,Z 轴向上(默认)
  • 角度: 弧度制(除特殊标注外)
  • 容差: 默认 1e-6
  • 返回约定: 无异常时返回有效值,失败时通过 std::optional 或空对象表示