#pragma once /** * @file dxf_import.h * @brief DXF 文件导入(AutoCAD R12+ 兼容) * * 解析 DXF 格式的 2D 图形,转换为 B-Rep 轮廓。 * 支持的实体类型:LINE, CIRCLE, ARC, LWPOLYLINE, SPLINE, POLYLINE * * @ingroup brep */ #include "vde/brep/brep.h" #include "vde/core/point.h" #include #include namespace vde::brep { /// 2D 轮廓点(用于拉伸生成体) struct DxfContour { std::string layer; ///< 图层名称 std::vector points; ///< 轮廓点序列(Z=0) bool closed = false; ///< 是否闭合 }; /// DXF 导入结果 struct DxfImportResult { std::vector contours; ///< 提取的 2D 轮廓 std::vector layers; ///< 所有图层名称 int entities_parsed = 0; ///< 成功解析的实体数 int entities_skipped = 0; ///< 跳过的实体数 }; /// 导入 DXF 文件,提取 2D 轮廓 /// @param filepath .dxf 文件路径 /// @return 轮廓列表 + 统计信息 [[nodiscard]] DxfImportResult import_dxf(const std::string& filepath); /// 从内存字符串导入 DXF /// @param dxf_data DXF 文件内容 /// @return 轮廓列表 + 统计信息 [[nodiscard]] DxfImportResult import_dxf_from_string(const std::string& dxf_data); /// 将 DXF 轮廓拉伸为 B-Rep 实体 /// @param contour 2D 轮廓 /// @param height 拉伸高度 /// @return B-Rep 实体 [[nodiscard]] BrepModel extrude_dxf_contour(const DxfContour& contour, double height); /// 导入 DXF 并拉伸所有轮廓为实体 /// @param filepath .dxf 文件路径 /// @param height 拉伸高度(默认 10) /// @return B-Rep 实体列表(每个轮廓一个实体) [[nodiscard]] std::vector import_dxf_as_solids(const std::string& filepath, double height = 10.0); } // namespace vde::brep