MoonBit ASCII DXF 读取与二维轮廓辅助检查库:七类核心轮廓、普通块展开、SVG预览与流式统计
moon add mik1e80/dxfkit@0.1.1let scan = @dxfkit.scan_tags(bytes)
let drawing = @dxfkit.build_drawing(scan)
let entities = drawing.entities()
let report = drawing.check({ tol: 0.05, min_gap: 0.5 })
println(report.to_text())
let svg = drawing.to_svg(0.05)| 检查 | 实际覆盖 |
|---|---|
| 退化几何 | 非正圆半径、空或单点轮廓、零长度线段 |
| 闭合 | 同图层开放实体的端点串链与缝隙;不等于完整拓扑证明 |
| 自相交 | 同一实体内非相邻折线段的真交叉 |
| 重复路径 | 同图层线段的共线重叠,排除同实体相邻段 |
| 最小净距 | 同图层不同实体的线段距离;跳过容差内的端点接触 |
| 检查覆盖 | 未支持或只提取元数据的实体、无轮廓、非默认OCS、未展开阵列、解析与离散诊断 |
| 文字与图层 | 未转换的文字、图层引用和关闭 / 冻结状态提示 |
pub(all) enum Encoding {
Utf8
Cp1252
Other(Int)
}pub(all) struct ExpandLimits {
max_placed : Int
max_points : Int
max_visits : Int
}pub(all) enum Geometry {
Line(start~ : Vec3, end~ : Vec3)
Point(at~ : Vec3)
Circle(center~ : Vec3, radius~ : Double)
Arc(center~ : Vec3, radius~ : Double, start_angle~ : Double, end_angle~ : Double)
Ellipse(center~ : Vec3, major~ : Vec3, ratio~ : Double, start_param~ : Double, end_param~ : Double)
Polyline(vertices~ : Array[PolyVertex], closed~ : Bool)
Text(at~ : Vec3, height~ : Double, value~ : String, rotation~ : Double)
Insert(at~ : Vec3, block~ : String, scale~ : Vec3, rotation~ : Double)
Face(corners~ : Array[Vec3])
Dimension(at~ : Vec3, block~ : String, measurement~ : Double)
Spline(degree~ : Int, knots~ : Array[Double], control_points~ : Array[Vec3], weights~ : Array[Double])
Hatch(at~ : Vec3, solid~ : Bool, pattern~ : String, paths~ : Int)
Unknown
}pub(all) struct Layer {
name : String
color : Int
linetype : String
frozen : Bool
locked : Bool
lineweight : Int
}pub(all) struct TagStream {
// private fields
}pub(all) enum TagValue {
Str(String)
I16(Int)
I32(Int)
I64(Int64)
F64(Double)
Bool(Bool)
Bin(Bytes)
}pub(all) struct Vec2 {
x : Double
y : Double
}pub(all) struct Vec3 {
x : Double
y : Double
z : Double
}fn angle_span(from : Double, to : Double) -> Doublefn is_handle_code(code : Int) -> Boolfn is_point_code(code : Int) -> Boolfn is_pointer_code(code : Int) -> Boolfn is_xdata_code(code : Int) -> Boolfn normalize_angle(rad : Double) -> Doublefn point_code_parts(code : Int) -> (Int, Int)?Install
Download zipMoonBit ASCII DXF 读取与二维轮廓辅助检查库:七类核心轮廓、普通块展开、SVG预览与流式统计