Files
ViewDesignEngine/include/vde/brep/iges_export.h
T
2026-07-24 11:09:45 +00:00

88 lines
3.2 KiB
C++
Raw 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.
#pragma once
/**
* @file iges_export.h
* @brief IGES 文件导出(版本 5.3
*
* 将 B-Rep 模型序列化为 IGES 格式。IGES 5.3 是广泛兼容的版本,
* 支持 B-Rep 拓扑结构和常见解析曲面类型。
*
* ## 输出格式
*
* 产生的 IGES 文件遵循 ANSI Y14.26M 标准,使用固定宽度 80 字符记录格式。
* 兼容于大多数 CAD 系统的 IGES 导入器。
*
* ## 输出的实体类型
*
* | 类型号 | 实体名 | 说明 |
* |--------|----------------------------|---------------------|
* | 116 | Point | 三维点 |
* | 110 | Line | 直线段 |
* | 100 | Circular Arc | 圆弧 |
* | 126 | Rational B-Spline Curve | 有理 B 样条曲线 |
* | 108 | Plane | 平面 |
* | 128 | Rational B-Spline Surface | 有理 B 样条曲面 |
* | 502 | Vertex | B-Rep 顶点 |
* | 504 | Edge | B-Rep 边 |
* | 508 | Loop | B-Rep 环 |
* | 510 | Face | B-Rep 面 |
* | 514 | Shell | B-Rep 壳 |
* | 186 | Manifold Solid B-Rep Object | B-Rep 实体 |
*
* @ingroup brep
*/
#include "vde/brep/brep.h"
#include <string>
#include <vector>
namespace vde::brep {
/**
* @brief 将 B-Rep 体导出为 IGES 格式字符串(版本 5.3)
*
* 序列化所有传入的体及其几何/拓扑数据为 IGES 固定宽度格式。
*
* **输出结构:**
* ```
* S 1H,,1H;, ... S0000001
* G ... G0000003
* D 116,1,2,... (Point entity) D0000001
* D 110,3,4,... (Line entity) D0000002
* ... ...
* P 116,0.,0.,0.; 1P0000001
* P 110,0.,0.,0.,1.,0.,0.; 3P0000002
* T 1 T0000001
* ```
*
* ## 实体输出策略
*
* 1. **几何实体**(点/线/弧/曲线/面/曲面)先输出并使 Directory 条目索引递增
* 2. **拓扑实体**(顶点/边/环/面/壳/B-Rep Object)随后输出,通过索引引用于几何实体
* 3. 如果体有 name,作为 B-Rep Object 的属性输出
*
* @param bodies B-Rep 体列表
* @return IGES 5.3 格式字符串
*
* @code{.cpp}
* auto body = make_box(10, 5, 3);
* std::string iges_str = export_iges({body});
* @endcode
*
* @see export_iges_file 直接写入文件
* @see export_step STEP 格式导出
*/
[[nodiscard]] std::string export_iges(const std::vector<BrepModel>& bodies);
/**
* @brief 将 B-Rep 体导出为 IGES 文件
*
* 调用 export_iges() 后写入文件。
*
* @param filepath 输出文件路径(建议扩展名 .igs 或 .iges
* @param bodies B-Rep 体列表
*
* @see export_iges 获取字符串输出
*/
void export_iges_file(const std::string& filepath, const std::vector<BrepModel>& bodies);
} // namespace vde::brep