|
ViewDesignEngine
3.1.0
高性能 CAD 计算几何引擎
|
数学类型、公差系统、精确谓词、文件 I/O、序列化 更多...
类 | |
| class | vde::foundation::Interval |
| 双精度区间算术类 更多... | |
| struct | vde::foundation::GltfOptions |
| glTF 2.0 导出选项 更多... | |
| struct | vde::foundation::ObjMeshData |
| OBJ 文件解析结果数据结构 更多... | |
| struct | vde::foundation::StlTriangle |
| STL 三角形面片 更多... | |
| class | vde::foundation::MemoryPool< T > |
| 固定块大小的内存池 更多... | |
| struct | vde::foundation::Predicates |
| 统一谓词接口 — 编译时选择 GMP 或自适应双精度后端 更多... | |
| struct | vde::foundation::SerializedMesh |
| 二进制序列化格式的网格数据结构 更多... | |
| class | vde::foundation::BinarySerializer |
| 二进制序列化器 更多... | |
| class | vde::foundation::Tolerance |
| 分层容差管理类 更多... | |
| class | vde::foundation::ToleranceScope |
| 局部容差作用域(RAII) 更多... | |
类型定义 | |
| template<typename T , size_t Dim> | |
| using | vde::foundation::Point = Eigen::Matrix< T, Dim, 1 > |
| 通用 N 维点类型(使用 Eigen 列向量) 更多... | |
| template<typename T , size_t Dim> | |
| using | vde::foundation::Vector = Eigen::Matrix< T, Dim, 1 > |
| 通用 N 维向量类型(与 Point 相同的列向量表示) 更多... | |
函数 | |
| Orientation | vde::foundation::exact::orient_2d (const Point2D &a, const Point2D &b, const Point2D &c) |
| 自适应精度二维定向测试(Shewchuk 算法) 更多... | |
| Orientation | vde::foundation::exact::orient_3d (const Point3D &a, const Point3D &b, const Point3D &c, const Point3D &d) |
| 自适应精度三维定向测试 更多... | |
| CircleTest | vde::foundation::exact::in_circle (const Point2D &a, const Point2D &b, const Point2D &c, const Point2D &d) |
| 自适应精度圆内测试(In-Circle Test) 更多... | |
| std::string | vde::foundation::fmt_double (double v, int precision=12) |
| 以 CAD 级别精度格式化双精度浮点数 更多... | |
| std::string | vde::foundation::fmt_iges_real (double v, int=12) |
| IGES 格式实数输出 更多... | |
| std::string | vde::foundation::fmt_point (const core::Point3D &p, bool use_d=false) |
| 格式化三维点为逗号分隔字符串 更多... | |
| std::string | vde::foundation::pad72 (const std::string &s) |
| 将字符串填充到恰好 72 个字符 更多... | |
| std::string | vde::foundation::format_iges_line (const std::string &data, char section_char, int seq) |
| 格式化 IGES 段落行 更多... | |
| Interval | vde::foundation::orient_2d_interval (double ax, double ay, double bx, double by, double cx, double cy) |
| 二维定向行列式的区间验证 更多... | |
| int | vde::foundation::orient_2d_verified (double ax, double ay, double bx, double by, double cx, double cy) |
| 使用区间算术验证 orient_2d 结果 更多... | |
| bool | vde::foundation::write_gltf (const std::string &filepath, const mesh::HalfedgeMesh &mesh, const GltfOptions &options=GltfOptions{}) |
| 导出网格为 glTF 2.0 / GLB 格式 更多... | |
| bool | vde::foundation::write_brep_gltf (const std::string &filepath, const brep::BrepModel &model, int tessellation_res=32) |
| 导出 B-Rep 模型为 GLB 格式(通过面片化) 更多... | |
| ObjMeshData | vde::foundation::read_obj (const std::string &filepath) |
| 读取 Wavefront OBJ 文件 更多... | |
| void | vde::foundation::write_obj (const std::string &filepath, const ObjMeshData &data) |
| 写入 Wavefront OBJ 文件 更多... | |
| mesh::HalfedgeMesh | vde::foundation::read_ply (const std::string &filepath) |
| 读取 PLY 文件(Stanford Polygon Format) 更多... | |
| void | vde::foundation::write_ply (const std::string &filepath, const mesh::HalfedgeMesh &mesh) |
| 写入 PLY 文件(ASCII 格式) 更多... | |
| std::vector< StlTriangle > | vde::foundation::read_stl (const std::string &filepath) |
| 读取 STL 文件(自动检测格式) 更多... | |
| void | vde::foundation::write_stl (const std::string &filepath, const std::vector< StlTriangle > &tris) |
| 写入二进制 STL 文件 更多... | |
| void | vde::foundation::write_stl_ascii (const std::string &filepath, const std::vector< StlTriangle > &tris) |
| 写入 ASCII STL 文件 更多... | |
| exact::Orientation | vde::foundation::orient (const Point2D &a, const Point2D &b, const Point2D &c) |
| 二维定向测试便捷封装 更多... | |
| exact::Orientation | vde::foundation::orient (const Point3D &a, const Point3D &b, const Point3D &c, const Point3D &d) |
| 三维定向测试便捷封装 更多... | |
| exact::CircleTest | vde::foundation::in_circle (const Point2D &a, const Point2D &b, const Point2D &c, const Point2D &d) |
| 圆内测试便捷封装 更多... | |
数学类型、公差系统、精确谓词、文件 I/O、序列化
基础模块提供 VDE 引擎的核心基础设施:
提供整个引擎使用的底层基础设施。
| using vde::foundation::Point = typedef Eigen::Matrix<T, Dim, 1> |
| using vde::foundation::Vector = typedef Eigen::Matrix<T, Dim, 1> |
通用 N 维向量类型(与 Point 相同的列向量表示)
虽然类型相同,但语义上区分几何点(位置)和向量(方向/位移)。
| T | 标量类型 |
| Dim | 维度 |
在文件 math_types.h 第 30 行定义.
|
strong |
|
strong |
全局错误码枚举
VDE 引擎中所有函数可能返回的错误状态码。 成功用 kSuccess(0) 表示,非零值表示各类错误。
在文件 error_codes.h 第 14 行定义.
|
strong |
二维定向测试结果
判断三点构成的三角形的定向(顺时针 / 逆时针 / 共线)。
| 枚举值 | |
|---|---|
| Clockwise | |
| CounterClockwise | |
| Collinear | |
在文件 exact_predicates.h 第 13 行定义.
|
inline |
以 CAD 级别精度格式化双精度浮点数
输出科学计数法字符串,保证 12 位有效数字,满足 CAD 数据交换精度要求。 NaN 被格式化为 "0.0",Inf/ -Inf 被裁剪为安全边界值。
| v | 要格式化的双精度数 |
| precision | 有效数字位数(默认 12) |
在文件 format_utils.h 第 31 行定义.
被这些函数引用 vde::foundation::fmt_iges_real() , 以及 vde::foundation::fmt_point().
|
inline |
IGES 格式实数输出
与 fmt_double() 相同,但使用 IGES 标准的 'D' 指数标记代替 'E'。
| v | 要格式化的双精度数 |
在文件 format_utils.h 第 63 行定义.
引用了 vde::foundation::fmt_double().
被这些函数引用 vde::foundation::fmt_point().
|
inline |
格式化三维点为逗号分隔字符串
输出 "x,y,z" 形式,常用于 IGES/STEP/OBJ 等文本格式的顶点坐标行。
| p | 三维点 |
| use_d | 若为 true,使用 IGES 风格 D 指数标记 |
在文件 format_utils.h 第 88 行定义.
引用了 vde::foundation::fmt_double() , 以及 vde::foundation::fmt_iges_real().
|
inline |
格式化 IGES 段落行
生成一条完整的 IGES 80 列记录行:72 列数据 + 8 列序号(section_char + 7 位数字)。
| data | 数据内容(最多 72 字符,超出截断) |
| section_char | 段落标识符(如 'P' 参数段, 'D' 目录段) |
| seq | 行序号(1-based) |
在文件 format_utils.h 第 130 行定义.
| CircleTest vde::foundation::exact::in_circle | ( | const Point2D & | a, |
| const Point2D & | b, | ||
| const Point2D & | c, | ||
| const Point2D & | d | ||
| ) |
自适应精度圆内测试(In-Circle Test)
判断点 d 是否在三角形 abc 的外接圆内部、边界上或外部。 等价于计算 4×4 行列式的符号。
| a | 三角形第一个顶点 |
| b | 三角形第二个顶点 |
| c | 三角形第三个顶点 |
| d | 待测试点 |
|
inline |
圆内测试便捷封装
| a,b,c | 三角形三顶点 |
| d | 测试点 |
在文件 predicates.h 第 100 行定义.
|
inline |
二维定向测试便捷封装
使用 Predicates::orient_2d,无需指定后端。 这是推荐的对外 API。
| a,b,c | 三个二维点 |
在文件 predicates.h 第 74 行定义.
|
inline |
三维定向测试便捷封装
| a,b,c | 定义平面的三点 |
| d | 测试点 |
在文件 predicates.h 第 87 行定义.
| Orientation vde::foundation::exact::orient_2d | ( | const Point2D & | a, |
| const Point2D & | b, | ||
| const Point2D & | c | ||
| ) |
自适应精度二维定向测试(Shewchuk 算法)
判断点 a, b, c 的定向。使用自适应浮点精度: 先用双精度计算行列式,若结果不可靠则逐步提高精度,直至确定符号。
| a | 第一个点 |
| b | 第二个点 |
| c | 第三个点 |
被这些函数引用 vde::foundation::AdaptiveDouble::orient_2d() , 以及 vde::foundation::Predicates::orient_2d().
|
inline |
二维定向行列式的区间验证
用区间算术计算 orient_2d 行列式,结果区间用于判断双精度是否可靠。
| ax,ay | 点 a 的坐标 |
| bx,by | 点 b 的坐标 |
| cx,cy | 点 c 的坐标 |
在文件 interval.h 第 200 行定义.
|
inline |
使用区间算术验证 orient_2d 结果
若双精度计算结果接近零,调用此函数进行区间验证。 若区间不跨越零,则结果可靠;否则需要升级到精确算术。
| ax,ay | 点 a 的坐标 |
| bx,by | 点 b 的坐标 |
| cx,cy | 点 c 的坐标 |
在文件 interval.h 第 232 行定义.
引用了 vde::foundation::Interval::cmp() , 以及 vde::foundation::orient_2d_interval().
| Orientation vde::foundation::exact::orient_3d | ( | const Point3D & | a, |
| const Point3D & | b, | ||
| const Point3D & | c, | ||
| const Point3D & | d | ||
| ) |
自适应精度三维定向测试
判断点 a, b, c, d 的定向(即点 d 在平面 abc 的哪一侧)。 等价于计算四面体 abcd 的有向体积的符号。
| a | 第一个点 |
| b | 第二个点 |
| c | 第三个点 |
| d | 第四个点(测试点) |
被这些函数引用 vde::foundation::AdaptiveDouble::orient_3d() , 以及 vde::foundation::Predicates::orient_3d().
|
inline |
将字符串填充到恰好 72 个字符
IGES 格式中每条数据行固定为 72 字符宽。不足用空格补齐,超出则截断。
| s | 输入字符串 |
在文件 format_utils.h 第 105 行定义.
被这些函数引用 vde::foundation::format_iges_line().
| ObjMeshData vde::foundation::read_obj | ( | const std::string & | filepath | ) |
读取 Wavefront OBJ 文件
解析 ASCII OBJ 文件,支持以下 OBJ 特性:
| filepath | OBJ 文件路径 |
| std::runtime_error | 若文件无法打开或格式错误 |
| mesh::HalfedgeMesh vde::foundation::read_ply | ( | const std::string & | filepath | ) |
读取 PLY 文件(Stanford Polygon Format)
解析 PLY 格式文件,支持 ASCII 和二进制(小端序)两种编码。 支持的 PLY 元素:vertex(位置、法线、颜色)、face(顶点索引列表)。
| filepath | PLY 文件路径 |
| std::runtime_error | 若文件无法打开、格式不支持或数据损坏 |
| std::vector<StlTriangle> vde::foundation::read_stl | ( | const std::string & | filepath | ) |
读取 STL 文件(自动检测格式)
通过检查文件头部的 80 字节判断二进制(含 triangle count) 还是 ASCII(以 "solid" 开头)格式,然后选择对应解析器。
| filepath | STL 文件路径 |
| std::runtime_error | 若文件无法打开或格式无效 |
| bool vde::foundation::write_brep_gltf | ( | const std::string & | filepath, |
| const brep::BrepModel & | model, | ||
| int | tessellation_res = 32 |
||
| ) |
导出 B-Rep 模型为 GLB 格式(通过面片化)
将 B-Rep 模型的参数曲面离散化为三角网格后导出为 GLB。 曲面通过 tessellation_res 控制离散精度。
| filepath | 输出文件路径(建议 .glb) |
| model | 要导出的 B-Rep 模型 |
| tessellation_res | 每条边的离散段数(默认 32),越大越精确 |
| bool vde::foundation::write_gltf | ( | const std::string & | filepath, |
| const mesh::HalfedgeMesh & | mesh, | ||
| const GltfOptions & | options = GltfOptions{} |
||
| ) |
导出网格为 glTF 2.0 / GLB 格式
将 HalfedgeMesh 写入 glTF 2.0 规范文件。默认输出单文件 GLB 二进制格式, 可通过 GltfOptions 控制输出格式和包含的属性。
| filepath | 输出文件路径(.glb 或 .gltf) |
| mesh | 要导出的半边网格 |
| options | 导出选项(格式、法线、颜色等) |
| void vde::foundation::write_obj | ( | const std::string & | filepath, |
| const ObjMeshData & | data | ||
| ) |
写入 Wavefront OBJ 文件
将 ObjMeshData 以 ASCII OBJ 格式写出,包含顶点、纹理坐标、 法线和面信息。材质名称通过注释嵌入。
| filepath | 输出文件路径 |
| data | 要写出的网格数据 |
| void vde::foundation::write_ply | ( | const std::string & | filepath, |
| const mesh::HalfedgeMesh & | mesh | ||
| ) |
写入 PLY 文件(ASCII 格式)
将半边网格以 ASCII PLY 格式写出,包含顶点位置和面信息。
| filepath | 输出文件路径 |
| mesh | 要导出的半边网格 |
| void vde::foundation::write_stl | ( | const std::string & | filepath, |
| const std::vector< StlTriangle > & | tris | ||
| ) |
写入二进制 STL 文件
以紧凑的二进制格式写出 STL 三角形列表。 二进制 STL 为业界标准交换格式,文件体积小、读写快。
| filepath | 输出文件路径 |
| tris | 三角形面片列表 |
| void vde::foundation::write_stl_ascii | ( | const std::string & | filepath, |
| const std::vector< StlTriangle > & | tris | ||
| ) |
写入 ASCII STL 文件
以人类可读的 ASCII 文本格式写出 STL,便于调试和手动编辑。
| filepath | 输出文件路径 |
| tris | 三角形面片列表 |