COLLADA 1.4/1.5 (.dae): import/export with materials + scene graph AMF 1.2 ISO/ASTM: multi-object with color + metadata VRML 1.0/97: IndexedFaceSet + Transform + Material G-code import: G00-G03/G17-G19/G20-G21/G81-G83/G90-G91/M/S/T E57/LAS: point cloud with classification + RGB + intensity 27/28 tests pass (1 COLLADA edge case)
62 lines
2.3 KiB
C++
62 lines
2.3 KiB
C++
#pragma once
|
|
#include "vde/core/cam_toolpath.h"
|
|
#include <string>
|
|
|
|
namespace vde::core {
|
|
|
|
/// G-code 导入状态(模态指令)
|
|
struct GcodeImportState {
|
|
Point3D position = Point3D::Zero(); ///< 当前刀具位置
|
|
Point3D arc_center = Point3D::Zero(); ///< 圆弧中心(增量偏移量)
|
|
|
|
bool absolute = true; ///< G90 绝对坐标 / G91 增量坐标
|
|
bool metric = true; ///< G21 毫米 / G20 英寸
|
|
int plane = 17; ///< G17(XY) / G18(ZX) / G19(YZ)
|
|
|
|
double feed_rate = 1000.0; ///< 当前进给率 (mm/min)
|
|
int spindle_speed = 0; ///< 主轴转速 (RPM)
|
|
bool spindle_on = false; ///< 主轴状态
|
|
bool spindle_cw = true; ///< M03 顺时针 / M04 逆时针
|
|
|
|
int tool_number = 0; ///< 当前刀具编号
|
|
|
|
// 钻孔循环参数
|
|
int canned_cycle = 0; ///< 0=无, 81=G81, 82=G82, 83=G83
|
|
double retract_plane = 0.0; ///< R 退刀平面
|
|
double peck_depth = 0.0; ///< Q 啄钻深度 (G83)
|
|
double dwell_time = 0.0; ///< P 暂停时间 (G82)
|
|
double drill_target_z = 0.0; ///< 钻孔目标深度 Z(模态保持)
|
|
|
|
double unit_factor = 1.0; ///< 单位转换系数 (inch→mm: 25.4)
|
|
};
|
|
|
|
/// 从 G-code 文件导入刀路
|
|
///
|
|
/// 解析标准 ISO G-code,支持的指令:
|
|
/// - G00/G01 直线移动(快速/切削进给)
|
|
/// - G02/G03 圆弧插补(顺/逆时针)
|
|
/// - G17/G18/G19 平面选择
|
|
/// - G90/G91 绝对/增量坐标
|
|
/// - G20/G21 英制/公制单位
|
|
/// - G81/G82/G83 钻孔固定循环
|
|
/// - M03/M04/M05 主轴控制
|
|
/// - S 主轴转速
|
|
/// - T/M06 刀具选择与换刀
|
|
/// - 注释:跳过 (...) 和 ; 注释
|
|
///
|
|
/// @param path G-code 文件路径
|
|
/// @return 解析后的刀路数据
|
|
///
|
|
/// @ingroup core
|
|
[[nodiscard]] Toolpath import_gcode(const std::string& path);
|
|
|
|
/// 从 G-code 字符串直接解析(用于测试/内嵌G-code)
|
|
///
|
|
/// @param gcode_text G-code 文本内容
|
|
/// @return 解析后的刀路数据
|
|
///
|
|
/// @ingroup core
|
|
[[nodiscard]] Toolpath import_gcode_from_string(const std::string& gcode_text);
|
|
|
|
} // namespace vde::core
|