@bitbybit-dev/base 1.6.1 → 1.7.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/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +36 -7
- package/lib/api/inputs/base-inputs.js +10 -0
- package/lib/api/inputs/color-inputs.d.ts +54 -1
- package/lib/api/inputs/color-inputs.js +73 -1
- package/lib/api/inputs/frame-inputs.d.ts +2 -1
- package/lib/api/inputs/frame-inputs.js +2 -1
- package/lib/api/inputs/io-inputs.d.ts +527 -59
- package/lib/api/inputs/io-inputs.js +432 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- package/lib/api/inputs/math-inputs.d.ts +62 -0
- package/lib/api/inputs/math-inputs.js +82 -0
- package/lib/api/inputs/mesh-inputs.d.ts +16 -0
- package/lib/api/inputs/mesh-inputs.js +14 -0
- package/lib/api/inputs/transforms-inputs.d.ts +76 -0
- package/lib/api/inputs/transforms-inputs.js +85 -0
- package/lib/api/kernel-calls/index.d.ts +1 -0
- package/lib/api/kernel-calls/index.js +1 -0
- package/lib/api/kernel-calls/settings.d.ts +82 -0
- package/lib/api/kernel-calls/settings.js +123 -0
- package/lib/api/recipes/surface-mesh.d.ts +2 -1
- package/lib/api/recipes/surface-mesh.js +5 -3
- package/lib/api/resolved-inputs/index.d.ts +32 -2
- package/lib/api/services/base-bitbybit.d.ts +12 -0
- package/lib/api/services/base-bitbybit.js +19 -3
- package/lib/api/services/color.d.ts +36 -2
- package/lib/api/services/color.js +60 -11
- package/lib/api/services/helpers/color/color-forms.constants.d.ts +10 -0
- package/lib/api/services/helpers/color/color-forms.constants.js +10 -0
- package/lib/api/services/helpers/color/color-forms.d.ts +3 -0
- package/lib/api/services/helpers/color/color-forms.js +27 -0
- package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
- package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
- package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
- package/lib/api/services/helpers/color/css-colors.js +61 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
- package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +24 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +85 -0
- package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
- package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
- package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
- package/lib/api/services/helpers/curves/nurbs.js +10 -9
- package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +24 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
- package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +81 -523
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +81 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +69 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +71 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -1
- package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
- package/lib/api/services/helpers/files/file-bytes.js +15 -0
- package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
- package/lib/api/services/helpers/files/ground-axes.js +4 -0
- package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
- package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
- package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
- package/lib/api/services/helpers/files/stl-axes.js +22 -0
- package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
- package/lib/api/services/helpers/files/stl-types.js +1 -0
- package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/stl.constants.js +11 -0
- package/lib/api/services/helpers/files/stl.d.ts +3 -0
- package/lib/api/services/helpers/files/stl.js +93 -0
- package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
- package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
- package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
- package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.js +108 -0
- package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
- package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
- package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +16 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +153 -0
- package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
- package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +13 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +13 -0
- package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
- package/lib/api/services/helpers/files/work-budget.js +26 -0
- package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
- package/lib/api/services/helpers/geometry/affine2.js +18 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
- package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
- package/lib/api/services/helpers/geometry/quaternions.constants.d.ts +3 -0
- package/lib/api/services/helpers/geometry/quaternions.constants.js +3 -0
- package/lib/api/services/helpers/geometry/quaternions.d.ts +14 -0
- package/lib/api/services/helpers/geometry/quaternions.js +71 -0
- package/lib/api/services/helpers/geometry/scalars.constants.d.ts +1 -0
- package/lib/api/services/helpers/geometry/scalars.constants.js +1 -0
- package/lib/api/services/helpers/geometry/scalars.d.ts +3 -0
- package/lib/api/services/helpers/geometry/scalars.js +29 -1
- package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +1 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.js +40 -40
- package/lib/api/services/io/drawing.d.ts +170 -0
- package/lib/api/services/io/drawing.js +212 -0
- package/lib/api/services/io/dxf.d.ts +134 -0
- package/lib/api/services/io/dxf.js +167 -0
- package/lib/api/services/io/index.d.ts +4 -0
- package/lib/api/services/io/index.js +4 -0
- package/lib/api/services/io/io.d.ts +14 -0
- package/lib/api/services/io/io.js +15 -0
- package/lib/api/services/io/svg.d.ts +64 -0
- package/lib/api/services/io/svg.js +102 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- package/lib/api/services/math.d.ts +35 -0
- package/lib/api/services/math.js +56 -1
- package/lib/api/services/mesh.d.ts +17 -0
- package/lib/api/services/mesh.js +27 -1
- package/lib/api/services/point.d.ts +4 -1
- package/lib/api/services/point.js +9 -4
- package/lib/api/services/recipes.d.ts +3 -0
- package/lib/api/services/recipes.js +4 -1
- package/lib/api/services/text.d.ts +4 -1
- package/lib/api/services/text.js +8 -3
- package/lib/api/services/transforms.d.ts +119 -1
- package/lib/api/services/transforms.js +158 -30
- package/package.json +1 -1
- package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
- package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
- package/lib/api/services/io.d.ts +0 -9
- package/lib/api/services/io.js +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cross3, dot3, subtract3 } from "../geometry/vectors";
|
|
2
|
-
import { FLAT_SHARE, LEAF_TRIANGLES, PARALLEL, POINT_SHARE, PRUNE_SLACK, RAY_DIRECTIONS, WELD_SHARE } from "./mesh-proximity.constants";
|
|
1
|
+
import { add3, cross3, dot3, scale3, subtract3 } from "../geometry/vectors";
|
|
2
|
+
import { FLAT_SHARE, LEAF_TRIANGLES, TRIANGLE_SIDES, PARALLEL, POINT_SHARE, PRUNE_SLACK, RAY_DIRECTIONS, WELD_SHARE } from "./mesh-proximity.constants";
|
|
3
3
|
import { windingComponents } from "./mesh-orientation";
|
|
4
4
|
import { uniqueVectors } from "../geometry/vector-grid";
|
|
5
5
|
const CORNERS = 3;
|
|
@@ -130,47 +130,47 @@ function segmentsSquared(p1, q1, p2, q2) {
|
|
|
130
130
|
const gap = subtract3(along(p1, d1, s), along(p2, d2, t));
|
|
131
131
|
return dot3(gap, gap);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function nearestOnEdges(p, corners) {
|
|
134
|
+
let best;
|
|
135
|
+
let bestGap = Infinity;
|
|
136
|
+
for (let at = 0; at < TRIANGLE_SIDES; at++) {
|
|
137
|
+
const next = (at + 1) % TRIANGLE_SIDES;
|
|
138
|
+
const from = corners[at];
|
|
139
|
+
const run = subtract3(corners[next], from);
|
|
140
|
+
const length = dot3(run, run);
|
|
141
|
+
const share = length > 0 ? Math.min(1, Math.max(0, dot3(subtract3(p, from), run) / length)) : 0;
|
|
142
|
+
const point = add3(from, scale3(run, share));
|
|
143
|
+
const away = subtract3(p, point);
|
|
144
|
+
const gap = dot3(away, away);
|
|
145
|
+
if (best === undefined || gap < bestGap) {
|
|
146
|
+
const weights = [0, 0, 0];
|
|
147
|
+
weights[at] = 1 - share;
|
|
148
|
+
weights[next] = share;
|
|
149
|
+
best = { point, weights };
|
|
150
|
+
bestGap = gap;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return best;
|
|
154
|
+
}
|
|
155
|
+
export function closestOnTriangle(p, a, b, c) {
|
|
134
156
|
const ab = subtract3(b, a);
|
|
135
157
|
const ac = subtract3(c, a);
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return dot3(bp, bp);
|
|
147
|
-
}
|
|
148
|
-
const vc = d1 * d4 - d3 * d2;
|
|
149
|
-
if (vc <= 0 && d1 >= 0 && d3 <= 0) {
|
|
150
|
-
const q = subtract3(p, along(a, ab, d1 / (d1 - d3)));
|
|
151
|
-
return dot3(q, q);
|
|
152
|
-
}
|
|
153
|
-
const cp = subtract3(p, c);
|
|
154
|
-
const d5 = dot3(ab, cp);
|
|
155
|
-
const d6 = dot3(ac, cp);
|
|
156
|
-
if (d6 >= 0 && d5 <= d6) {
|
|
157
|
-
return dot3(cp, cp);
|
|
158
|
-
}
|
|
159
|
-
const vb = d5 * d2 - d1 * d6;
|
|
160
|
-
if (vb <= 0 && d2 >= 0 && d6 <= 0) {
|
|
161
|
-
const q = subtract3(p, along(a, ac, d2 / (d2 - d6)));
|
|
162
|
-
return dot3(q, q);
|
|
163
|
-
}
|
|
164
|
-
const va = d3 * d6 - d5 * d4;
|
|
165
|
-
if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {
|
|
166
|
-
const q = subtract3(p, along(b, subtract3(c, b), (d4 - d3) / (d4 - d3 + (d5 - d6))));
|
|
167
|
-
return dot3(q, q);
|
|
158
|
+
const facing = cross3(ab, ac);
|
|
159
|
+
const area = dot3(facing, facing);
|
|
160
|
+
if (area > FLAT_SHARE * dot3(ab, ab) * dot3(ac, ac)) {
|
|
161
|
+
const foot = subtract3(p, scale3(facing, dot3(facing, subtract3(p, a)) / area));
|
|
162
|
+
const u = dot3(cross3(subtract3(b, foot), subtract3(c, foot)), facing) / area;
|
|
163
|
+
const v = dot3(cross3(subtract3(c, foot), subtract3(a, foot)), facing) / area;
|
|
164
|
+
const w = 1 - u - v;
|
|
165
|
+
if (u >= 0 && v >= 0 && w >= 0) {
|
|
166
|
+
return { point: foot, weights: [u, v, w] };
|
|
167
|
+
}
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
return dot3(
|
|
169
|
+
return nearestOnEdges(p, [a, b, c]);
|
|
170
|
+
}
|
|
171
|
+
function pointTriangleSquared(p, a, b, c) {
|
|
172
|
+
const gap = subtract3(p, closestOnTriangle(p, a, b, c).point);
|
|
173
|
+
return dot3(gap, gap);
|
|
174
174
|
}
|
|
175
175
|
function rayTriangleHit(from, direction, a, b, c) {
|
|
176
176
|
const e1 = subtract3(b, a);
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import type { Dxf } from "./dxf";
|
|
3
|
+
import type { Svg } from "./svg";
|
|
4
|
+
/**
|
|
5
|
+
* Builds drawings as data, for any file format: segments of every kind, paths joined from segments,
|
|
6
|
+
* and parts that put paths on a layer with a color and a line type. `io.dxf.dxfCreate` writes the
|
|
7
|
+
* parts as DXF and `io.svg.svgCreate` as SVG; `svgToDxf` and `dxfToSvg` convert one file into the
|
|
8
|
+
* other through these parts.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Drawing {
|
|
11
|
+
private readonly dxfOf;
|
|
12
|
+
private readonly svgOf;
|
|
13
|
+
constructor(dxfOf: () => Dxf, svgOf: () => Svg);
|
|
14
|
+
/**
|
|
15
|
+
* Makes a straight segment of a drawing path, from `start` to `end`.
|
|
16
|
+
* @param inputs - The start and the end point
|
|
17
|
+
* @returns The line segment
|
|
18
|
+
* @group drawing
|
|
19
|
+
* @shortname line segment
|
|
20
|
+
* @drawable false
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
lineSegment(inputs: Inputs.IO.DrawingLineSegmentDto): Inputs.IO.DrawingLineSegmentDto;
|
|
27
|
+
/**
|
|
28
|
+
* Makes a circular arc of a drawing path, running counterclockwise about its `center` from
|
|
29
|
+
* `startAngle` to `endAngle`, in degrees, in the XY plane unless a `normal` tilts it.
|
|
30
|
+
* @param inputs - The center, the radius, the start and end angles and the plane's normal
|
|
31
|
+
* @returns The arc segment
|
|
32
|
+
* @group drawing
|
|
33
|
+
* @shortname arc segment
|
|
34
|
+
* @drawable false
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [0, 0], radius: 10, startAngle: 0, endAngle: 90 });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
arcSegment(inputs: Inputs.IO.DrawingArcSegmentDto): Inputs.IO.DrawingArcSegmentDto;
|
|
41
|
+
/**
|
|
42
|
+
* Makes a whole circle of a drawing path from its `center` and `radius`, in the XY plane unless a
|
|
43
|
+
* `normal` tilts it.
|
|
44
|
+
* @param inputs - The center, the radius and the plane's normal
|
|
45
|
+
* @returns The circle segment
|
|
46
|
+
* @group drawing
|
|
47
|
+
* @shortname circle segment
|
|
48
|
+
* @drawable false
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
circleSegment(inputs: Inputs.IO.DrawingCircleSegmentDto): Inputs.IO.DrawingCircleSegmentDto;
|
|
55
|
+
/**
|
|
56
|
+
* Makes connected straight segments through `points`, which `bulges` can bend into arcs;
|
|
57
|
+
* `closed` joins the last point back to the first.
|
|
58
|
+
* @param inputs - The points, whether the polyline is closed, and the bulges
|
|
59
|
+
* @returns The polyline segment
|
|
60
|
+
* @group drawing
|
|
61
|
+
* @shortname polyline segment
|
|
62
|
+
* @drawable false
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const slot = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [30, 0], [30, 10], [0, 10]], closed: true, bulges: [0, 1, 0, 1] });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
polylineSegment(inputs: Inputs.IO.DrawingPolylineSegmentDto): Inputs.IO.DrawingPolylineSegmentDto;
|
|
69
|
+
/**
|
|
70
|
+
* Makes a B-spline or NURBS curve of a drawing path from its control points and degree, with
|
|
71
|
+
* its knots and weights when they are given.
|
|
72
|
+
* @param inputs - The control points, the degree, whether it is closed, the knots and the weights
|
|
73
|
+
* @returns The spline segment
|
|
74
|
+
* @group drawing
|
|
75
|
+
* @shortname spline segment
|
|
76
|
+
* @drawable false
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const wave = bitbybit.io.drawing.splineSegment({ controlPoints: [[0, 0], [10, 8], [20, -8], [30, 0]], degree: 3 });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
splineSegment(inputs: Inputs.IO.DrawingSplineSegmentDto): Inputs.IO.DrawingSplineSegmentDto;
|
|
83
|
+
/**
|
|
84
|
+
* Makes an ellipse, or an arc of one, for a drawing path.
|
|
85
|
+
*
|
|
86
|
+
* The ellipse is given by its center, the vector to the end of its major axis and the minor to
|
|
87
|
+
* major ratio; parameters in radians pick the arc, running counterclockwise about the normal.
|
|
88
|
+
* @param inputs - The center, the major axis, the ratio, the start and end parameters and the plane's normal
|
|
89
|
+
* @returns The ellipse segment
|
|
90
|
+
* @group drawing
|
|
91
|
+
* @shortname ellipse segment
|
|
92
|
+
* @drawable false
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const lens = bitbybit.io.drawing.ellipseSegment({ center: [0, 0], majorAxis: [20, 0], ratio: 0.5, startParameter: 0, endParameter: Math.PI });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
ellipseSegment(inputs: Inputs.IO.DrawingEllipseSegmentDto): Inputs.IO.DrawingEllipseSegmentDto;
|
|
99
|
+
/**
|
|
100
|
+
* Joins segments into one path, drawn in order like the edges of a wire; segments that meet
|
|
101
|
+
* are drawn as one stroke in SVG.
|
|
102
|
+
* @param inputs - The segments, in order
|
|
103
|
+
* @returns The path
|
|
104
|
+
* @group drawing
|
|
105
|
+
* @shortname path
|
|
106
|
+
* @drawable false
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
110
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [40, 10], radius: 10, startAngle: 270, endAngle: 360 });
|
|
111
|
+
* const outline = bitbybit.io.drawing.path({ segments: [edge, corner] });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
path(inputs: Inputs.IO.DrawingPathDto): Inputs.IO.DrawingPathDto;
|
|
115
|
+
/**
|
|
116
|
+
* Puts paths on a named layer with a color and a line type, making one part of a drawing.
|
|
117
|
+
*
|
|
118
|
+
* A drawing may hold several parts; `io.dxf.dxfCreate` writes them as DXF and `io.svg.svgCreate`
|
|
119
|
+
* as SVG.
|
|
120
|
+
* @param inputs - The layer name, the color, the paths and the line type
|
|
121
|
+
* @returns The part
|
|
122
|
+
* @group drawing
|
|
123
|
+
* @shortname part
|
|
124
|
+
* @drawable false
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
128
|
+
* const cut = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }] });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
part(inputs: Inputs.IO.DrawingPartDto): Inputs.IO.DrawingPartDto;
|
|
132
|
+
/**
|
|
133
|
+
* Converts an SVG file into a DXF file, reading it as `io.svg.svgRead` does and writing it as
|
|
134
|
+
* `io.dxf.dxfCreate` does.
|
|
135
|
+
*
|
|
136
|
+
* Inkscape layers, stroke colors and dash patterns become DXF layers, colors and line types, and
|
|
137
|
+
* curves stay exact. With `unit` the drawing is read at true size and the DXF states that unit. A
|
|
138
|
+
* drawing too large to write throws.
|
|
139
|
+
* @param inputs - The SVG text, the unit, whether hidden elements are written, and the DXF's color format, version and curve tolerance
|
|
140
|
+
* @returns The DXF text and the reading's warnings
|
|
141
|
+
* @group convert
|
|
142
|
+
* @shortname svg to dxf
|
|
143
|
+
* @drawable false
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const converted = bitbybit.io.drawing.svgToDxf({ svg: svgText, unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
147
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: converted.dxf });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
svgToDxf(inputs: Inputs.IO.SvgToDxfDto): Inputs.IO.SvgToDxfResultDto;
|
|
151
|
+
/**
|
|
152
|
+
* Converts a DXF file into an SVG file, reading it as `io.dxf.dxfRead` does and writing it as
|
|
153
|
+
* `io.svg.svgCreate` does.
|
|
154
|
+
*
|
|
155
|
+
* Layers become Inkscape layers and the SVG takes its true size from the unit the DXF states.
|
|
156
|
+
* Splines given only by fit points are left out and named in `warnings`; a drawing too large to
|
|
157
|
+
* write throws.
|
|
158
|
+
* @param inputs - The DXF file as text or bytes, whether hidden layers are written, and the SVG's line width, border and curve tolerance
|
|
159
|
+
* @returns The SVG text and the reading's warnings
|
|
160
|
+
* @group convert
|
|
161
|
+
* @shortname dxf to svg
|
|
162
|
+
* @drawable false
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const converted = bitbybit.io.drawing.dxfToSvg({ dxf: dxfText, includeHiddenLayers: true });
|
|
166
|
+
* const drawing = bitbybit.io.svg.svgRead({ svg: converted.svg });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
dxfToSvg(inputs: Inputs.IO.DxfToSvgDto): Inputs.IO.DxfToSvgResultDto;
|
|
170
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
import { resolveDto } from "../../kernel-calls";
|
|
3
|
+
/**
|
|
4
|
+
* Builds drawings as data, for any file format: segments of every kind, paths joined from segments,
|
|
5
|
+
* and parts that put paths on a layer with a color and a line type. `io.dxf.dxfCreate` writes the
|
|
6
|
+
* parts as DXF and `io.svg.svgCreate` as SVG; `svgToDxf` and `dxfToSvg` convert one file into the
|
|
7
|
+
* other through these parts.
|
|
8
|
+
*/
|
|
9
|
+
export class Drawing {
|
|
10
|
+
constructor(dxfOf, svgOf) {
|
|
11
|
+
this.dxfOf = dxfOf;
|
|
12
|
+
this.svgOf = svgOf;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Makes a straight segment of a drawing path, from `start` to `end`.
|
|
16
|
+
* @param inputs - The start and the end point
|
|
17
|
+
* @returns The line segment
|
|
18
|
+
* @group drawing
|
|
19
|
+
* @shortname line segment
|
|
20
|
+
* @drawable false
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
lineSegment(inputs) {
|
|
27
|
+
return inputs;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Makes a circular arc of a drawing path, running counterclockwise about its `center` from
|
|
31
|
+
* `startAngle` to `endAngle`, in degrees, in the XY plane unless a `normal` tilts it.
|
|
32
|
+
* @param inputs - The center, the radius, the start and end angles and the plane's normal
|
|
33
|
+
* @returns The arc segment
|
|
34
|
+
* @group drawing
|
|
35
|
+
* @shortname arc segment
|
|
36
|
+
* @drawable false
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [0, 0], radius: 10, startAngle: 0, endAngle: 90 });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
arcSegment(inputs) {
|
|
43
|
+
return inputs;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Makes a whole circle of a drawing path from its `center` and `radius`, in the XY plane unless a
|
|
47
|
+
* `normal` tilts it.
|
|
48
|
+
* @param inputs - The center, the radius and the plane's normal
|
|
49
|
+
* @returns The circle segment
|
|
50
|
+
* @group drawing
|
|
51
|
+
* @shortname circle segment
|
|
52
|
+
* @drawable false
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
circleSegment(inputs) {
|
|
59
|
+
return inputs;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Makes connected straight segments through `points`, which `bulges` can bend into arcs;
|
|
63
|
+
* `closed` joins the last point back to the first.
|
|
64
|
+
* @param inputs - The points, whether the polyline is closed, and the bulges
|
|
65
|
+
* @returns The polyline segment
|
|
66
|
+
* @group drawing
|
|
67
|
+
* @shortname polyline segment
|
|
68
|
+
* @drawable false
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const slot = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [30, 0], [30, 10], [0, 10]], closed: true, bulges: [0, 1, 0, 1] });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
polylineSegment(inputs) {
|
|
75
|
+
const resolved = resolveDto(Inputs.IO.DrawingPolylineSegmentDto, inputs);
|
|
76
|
+
return resolved;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Makes a B-spline or NURBS curve of a drawing path from its control points and degree, with
|
|
80
|
+
* its knots and weights when they are given.
|
|
81
|
+
* @param inputs - The control points, the degree, whether it is closed, the knots and the weights
|
|
82
|
+
* @returns The spline segment
|
|
83
|
+
* @group drawing
|
|
84
|
+
* @shortname spline segment
|
|
85
|
+
* @drawable false
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const wave = bitbybit.io.drawing.splineSegment({ controlPoints: [[0, 0], [10, 8], [20, -8], [30, 0]], degree: 3 });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
splineSegment(inputs) {
|
|
92
|
+
const resolved = resolveDto(Inputs.IO.DrawingSplineSegmentDto, inputs);
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Makes an ellipse, or an arc of one, for a drawing path.
|
|
97
|
+
*
|
|
98
|
+
* The ellipse is given by its center, the vector to the end of its major axis and the minor to
|
|
99
|
+
* major ratio; parameters in radians pick the arc, running counterclockwise about the normal.
|
|
100
|
+
* @param inputs - The center, the major axis, the ratio, the start and end parameters and the plane's normal
|
|
101
|
+
* @returns The ellipse segment
|
|
102
|
+
* @group drawing
|
|
103
|
+
* @shortname ellipse segment
|
|
104
|
+
* @drawable false
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const lens = bitbybit.io.drawing.ellipseSegment({ center: [0, 0], majorAxis: [20, 0], ratio: 0.5, startParameter: 0, endParameter: Math.PI });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
ellipseSegment(inputs) {
|
|
111
|
+
const resolved = resolveDto(Inputs.IO.DrawingEllipseSegmentDto, inputs);
|
|
112
|
+
return resolved;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Joins segments into one path, drawn in order like the edges of a wire; segments that meet
|
|
116
|
+
* are drawn as one stroke in SVG.
|
|
117
|
+
* @param inputs - The segments, in order
|
|
118
|
+
* @returns The path
|
|
119
|
+
* @group drawing
|
|
120
|
+
* @shortname path
|
|
121
|
+
* @drawable false
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const edge = bitbybit.io.drawing.lineSegment({ start: [0, 0], end: [40, 0] });
|
|
125
|
+
* const corner = bitbybit.io.drawing.arcSegment({ center: [40, 10], radius: 10, startAngle: 270, endAngle: 360 });
|
|
126
|
+
* const outline = bitbybit.io.drawing.path({ segments: [edge, corner] });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
path(inputs) {
|
|
130
|
+
return inputs;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Puts paths on a named layer with a color and a line type, making one part of a drawing.
|
|
134
|
+
*
|
|
135
|
+
* A drawing may hold several parts; `io.dxf.dxfCreate` writes them as DXF and `io.svg.svgCreate`
|
|
136
|
+
* as SVG.
|
|
137
|
+
* @param inputs - The layer name, the color, the paths and the line type
|
|
138
|
+
* @returns The part
|
|
139
|
+
* @group drawing
|
|
140
|
+
* @shortname part
|
|
141
|
+
* @drawable false
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const square = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
145
|
+
* const cut = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [square] }] });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
part(inputs) {
|
|
149
|
+
const resolved = resolveDto(Inputs.IO.DrawingPartDto, inputs);
|
|
150
|
+
return resolved;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Converts an SVG file into a DXF file, reading it as `io.svg.svgRead` does and writing it as
|
|
154
|
+
* `io.dxf.dxfCreate` does.
|
|
155
|
+
*
|
|
156
|
+
* Inkscape layers, stroke colors and dash patterns become DXF layers, colors and line types, and
|
|
157
|
+
* curves stay exact. With `unit` the drawing is read at true size and the DXF states that unit. A
|
|
158
|
+
* drawing too large to write throws.
|
|
159
|
+
* @param inputs - The SVG text, the unit, whether hidden elements are written, and the DXF's color format, version and curve tolerance
|
|
160
|
+
* @returns The DXF text and the reading's warnings
|
|
161
|
+
* @group convert
|
|
162
|
+
* @shortname svg to dxf
|
|
163
|
+
* @drawable false
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const converted = bitbybit.io.drawing.svgToDxf({ svg: svgText, unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
167
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: converted.dxf });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
svgToDxf(inputs) {
|
|
171
|
+
const resolved = resolveDto(Inputs.IO.SvgToDxfDto, inputs);
|
|
172
|
+
const drawing = this.svgOf().svgRead({ svg: resolved.svg, unit: resolved.unit, includeInvisible: resolved.includeInvisible });
|
|
173
|
+
const dxf = this.dxfOf().dxfCreate({
|
|
174
|
+
dxfPathsParts: drawing.parts,
|
|
175
|
+
colorFormat: resolved.colorFormat,
|
|
176
|
+
acadVersion: resolved.acadVersion,
|
|
177
|
+
unit: resolved.unit,
|
|
178
|
+
curveTolerance: resolved.curveTolerance,
|
|
179
|
+
});
|
|
180
|
+
return { dxf, warnings: drawing.warnings };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Converts a DXF file into an SVG file, reading it as `io.dxf.dxfRead` does and writing it as
|
|
184
|
+
* `io.svg.svgCreate` does.
|
|
185
|
+
*
|
|
186
|
+
* Layers become Inkscape layers and the SVG takes its true size from the unit the DXF states.
|
|
187
|
+
* Splines given only by fit points are left out and named in `warnings`; a drawing too large to
|
|
188
|
+
* write throws.
|
|
189
|
+
* @param inputs - The DXF file as text or bytes, whether hidden layers are written, and the SVG's line width, border and curve tolerance
|
|
190
|
+
* @returns The SVG text and the reading's warnings
|
|
191
|
+
* @group convert
|
|
192
|
+
* @shortname dxf to svg
|
|
193
|
+
* @drawable false
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const converted = bitbybit.io.drawing.dxfToSvg({ dxf: dxfText, includeHiddenLayers: true });
|
|
197
|
+
* const drawing = bitbybit.io.svg.svgRead({ svg: converted.svg });
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
dxfToSvg(inputs) {
|
|
201
|
+
const resolved = resolveDto(Inputs.IO.DxfToSvgDto, inputs);
|
|
202
|
+
const drawing = this.dxfOf().dxfRead({ dxf: resolved.dxf, includeHiddenLayers: resolved.includeHiddenLayers });
|
|
203
|
+
const svg = this.svgOf().svgCreate({
|
|
204
|
+
parts: drawing.parts,
|
|
205
|
+
unit: drawing.unit,
|
|
206
|
+
strokeWidth: resolved.strokeWidth,
|
|
207
|
+
margin: resolved.margin,
|
|
208
|
+
tolerance: resolved.tolerance,
|
|
209
|
+
});
|
|
210
|
+
return { svg, warnings: drawing.warnings };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as Inputs from "../../inputs";
|
|
2
|
+
/**
|
|
3
|
+
* Writes a drawing as a DXF file and reads a DXF file back into one. The drawing itself is built with
|
|
4
|
+
* `io.drawing`; the builders here are its former DXF-named copies.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Dxf {
|
|
7
|
+
private readonly dxfGenerator;
|
|
8
|
+
/**
|
|
9
|
+
* Makes a straight segment for a drawing, under its former DXF name.
|
|
10
|
+
* @param inputs - The line segment definition
|
|
11
|
+
* @returns The line segment
|
|
12
|
+
* @group dxf
|
|
13
|
+
* @shortname line segment
|
|
14
|
+
* @drawable false
|
|
15
|
+
* @deprecated Use `io.drawing.lineSegment`, the same builder under the drawing's own name; this one is
|
|
16
|
+
* removed in the next major version.
|
|
17
|
+
*/
|
|
18
|
+
lineSegment(inputs: Inputs.IO.DxfLineSegmentDto): Inputs.IO.DxfLineSegmentDto;
|
|
19
|
+
/**
|
|
20
|
+
* Makes a circular arc for a drawing, under its former DXF name.
|
|
21
|
+
* @param inputs - The arc segment definition
|
|
22
|
+
* @returns The arc segment
|
|
23
|
+
* @group dxf
|
|
24
|
+
* @shortname arc segment
|
|
25
|
+
* @drawable false
|
|
26
|
+
* @deprecated Use `io.drawing.arcSegment`, the same builder under the drawing's own name; this one is
|
|
27
|
+
* removed in the next major version.
|
|
28
|
+
*/
|
|
29
|
+
arcSegment(inputs: Inputs.IO.DxfArcSegmentDto): Inputs.IO.DxfArcSegmentDto;
|
|
30
|
+
/**
|
|
31
|
+
* Makes a whole circle for a drawing, under its former DXF name.
|
|
32
|
+
* @param inputs - The circle segment definition
|
|
33
|
+
* @returns The circle segment
|
|
34
|
+
* @group dxf
|
|
35
|
+
* @shortname circle segment
|
|
36
|
+
* @drawable false
|
|
37
|
+
* @deprecated Use `io.drawing.circleSegment`, the same builder under the drawing's own name; this one is
|
|
38
|
+
* removed in the next major version.
|
|
39
|
+
*/
|
|
40
|
+
circleSegment(inputs: Inputs.IO.DxfCircleSegmentDto): Inputs.IO.DxfCircleSegmentDto;
|
|
41
|
+
/**
|
|
42
|
+
* Makes connected straight segments for a drawing, under its former DXF name.
|
|
43
|
+
* @param inputs - The polyline segment definition
|
|
44
|
+
* @returns The polyline segment
|
|
45
|
+
* @group dxf
|
|
46
|
+
* @shortname polyline segment
|
|
47
|
+
* @drawable false
|
|
48
|
+
* @deprecated Use `io.drawing.polylineSegment`, the same builder under the drawing's own name; this one is
|
|
49
|
+
* removed in the next major version.
|
|
50
|
+
*/
|
|
51
|
+
polylineSegment(inputs: Inputs.IO.DxfPolylineSegmentDto): Inputs.IO.DxfPolylineSegmentDto;
|
|
52
|
+
/**
|
|
53
|
+
* Makes a B-spline or NURBS curve for a drawing, under its former DXF name.
|
|
54
|
+
* @param inputs - The spline segment definition
|
|
55
|
+
* @returns The spline segment
|
|
56
|
+
* @group dxf
|
|
57
|
+
* @shortname spline segment
|
|
58
|
+
* @drawable false
|
|
59
|
+
* @deprecated Use `io.drawing.splineSegment`, the same builder under the drawing's own name; this one is
|
|
60
|
+
* removed in the next major version.
|
|
61
|
+
*/
|
|
62
|
+
splineSegment(inputs: Inputs.IO.DxfSplineSegmentDto): Inputs.IO.DxfSplineSegmentDto;
|
|
63
|
+
/**
|
|
64
|
+
* Makes an ellipse or an arc of one for a drawing, under its former DXF name.
|
|
65
|
+
* @param inputs - The ellipse segment definition
|
|
66
|
+
* @returns The ellipse segment
|
|
67
|
+
* @group dxf
|
|
68
|
+
* @shortname ellipse segment
|
|
69
|
+
* @drawable false
|
|
70
|
+
* @deprecated Use `io.drawing.ellipseSegment`, the same builder under the drawing's own name; this one is
|
|
71
|
+
* removed in the next major version.
|
|
72
|
+
*/
|
|
73
|
+
ellipseSegment(inputs: Inputs.IO.DxfEllipseSegmentDto): Inputs.IO.DxfEllipseSegmentDto;
|
|
74
|
+
/**
|
|
75
|
+
* Makes a path joined from segments for a drawing, under its former DXF name.
|
|
76
|
+
* @param inputs - The path definition
|
|
77
|
+
* @returns The path
|
|
78
|
+
* @group dxf
|
|
79
|
+
* @shortname path
|
|
80
|
+
* @drawable false
|
|
81
|
+
* @deprecated Use `io.drawing.path`, the same builder under the drawing's own name; this one is
|
|
82
|
+
* removed in the next major version.
|
|
83
|
+
*/
|
|
84
|
+
path(inputs: Inputs.IO.DxfPathDto): Inputs.IO.DxfPathDto;
|
|
85
|
+
/**
|
|
86
|
+
* Makes a part of a drawing on one layer for a drawing, under its former DXF name.
|
|
87
|
+
* @param inputs - The paths part definition
|
|
88
|
+
* @returns The paths part
|
|
89
|
+
* @group dxf
|
|
90
|
+
* @shortname paths part
|
|
91
|
+
* @drawable false
|
|
92
|
+
* @deprecated Use `io.drawing.part`, the same builder under the drawing's own name; this one is
|
|
93
|
+
* removed in the next major version.
|
|
94
|
+
*/
|
|
95
|
+
pathsPart(inputs: Inputs.IO.DxfPathsPartDto): Inputs.IO.DxfPathsPartDto;
|
|
96
|
+
/**
|
|
97
|
+
* Writes a DXF file from path parts, each on its layer with its color and line type.
|
|
98
|
+
*
|
|
99
|
+
* `AC1015` keeps every curve exact. `AC1009` (R12) writes splines and ellipses as polylines
|
|
100
|
+
* within `curveTolerance`, never finer than a millionth of the drawing. Points off one Z make a
|
|
101
|
+
* 3D polyline; a drawing too large to write throws.
|
|
102
|
+
* @param inputs DXF model definition
|
|
103
|
+
* @returns DXF file content as string
|
|
104
|
+
* @group dxf
|
|
105
|
+
* @shortname dxf create
|
|
106
|
+
* @drawable false
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const outline = bitbybit.io.drawing.polylineSegment({ points: [[0, 0], [40, 0], [40, 30], [0, 30]], closed: true });
|
|
110
|
+
* const hole = bitbybit.io.drawing.circleSegment({ center: [20, 15], radius: 6 });
|
|
111
|
+
* const part = bitbybit.io.drawing.part({ layer: "cut", color: "#ff0000", paths: [{ segments: [outline] }, { segments: [hole] }] });
|
|
112
|
+
* const dxf = bitbybit.io.dxf.dxfCreate({ dxfPathsParts: [part], unit: Bit.Inputs.Base.unitOfLengthEnum.millimetre });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
dxfCreate(inputs: Inputs.IO.DxfModelDto): string;
|
|
116
|
+
/**
|
|
117
|
+
* Reads a DXF file into path parts by layer, color and line type, the model `dxfCreate` writes.
|
|
118
|
+
*
|
|
119
|
+
* Lines, arcs, circles, ellipses, polylines and splines are read exactly in the file's
|
|
120
|
+
* coordinates, block inserts expanded. Text, dimensions and hatches are left out and named in
|
|
121
|
+
* `warnings`; splines given only by fit points are read by `occt.io.loadDxf`.
|
|
122
|
+
* @param inputs - The DXF file, as text or bytes, and whether hidden layers are read
|
|
123
|
+
* @returns The drawing's parts, unit, version and warnings
|
|
124
|
+
* @group dxf
|
|
125
|
+
* @shortname dxf read
|
|
126
|
+
* @drawable false
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const drawing = bitbybit.io.dxf.dxfRead({ dxf: dxfText });
|
|
130
|
+
* const svg = bitbybit.io.svg.svgCreate({ parts: drawing.parts, unit: drawing.unit });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
dxfRead(inputs: Inputs.IO.DxfReadDto): Inputs.IO.DxfDrawingDto;
|
|
134
|
+
}
|