第三轮(第一轮审查报告剩余内核问题):
- VDE-1246(新发现 High):布尔结果面朝向矛盾但 validate valid、体积错误。
新增 OrientationConsistency + orientation_consistency()(流形边方向不变量);
validate(strict_orientation) 严格模式(默认语义不变);fix_shell_orientation_strict()
(嵌套内环岛面拆分 + 边奇偶 BFS + 分量体积/嵌套深度定号);heal_shell_orientation 收尾调用;
brep_union/intersection/difference 返回前 finalize_boolean_orientation(仅不一致时修复,正常零开销)。
环形槽 fixture:32 同向边/33 面 → 0/0;71→72 面;体积 62610.69 → 65607.280328(rel 4.4e-16);
开口保持 2 环、无桥接面;网格体积 rel 4.4e-16。
- VDE-1239 §1:根因=凹形单环平面面固定顶点扇形三角化(U 形 800mm² → 1100/+37.5%、越界/重叠/零面积)
→ 新增 triangulate_planar_ring() ear-clipping(失败回退 CDT),平面单环快路径改用耳切;
新增 DisplayMesh::degenerate_triangles/duplicate_triangles 诊断。合成 n42 形态 51 面:面积比 1.0000237、
重叠/重复/零面积 0;全平面 boolean 链总面积 vs 解析 ≤1e-6。跨面 T-junction 残缝未缝合(诊断+建议)。
- VDE-1242:CapKind{kPlanar,kFitted3D} + 非平面开口 fitted3d 3D 封口(边界顶点真实 3D、cap 距 rim=0、
watertight、网格开边 0、体积 1666.7 vs 平面近似 1083.9);even-odd 任意深度嵌套(depth≤2 实测:
空腔体积 8011.9256 精确、openings=2、loops=3、cap 面积解析一致)。
- C API 显示选项全暴露:VdeDisplayOptions/VdeWireframeOptions + vde_body_to_display_mesh_opt/
vde_body_to_wireframe_opt(quality/expected_faces/open_edge_weld_tolerance/merge_tolerance/
tangent_angle/include_hidden;opt=NULL 默认;旧 ABI 不变);Python ctypes 同步;display 17/17。
工程健壮性(R3 验证发现):
- ParallelTaskGraph 依赖完成语义修复(真实缺陷:锁内先置 completed 再执行 func,依赖任务可能提前执行);
改 dispatched + 函数返回后置 completed + cv 唤醒;压测 100/100。
- HLR perf 用例改为 best-of-2 + 绝对预算 1500ms(保留历史基线比值打印),消除负载假阳性;
HLR 10/10。
- CI 各 job 增加 timeout-minutes(build 90/TSan 90/ASan 120/Valgrind 60/Coverage 90/Perf 60)。
- 版本 1.0.23 全链路一致。
验证(docs/reference/54 独立验证报告):
- 全量 ctest:Lead 7206/7206 PASS(0 failed、22 skipped、388.95s);verifier 独立构建 7206/7206 PASS
(0 failed、0 timeout、393.9s);R3 独立探针 162/162;独立全量构建 898/898、0 error;
R3 变更文件 0 新增 warning。
ViewDesignEngine API 参考文档
版本: 1.0.1 | 分支: main | 语言: C++20
📚 文档索引
| 模块 | 文档 | 说明 |
|---|---|---|
| 总览 | 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 模块:22 种格式的导入导出(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/ 核心几何与计算
│ ├── 基础数学: 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(原生识别+转换通道+插件), 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)
🚀 快速开始
基础几何操作
#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::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或空对象表示