@bitbybit-dev/base 0.20.8 → 0.20.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,17 +62,17 @@ export declare namespace Base {
62
62
  type TransformMatrix = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
63
63
  type TransformMatrixes = TransformMatrix[];
64
64
  enum horizontalAlignEnum {
65
- /**
66
- * Aligns to the left
67
- */
68
65
  left = "left",
69
- /**
70
- * Aligns to the center
71
- */
72
66
  center = "center",
73
- /**
74
- * Aligns to the right
75
- */
76
67
  right = "right"
77
68
  }
69
+ enum verticalAlignmentEnum {
70
+ top = "top",
71
+ middle = "middle",
72
+ bottom = "bottom"
73
+ }
74
+ enum topBottomEnum {
75
+ top = "top",
76
+ bottom = "bottom"
77
+ }
78
78
  }
@@ -3,17 +3,19 @@ export var Base;
3
3
  (function (Base) {
4
4
  let horizontalAlignEnum;
5
5
  (function (horizontalAlignEnum) {
6
- /**
7
- * Aligns to the left
8
- */
9
6
  horizontalAlignEnum["left"] = "left";
10
- /**
11
- * Aligns to the center
12
- */
13
7
  horizontalAlignEnum["center"] = "center";
14
- /**
15
- * Aligns to the right
16
- */
17
8
  horizontalAlignEnum["right"] = "right";
18
9
  })(horizontalAlignEnum = Base.horizontalAlignEnum || (Base.horizontalAlignEnum = {}));
10
+ let verticalAlignmentEnum;
11
+ (function (verticalAlignmentEnum) {
12
+ verticalAlignmentEnum["top"] = "top";
13
+ verticalAlignmentEnum["middle"] = "middle";
14
+ verticalAlignmentEnum["bottom"] = "bottom";
15
+ })(verticalAlignmentEnum = Base.verticalAlignmentEnum || (Base.verticalAlignmentEnum = {}));
16
+ let topBottomEnum;
17
+ (function (topBottomEnum) {
18
+ topBottomEnum["top"] = "top";
19
+ topBottomEnum["bottom"] = "bottom";
20
+ })(topBottomEnum = Base.topBottomEnum || (Base.topBottomEnum = {}));
19
21
  })(Base || (Base = {}));
@@ -11,3 +11,4 @@ export * from "./dates-inputs";
11
11
  export * from "./line-inputs";
12
12
  export * from "./polyline-inputs";
13
13
  export * from "./mesh-inputs";
14
+ export * from "./io-inputs";
@@ -11,3 +11,4 @@ export * from "./dates-inputs";
11
11
  export * from "./line-inputs";
12
12
  export * from "./polyline-inputs";
13
13
  export * from "./mesh-inputs";
14
+ export * from "./io-inputs";
@@ -11,3 +11,4 @@ export * from "./dates-inputs";
11
11
  export * from "./line-inputs";
12
12
  export * from "./polyline-inputs";
13
13
  export * from "./mesh-inputs";
14
+ export * from "./io-inputs";
@@ -11,3 +11,4 @@ export * from "./dates-inputs";
11
11
  export * from "./line-inputs";
12
12
  export * from "./polyline-inputs";
13
13
  export * from "./mesh-inputs";
14
+ export * from "./io-inputs";
@@ -0,0 +1,153 @@
1
+ import { Base } from "./base-inputs";
2
+ export declare namespace IO {
3
+ /**
4
+ * Line segment defined by start and end points
5
+ */
6
+ class DxfLineSegmentDto {
7
+ constructor(start?: Base.Point2, end?: Base.Point2);
8
+ /**
9
+ * Start point of the line
10
+ * @default undefined
11
+ */
12
+ start: Base.Point2;
13
+ /**
14
+ * End point of the line
15
+ * @default undefined
16
+ */
17
+ end: Base.Point2;
18
+ }
19
+ /**
20
+ * Arc segment defined by center, radius, and start/end angles in degrees
21
+ */
22
+ class DxfArcSegmentDto {
23
+ constructor(center?: Base.Point2, radius?: number, startAngle?: number, endAngle?: number);
24
+ /**
25
+ * Center point of the arc
26
+ * @default undefined
27
+ */
28
+ center: Base.Point2;
29
+ /**
30
+ * Radius of the arc
31
+ * @default undefined
32
+ */
33
+ radius: number;
34
+ /**
35
+ * Start angle in degrees
36
+ * @default undefined
37
+ */
38
+ startAngle: number;
39
+ /**
40
+ * End angle in degrees (counter-clockwise from start angle)
41
+ * @default undefined
42
+ */
43
+ endAngle: number;
44
+ }
45
+ /**
46
+ * Circle defined by center and radius
47
+ */
48
+ class DxfCircleSegmentDto {
49
+ constructor(center?: Base.Point2, radius?: number);
50
+ /**
51
+ * Center point of the circle
52
+ * @default undefined
53
+ */
54
+ center: Base.Point2;
55
+ /**
56
+ * Radius of the circle
57
+ * @default undefined
58
+ */
59
+ radius: number;
60
+ }
61
+ /**
62
+ * Polyline segment defined by multiple points
63
+ * Can include bulge values to create arc segments between vertices
64
+ */
65
+ class DxfPolylineSegmentDto {
66
+ constructor(points?: Base.Point2[], closed?: boolean, bulges?: number[]);
67
+ /**
68
+ * Points defining the polyline vertices
69
+ * @default undefined
70
+ */
71
+ points: Base.Point2[];
72
+ /**
73
+ * Whether the polyline is closed
74
+ * @default false
75
+ */
76
+ closed?: boolean;
77
+ /**
78
+ * Bulge values for each vertex (optional)
79
+ * Bulge = tan(angle/4) where angle is the arc angle in radians
80
+ * Positive = counterclockwise, Negative = clockwise
81
+ * 0 = straight line segment
82
+ * Array length should match points length (or be undefined for all straight segments)
83
+ * @default undefined
84
+ */
85
+ bulges?: number[];
86
+ }
87
+ /**
88
+ * Spline/B-spline segment defined by control points and degree
89
+ */
90
+ class DxfSplineSegmentDto {
91
+ constructor(controlPoints?: Base.Point2[], degree?: number, closed?: boolean);
92
+ /**
93
+ * Control points defining the spline
94
+ * @default undefined
95
+ */
96
+ controlPoints: Base.Point2[];
97
+ /**
98
+ * Degree of the spline (typically 2 or 3)
99
+ * @default 3
100
+ */
101
+ degree?: number;
102
+ /**
103
+ * Whether the spline is closed
104
+ * @default false
105
+ */
106
+ closed?: boolean;
107
+ }
108
+ /**
109
+ * A path can contain multiple segments of different types (lines, arcs, polylines, circles, splines)
110
+ * Similar to OCCT wires that can combine different edge types
111
+ */
112
+ class DxfPathDto {
113
+ constructor(segments?: (DxfLineSegmentDto | DxfArcSegmentDto | DxfCircleSegmentDto | DxfPolylineSegmentDto | DxfSplineSegmentDto)[]);
114
+ /**
115
+ * Array of segments that make up this path
116
+ * Can include lines, arcs, circles, polylines, and splines
117
+ * @default undefined
118
+ */
119
+ segments: (DxfLineSegmentDto | DxfArcSegmentDto | DxfCircleSegmentDto | DxfPolylineSegmentDto | DxfSplineSegmentDto)[];
120
+ }
121
+ /**
122
+ * A part containing multiple paths on the same layer with the same color
123
+ */
124
+ class DxfPathsPartDto {
125
+ constructor(layer?: string, color?: Base.Color, paths?: DxfPathDto[]);
126
+ /**
127
+ * Layer name for all paths in this part
128
+ * @default Default
129
+ */
130
+ layer: string;
131
+ /**
132
+ * Color for all paths in this part
133
+ * @default #000000
134
+ */
135
+ color: Base.Color;
136
+ /**
137
+ * Array of paths, each containing multiple segments
138
+ * @default undefined
139
+ */
140
+ paths: DxfPathDto[];
141
+ }
142
+ /**
143
+ * Main DXF model containing all path parts
144
+ */
145
+ class DxfModelDto {
146
+ constructor(dxfPathsParts?: DxfPathsPartDto[]);
147
+ /**
148
+ * Array of path parts, each containing paths with segments
149
+ * @default undefined
150
+ */
151
+ dxfPathsParts: DxfPathsPartDto[];
152
+ }
153
+ }
@@ -0,0 +1,152 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ export var IO;
3
+ (function (IO) {
4
+ /**
5
+ * Line segment defined by start and end points
6
+ */
7
+ class DxfLineSegmentDto {
8
+ constructor(start, end) {
9
+ if (start !== undefined) {
10
+ this.start = start;
11
+ }
12
+ if (end !== undefined) {
13
+ this.end = end;
14
+ }
15
+ }
16
+ }
17
+ IO.DxfLineSegmentDto = DxfLineSegmentDto;
18
+ /**
19
+ * Arc segment defined by center, radius, and start/end angles in degrees
20
+ */
21
+ class DxfArcSegmentDto {
22
+ constructor(center, radius, startAngle, endAngle) {
23
+ if (center !== undefined) {
24
+ this.center = center;
25
+ }
26
+ if (radius !== undefined) {
27
+ this.radius = radius;
28
+ }
29
+ if (startAngle !== undefined) {
30
+ this.startAngle = startAngle;
31
+ }
32
+ if (endAngle !== undefined) {
33
+ this.endAngle = endAngle;
34
+ }
35
+ }
36
+ }
37
+ IO.DxfArcSegmentDto = DxfArcSegmentDto;
38
+ /**
39
+ * Circle defined by center and radius
40
+ */
41
+ class DxfCircleSegmentDto {
42
+ constructor(center, radius) {
43
+ if (center !== undefined) {
44
+ this.center = center;
45
+ }
46
+ if (radius !== undefined) {
47
+ this.radius = radius;
48
+ }
49
+ }
50
+ }
51
+ IO.DxfCircleSegmentDto = DxfCircleSegmentDto;
52
+ /**
53
+ * Polyline segment defined by multiple points
54
+ * Can include bulge values to create arc segments between vertices
55
+ */
56
+ class DxfPolylineSegmentDto {
57
+ constructor(points, closed, bulges) {
58
+ /**
59
+ * Whether the polyline is closed
60
+ * @default false
61
+ */
62
+ this.closed = false;
63
+ if (points !== undefined) {
64
+ this.points = points;
65
+ }
66
+ if (closed !== undefined) {
67
+ this.closed = closed;
68
+ }
69
+ if (bulges !== undefined) {
70
+ this.bulges = bulges;
71
+ }
72
+ }
73
+ }
74
+ IO.DxfPolylineSegmentDto = DxfPolylineSegmentDto;
75
+ /**
76
+ * Spline/B-spline segment defined by control points and degree
77
+ */
78
+ class DxfSplineSegmentDto {
79
+ constructor(controlPoints, degree, closed) {
80
+ /**
81
+ * Degree of the spline (typically 2 or 3)
82
+ * @default 3
83
+ */
84
+ this.degree = 3;
85
+ /**
86
+ * Whether the spline is closed
87
+ * @default false
88
+ */
89
+ this.closed = false;
90
+ if (controlPoints !== undefined) {
91
+ this.controlPoints = controlPoints;
92
+ }
93
+ if (degree !== undefined) {
94
+ this.degree = degree;
95
+ }
96
+ if (closed !== undefined) {
97
+ this.closed = closed;
98
+ }
99
+ }
100
+ }
101
+ IO.DxfSplineSegmentDto = DxfSplineSegmentDto;
102
+ /**
103
+ * A path can contain multiple segments of different types (lines, arcs, polylines, circles, splines)
104
+ * Similar to OCCT wires that can combine different edge types
105
+ */
106
+ class DxfPathDto {
107
+ constructor(segments) {
108
+ if (segments !== undefined) {
109
+ this.segments = segments;
110
+ }
111
+ }
112
+ }
113
+ IO.DxfPathDto = DxfPathDto;
114
+ /**
115
+ * A part containing multiple paths on the same layer with the same color
116
+ */
117
+ class DxfPathsPartDto {
118
+ constructor(layer, color, paths) {
119
+ /**
120
+ * Layer name for all paths in this part
121
+ * @default Default
122
+ */
123
+ this.layer = "Default";
124
+ /**
125
+ * Color for all paths in this part
126
+ * @default #000000
127
+ */
128
+ this.color = "#000000";
129
+ if (layer !== undefined) {
130
+ this.layer = layer;
131
+ }
132
+ if (color !== undefined) {
133
+ this.color = color;
134
+ }
135
+ if (paths !== undefined) {
136
+ this.paths = paths;
137
+ }
138
+ }
139
+ }
140
+ IO.DxfPathsPartDto = DxfPathsPartDto;
141
+ /**
142
+ * Main DXF model containing all path parts
143
+ */
144
+ class DxfModelDto {
145
+ constructor(dxfPathsParts) {
146
+ if (dxfPathsParts !== undefined) {
147
+ this.dxfPathsParts = dxfPathsParts;
148
+ }
149
+ }
150
+ }
151
+ IO.DxfModelDto = DxfModelDto;
152
+ })(IO || (IO = {}));
@@ -95,6 +95,33 @@ export declare const simplex: {
95
95
  124: number[];
96
96
  125: number[];
97
97
  126: number[];
98
+ 176: number[];
99
+ 178: number[];
100
+ 179: number[];
101
+ 181: number[];
102
+ 185: number[];
103
+ 188: number[];
104
+ 189: number[];
105
+ 190: number[];
106
+ 215: number[];
107
+ 247: number[];
108
+ 177: number[];
109
+ 8304: number[];
110
+ 8308: number[];
111
+ 8309: number[];
112
+ 8310: number[];
113
+ 8311: number[];
114
+ 8312: number[];
115
+ 8313: number[];
116
+ 8320: number[];
117
+ 8321: number[];
118
+ 8322: number[];
119
+ 8323: number[];
120
+ 8324: number[];
121
+ 8776: number[];
122
+ 8730: number[];
123
+ 8731: number[];
124
+ 8732: number[];
98
125
  };
99
126
  export declare const defaultsVectorParams: {
100
127
  xOffset: number;
@@ -198,6 +225,33 @@ export declare const defaultsVectorParams: {
198
225
  124: number[];
199
226
  125: number[];
200
227
  126: number[];
228
+ 176: number[];
229
+ 178: number[];
230
+ 179: number[];
231
+ 181: number[];
232
+ 185: number[];
233
+ 188: number[];
234
+ 189: number[];
235
+ 190: number[];
236
+ 215: number[];
237
+ 247: number[];
238
+ 177: number[];
239
+ 8304: number[];
240
+ 8308: number[];
241
+ 8309: number[];
242
+ 8310: number[];
243
+ 8311: number[];
244
+ 8312: number[];
245
+ 8313: number[];
246
+ 8320: number[];
247
+ 8321: number[];
248
+ 8322: number[];
249
+ 8323: number[];
250
+ 8324: number[];
251
+ 8776: number[];
252
+ 8730: number[];
253
+ 8731: number[];
254
+ 8732: number[];
201
255
  };
202
256
  height: number;
203
257
  lineSpacing: number;
@@ -97,7 +97,63 @@ export const simplex = {
97
97
  123: [14, 9, 25, 7, 24, 6, 23, 5, 21, 5, 19, 6, 17, 7, 16, 8, 14, 8, 12, 6, 10, undefined, 7, 24, 6, 22, 6, 20, 7, 18, 8, 17, 9, 15, 9, 13, 8, 11, 4, 9, 8, 7, 9, 5, 9, 3, 8, 1, 7, 0, 6, -2, 6, -4, 7, -6, undefined, 6, 8, 8, 6, 8, 4, 7, 2, 6, 1, 5, -1, 5, -3, 6, -5, 7, -6, 9, -7],
98
98
  124: [8, 4, 25, 4, -7],
99
99
  125: [14, 5, 25, 7, 24, 8, 23, 9, 21, 9, 19, 8, 17, 7, 16, 6, 14, 6, 12, 8, 10, undefined, 7, 24, 8, 22, 8, 20, 7, 18, 6, 17, 5, 15, 5, 13, 6, 11, 10, 9, 6, 7, 5, 5, 5, 3, 6, 1, 7, 0, 8, -2, 8, -4, 7, -6, undefined, 8, 8, 6, 6, 6, 4, 7, 2, 8, 1, 9, -1, 9, -3, 8, -5, 7, -6, 5, -7],
100
- 126: [24, 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16, 7, 18, 7, 20, 8, 21, 10, undefined, 3, 8, 4, 10, 6, 11, 8, 11, 10, 10, 14, 7, 16, 6, 18, 6, 20, 7, 21, 10, 21, 12]
100
+ 126: [24, 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16, 7, 18, 7, 20, 8, 21, 10, undefined, 3, 8, 4, 10, 6, 11, 8, 11, 10, 10, 14, 7, 16, 6, 18, 6, 20, 7, 21, 10, 21, 12],
101
+ // Extended characters for units and measurements
102
+ // 176: ° (degree symbol)
103
+ 176: [14, 7, 21, 5, 20, 4, 18, 4, 16, 5, 14, 7, 13, 9, 14, 10, 16, 10, 18, 9, 20, 7, 21],
104
+ // 178: ² (superscript 2) - positioned at top, same size as other superscripts
105
+ 178: [14, 5, 17, 5, 18, 6, 19, 7, 20, 9, 21, 10, 21, 11, 20, 12, 19, 12, 18, 11, 17, 10, 16, 6, 14, 12, 14],
106
+ // 179: ³ (superscript 3) - cleaner design matching ²
107
+ 179: [14, 5, 21, 11, 21, 8, 18, 9, 18, 10, 17, 11, 16, 11, 15, 10, 14, 8, 14, 6, 15, 5, 16],
108
+ // 181: µ (micro symbol)
109
+ 181: [19, 4, 14, 4, -7, undefined, 4, 14, 4, 4, 5, 1, 7, 0, 10, 0, 12, 1, 15, 4, undefined, 15, 14, 15, 0],
110
+ // 185: ¹ (superscript 1) - same size and position as ²
111
+ 185: [14, 7, 19, 8, 20, 10, 21, 10, 14],
112
+ // 188: ¼ (one quarter) - slash going / direction (bottom-left to top-right)
113
+ 188: [26, 4, 19, 5, 20, 7, 21, 7, 14, undefined, 6, 0, 18, 21, undefined, 16, 11, 16, 7, 22, 7, undefined, 18, 11, 18, 0, undefined, 16, 0, 22, 0],
114
+ // 189: ½ (one half) - slash going / direction (bottom-left to top-right)
115
+ 189: [26, 4, 19, 5, 20, 7, 21, 7, 14, undefined, 6, 0, 18, 21, undefined, 15, 4, 15, 5, 16, 6, 17, 7, 19, 7, 20, 6, 20, 5, 19, 4, 17, 2, 15, 0, 21, 0],
116
+ // 190: ¾ (three quarters) - slash going / direction (bottom-left to top-right)
117
+ 190: [26, 4, 21, 10, 21, 8, 18, 9, 18, 10, 17, 11, 16, 11, 15, 10, 14, 8, 14, 6, 15, 5, 16, undefined, 6, 0, 18, 21, undefined, 16, 11, 16, 7, 22, 7, undefined, 18, 11, 18, 0, undefined, 16, 0, 22, 0],
118
+ // 215: × (multiplication sign)
119
+ 215: [18, 3, 15, 15, 3, undefined, 15, 15, 3, 3],
120
+ // 247: ÷ (division sign)
121
+ 247: [22, 4, 9, 18, 9, undefined, 11, 15, 10, 14, 11, 13, 12, 14, 11, 15, undefined, 11, 5, 10, 4, 11, 3, 12, 4, 11, 5],
122
+ // Additional useful characters
123
+ // 177: ± (plus-minus) - better proportions
124
+ 177: [26, 13, 18, 13, 6, undefined, 4, 12, 22, 12, undefined, 4, 3, 22, 3],
125
+ // 8304: ⁰ (superscript 0) - same size and position as other superscripts
126
+ 8304: [14, 8, 21, 7, 20, 6, 19, 5, 17, 5, 15, 6, 14, 8, 14, 9, 14, 11, 15, 12, 17, 12, 19, 11, 20, 9, 21, 8, 21],
127
+ // 8308: ⁴ (superscript 4) - same size and position
128
+ 8308: [14, 10, 21, 6, 17, 12, 17, undefined, 10, 21, 10, 14],
129
+ // 8309: ⁵ (superscript 5) - cleaner design
130
+ 8309: [14, 11, 21, 6, 21, 5, 17, 6, 17, 7, 18, 9, 18, 10, 17, 11, 16, 11, 15, 10, 14, 8, 14, 6, 15, 5, 16],
131
+ // 8310: ⁶ (superscript 6) - same size and position
132
+ 8310: [14, 11, 19, 10, 20, 9, 21, 7, 21, 6, 20, 5, 18, 5, 15, 6, 14, 8, 14, 9, 14, 10, 15, 11, 16, 11, 17, 10, 18, 9, 18, 8, 17, 7, 16, 6, 15],
133
+ // 8311: ⁷ (superscript 7) - same size and position
134
+ 8311: [14, 11, 21, 7, 14, undefined, 5, 21, 11, 21],
135
+ // 8312: ⁸ (superscript 8) - same size and position
136
+ 8312: [14, 8, 21, 7, 20, 6, 19, 6, 18, 7, 17, 8, 17, 9, 18, 10, 19, 10, 20, 9, 21, 8, 21, 7, 20, undefined, 8, 17, 7, 16, 6, 15, 6, 14, 7, 13, 8, 13, 9, 14, 10, 15, 10, 16, 9, 17],
137
+ // 8313: ⁹ (superscript 9) - same size and position
138
+ 8313: [14, 10, 17, 9, 16, 8, 16, 7, 17, 6, 18, 6, 19, 7, 20, 8, 20, 9, 19, 10, 18, 10, 15, 9, 14, 7, 14, 6, 15, 5, 16],
139
+ // 8320: ₀ (subscript 0)
140
+ 8320: [14, 8, 7, 7, 6, 6, 5, 5, 3, 5, 1, 6, 0, 8, 0, 9, 0, 11, 1, 12, 3, 12, 5, 11, 6, 9, 7, 8, 7],
141
+ // 8321: ₁ (subscript 1)
142
+ 8321: [14, 7, 5, 8, 6, 10, 7, 10, 0],
143
+ // 8322: ₂ (subscript 2)
144
+ 8322: [14, 5, 4, 5, 5, 6, 6, 7, 7, 9, 7, 10, 6, 11, 5, 11, 4, 10, 3, 9, 2, 6, 0, 12, 0],
145
+ // 8323: ₃ (subscript 3)
146
+ 8323: [14, 5, 7, 11, 7, 8, 4, 10, 4, 11, 3, 12, 2, 12, 1, 11, 0, 9, 0, 7, 1, 6, 2, 5, 3],
147
+ // 8324: ₄ (subscript 4)
148
+ 8324: [14, 10, 7, 6, 3, 12, 3, undefined, 10, 7, 10, 0],
149
+ // 8776: ≈ (approximately equal)
150
+ 8776: [24, 3, 11, 4, 13, 6, 14, 8, 14, 10, 13, 14, 10, 16, 9, 18, 9, 20, 10, 21, 12, undefined, 3, 5, 4, 7, 6, 8, 8, 8, 10, 7, 14, 4, 16, 3, 18, 3, 20, 4, 21, 6],
151
+ // 8730: √ (square root) - fixed to look like a proper check mark with extension
152
+ 8730: [20, 4, 12, 6, 8, 8, 0, undefined, 8, 0, 10, 21, undefined, 10, 21, 20, 21],
153
+ // 8731: ∛ (cube root) - with cleaner 3 indicator
154
+ 8731: [24, 2, 21, 5, 21, 4, 19, 5, 18, 6, 17, 6, 16, 5, 15, 3, 15, 2, 16, undefined, 8, 12, 10, 8, 12, 0, undefined, 12, 0, 14, 21, undefined, 14, 21, 24, 21],
155
+ // 8732: ∜ (fourth root) - with 4 indicator same size as 3
156
+ 8732: [24, 5, 21, 3, 18, 6, 18, undefined, 5, 21, 5, 15, undefined, 8, 12, 10, 8, 12, 0, undefined, 12, 0, 14, 21, undefined, 14, 21, 24, 21]
101
157
  };
102
158
  export const defaultsVectorParams = {
103
159
  xOffset: 0,
@@ -0,0 +1,82 @@
1
+ import * as Inputs from "../../../inputs";
2
+ export declare class DxfGenerator {
3
+ private entityHandle;
4
+ /**
5
+ * Generate a complete DXF file content from path-based entities
6
+ */
7
+ generateDxf(dxfInputs: Inputs.IO.DxfModelDto): string;
8
+ /**
9
+ * Generate DXF header section
10
+ */
11
+ private generateHeader;
12
+ /**
13
+ * Generate DXF tables section (layers, line types, etc.)
14
+ */
15
+ private generateTables;
16
+ /**
17
+ * Generate layer table based on unique layers in all parts
18
+ */
19
+ private generateLayerTable;
20
+ /**
21
+ * Generate DXF entities section with all path segments
22
+ */
23
+ private generateEntities;
24
+ /**
25
+ * Generate entity for a single segment based on its type
26
+ */
27
+ private generateSegmentEntity;
28
+ /**
29
+ * Type guard for line segments
30
+ */
31
+ private isLineSegment;
32
+ /**
33
+ * Type guard for arc segments
34
+ */
35
+ private isArcSegment;
36
+ /**
37
+ * Type guard for circle segments
38
+ */
39
+ private isCircleSegment;
40
+ /**
41
+ * Type guard for polyline segments
42
+ */
43
+ private isPolylineSegment;
44
+ /**
45
+ * Type guard for spline segments
46
+ */
47
+ private isSplineSegment;
48
+ /**
49
+ * Generate a LINE entity
50
+ */
51
+ private generateLineEntity;
52
+ /**
53
+ * Generate a CIRCLE entity
54
+ */
55
+ private generateCircleEntity;
56
+ /**
57
+ * Generate an ARC entity
58
+ */
59
+ private generateArcEntity;
60
+ /**
61
+ * Generate a LWPOLYLINE entity
62
+ */
63
+ private generatePolylineEntity;
64
+ /**
65
+ * Generate a SPLINE entity
66
+ */
67
+ private generateSplineEntity;
68
+ /**
69
+ * Check if polyline should be closed (first and last points are the same)
70
+ */
71
+ private isClosedPolyline;
72
+ /**
73
+ * Get next entity handle as hex string
74
+ */
75
+ private getNextHandle;
76
+ /**
77
+ * Convert color to DXF format
78
+ * Accepts hex color (#RRGGBB) or ACI color index (1-255)
79
+ * Returns appropriate DXF color codes
80
+ */
81
+ private convertColorToDxf;
82
+ }
@@ -0,0 +1,371 @@
1
+ export class DxfGenerator {
2
+ constructor() {
3
+ this.entityHandle = 1;
4
+ }
5
+ /**
6
+ * Generate a complete DXF file content from path-based entities
7
+ */
8
+ generateDxf(dxfInputs) {
9
+ const dxfContent = [];
10
+ // Header section
11
+ dxfContent.push(...this.generateHeader());
12
+ // Tables section
13
+ dxfContent.push(...this.generateTables(dxfInputs));
14
+ // Entities section
15
+ dxfContent.push(...this.generateEntities(dxfInputs));
16
+ // End of file
17
+ dxfContent.push("0", "EOF");
18
+ return dxfContent.join("\n");
19
+ }
20
+ /**
21
+ * Generate DXF header section
22
+ */
23
+ generateHeader() {
24
+ return [
25
+ "0",
26
+ "SECTION",
27
+ "2",
28
+ "HEADER",
29
+ "9",
30
+ "$ACADVER",
31
+ "1",
32
+ "AC1015",
33
+ "9",
34
+ "$DWGCODEPAGE",
35
+ "3",
36
+ "ANSI_1252",
37
+ "9",
38
+ "$LASTSAVEDBY",
39
+ "1",
40
+ "bitbybit.dev",
41
+ "9",
42
+ "$HANDSEED",
43
+ "5",
44
+ "20000",
45
+ "0",
46
+ "ENDSEC"
47
+ ];
48
+ }
49
+ /**
50
+ * Generate DXF tables section (layers, line types, etc.)
51
+ */
52
+ generateTables(dxfInputs) {
53
+ const tables = [
54
+ "0",
55
+ "SECTION",
56
+ "2",
57
+ "TABLES"
58
+ ];
59
+ // Layer table
60
+ tables.push(...this.generateLayerTable(dxfInputs));
61
+ tables.push("0", "ENDSEC");
62
+ return tables;
63
+ }
64
+ /**
65
+ * Generate layer table based on unique layers in all parts
66
+ */
67
+ generateLayerTable(dxfInputs) {
68
+ const layers = new Set();
69
+ // Collect all unique layer names
70
+ if (dxfInputs.dxfPathsParts) {
71
+ dxfInputs.dxfPathsParts.forEach(part => {
72
+ if (part.layer) {
73
+ layers.add(part.layer);
74
+ }
75
+ });
76
+ }
77
+ // Add default layer if no layers specified
78
+ if (layers.size === 0) {
79
+ layers.add("0");
80
+ }
81
+ const layerTable = [
82
+ "0",
83
+ "TABLE",
84
+ "2",
85
+ "LAYER",
86
+ "5",
87
+ "2",
88
+ "100",
89
+ "AcDbSymbolTable",
90
+ "70",
91
+ layers.size.toString()
92
+ ];
93
+ // Generate layer entries
94
+ layers.forEach(layerName => {
95
+ layerTable.push("0", "LAYER", "5", this.getNextHandle(), "100", "AcDbSymbolTableRecord", "100", "AcDbLayerTableRecord", "2", layerName, "70", "0", "62", "7", // Default color (white)
96
+ "6", "CONTINUOUS" // Line type
97
+ );
98
+ });
99
+ layerTable.push("0", "ENDTAB");
100
+ return layerTable;
101
+ }
102
+ /**
103
+ * Generate DXF entities section with all path segments
104
+ */
105
+ generateEntities(dxfInputs) {
106
+ const entities = [
107
+ "0",
108
+ "SECTION",
109
+ "2",
110
+ "ENTITIES"
111
+ ];
112
+ if (dxfInputs.dxfPathsParts) {
113
+ dxfInputs.dxfPathsParts.forEach(part => {
114
+ if (part.paths) {
115
+ part.paths.forEach(path => {
116
+ if (path.segments) {
117
+ path.segments.forEach(segment => {
118
+ entities.push(...this.generateSegmentEntity(segment, part));
119
+ });
120
+ }
121
+ });
122
+ }
123
+ });
124
+ }
125
+ entities.push("0", "ENDSEC");
126
+ return entities;
127
+ }
128
+ /**
129
+ * Generate entity for a single segment based on its type
130
+ */
131
+ generateSegmentEntity(segment, part) {
132
+ // Check segment type and generate appropriate entity
133
+ if (this.isLineSegment(segment)) {
134
+ return this.generateLineEntity(segment, part);
135
+ }
136
+ else if (this.isArcSegment(segment)) {
137
+ return this.generateArcEntity(segment, part);
138
+ }
139
+ else if (this.isCircleSegment(segment)) {
140
+ return this.generateCircleEntity(segment, part);
141
+ }
142
+ else if (this.isPolylineSegment(segment)) {
143
+ return this.generatePolylineEntity(segment, part);
144
+ }
145
+ else if (this.isSplineSegment(segment)) {
146
+ return this.generateSplineEntity(segment, part);
147
+ }
148
+ return [];
149
+ }
150
+ /**
151
+ * Type guard for line segments
152
+ */
153
+ isLineSegment(segment) {
154
+ return segment.start !== undefined && segment.end !== undefined && segment.radius === undefined;
155
+ }
156
+ /**
157
+ * Type guard for arc segments
158
+ */
159
+ isArcSegment(segment) {
160
+ return segment.center !== undefined && segment.radius !== undefined && segment.startAngle !== undefined && segment.endAngle !== undefined;
161
+ }
162
+ /**
163
+ * Type guard for circle segments
164
+ */
165
+ isCircleSegment(segment) {
166
+ return segment.center !== undefined && segment.radius !== undefined && segment.startAngle === undefined;
167
+ }
168
+ /**
169
+ * Type guard for polyline segments
170
+ */
171
+ isPolylineSegment(segment) {
172
+ return segment.points !== undefined && Array.isArray(segment.points);
173
+ }
174
+ /**
175
+ * Type guard for spline segments
176
+ */
177
+ isSplineSegment(segment) {
178
+ return segment.controlPoints !== undefined && Array.isArray(segment.controlPoints);
179
+ }
180
+ /**
181
+ * Generate a LINE entity
182
+ */
183
+ generateLineEntity(line, part) {
184
+ const entity = [
185
+ "0",
186
+ "LINE",
187
+ "5",
188
+ this.getNextHandle(),
189
+ "100",
190
+ "AcDbEntity"
191
+ ];
192
+ // Add layer
193
+ entity.push("8", part.layer || "0");
194
+ // Add color if specified
195
+ if (part.color !== undefined) {
196
+ const colorCodes = this.convertColorToDxf(part.color);
197
+ colorCodes.forEach(cc => entity.push(cc.code, cc.value));
198
+ }
199
+ entity.push("100", "AcDbLine", "10", line.start[0].toString(), "20", line.start[1].toString(), "30", "0", // Z coordinate (2D)
200
+ "11", line.end[0].toString(), "21", line.end[1].toString(), "31", "0" // Z coordinate (2D)
201
+ );
202
+ return entity;
203
+ }
204
+ /**
205
+ * Generate a CIRCLE entity
206
+ */
207
+ generateCircleEntity(circle, part) {
208
+ const entity = [
209
+ "0",
210
+ "CIRCLE",
211
+ "5",
212
+ this.getNextHandle(),
213
+ "100",
214
+ "AcDbEntity"
215
+ ];
216
+ // Add layer
217
+ entity.push("8", part.layer || "0");
218
+ // Add color if specified
219
+ if (part.color !== undefined) {
220
+ const colorCodes = this.convertColorToDxf(part.color);
221
+ colorCodes.forEach(cc => entity.push(cc.code, cc.value));
222
+ }
223
+ entity.push("100", "AcDbCircle", "10", circle.center[0].toString(), "20", circle.center[1].toString(), "30", "0", // Z coordinate (2D)
224
+ "40", circle.radius.toString());
225
+ return entity;
226
+ }
227
+ /**
228
+ * Generate an ARC entity
229
+ */
230
+ generateArcEntity(arc, part) {
231
+ const entity = [
232
+ "0",
233
+ "ARC",
234
+ "5",
235
+ this.getNextHandle(),
236
+ "100",
237
+ "AcDbEntity"
238
+ ];
239
+ // Add layer
240
+ entity.push("8", part.layer || "0");
241
+ // Add color if specified
242
+ if (part.color !== undefined) {
243
+ const colorCodes = this.convertColorToDxf(part.color);
244
+ colorCodes.forEach(cc => entity.push(cc.code, cc.value));
245
+ }
246
+ entity.push("100", "AcDbCircle", "10", arc.center[0].toString(), "20", arc.center[1].toString(), "30", "0", // Z coordinate (2D)
247
+ "40", arc.radius.toString(), "100", "AcDbArc", "50", arc.startAngle.toString(), "51", arc.endAngle.toString());
248
+ return entity;
249
+ }
250
+ /**
251
+ * Generate a LWPOLYLINE entity
252
+ */
253
+ generatePolylineEntity(polyline, part) {
254
+ const entity = [
255
+ "0",
256
+ "LWPOLYLINE",
257
+ "5",
258
+ this.getNextHandle(),
259
+ "100",
260
+ "AcDbEntity"
261
+ ];
262
+ // Add layer
263
+ entity.push("8", part.layer || "0");
264
+ // Add color if specified
265
+ if (part.color !== undefined) {
266
+ const colorCodes = this.convertColorToDxf(part.color);
267
+ colorCodes.forEach(cc => entity.push(cc.code, cc.value));
268
+ }
269
+ const isClosed = polyline.closed || (polyline.points.length > 2 && this.isClosedPolyline(polyline.points));
270
+ entity.push("100", "AcDbPolyline", "90", polyline.points.length.toString(), "70", isClosed ? "1" : "0");
271
+ // Add vertices
272
+ polyline.points.forEach((point, index) => {
273
+ entity.push("10", point[0].toString(), "20", point[1].toString());
274
+ // Add bulge value if specified (for arc segments)
275
+ if (polyline.bulges && polyline.bulges.length > index) {
276
+ const bulge = polyline.bulges[index];
277
+ if (bulge !== 0) {
278
+ entity.push("42", bulge.toString());
279
+ }
280
+ }
281
+ });
282
+ return entity;
283
+ }
284
+ /**
285
+ * Generate a SPLINE entity
286
+ */
287
+ generateSplineEntity(spline, part) {
288
+ const entity = [
289
+ "0",
290
+ "SPLINE",
291
+ "5",
292
+ this.getNextHandle(),
293
+ "100",
294
+ "AcDbEntity"
295
+ ];
296
+ // Add layer
297
+ entity.push("8", part.layer || "0");
298
+ // Add color if specified
299
+ if (part.color !== undefined) {
300
+ const colorCodes = this.convertColorToDxf(part.color);
301
+ colorCodes.forEach(cc => entity.push(cc.code, cc.value));
302
+ }
303
+ const degree = spline.degree || 3;
304
+ const numControlPoints = spline.controlPoints.length;
305
+ const numKnots = numControlPoints + degree + 1;
306
+ // Spline flags: 1 = closed, 2 = periodic, 4 = rational, 8 = planar, 16 = linear
307
+ const flags = spline.closed ? 1 : 0;
308
+ entity.push("100", "AcDbSpline", "210", "0", "220", "0", "230", "1", // Normal vector (Z-axis for 2D)
309
+ "70", flags.toString(), "71", degree.toString(), "72", numKnots.toString(), "73", numControlPoints.toString(), "74", "0" // Number of fit points (we're using control points)
310
+ );
311
+ // Generate knot values (uniform knot vector)
312
+ for (let i = 0; i < numKnots; i++) {
313
+ entity.push("40", i.toString());
314
+ }
315
+ // Add control points
316
+ spline.controlPoints.forEach(point => {
317
+ entity.push("10", point[0].toString(), "20", point[1].toString(), "30", "0" // Z coordinate (2D)
318
+ );
319
+ });
320
+ return entity;
321
+ }
322
+ /**
323
+ * Check if polyline should be closed (first and last points are the same)
324
+ */
325
+ isClosedPolyline(points) {
326
+ if (points.length < 3)
327
+ return false;
328
+ const first = points[0];
329
+ const last = points[points.length - 1];
330
+ return Math.abs(first[0] - last[0]) < 1e-10 &&
331
+ Math.abs(first[1] - last[1]) < 1e-10;
332
+ }
333
+ /**
334
+ * Get next entity handle as hex string
335
+ */
336
+ getNextHandle() {
337
+ return (++this.entityHandle).toString(16).toUpperCase();
338
+ }
339
+ /**
340
+ * Convert color to DXF format
341
+ * Accepts hex color (#RRGGBB) or ACI color index (1-255)
342
+ * Returns appropriate DXF color codes
343
+ */
344
+ convertColorToDxf(color) {
345
+ // If it's already a number (ACI index), use it directly
346
+ if (/^\d+$/.test(color)) {
347
+ const colorIndex = parseInt(color, 10);
348
+ if (colorIndex >= 1 && colorIndex <= 255) {
349
+ return [{ code: "62", value: color }];
350
+ }
351
+ }
352
+ // If it's a hex color, convert to true color (24-bit RGB)
353
+ if (color.startsWith("#")) {
354
+ const hex = color.substring(1);
355
+ if (hex.length === 6) {
356
+ const r = parseInt(hex.substring(0, 2), 16);
357
+ const g = parseInt(hex.substring(2, 4), 16);
358
+ const b = parseInt(hex.substring(4, 6), 16);
359
+ // True color value = (R * 65536) + (G * 256) + B
360
+ const trueColor = (r * 65536) + (g * 256) + b;
361
+ // Use group code 420 for true color (24-bit)
362
+ return [
363
+ { code: "62", value: "256" },
364
+ { code: "420", value: trueColor.toString() }
365
+ ];
366
+ }
367
+ }
368
+ // Default to white (7) if color can't be parsed
369
+ return [{ code: "62", value: "7" }];
370
+ }
371
+ }
@@ -0,0 +1,77 @@
1
+ import * as Inputs from "../../../inputs";
2
+ export declare class Dxf {
3
+ private dxfGenerator;
4
+ /**
5
+ * Creates a line segment for DXF paths
6
+ * @param inputs Line segment definition
7
+ * @returns Line segment DTO
8
+ * @group dxf
9
+ * @shortname line segment
10
+ * @drawable false
11
+ */
12
+ lineSegment(inputs: Inputs.IO.DxfLineSegmentDto): Inputs.IO.DxfLineSegmentDto;
13
+ /**
14
+ * Creates an arc segment for DXF paths
15
+ * @param inputs Arc segment definition
16
+ * @returns Arc segment DTO
17
+ * @group dxf
18
+ * @shortname arc segment
19
+ * @drawable false
20
+ */
21
+ arcSegment(inputs: Inputs.IO.DxfArcSegmentDto): Inputs.IO.DxfArcSegmentDto;
22
+ /**
23
+ * Creates a circle segment for DXF paths
24
+ * @param inputs Circle segment definition
25
+ * @returns Circle segment DTO
26
+ * @group dxf
27
+ * @shortname circle segment
28
+ * @drawable false
29
+ */
30
+ circleSegment(inputs: Inputs.IO.DxfCircleSegmentDto): Inputs.IO.DxfCircleSegmentDto;
31
+ /**
32
+ * Creates a polyline segment for DXF paths
33
+ * @param inputs Polyline segment definition
34
+ * @returns Polyline segment DTO
35
+ * @group dxf
36
+ * @shortname polyline segment
37
+ * @drawable false
38
+ */
39
+ polylineSegment(inputs: Inputs.IO.DxfPolylineSegmentDto): Inputs.IO.DxfPolylineSegmentDto;
40
+ /**
41
+ * Creates a spline segment for DXF paths
42
+ * @param inputs Spline segment definition
43
+ * @returns Spline segment DTO
44
+ * @group dxf
45
+ * @shortname spline segment
46
+ * @drawable false
47
+ */
48
+ splineSegment(inputs: Inputs.IO.DxfSplineSegmentDto): Inputs.IO.DxfSplineSegmentDto;
49
+ /**
50
+ * Creates a path from segments
51
+ * @param inputs Path definition with segments
52
+ * @returns Path DTO
53
+ * @group dxf
54
+ * @shortname path
55
+ * @drawable false
56
+ */
57
+ path(inputs: Inputs.IO.DxfPathDto): Inputs.IO.DxfPathDto;
58
+ /**
59
+ * Creates a paths part with layer and color
60
+ * @param inputs Paths part definition
61
+ * @returns Paths part DTO
62
+ * @group dxf
63
+ * @shortname paths part
64
+ * @drawable false
65
+ */
66
+ pathsPart(inputs: Inputs.IO.DxfPathsPartDto): Inputs.IO.DxfPathsPartDto;
67
+ /**
68
+ * DXF generator that supports lines, arcs, circles, polylines, and splines organized in paths.
69
+ * Paths can combine multiple segment types similar to OCCT wires.
70
+ * @param inputs DXF model definition
71
+ * @returns DXF file content as string
72
+ * @group dxf
73
+ * @shortname dxf create
74
+ * @drawable false
75
+ */
76
+ dxfCreate(inputs: Inputs.IO.DxfModelDto): string;
77
+ }
@@ -0,0 +1,95 @@
1
+ import { DxfGenerator } from "./dxf-generator";
2
+ export class Dxf {
3
+ constructor() {
4
+ this.dxfGenerator = new DxfGenerator();
5
+ }
6
+ /**
7
+ * Creates a line segment for DXF paths
8
+ * @param inputs Line segment definition
9
+ * @returns Line segment DTO
10
+ * @group dxf
11
+ * @shortname line segment
12
+ * @drawable false
13
+ */
14
+ lineSegment(inputs) {
15
+ return inputs;
16
+ }
17
+ /**
18
+ * Creates an arc segment for DXF paths
19
+ * @param inputs Arc segment definition
20
+ * @returns Arc segment DTO
21
+ * @group dxf
22
+ * @shortname arc segment
23
+ * @drawable false
24
+ */
25
+ arcSegment(inputs) {
26
+ return inputs;
27
+ }
28
+ /**
29
+ * Creates a circle segment for DXF paths
30
+ * @param inputs Circle segment definition
31
+ * @returns Circle segment DTO
32
+ * @group dxf
33
+ * @shortname circle segment
34
+ * @drawable false
35
+ */
36
+ circleSegment(inputs) {
37
+ return inputs;
38
+ }
39
+ /**
40
+ * Creates a polyline segment for DXF paths
41
+ * @param inputs Polyline segment definition
42
+ * @returns Polyline segment DTO
43
+ * @group dxf
44
+ * @shortname polyline segment
45
+ * @drawable false
46
+ */
47
+ polylineSegment(inputs) {
48
+ return inputs;
49
+ }
50
+ /**
51
+ * Creates a spline segment for DXF paths
52
+ * @param inputs Spline segment definition
53
+ * @returns Spline segment DTO
54
+ * @group dxf
55
+ * @shortname spline segment
56
+ * @drawable false
57
+ */
58
+ splineSegment(inputs) {
59
+ return inputs;
60
+ }
61
+ /**
62
+ * Creates a path from segments
63
+ * @param inputs Path definition with segments
64
+ * @returns Path DTO
65
+ * @group dxf
66
+ * @shortname path
67
+ * @drawable false
68
+ */
69
+ path(inputs) {
70
+ return inputs;
71
+ }
72
+ /**
73
+ * Creates a paths part with layer and color
74
+ * @param inputs Paths part definition
75
+ * @returns Paths part DTO
76
+ * @group dxf
77
+ * @shortname paths part
78
+ * @drawable false
79
+ */
80
+ pathsPart(inputs) {
81
+ return inputs;
82
+ }
83
+ /**
84
+ * DXF generator that supports lines, arcs, circles, polylines, and splines organized in paths.
85
+ * Paths can combine multiple segment types similar to OCCT wires.
86
+ * @param inputs DXF model definition
87
+ * @returns DXF file content as string
88
+ * @group dxf
89
+ * @shortname dxf create
90
+ * @drawable false
91
+ */
92
+ dxfCreate(inputs) {
93
+ return this.dxfGenerator.generateDxf(inputs);
94
+ }
95
+ }
@@ -11,3 +11,4 @@ export * from "./geometry-helper";
11
11
  export * from "./line";
12
12
  export * from "./polyline";
13
13
  export * from "./mesh";
14
+ export * from "./io";
@@ -11,3 +11,4 @@ export * from "./geometry-helper";
11
11
  export * from "./line";
12
12
  export * from "./polyline";
13
13
  export * from "./mesh";
14
+ export * from "./io";
@@ -0,0 +1,5 @@
1
+ import { Dxf } from "./helpers/dxf/dxf";
2
+ export declare class IoBitByBit {
3
+ dxf: Dxf;
4
+ constructor();
5
+ }
@@ -0,0 +1,6 @@
1
+ import { Dxf } from "./helpers/dxf/dxf";
2
+ export class IoBitByBit {
3
+ constructor() {
4
+ this.dxf = new Dxf();
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitbybit-dev/base",
3
- "version": "0.20.8",
3
+ "version": "0.20.9",
4
4
  "description": "Bit By Bit Developers Base CAD Library to Program Geometry",
5
5
  "main": "index.js",
6
6
  "repository": {