@ifc-lite/drawing-2d 1.18.6 → 1.20.0
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.
- package/README.md +23 -0
- package/dist/dxf/aci-colors.d.ts +17 -0
- package/dist/dxf/aci-colors.d.ts.map +1 -0
- package/dist/dxf/aci-colors.js +142 -0
- package/dist/dxf/aci-colors.js.map +1 -0
- package/dist/dxf/convert.d.ts +32 -0
- package/dist/dxf/convert.d.ts.map +1 -0
- package/dist/dxf/convert.js +382 -0
- package/dist/dxf/convert.js.map +1 -0
- package/dist/dxf/geom.d.ts +70 -0
- package/dist/dxf/geom.d.ts.map +1 -0
- package/dist/dxf/geom.js +194 -0
- package/dist/dxf/geom.js.map +1 -0
- package/dist/dxf/index.d.ts +13 -0
- package/dist/dxf/index.d.ts.map +1 -0
- package/dist/dxf/index.js +44 -0
- package/dist/dxf/index.js.map +1 -0
- package/dist/dxf/parser.d.ts +9 -0
- package/dist/dxf/parser.d.ts.map +1 -0
- package/dist/dxf/parser.js +903 -0
- package/dist/dxf/parser.js.map +1 -0
- package/dist/dxf/types.d.ts +255 -0
- package/dist/dxf/types.d.ts.map +1 -0
- package/dist/dxf/types.js +10 -0
- package/dist/dxf/types.js.map +1 -0
- package/dist/dxf/writer.d.ts +111 -0
- package/dist/dxf/writer.d.ts.map +1 -0
- package/dist/dxf/writer.js +338 -0
- package/dist/dxf/writer.js.map +1 -0
- package/dist/dxf-exporter.d.ts +66 -0
- package/dist/dxf-exporter.d.ts.map +1 -0
- package/dist/dxf-exporter.js +137 -0
- package/dist/dxf-exporter.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/svg-exporter.d.ts +23 -0
- package/dist/svg-exporter.d.ts.map +1 -1
- package/dist/svg-exporter.js +80 -1
- package/dist/svg-exporter.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometry helpers for DXF import: arc/bulge tessellation and 2D affine
|
|
3
|
+
* transforms. Shared by the parser (HATCH edge paths) and the converter
|
|
4
|
+
* (entity tessellation, block expansion).
|
|
5
|
+
*/
|
|
6
|
+
import type { DxfVertex } from './types.js';
|
|
7
|
+
export declare function arcSegmentCount(sweepRad: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Sample a circular arc from `startDeg` to `endDeg` (degrees, CCW from +X).
|
|
10
|
+
* When `endDeg <= startDeg` the arc wraps through 360 (DXF convention).
|
|
11
|
+
* Includes both endpoints.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sampleArc(cx: number, cy: number, r: number, startDeg: number, endDeg: number): Array<{
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}>;
|
|
17
|
+
/** Sample a full circle (closed loop; last point NOT repeated). */
|
|
18
|
+
export declare function sampleCircle(cx: number, cy: number, r: number): Array<{
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Sample an elliptical arc. `startParam`/`endParam` are parametric angles in
|
|
24
|
+
* radians; the point at parameter t is `c + major·cos(t) + minor·sin(t)`
|
|
25
|
+
* where `minor = ratio · perp(major)`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sampleEllipse(cx: number, cy: number, majorX: number, majorY: number, ratio: number, startParam: number, endParam: number): Array<{
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Expand a polyline vertex loop with bulges into a flat point list.
|
|
33
|
+
* A bulge b = tan(sweep/4) describes the arc from a vertex to the next one
|
|
34
|
+
* (positive = CCW). Closed loops also expand the bulge of the last vertex
|
|
35
|
+
* (arc back to the first). Includes the first point; for closed loops the
|
|
36
|
+
* first point is not repeated at the end.
|
|
37
|
+
*/
|
|
38
|
+
export declare function expandBulgedVertices(vertices: DxfVertex[], closed: boolean): Array<{
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Sample a SPLINE entity as a polyline. Fit points win when present (they
|
|
44
|
+
* lie on the curve); otherwise a clamped B-spline is evaluated with de
|
|
45
|
+
* Boor's algorithm. Degenerate knot vectors fall back to the control
|
|
46
|
+
* polygon.
|
|
47
|
+
*/
|
|
48
|
+
export declare function tessellateSpline(degree: number, knots: number[], controlPoints: Array<{
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
}>, fitPoints: Array<{
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
}>, segmentsPerSpan?: number): Array<{
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** Column-major 2D affine: x' = a·x + c·y + tx, y' = b·x + d·y + ty. */
|
|
59
|
+
export type Mat2d = [number, number, number, number, number, number];
|
|
60
|
+
export declare const MAT_IDENTITY: Mat2d;
|
|
61
|
+
/** Compose so that `m2` is applied first, then `m1`. */
|
|
62
|
+
export declare function matMultiply(m1: Mat2d, m2: Mat2d): Mat2d;
|
|
63
|
+
export declare function matApply(m: Mat2d, x: number, y: number): {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
};
|
|
67
|
+
/** translate(tx,ty) ∘ rotate(deg CCW) ∘ scale(sx,sy). */
|
|
68
|
+
export declare function matTRS(tx: number, ty: number, rotationDeg: number, sx: number, sy: number): Mat2d;
|
|
69
|
+
export declare function matTranslate(tx: number, ty: number): Mat2d;
|
|
70
|
+
//# sourceMappingURL=geom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geom.d.ts","sourceRoot":"","sources":["../../src/dxf/geom.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,wBAAgB,e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M,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAC1C,eAAe,SAAI,GAClB,KAAK,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBjC;AAoCD,wEAAwE;AACxE,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErE,eAAO,MAAM,YAAY,EAAE,KAA0B,CAAC;AAEtD,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,KAAK,CASvD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAEjF;AAED,yDAAyD;AACzD,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAKjG;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAE1D"}
|
package/dist/dxf/geom.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/** Angular resolution for tessellated arcs (radians). ~5 degrees. */
|
|
5
|
+
const ARC_STEP = Math.PI / 36;
|
|
6
|
+
const MIN_ARC_SEGMENTS = 4;
|
|
7
|
+
const MAX_ARC_SEGMENTS = 128;
|
|
8
|
+
export function arcSegmentCount(sweepRad) {
|
|
9
|
+
const n = Math.ceil(Math.abs(sweepRad) / ARC_STEP);
|
|
10
|
+
return Math.min(MAX_ARC_SEGMENTS, Math.max(MIN_ARC_SEGMENTS, n));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sample a circular arc from `startDeg` to `endDeg` (degrees, CCW from +X).
|
|
14
|
+
* When `endDeg <= startDeg` the arc wraps through 360 (DXF convention).
|
|
15
|
+
* Includes both endpoints.
|
|
16
|
+
*/
|
|
17
|
+
export function sampleArc(cx, cy, r, startDeg, endDeg) {
|
|
18
|
+
const start = (startDeg * Math.PI) / 180;
|
|
19
|
+
let end = (endDeg * Math.PI) / 180;
|
|
20
|
+
if (end <= start)
|
|
21
|
+
end += Math.PI * 2;
|
|
22
|
+
const sweep = end - start;
|
|
23
|
+
const n = arcSegmentCount(sweep);
|
|
24
|
+
const pts = [];
|
|
25
|
+
for (let i = 0; i <= n; i++) {
|
|
26
|
+
const a = start + (sweep * i) / n;
|
|
27
|
+
pts.push({ x: cx + r * Math.cos(a), y: cy + r * Math.sin(a) });
|
|
28
|
+
}
|
|
29
|
+
return pts;
|
|
30
|
+
}
|
|
31
|
+
/** Sample a full circle (closed loop; last point NOT repeated). */
|
|
32
|
+
export function sampleCircle(cx, cy, r) {
|
|
33
|
+
const n = arcSegmentCount(Math.PI * 2);
|
|
34
|
+
const pts = [];
|
|
35
|
+
for (let i = 0; i < n; i++) {
|
|
36
|
+
const a = (Math.PI * 2 * i) / n;
|
|
37
|
+
pts.push({ x: cx + r * Math.cos(a), y: cy + r * Math.sin(a) });
|
|
38
|
+
}
|
|
39
|
+
return pts;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sample an elliptical arc. `startParam`/`endParam` are parametric angles in
|
|
43
|
+
* radians; the point at parameter t is `c + major·cos(t) + minor·sin(t)`
|
|
44
|
+
* where `minor = ratio · perp(major)`.
|
|
45
|
+
*/
|
|
46
|
+
export function sampleEllipse(cx, cy, majorX, majorY, ratio, startParam, endParam) {
|
|
47
|
+
let end = endParam;
|
|
48
|
+
if (end <= startParam)
|
|
49
|
+
end += Math.PI * 2;
|
|
50
|
+
const sweep = end - startParam;
|
|
51
|
+
const n = arcSegmentCount(sweep);
|
|
52
|
+
const minorX = -majorY * ratio;
|
|
53
|
+
const minorY = majorX * ratio;
|
|
54
|
+
const pts = [];
|
|
55
|
+
for (let i = 0; i <= n; i++) {
|
|
56
|
+
const t = startParam + (sweep * i) / n;
|
|
57
|
+
const c = Math.cos(t);
|
|
58
|
+
const s = Math.sin(t);
|
|
59
|
+
pts.push({ x: cx + majorX * c + minorX * s, y: cy + majorY * c + minorY * s });
|
|
60
|
+
}
|
|
61
|
+
return pts;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Expand a polyline vertex loop with bulges into a flat point list.
|
|
65
|
+
* A bulge b = tan(sweep/4) describes the arc from a vertex to the next one
|
|
66
|
+
* (positive = CCW). Closed loops also expand the bulge of the last vertex
|
|
67
|
+
* (arc back to the first). Includes the first point; for closed loops the
|
|
68
|
+
* first point is not repeated at the end.
|
|
69
|
+
*/
|
|
70
|
+
export function expandBulgedVertices(vertices, closed) {
|
|
71
|
+
const out = [];
|
|
72
|
+
const count = vertices.length;
|
|
73
|
+
if (count === 0)
|
|
74
|
+
return out;
|
|
75
|
+
const segments = closed ? count : count - 1;
|
|
76
|
+
out.push({ x: vertices[0].x, y: vertices[0].y });
|
|
77
|
+
for (let i = 0; i < segments; i++) {
|
|
78
|
+
const a = vertices[i];
|
|
79
|
+
const b = vertices[(i + 1) % count];
|
|
80
|
+
const isLast = i === segments - 1;
|
|
81
|
+
if (!a.bulge || !isFinite(a.bulge)) {
|
|
82
|
+
if (!(closed && isLast))
|
|
83
|
+
out.push({ x: b.x, y: b.y });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
// Arc through a→b with included angle 4·atan(bulge).
|
|
87
|
+
const sweep = 4 * Math.atan(a.bulge);
|
|
88
|
+
const dx = b.x - a.x;
|
|
89
|
+
const dy = b.y - a.y;
|
|
90
|
+
const chord = Math.hypot(dx, dy);
|
|
91
|
+
if (chord < 1e-12 || Math.abs(sweep) < 1e-9) {
|
|
92
|
+
if (!(closed && isLast))
|
|
93
|
+
out.push({ x: b.x, y: b.y });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const radius = chord / (2 * Math.sin(Math.abs(sweep) / 2));
|
|
97
|
+
// Centre is offset from the chord midpoint along the perpendicular;
|
|
98
|
+
// sign of the bulge picks the side.
|
|
99
|
+
const mx = (a.x + b.x) / 2;
|
|
100
|
+
const my = (a.y + b.y) / 2;
|
|
101
|
+
const h = Math.sqrt(Math.max(0, radius * radius - (chord / 2) * (chord / 2)));
|
|
102
|
+
const side = (sweep > 0 ? 1 : -1) * (Math.abs(sweep) > Math.PI ? -1 : 1);
|
|
103
|
+
const ux = -dy / chord;
|
|
104
|
+
const uy = dx / chord;
|
|
105
|
+
const ccx = mx + ux * h * side;
|
|
106
|
+
const ccy = my + uy * h * side;
|
|
107
|
+
const startAngle = Math.atan2(a.y - ccy, a.x - ccx);
|
|
108
|
+
const n = arcSegmentCount(sweep);
|
|
109
|
+
for (let k = 1; k <= n; k++) {
|
|
110
|
+
if (closed && isLast && k === n)
|
|
111
|
+
break; // do not repeat the first point
|
|
112
|
+
const t = startAngle + (sweep * k) / n;
|
|
113
|
+
out.push({ x: ccx + radius * Math.cos(t), y: ccy + radius * Math.sin(t) });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Sample a SPLINE entity as a polyline. Fit points win when present (they
|
|
120
|
+
* lie on the curve); otherwise a clamped B-spline is evaluated with de
|
|
121
|
+
* Boor's algorithm. Degenerate knot vectors fall back to the control
|
|
122
|
+
* polygon.
|
|
123
|
+
*/
|
|
124
|
+
export function tessellateSpline(degree, knots, controlPoints, fitPoints, segmentsPerSpan = 8) {
|
|
125
|
+
if (fitPoints.length >= 2)
|
|
126
|
+
return fitPoints.map((p) => ({ x: p.x, y: p.y }));
|
|
127
|
+
const deg = Math.max(1, degree);
|
|
128
|
+
const expectedKnots = controlPoints.length + deg + 1;
|
|
129
|
+
if (controlPoints.length < deg + 1 || knots.length !== expectedKnots) {
|
|
130
|
+
return controlPoints.map((p) => ({ x: p.x, y: p.y }));
|
|
131
|
+
}
|
|
132
|
+
const tMin = knots[deg];
|
|
133
|
+
const tMax = knots[knots.length - 1 - deg];
|
|
134
|
+
if (!(tMax > tMin)) {
|
|
135
|
+
return controlPoints.map((p) => ({ x: p.x, y: p.y }));
|
|
136
|
+
}
|
|
137
|
+
const samples = Math.min(1024, Math.max(8, (controlPoints.length - deg) * segmentsPerSpan));
|
|
138
|
+
const points = [];
|
|
139
|
+
for (let i = 0; i <= samples; i++) {
|
|
140
|
+
const t = tMin + ((tMax - tMin) * i) / samples;
|
|
141
|
+
points.push(deBoor(t, deg, controlPoints, knots));
|
|
142
|
+
}
|
|
143
|
+
return points;
|
|
144
|
+
}
|
|
145
|
+
/** de Boor's algorithm for a clamped B-spline at parameter t. */
|
|
146
|
+
function deBoor(t, degree, ctrl, knots) {
|
|
147
|
+
let k = degree;
|
|
148
|
+
const maxSpan = knots.length - degree - 2;
|
|
149
|
+
while (k < maxSpan && t >= knots[k + 1])
|
|
150
|
+
k++;
|
|
151
|
+
const d = [];
|
|
152
|
+
for (let j = 0; j <= degree; j++) {
|
|
153
|
+
const p = ctrl[Math.min(ctrl.length - 1, Math.max(0, j + k - degree))];
|
|
154
|
+
d.push({ x: p.x, y: p.y });
|
|
155
|
+
}
|
|
156
|
+
for (let r = 1; r <= degree; r++) {
|
|
157
|
+
for (let j = degree; j >= r; j--) {
|
|
158
|
+
const i = j + k - degree;
|
|
159
|
+
const denom = knots[i + degree - r + 1] - knots[i];
|
|
160
|
+
const alpha = denom > 0 ? (t - knots[i]) / denom : 0;
|
|
161
|
+
d[j] = {
|
|
162
|
+
x: (1 - alpha) * d[j - 1].x + alpha * d[j].x,
|
|
163
|
+
y: (1 - alpha) * d[j - 1].y + alpha * d[j].y,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return d[degree];
|
|
168
|
+
}
|
|
169
|
+
export const MAT_IDENTITY = [1, 0, 0, 1, 0, 0];
|
|
170
|
+
/** Compose so that `m2` is applied first, then `m1`. */
|
|
171
|
+
export function matMultiply(m1, m2) {
|
|
172
|
+
return [
|
|
173
|
+
m1[0] * m2[0] + m1[2] * m2[1],
|
|
174
|
+
m1[1] * m2[0] + m1[3] * m2[1],
|
|
175
|
+
m1[0] * m2[2] + m1[2] * m2[3],
|
|
176
|
+
m1[1] * m2[2] + m1[3] * m2[3],
|
|
177
|
+
m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
|
|
178
|
+
m1[1] * m2[4] + m1[3] * m2[5] + m1[5],
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
export function matApply(m, x, y) {
|
|
182
|
+
return { x: m[0] * x + m[2] * y + m[4], y: m[1] * x + m[3] * y + m[5] };
|
|
183
|
+
}
|
|
184
|
+
/** translate(tx,ty) ∘ rotate(deg CCW) ∘ scale(sx,sy). */
|
|
185
|
+
export function matTRS(tx, ty, rotationDeg, sx, sy) {
|
|
186
|
+
const rad = (rotationDeg * Math.PI) / 180;
|
|
187
|
+
const c = Math.cos(rad);
|
|
188
|
+
const s = Math.sin(rad);
|
|
189
|
+
return [c * sx, s * sx, -s * sy, c * sy, tx, ty];
|
|
190
|
+
}
|
|
191
|
+
export function matTranslate(tx, ty) {
|
|
192
|
+
return [1, 0, 0, 1, tx, ty];
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=geom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geom.js","sourceRoot":"","sources":["../../src/dxf/geom.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAU/D,qEAAqE;AACrE,MAAM,QAAQ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C,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,MAAM,CAAC,EAAU,EAAE,EAAU,EAAE,WAAmB,EAAE,EAAU,EAAE,EAAU;IACxF,MAAM,GAAG,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAU,EAAE,EAAU;IACjD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DxfUnderlay } from './types.js';
|
|
2
|
+
export { parseDxf, readDxfPairs, decodeDxfText, stripMtextFormatting } from './parser.js';
|
|
3
|
+
export { convertDxfToUnderlay, applyDxfPlacement, type DxfConvertOptions } from './convert.js';
|
|
4
|
+
export { aciToCss } from './aci-colors.js';
|
|
5
|
+
export { DEFAULT_DXF_PLACEMENT } from './types.js';
|
|
6
|
+
export type { DxfDocument, DxfEntity, DxfLayerInfo, DxfBlockInfo, DxfPair, DxfUnderlay, DxfUnderlayLayer, DxfUnderlayPath, DxfUnderlayFill, DxfUnderlayText, DxfPlacement, } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Parse and convert an ASCII DXF file to a reference underlay in one step.
|
|
9
|
+
* Unitless files whose extents exceed {@link UNITLESS_MM_EXTENT_THRESHOLD}
|
|
10
|
+
* drawing units are assumed to be in millimetres (with a warning).
|
|
11
|
+
*/
|
|
12
|
+
export declare function importDxf(text: string, name?: string): DxfUnderlay;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dxf/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EACV,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,YAAY,CAAC;AASpB;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,WAAW,CAejE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* DXF import as a 2D reference underlay (issue #1782).
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { importDxf } from '@ifc-lite/drawing-2d';
|
|
9
|
+
* const underlay = importDxf(dxfText, 'site-plan.dxf');
|
|
10
|
+
* // underlay.layers[n].paths / .fills / .texts are in drawing space (metres)
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { parseDxf } from './parser.js';
|
|
14
|
+
import { convertDxfToUnderlay } from './convert.js';
|
|
15
|
+
export { parseDxf, readDxfPairs, decodeDxfText, stripMtextFormatting } from './parser.js';
|
|
16
|
+
export { convertDxfToUnderlay, applyDxfPlacement } from './convert.js';
|
|
17
|
+
export { aciToCss } from './aci-colors.js';
|
|
18
|
+
export { DEFAULT_DXF_PLACEMENT } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Unitless DXF files ($INSUNITS = 0) with large coordinate extents are
|
|
21
|
+
* almost always millimetre drawings (the AutoCAD metric template leaves
|
|
22
|
+
* INSUNITS unset). Above this extent in raw drawing units, assume mm.
|
|
23
|
+
*/
|
|
24
|
+
const UNITLESS_MM_EXTENT_THRESHOLD = 5000;
|
|
25
|
+
/**
|
|
26
|
+
* Parse and convert an ASCII DXF file to a reference underlay in one step.
|
|
27
|
+
* Unitless files whose extents exceed {@link UNITLESS_MM_EXTENT_THRESHOLD}
|
|
28
|
+
* drawing units are assumed to be in millimetres (with a warning).
|
|
29
|
+
*/
|
|
30
|
+
export function importDxf(text, name = 'DXF') {
|
|
31
|
+
const doc = parseDxf(text);
|
|
32
|
+
const underlay = convertDxfToUnderlay(doc, name);
|
|
33
|
+
if (doc.insunits === 0) {
|
|
34
|
+
const b = underlay.bounds;
|
|
35
|
+
const extent = Math.max(b.max.x - b.min.x, b.max.y - b.min.y);
|
|
36
|
+
if (extent > UNITLESS_MM_EXTENT_THRESHOLD) {
|
|
37
|
+
const rescaled = convertDxfToUnderlay(doc, name, { metersPerUnit: 0.001 });
|
|
38
|
+
rescaled.warnings.push(`DXF has no $INSUNITS and spans ${Math.round(extent)} units; assumed millimetres.`);
|
|
39
|
+
return rescaled;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return underlay;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @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pB,kCAAkC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,8BAA8B,CACnF,CAAC;YACF,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DxfDocument, DxfPair } from './types.js';
|
|
2
|
+
/** Split an ASCII DXF file into (code, value) pairs. */
|
|
3
|
+
export declare function readDxfPairs(text: string): DxfPair[];
|
|
4
|
+
/** Decode DXF special sequences (%%d, %%p, %%c, \U+XXXX). */
|
|
5
|
+
export declare function decodeDxfText(raw: string): string;
|
|
6
|
+
/** Strip MTEXT inline formatting down to plain text. Best-effort. */
|
|
7
|
+
export declare function stripMtextFormatting(raw: string): string;
|
|
8
|
+
export declare function parseDxf(text: string): DxfDocument;
|
|
9
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/dxf/parser.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAKV,WAAW,EASX,OAAO,EAIR,MAAM,YAAY,CAAC;AAapB,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAoBpD;AAMD,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjD;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWxD;AA8BD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CA0ClD"}
|