|
| 1 | +import { Base } from "./base-inputs"; |
| 2 | + |
| 3 | +/* eslint-disable @typescript-eslint/no-namespace */ |
| 4 | + |
| 5 | +export namespace IO { |
| 6 | + |
| 7 | + /** |
| 8 | + * Line segment defined by start and end points |
| 9 | + */ |
| 10 | + export class DxfLineSegmentDto { |
| 11 | + constructor(start?: Base.Point2, end?: Base.Point2) { |
| 12 | + if (start !== undefined) { this.start = start; } |
| 13 | + if (end !== undefined) { this.end = end; } |
| 14 | + } |
| 15 | + /** |
| 16 | + * Start point of the line |
| 17 | + * @default undefined |
| 18 | + */ |
| 19 | + start: Base.Point2; |
| 20 | + /** |
| 21 | + * End point of the line |
| 22 | + * @default undefined |
| 23 | + */ |
| 24 | + end: Base.Point2; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Arc segment defined by center, radius, and start/end angles in degrees |
| 29 | + */ |
| 30 | + export class DxfArcSegmentDto { |
| 31 | + constructor(center?: Base.Point2, radius?: number, startAngle?: number, endAngle?: number) { |
| 32 | + if (center !== undefined) { this.center = center; } |
| 33 | + if (radius !== undefined) { this.radius = radius; } |
| 34 | + if (startAngle !== undefined) { this.startAngle = startAngle; } |
| 35 | + if (endAngle !== undefined) { this.endAngle = endAngle; } |
| 36 | + } |
| 37 | + /** |
| 38 | + * Center point of the arc |
| 39 | + * @default undefined |
| 40 | + */ |
| 41 | + center: Base.Point2; |
| 42 | + /** |
| 43 | + * Radius of the arc |
| 44 | + * @default undefined |
| 45 | + */ |
| 46 | + radius: number; |
| 47 | + /** |
| 48 | + * Start angle in degrees |
| 49 | + * @default undefined |
| 50 | + */ |
| 51 | + startAngle: number; |
| 52 | + /** |
| 53 | + * End angle in degrees (counter-clockwise from start angle) |
| 54 | + * @default undefined |
| 55 | + */ |
| 56 | + endAngle: number; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Circle defined by center and radius |
| 61 | + */ |
| 62 | + export class DxfCircleSegmentDto { |
| 63 | + constructor(center?: Base.Point2, radius?: number) { |
| 64 | + if (center !== undefined) { this.center = center; } |
| 65 | + if (radius !== undefined) { this.radius = radius; } |
| 66 | + } |
| 67 | + /** |
| 68 | + * Center point of the circle |
| 69 | + * @default undefined |
| 70 | + */ |
| 71 | + center: Base.Point2; |
| 72 | + /** |
| 73 | + * Radius of the circle |
| 74 | + * @default undefined |
| 75 | + */ |
| 76 | + radius: number; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Polyline segment defined by multiple points |
| 81 | + * Can include bulge values to create arc segments between vertices |
| 82 | + */ |
| 83 | + export class DxfPolylineSegmentDto { |
| 84 | + constructor(points?: Base.Point2[], closed?: boolean, bulges?: number[]) { |
| 85 | + if (points !== undefined) { this.points = points; } |
| 86 | + if (closed !== undefined) { this.closed = closed; } |
| 87 | + if (bulges !== undefined) { this.bulges = bulges; } |
| 88 | + } |
| 89 | + /** |
| 90 | + * Points defining the polyline vertices |
| 91 | + * @default undefined |
| 92 | + */ |
| 93 | + points: Base.Point2[]; |
| 94 | + /** |
| 95 | + * Whether the polyline is closed |
| 96 | + * @default false |
| 97 | + */ |
| 98 | + closed? = false; |
| 99 | + /** |
| 100 | + * Bulge values for each vertex (optional) |
| 101 | + * Bulge = tan(angle/4) where angle is the arc angle in radians |
| 102 | + * Positive = counterclockwise, Negative = clockwise |
| 103 | + * 0 = straight line segment |
| 104 | + * Array length should match points length (or be undefined for all straight segments) |
| 105 | + * @default undefined |
| 106 | + */ |
| 107 | + bulges?: number[]; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Spline/B-spline segment defined by control points and degree |
| 112 | + */ |
| 113 | + export class DxfSplineSegmentDto { |
| 114 | + constructor(controlPoints?: Base.Point2[], degree?: number, closed?: boolean) { |
| 115 | + if (controlPoints !== undefined) { this.controlPoints = controlPoints; } |
| 116 | + if (degree !== undefined) { this.degree = degree; } |
| 117 | + if (closed !== undefined) { this.closed = closed; } |
| 118 | + } |
| 119 | + /** |
| 120 | + * Control points defining the spline |
| 121 | + * @default undefined |
| 122 | + */ |
| 123 | + controlPoints: Base.Point2[]; |
| 124 | + /** |
| 125 | + * Degree of the spline (typically 2 or 3) |
| 126 | + * @default 3 |
| 127 | + */ |
| 128 | + degree? = 3; |
| 129 | + /** |
| 130 | + * Whether the spline is closed |
| 131 | + * @default false |
| 132 | + */ |
| 133 | + closed? = false; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * A path can contain multiple segments of different types (lines, arcs, polylines, circles, splines) |
| 138 | + * Similar to OCCT wires that can combine different edge types |
| 139 | + */ |
| 140 | + export class DxfPathDto { |
| 141 | + constructor(segments?: (DxfLineSegmentDto | DxfArcSegmentDto | DxfCircleSegmentDto | DxfPolylineSegmentDto | DxfSplineSegmentDto)[]) { |
| 142 | + if (segments !== undefined) { this.segments = segments; } |
| 143 | + } |
| 144 | + /** |
| 145 | + * Array of segments that make up this path |
| 146 | + * Can include lines, arcs, circles, polylines, and splines |
| 147 | + * @default undefined |
| 148 | + */ |
| 149 | + segments: (DxfLineSegmentDto | DxfArcSegmentDto | DxfCircleSegmentDto | DxfPolylineSegmentDto | DxfSplineSegmentDto)[]; |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * A part containing multiple paths on the same layer with the same color |
| 154 | + */ |
| 155 | + export class DxfPathsPartDto { |
| 156 | + constructor(layer?: string, color?: Base.Color, paths?: DxfPathDto[]) { |
| 157 | + if (layer !== undefined) { this.layer = layer; } |
| 158 | + if (color !== undefined) { this.color = color; } |
| 159 | + if (paths !== undefined) { this.paths = paths; } |
| 160 | + } |
| 161 | + /** |
| 162 | + * Layer name for all paths in this part |
| 163 | + * @default Default |
| 164 | + */ |
| 165 | + layer = "Default"; |
| 166 | + /** |
| 167 | + * Color for all paths in this part |
| 168 | + * @default #000000 |
| 169 | + */ |
| 170 | + color: Base.Color = "#000000"; |
| 171 | + /** |
| 172 | + * Array of paths, each containing multiple segments |
| 173 | + * @default undefined |
| 174 | + */ |
| 175 | + paths: DxfPathDto[]; |
| 176 | + } |
| 177 | + |
| 178 | + /** |
| 179 | + * Main DXF model containing all path parts |
| 180 | + */ |
| 181 | + export class DxfModelDto { |
| 182 | + constructor(dxfPathsParts?: DxfPathsPartDto[]) { |
| 183 | + if (dxfPathsParts !== undefined) { this.dxfPathsParts = dxfPathsParts; } |
| 184 | + } |
| 185 | + /** |
| 186 | + * Array of path parts, each containing paths with segments |
| 187 | + * @default undefined |
| 188 | + */ |
| 189 | + dxfPathsParts: DxfPathsPartDto[]; |
| 190 | + } |
| 191 | + |
| 192 | +} |
| 193 | + |
| 194 | + |
0 commit comments