@bitbybit-dev/base 1.7.0 → 1.8.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/NOTICE +24 -0
- package/README.md +3 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +20 -0
- package/lib/api/inputs/base-inputs.js +22 -0
- package/lib/api/inputs/io-inputs.d.ts +408 -8
- package/lib/api/inputs/io-inputs.js +344 -7
- package/lib/api/inputs/mesh-inputs.d.ts +20 -1
- package/lib/api/inputs/mesh-inputs.js +23 -0
- package/lib/api/inputs/recipes-inputs.d.ts +13 -5
- package/lib/api/inputs/recipes-inputs.js +10 -5
- package/lib/api/kernel-calls/index.d.ts +1 -0
- package/lib/api/kernel-calls/index.js +1 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +3 -1
- package/lib/api/kernel-calls/resolve-dto.js +7 -2
- package/lib/api/kernel-calls/settings.d.ts +19 -0
- package/lib/api/kernel-calls/up-axis-aliases.d.ts +25 -0
- package/lib/api/kernel-calls/up-axis-aliases.js +70 -0
- package/lib/api/models/simplex.d.ts +2 -0
- package/lib/api/models/simplex.js +10 -1
- package/lib/api/resolved-inputs/index.d.ts +11 -2
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +3 -1
- package/lib/api/services/helpers/curves/conic-arcs.js +4 -2
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +16 -6
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.js +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.d.ts +4 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.js +271 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +28 -11
- package/lib/api/services/helpers/files/drawing/drawing-hatch.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.js +123 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.js +91 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +6 -1
- package/lib/api/services/helpers/files/drawing/drawing-model.js +97 -13
- package/lib/api/services/helpers/files/drawing/drawing-scale.d.ts +2 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.js +47 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.d.ts +9 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.js +25 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +57 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +13 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.js +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +5 -1
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +5 -2
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +26 -10
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.js +312 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +37 -3
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.js +151 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +27 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +63 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +17 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +1 -1
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +71 -181
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +5 -4
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +25 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +13 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +1 -1
- package/lib/api/services/helpers/files/svg/svg-strokes.js +47 -23
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +100 -23
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +2 -1
- package/lib/api/services/helpers/files/svg/svg.constants.js +2 -1
- package/lib/api/services/helpers/geometry/loop-fill.d.ts +2 -0
- package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
- package/lib/api/services/helpers/helper-types.d.ts +33 -0
- package/lib/api/services/helpers/text/stroke-font.d.ts +6 -0
- package/lib/api/services/helpers/text/stroke-font.js +177 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.d.ts +2 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.js +18 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.d.ts +14 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.js +34 -0
- package/lib/api/services/io/drawing.d.ts +198 -0
- package/lib/api/services/io/drawing.js +242 -0
- package/lib/api/services/io/dxf.d.ts +3 -3
- package/lib/api/services/io/dxf.js +4 -4
- package/lib/api/services/io/svg.d.ts +13 -11
- package/lib/api/services/io/svg.js +15 -12
- package/lib/api/services/mesh.d.ts +19 -0
- package/lib/api/services/mesh.js +40 -0
- package/lib/api/services/recipes.js +3 -2
- package/lib/api/services/text.d.ts +3 -3
- package/lib/api/services/text.js +7 -25
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as Inputs from "../../../../inputs";
|
|
2
|
+
import { InputError } from "../../../../kernel-calls";
|
|
3
|
+
import { bulgeArcOf, conicArcSamples } from "../../curves/conic-arcs";
|
|
4
|
+
import { radiansOf } from "../../geometry/scalars";
|
|
5
|
+
import { add2, between2, dot2, leftOf2, polar2, scale2 } from "../../geometry/vectors";
|
|
6
|
+
import { drawingBounds } from "./drawing-geometry";
|
|
7
|
+
import { drawingLoopsOf } from "./drawing-loops";
|
|
8
|
+
import { DEFAULT_LAYER, HATCH_FAMILIES, LEAST_LOOP_CORNERS, MOST_HATCH_LINES, SAME_POINT } from "./drawing.constants";
|
|
9
|
+
const flatLoopOf = (loop, tolerance, budget) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const points = [];
|
|
12
|
+
const count = loop.points.length;
|
|
13
|
+
for (let at = 0; at < count; at++) {
|
|
14
|
+
const start = loop.points[at];
|
|
15
|
+
const bulge = (_a = loop.bulges[at]) !== null && _a !== void 0 ? _a : 0;
|
|
16
|
+
points.push([start[0], start[1]]);
|
|
17
|
+
if (bulge === 0) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const end = loop.points[(at + 1) % count];
|
|
21
|
+
const samples = conicArcSamples(bulgeArcOf([start[0], start[1], 0], [end[0], end[1], 0], bulge), tolerance, budget);
|
|
22
|
+
for (let sample = 1; sample < samples.length - 1; sample++) {
|
|
23
|
+
points.push([samples[sample][0], samples[sample][1]]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return points;
|
|
27
|
+
};
|
|
28
|
+
export const hatchOutlinesOf = (hatch, tolerance, budget) => drawingLoopsOf(hatch.boundaries, tolerance, budget)
|
|
29
|
+
.map(loop => flatLoopOf(loop, tolerance, budget))
|
|
30
|
+
.filter(loop => loop.length >= LEAST_LOOP_CORNERS);
|
|
31
|
+
const stepsAcross = (outlines, family, spacing) => {
|
|
32
|
+
let lowest = Infinity;
|
|
33
|
+
let highest = -Infinity;
|
|
34
|
+
for (const outline of outlines) {
|
|
35
|
+
for (const point of outline) {
|
|
36
|
+
const offset = dot2(point, family.across);
|
|
37
|
+
lowest = Math.min(lowest, offset);
|
|
38
|
+
highest = Math.max(highest, offset);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { first: Math.ceil((lowest - family.phase) / spacing), last: Math.floor((highest - family.phase) / spacing) };
|
|
42
|
+
};
|
|
43
|
+
const crossingsOf = (outlines, family, spacing, steps) => {
|
|
44
|
+
const crossings = Array.from({ length: steps.last - steps.first + 1 }, () => []);
|
|
45
|
+
const offsetOf = (step) => family.phase + step * spacing;
|
|
46
|
+
for (const outline of outlines) {
|
|
47
|
+
for (let at = 0; at < outline.length; at++) {
|
|
48
|
+
const start = outline[at];
|
|
49
|
+
const end = outline[(at + 1) % outline.length];
|
|
50
|
+
const from = dot2(start, family.across);
|
|
51
|
+
const to = dot2(end, family.across);
|
|
52
|
+
if (from === to) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const lowest = Math.max(steps.first, Math.floor((Math.min(from, to) - family.phase) / spacing));
|
|
56
|
+
const highest = Math.min(steps.last, Math.ceil((Math.max(from, to) - family.phase) / spacing));
|
|
57
|
+
for (let step = lowest; step <= highest; step++) {
|
|
58
|
+
const offset = offsetOf(step);
|
|
59
|
+
if ((from > offset) !== (to > offset)) {
|
|
60
|
+
crossings[step - steps.first].push(dot2(between2(start, end, (offset - from) / (to - from)), family.direction));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return crossings;
|
|
66
|
+
};
|
|
67
|
+
export const clippedHatchLinesOf = (hatch, tolerance, property, budget) => {
|
|
68
|
+
const outlines = hatchOutlinesOf(hatch, tolerance, budget);
|
|
69
|
+
if (outlines.length === 0) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const lines = [];
|
|
73
|
+
let counted = 0;
|
|
74
|
+
for (const family of hatchFamiliesOf(hatch)) {
|
|
75
|
+
const steps = stepsAcross(outlines, family, hatch.spacing);
|
|
76
|
+
counted += Math.max(0, steps.last - steps.first + 1);
|
|
77
|
+
if (counted > MOST_HATCH_LINES) {
|
|
78
|
+
throw new InputError(`\`${property}\` is ${hatch.spacing} for a region that would take more than ${MOST_HATCH_LINES} lines: widen the spacing.`, property);
|
|
79
|
+
}
|
|
80
|
+
crossingsOf(outlines, family, hatch.spacing, steps).forEach((crossing, at) => {
|
|
81
|
+
const base = scale2(family.across, family.phase + (steps.first + at) * hatch.spacing);
|
|
82
|
+
const sorted = [...crossing].sort((a, b) => a - b);
|
|
83
|
+
for (let pair = 0; pair + 1 < sorted.length; pair += 2) {
|
|
84
|
+
const enter = sorted[pair];
|
|
85
|
+
const leave = sorted[pair + 1];
|
|
86
|
+
if (leave - enter > SAME_POINT) {
|
|
87
|
+
lines.push([add2(base, scale2(family.direction, enter)), add2(base, scale2(family.direction, leave))]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return lines;
|
|
93
|
+
};
|
|
94
|
+
export const hatchFamiliesOf = (hatch) => HATCH_FAMILIES[hatch.pattern].map(([turn, share]) => {
|
|
95
|
+
const angle = hatch.angle + turn;
|
|
96
|
+
const direction = polar2(1, radiansOf(angle));
|
|
97
|
+
return { turn, angle, direction, across: leftOf2(direction), phase: (1 - share) * hatch.spacing };
|
|
98
|
+
});
|
|
99
|
+
export const hatchLinesOf = (hatch, tolerance, property, budget) => {
|
|
100
|
+
const region = { layer: DEFAULT_LAYER, color: "#000000", lineType: Inputs.IO.lineTypeEnum.continuous, lineWeight: undefined, paths: hatch.boundaries, texts: [], hatches: [] };
|
|
101
|
+
const bounds = drawingBounds([region], tolerance, budget);
|
|
102
|
+
if (bounds === undefined) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
const corners = [[bounds.min[0], bounds.min[1]], [bounds.max[0], bounds.min[1]], [bounds.max[0], bounds.max[1]], [bounds.min[0], bounds.max[1]]];
|
|
106
|
+
const lines = [];
|
|
107
|
+
for (const family of hatchFamiliesOf(hatch)) {
|
|
108
|
+
const reaches = corners.map(corner => dot2(corner, family.direction));
|
|
109
|
+
const offsets = corners.map(corner => dot2(corner, family.across));
|
|
110
|
+
const from = Math.min(...reaches);
|
|
111
|
+
const to = Math.max(...reaches);
|
|
112
|
+
const first = Math.ceil((Math.min(...offsets) - family.phase) / hatch.spacing);
|
|
113
|
+
const last = Math.floor((Math.max(...offsets) - family.phase) / hatch.spacing);
|
|
114
|
+
if (lines.length + Math.max(0, last - first + 1) > MOST_HATCH_LINES) {
|
|
115
|
+
throw new InputError(`\`${property}\` is ${hatch.spacing} for a region that would take more than ${MOST_HATCH_LINES} lines: widen the spacing.`, property);
|
|
116
|
+
}
|
|
117
|
+
for (let step = first; step <= last; step++) {
|
|
118
|
+
const base = scale2(family.across, family.phase + step * hatch.spacing);
|
|
119
|
+
lines.push([add2(base, scale2(family.direction, from)), add2(base, scale2(family.direction, to))]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return lines;
|
|
123
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { bulgeOfSweep, conicArcSamples, ellipseFramePoint } from "../../curves/conic-arcs";
|
|
2
|
+
import { circleArcOf, meetsReversed, pointsMeet, polylineSpans, segmentSamples } from "./drawing-geometry";
|
|
3
|
+
import { JOIN_DISTANCE } from "./drawing.constants";
|
|
4
|
+
const flat = (point) => [point[0], point[1]];
|
|
5
|
+
const straightRun = (points) => ({ points: points.map(flat), bulges: points.slice(1).map(() => 0) });
|
|
6
|
+
const circularRun = (segment, tolerance, budget) => {
|
|
7
|
+
const arc = circleArcOf(segment);
|
|
8
|
+
if (segment.normal[0] !== 0 || segment.normal[1] !== 0) {
|
|
9
|
+
return straightRun(conicArcSamples(arc, tolerance, budget));
|
|
10
|
+
}
|
|
11
|
+
const spans = Math.max(1, Math.ceil(arc.sweep / Math.PI - JOIN_DISTANCE));
|
|
12
|
+
const step = arc.sweep / spans;
|
|
13
|
+
const bulge = Math.sign(segment.normal[2]) * bulgeOfSweep(step);
|
|
14
|
+
return {
|
|
15
|
+
points: Array.from({ length: spans + 1 }, (_, at) => flat(ellipseFramePoint(arc.frame, arc.start + at * step))),
|
|
16
|
+
bulges: Array.from({ length: spans }, () => bulge),
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const runOf = (segment, tolerance, budget) => {
|
|
20
|
+
switch (segment.kind) {
|
|
21
|
+
case "line":
|
|
22
|
+
return straightRun([segment.start, segment.end]);
|
|
23
|
+
case "polyline": {
|
|
24
|
+
const spans = polylineSpans(segment);
|
|
25
|
+
return {
|
|
26
|
+
points: Array.from({ length: spans + 1 }, (_, at) => flat(segment.points[at % segment.points.length])),
|
|
27
|
+
bulges: Array.from({ length: spans }, (_, span) => { var _a; return segment.planar ? (_a = segment.bulges[span]) !== null && _a !== void 0 ? _a : 0 : 0; }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
case "circle":
|
|
31
|
+
case "arc":
|
|
32
|
+
return circularRun(segment, tolerance, budget);
|
|
33
|
+
default:
|
|
34
|
+
return straightRun(segmentSamples(segment, tolerance, budget));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const reversed = (run) => ({ points: [...run.points].reverse(), bulges: [...run.bulges].reverse().map(bulge => -bulge) });
|
|
38
|
+
const appended = (open, run) => {
|
|
39
|
+
for (let at = 1; at < run.points.length; at++) {
|
|
40
|
+
open.points.push(run.points[at]);
|
|
41
|
+
}
|
|
42
|
+
for (const bulge of run.bulges) {
|
|
43
|
+
open.bulges.push(bulge);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const drawingLoopsOf = (paths, tolerance, budget) => {
|
|
47
|
+
const loops = [];
|
|
48
|
+
let open;
|
|
49
|
+
const close = () => {
|
|
50
|
+
if (open !== undefined && open.points.length > 1) {
|
|
51
|
+
if (pointsMeet(open.points[0], open.points[open.points.length - 1])) {
|
|
52
|
+
open.points.pop();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
open.bulges.push(0);
|
|
56
|
+
}
|
|
57
|
+
if (open.points.length > 2 || open.bulges.some(bulge => bulge !== 0)) {
|
|
58
|
+
loops.push(open);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
open = undefined;
|
|
62
|
+
};
|
|
63
|
+
for (const path of paths) {
|
|
64
|
+
for (const segment of path.segments) {
|
|
65
|
+
let run = runOf(segment, tolerance, budget);
|
|
66
|
+
if (run.points.length < 2) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (open !== undefined) {
|
|
70
|
+
const end = open.points[open.points.length - 1];
|
|
71
|
+
if (meetsReversed(end, run.points[0], run.points[run.points.length - 1])) {
|
|
72
|
+
run = reversed(run);
|
|
73
|
+
}
|
|
74
|
+
if (pointsMeet(end, run.points[0])) {
|
|
75
|
+
appended(open, run);
|
|
76
|
+
if (pointsMeet(open.points[0], open.points[open.points.length - 1])) {
|
|
77
|
+
close();
|
|
78
|
+
}
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
close();
|
|
82
|
+
}
|
|
83
|
+
open = { points: [...run.points], bulges: [...run.bulges] };
|
|
84
|
+
if (pointsMeet(open.points[0], open.points[open.points.length - 1])) {
|
|
85
|
+
close();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
close();
|
|
89
|
+
}
|
|
90
|
+
return loops;
|
|
91
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as Inputs from "../../../../inputs";
|
|
2
|
-
import type { DrawingPart, DrawingPath } from "./drawing-types";
|
|
2
|
+
import type { DrawingHatch, DrawingPart, DrawingPath, DrawingSegment, DrawingText } from "./drawing-types";
|
|
3
|
+
export declare const isDrawable: (value: unknown) => value is number;
|
|
4
|
+
export declare const finiteNumber: (value: unknown, property: string) => number;
|
|
3
5
|
export declare const positiveNumber: (value: unknown, property: string) => number;
|
|
6
|
+
export declare const segmentKindOf: (segment: unknown) => DrawingSegment["kind"] | undefined;
|
|
4
7
|
export declare const drawingPathOf: (path: Inputs.IO.DrawingPathDto | undefined, property: string) => DrawingPath;
|
|
8
|
+
export declare const drawingTextOf: (text: unknown, property: string) => DrawingText;
|
|
9
|
+
export declare const drawingHatchOf: (hatch: unknown, property: string) => DrawingHatch;
|
|
5
10
|
export declare const drawingPartsOf: (parts: readonly unknown[] | undefined, property: string) => DrawingPart[];
|
|
@@ -6,13 +6,18 @@ import { clampedForm, clampedUniformKnots, periodicUniformForm } from "../../cur
|
|
|
6
6
|
import { unitOf } from "../../geometry/frame-axes";
|
|
7
7
|
import { radiansOf } from "../../geometry/scalars";
|
|
8
8
|
import { distance3, dot3 } from "../../geometry/vectors";
|
|
9
|
-
import {
|
|
9
|
+
import { simplex } from "../../../../models/simplex";
|
|
10
|
+
import { strokeTextAdvance } from "../../text/stroke-font";
|
|
11
|
+
import { CONTROL_CHARACTER, DEFAULT_LAYER, DEFAULT_SPLINE_DEGREE, FIRST_PRINTABLE_CODE, FORBIDDEN_LAYER_CHARACTERS, FULL_TURN_DEGREES, HIGHEST_SPLINE_DEGREE, LARGEST_NUMBER, LEAST_WEIGHT, LONGEST_TEXT, PERPENDICULAR_COSINE, POINT_SIZES, SAME_POINT, TEXT_ANCHORS, } from "./drawing.constants";
|
|
10
12
|
import { DXF_MAX_NAME_LENGTH } from "../dxf/dxf.constants";
|
|
11
13
|
const PLUS_Z = [0, 0, 1];
|
|
12
14
|
const LINE_TYPES = new Set(Object.values(Inputs.IO.lineTypeEnum));
|
|
15
|
+
const HATCH_PATTERNS = new Set(Object.values(Inputs.IO.hatchPatternEnum));
|
|
16
|
+
const TEXT_DEFAULTS = new Inputs.IO.DrawingTextDto();
|
|
17
|
+
const HATCH_DEFAULTS = new Inputs.IO.DrawingHatchDto();
|
|
13
18
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
14
|
-
const isDrawable = (value) => typeof value === "number" && Math.abs(value) < LARGEST_NUMBER;
|
|
15
|
-
const finiteNumber = (value, property) => {
|
|
19
|
+
export const isDrawable = (value) => typeof value === "number" && Math.abs(value) < LARGEST_NUMBER;
|
|
20
|
+
export const finiteNumber = (value, property) => {
|
|
16
21
|
if (!isDrawable(value)) {
|
|
17
22
|
throw new InputError(`\`${property}\` must be a finite number below ${LARGEST_NUMBER} in size.`, property);
|
|
18
23
|
}
|
|
@@ -172,29 +177,47 @@ const ellipseOf = (segment, property) => {
|
|
|
172
177
|
normal,
|
|
173
178
|
};
|
|
174
179
|
};
|
|
175
|
-
const
|
|
180
|
+
export const segmentKindOf = (segment) => {
|
|
176
181
|
if (!isRecord(segment)) {
|
|
177
|
-
|
|
182
|
+
return undefined;
|
|
178
183
|
}
|
|
179
184
|
if (segment["majorAxis"] !== undefined) {
|
|
180
|
-
return
|
|
185
|
+
return "ellipse";
|
|
181
186
|
}
|
|
182
187
|
if (segment["center"] !== undefined && (segment["startAngle"] !== undefined || segment["endAngle"] !== undefined)) {
|
|
183
|
-
return
|
|
188
|
+
return "arc";
|
|
184
189
|
}
|
|
185
190
|
if (segment["center"] !== undefined && segment["radius"] !== undefined) {
|
|
186
|
-
return
|
|
191
|
+
return "circle";
|
|
187
192
|
}
|
|
188
193
|
if (segment["start"] !== undefined && segment["end"] !== undefined) {
|
|
189
|
-
return
|
|
194
|
+
return "line";
|
|
190
195
|
}
|
|
191
196
|
if (Array.isArray(segment["points"])) {
|
|
192
|
-
return
|
|
197
|
+
return "polyline";
|
|
198
|
+
}
|
|
199
|
+
return Array.isArray(segment["controlPoints"]) ? "spline" : undefined;
|
|
200
|
+
};
|
|
201
|
+
const segmentOf = (segment, property) => {
|
|
202
|
+
if (!isRecord(segment)) {
|
|
203
|
+
throw new InputError(`\`${property}\` must be a segment.`, property);
|
|
193
204
|
}
|
|
194
|
-
|
|
195
|
-
|
|
205
|
+
switch (segmentKindOf(segment)) {
|
|
206
|
+
case "ellipse":
|
|
207
|
+
return ellipseOf(segment, property);
|
|
208
|
+
case "arc":
|
|
209
|
+
return arcOf(segment, property);
|
|
210
|
+
case "circle":
|
|
211
|
+
return circleOf(segment, property);
|
|
212
|
+
case "line":
|
|
213
|
+
return lineOf(segment, property);
|
|
214
|
+
case "polyline":
|
|
215
|
+
return polylineOf(segment, property);
|
|
216
|
+
case "spline":
|
|
217
|
+
return splineOf(segment, property);
|
|
218
|
+
case undefined:
|
|
219
|
+
throw new InputError(`\`${property}\` is not a line, arc, circle, polyline, spline or ellipse segment.`, property);
|
|
196
220
|
}
|
|
197
|
-
throw new InputError(`\`${property}\` is not a line, arc, circle, polyline, spline or ellipse segment.`, property);
|
|
198
221
|
};
|
|
199
222
|
const layerOf = (value, property) => {
|
|
200
223
|
const layer = typeof value === "string" ? value.trim() : "";
|
|
@@ -231,6 +254,64 @@ export const drawingPathOf = (path, property) => {
|
|
|
231
254
|
}
|
|
232
255
|
return { segments: path.segments.map((segment, at) => segmentOf(segment, `${property}.segments[${at}]`)) };
|
|
233
256
|
};
|
|
257
|
+
const listOf = (value, property, what) => {
|
|
258
|
+
if (value === undefined || value === null) {
|
|
259
|
+
return [];
|
|
260
|
+
}
|
|
261
|
+
if (!Array.isArray(value)) {
|
|
262
|
+
throw new InputError(`\`${property}\` must be a list of ${what}.`, property);
|
|
263
|
+
}
|
|
264
|
+
return value;
|
|
265
|
+
};
|
|
266
|
+
export const drawingTextOf = (text, property) => {
|
|
267
|
+
var _a, _b, _c, _d;
|
|
268
|
+
const named = (name) => property === "" ? name : `${property}.${name}`;
|
|
269
|
+
if (!isRecord(text) || typeof text["text"] !== "string") {
|
|
270
|
+
throw new InputError(`\`${named("text")}\` must be a text.`, named("text"));
|
|
271
|
+
}
|
|
272
|
+
const value = text["text"];
|
|
273
|
+
if (value.length > LONGEST_TEXT) {
|
|
274
|
+
throw new InputError(`\`${named("text")}\` is ${value.length} characters long; a line of text holds at most ${LONGEST_TEXT}.`, named("text"));
|
|
275
|
+
}
|
|
276
|
+
if (CONTROL_CHARACTER.test(value)) {
|
|
277
|
+
throw new InputError(`\`${named("text")}\` holds a line break or another control character; a text is one line.`, named("text"));
|
|
278
|
+
}
|
|
279
|
+
const anchor = (_a = text["anchor"]) !== null && _a !== void 0 ? _a : TEXT_DEFAULTS.anchor;
|
|
280
|
+
if (typeof anchor !== "string" || !TEXT_ANCHORS.has(anchor)) {
|
|
281
|
+
throw new InputError(`\`${named("anchor")}\` must be one of ${[...TEXT_ANCHORS].join(", ")}.`, named("anchor"));
|
|
282
|
+
}
|
|
283
|
+
const height = positiveNumber((_b = text["height"]) !== null && _b !== void 0 ? _b : TEXT_DEFAULTS.height, named("height"));
|
|
284
|
+
const widthFactor = positiveNumber((_c = text["widthFactor"]) !== null && _c !== void 0 ? _c : TEXT_DEFAULTS.widthFactor, named("widthFactor"));
|
|
285
|
+
const rotationDegrees = finiteNumber((_d = text["rotation"]) !== null && _d !== void 0 ? _d : TEXT_DEFAULTS.rotation, named("rotation"));
|
|
286
|
+
return {
|
|
287
|
+
value,
|
|
288
|
+
position: pointOf(text["position"], named("position")),
|
|
289
|
+
height,
|
|
290
|
+
anchor: anchor,
|
|
291
|
+
rotation: radiansOf(rotationDegrees),
|
|
292
|
+
rotationDegrees,
|
|
293
|
+
widthFactor,
|
|
294
|
+
width: strokeTextAdvance(simplex, value) * height * widthFactor,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
export const drawingHatchOf = (hatch, property) => {
|
|
298
|
+
var _a, _b, _c;
|
|
299
|
+
const named = (name) => property === "" ? name : `${property}.${name}`;
|
|
300
|
+
if (!isRecord(hatch) || !Array.isArray(hatch["boundaries"]) || hatch["boundaries"].length === 0) {
|
|
301
|
+
throw new InputError(`\`${named("boundaries")}\` must be a list of at least one path.`, named("boundaries"));
|
|
302
|
+
}
|
|
303
|
+
const pattern = (_a = hatch["pattern"]) !== null && _a !== void 0 ? _a : HATCH_DEFAULTS.pattern;
|
|
304
|
+
if (typeof pattern !== "string" || !HATCH_PATTERNS.has(pattern)) {
|
|
305
|
+
throw new InputError(`\`${named("pattern")}\` must be one of ${[...HATCH_PATTERNS].join(", ")}.`, named("pattern"));
|
|
306
|
+
}
|
|
307
|
+
const boundaries = hatch["boundaries"];
|
|
308
|
+
return {
|
|
309
|
+
boundaries: boundaries.map((path, at) => drawingPathOf(path, `${named("boundaries")}[${at}]`)),
|
|
310
|
+
pattern: pattern,
|
|
311
|
+
angle: finiteNumber((_b = hatch["angle"]) !== null && _b !== void 0 ? _b : HATCH_DEFAULTS.angle, named("angle")),
|
|
312
|
+
spacing: positiveNumber((_c = hatch["spacing"]) !== null && _c !== void 0 ? _c : HATCH_DEFAULTS.spacing, named("spacing")),
|
|
313
|
+
};
|
|
314
|
+
};
|
|
234
315
|
export const drawingPartsOf = (parts, property) => {
|
|
235
316
|
if (!Array.isArray(parts)) {
|
|
236
317
|
throw new InputError(`\`${property}\` must be a list of path parts.`, property);
|
|
@@ -246,7 +327,10 @@ export const drawingPartsOf = (parts, property) => {
|
|
|
246
327
|
layer: layerOf((_a = part["layer"]) !== null && _a !== void 0 ? _a : DEFAULT_LAYER, `${where}.layer`),
|
|
247
328
|
color: colorOf((_b = part["color"]) !== null && _b !== void 0 ? _b : "#000000", `${where}.color`),
|
|
248
329
|
lineType: lineTypeOf(part["lineType"], `${where}.lineType`),
|
|
330
|
+
lineWeight: part["lineWeight"] === undefined || part["lineWeight"] === null ? undefined : positiveNumber(part["lineWeight"], `${where}.lineWeight`),
|
|
249
331
|
paths: paths.map((path, index) => drawingPathOf(path, `${where}.paths[${index}]`)),
|
|
332
|
+
texts: listOf(part["texts"], `${where}.texts`, "texts").map((text, index) => drawingTextOf(text, `${where}.texts[${index}]`)),
|
|
333
|
+
hatches: listOf(part["hatches"], `${where}.hatches`, "hatches").map((hatch, index) => drawingHatchOf(hatch, `${where}.hatches[${index}]`)),
|
|
250
334
|
};
|
|
251
335
|
});
|
|
252
336
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as Inputs from "../../../../inputs";
|
|
2
|
+
import { scale2, scale3 } from "../../geometry/vectors";
|
|
3
|
+
import { drawingPartsOf, positiveNumber, segmentKindOf } from "./drawing-model";
|
|
4
|
+
const TEXT_DEFAULTS = new Inputs.IO.DrawingTextDto();
|
|
5
|
+
const HATCH_DEFAULTS = new Inputs.IO.DrawingHatchDto();
|
|
6
|
+
const scaledPoint = (point, factor) => point.length === 2 ? scale2(point, factor) : scale3(point, factor);
|
|
7
|
+
const scaledPoints = (points, factor) => points.map(point => scaledPoint(point, factor));
|
|
8
|
+
const copiedNormal = (normal) => normal === undefined ? {} : { normal: [...normal] };
|
|
9
|
+
const scaledSegment = (segment, factor) => {
|
|
10
|
+
switch (segmentKindOf(segment)) {
|
|
11
|
+
case "ellipse": {
|
|
12
|
+
const ellipse = segment;
|
|
13
|
+
return Object.assign(Object.assign(Object.assign({}, ellipse), { center: scaledPoint(ellipse.center, factor), majorAxis: scaledPoint(ellipse.majorAxis, factor) }), copiedNormal(ellipse.normal));
|
|
14
|
+
}
|
|
15
|
+
case "arc":
|
|
16
|
+
case "circle": {
|
|
17
|
+
const round = segment;
|
|
18
|
+
return Object.assign(Object.assign(Object.assign({}, round), { center: scaledPoint(round.center, factor), radius: round.radius * factor }), copiedNormal(round.normal));
|
|
19
|
+
}
|
|
20
|
+
case "line": {
|
|
21
|
+
const line = segment;
|
|
22
|
+
return Object.assign(Object.assign({}, line), { start: scaledPoint(line.start, factor), end: scaledPoint(line.end, factor) });
|
|
23
|
+
}
|
|
24
|
+
case "polyline": {
|
|
25
|
+
const polyline = segment;
|
|
26
|
+
return Object.assign(Object.assign(Object.assign({}, polyline), { points: scaledPoints(polyline.points, factor) }), (polyline.bulges === undefined ? {} : { bulges: [...polyline.bulges] }));
|
|
27
|
+
}
|
|
28
|
+
default: {
|
|
29
|
+
const spline = segment;
|
|
30
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, spline), { controlPoints: scaledPoints(spline.controlPoints, factor) }), (spline.knots === undefined ? {} : { knots: [...spline.knots] })), (spline.weights === undefined ? {} : { weights: [...spline.weights] }));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const scaledPath = (path, factor) => (Object.assign(Object.assign({}, path), { segments: path.segments.map(segment => scaledSegment(segment, factor)) }));
|
|
35
|
+
const scaledText = (text, factor) => { var _a; return (Object.assign(Object.assign({}, text), { position: scaledPoint(text.position, factor), height: ((_a = text.height) !== null && _a !== void 0 ? _a : TEXT_DEFAULTS.height) * factor })); };
|
|
36
|
+
const scaledHatch = (hatch, factor) => { var _a; return (Object.assign(Object.assign({}, hatch), { boundaries: hatch.boundaries.map(path => scaledPath(path, factor)), spacing: ((_a = hatch.spacing) !== null && _a !== void 0 ? _a : HATCH_DEFAULTS.spacing) * factor })); };
|
|
37
|
+
const scaledPart = (part, factor) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const texts = (_a = part.texts) === null || _a === void 0 ? void 0 : _a.map(text => scaledText(text, factor));
|
|
40
|
+
const hatches = (_b = part.hatches) === null || _b === void 0 ? void 0 : _b.map(hatch => scaledHatch(hatch, factor));
|
|
41
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, part), { paths: part.paths.map(path => scaledPath(path, factor)) }), (texts === undefined ? {} : { texts })), (hatches === undefined ? {} : { hatches })), (typeof part.lineWeight === "number" ? { lineWeight: part.lineWeight * factor } : {}));
|
|
42
|
+
};
|
|
43
|
+
export const scaledDrawingParts = (parts, factor, property) => {
|
|
44
|
+
const checkedFactor = positiveNumber(factor, "factor");
|
|
45
|
+
drawingPartsOf(parts, property);
|
|
46
|
+
return parts.map(part => scaledPart(part, checkedFactor));
|
|
47
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Inputs from "../../../../inputs";
|
|
2
|
+
import type { DrawingText } from "./drawing-types";
|
|
3
|
+
type Point3 = Inputs.Base.Point3;
|
|
4
|
+
export declare const textInked: (text: DrawingText) => boolean;
|
|
5
|
+
export declare const textStartOf: (text: DrawingText) => Point3;
|
|
6
|
+
export declare const textEndOf: (text: DrawingText) => Point3;
|
|
7
|
+
export declare const textCornersOf: (text: DrawingText) => Point3[];
|
|
8
|
+
export declare const textStrokesOf: (text: DrawingText) => Point3[][];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { simplex } from "../../../../models/simplex";
|
|
2
|
+
import { add2, rotated2 } from "../../geometry/vectors";
|
|
3
|
+
import { strokeFontInk, strokeGlyph, strokeTextStrokes } from "../../text/stroke-font";
|
|
4
|
+
import { ANCHOR_SHARES } from "./drawing.constants";
|
|
5
|
+
const placed = (text, along, up) => {
|
|
6
|
+
const at = add2([text.position[0], text.position[1]], rotated2([along - text.width * ANCHOR_SHARES[text.anchor], up], text.rotation));
|
|
7
|
+
return [at[0], at[1], text.position[2]];
|
|
8
|
+
};
|
|
9
|
+
export const textInked = (text) => {
|
|
10
|
+
for (let unit = 0; unit < text.value.length; unit += 1) {
|
|
11
|
+
if (strokeGlyph(simplex, text.value.charCodeAt(unit)).strokes.some(stroke => stroke.length > 0)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
export const textStartOf = (text) => placed(text, 0, 0);
|
|
18
|
+
export const textEndOf = (text) => placed(text, text.width, 0);
|
|
19
|
+
export const textCornersOf = (text) => {
|
|
20
|
+
const ink = strokeFontInk(simplex);
|
|
21
|
+
const low = ink.lowest * text.height;
|
|
22
|
+
const high = ink.highest * text.height;
|
|
23
|
+
return [placed(text, 0, low), placed(text, text.width, low), placed(text, text.width, high), placed(text, 0, high)];
|
|
24
|
+
};
|
|
25
|
+
export const textStrokesOf = (text) => strokeTextStrokes(simplex, text.value).map(stroke => stroke.map(point => placed(text, point[0] * text.height * text.widthFactor, point[1] * text.height)));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as Inputs from "../../../../inputs";
|
|
2
2
|
import type { NurbsCurveForm } from "../../curves/nurbs-forms";
|
|
3
|
+
import type { HatchFamilyTurn } from "./drawing.constants";
|
|
3
4
|
type Point3 = Inputs.Base.Point3;
|
|
4
5
|
type Vec3 = Inputs.Base.Vector3;
|
|
5
6
|
export interface DrawingLine {
|
|
@@ -47,14 +48,70 @@ export type DrawingSegment = DrawingLine | DrawingCircle | DrawingArc | DrawingP
|
|
|
47
48
|
export interface DrawingPath {
|
|
48
49
|
readonly segments: readonly DrawingSegment[];
|
|
49
50
|
}
|
|
51
|
+
export type DrawingTextAnchor = "start" | "middle" | "end";
|
|
52
|
+
export interface DrawingText {
|
|
53
|
+
readonly value: string;
|
|
54
|
+
readonly position: Point3;
|
|
55
|
+
readonly height: number;
|
|
56
|
+
readonly anchor: DrawingTextAnchor;
|
|
57
|
+
readonly rotation: number;
|
|
58
|
+
readonly rotationDegrees: number;
|
|
59
|
+
readonly widthFactor: number;
|
|
60
|
+
readonly width: number;
|
|
61
|
+
}
|
|
62
|
+
export interface DrawingHatch {
|
|
63
|
+
readonly boundaries: readonly DrawingPath[];
|
|
64
|
+
readonly pattern: Inputs.IO.hatchPatternEnum;
|
|
65
|
+
readonly angle: number;
|
|
66
|
+
readonly spacing: number;
|
|
67
|
+
}
|
|
68
|
+
export interface DrawingHatchFamily {
|
|
69
|
+
readonly turn: HatchFamilyTurn;
|
|
70
|
+
readonly angle: number;
|
|
71
|
+
readonly direction: Inputs.Base.Point2;
|
|
72
|
+
readonly across: Inputs.Base.Point2;
|
|
73
|
+
readonly phase: number;
|
|
74
|
+
}
|
|
75
|
+
export interface DrawingLoop {
|
|
76
|
+
readonly points: readonly Inputs.Base.Point2[];
|
|
77
|
+
readonly bulges: readonly number[];
|
|
78
|
+
}
|
|
50
79
|
export interface DrawingPart {
|
|
51
80
|
readonly layer: string;
|
|
52
81
|
readonly color: string;
|
|
53
82
|
readonly lineType: Inputs.IO.lineTypeEnum;
|
|
83
|
+
readonly lineWeight: number | undefined;
|
|
54
84
|
readonly paths: readonly DrawingPath[];
|
|
85
|
+
readonly texts: readonly DrawingText[];
|
|
86
|
+
readonly hatches: readonly DrawingHatch[];
|
|
55
87
|
}
|
|
56
88
|
export interface DrawingBounds {
|
|
57
89
|
readonly min: Point3;
|
|
58
90
|
readonly max: Point3;
|
|
59
91
|
}
|
|
92
|
+
export interface DrawingDimension {
|
|
93
|
+
readonly kind: Inputs.IO.dimensionKindEnum;
|
|
94
|
+
readonly start: Inputs.Base.Point2;
|
|
95
|
+
readonly end: Inputs.Base.Point2;
|
|
96
|
+
readonly direction: Inputs.Base.Vector2 | undefined;
|
|
97
|
+
readonly offset: number;
|
|
98
|
+
readonly sweep: number;
|
|
99
|
+
readonly text: string;
|
|
100
|
+
readonly textHeight: number;
|
|
101
|
+
readonly arrowLength: number;
|
|
102
|
+
}
|
|
103
|
+
export interface DimensionLayout {
|
|
104
|
+
readonly lines: Inputs.Base.Point2[][];
|
|
105
|
+
readonly fills: Inputs.Base.Point2[][];
|
|
106
|
+
readonly text: DrawingText;
|
|
107
|
+
}
|
|
108
|
+
export interface DimensionLine {
|
|
109
|
+
readonly from: Inputs.Base.Point2;
|
|
110
|
+
readonly to: Inputs.Base.Point2;
|
|
111
|
+
readonly arrowAtFrom: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface TextInk {
|
|
114
|
+
readonly low: number;
|
|
115
|
+
readonly high: number;
|
|
116
|
+
}
|
|
60
117
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const SAME_POINT = 1e-10;
|
|
2
2
|
export declare const PERPENDICULAR_COSINE = 1e-9;
|
|
3
3
|
export declare const FULL_TURN_DEGREES = 360;
|
|
4
|
+
export declare const QUARTER_TURN_DEGREES = 90;
|
|
4
5
|
export declare const ARBITRARY_AXIS_LIMIT: number;
|
|
5
6
|
export declare const FORBIDDEN_LAYER_CHARACTERS: RegExp;
|
|
6
7
|
export declare const FIRST_PRINTABLE_CODE = 32;
|
|
@@ -18,6 +19,18 @@ export declare const WRITER_WORK_PER_NUMBER: number;
|
|
|
18
19
|
export declare const WRITER_WORK_FLOOR: number;
|
|
19
20
|
export declare const WRITER_WORK_CEILING: number;
|
|
20
21
|
export declare const NUMBERS_PER_PART = 1;
|
|
22
|
+
export declare const NUMBERS_PER_TEXT = 8;
|
|
23
|
+
export declare const NUMBERS_PER_CHARACTER = 64;
|
|
24
|
+
export declare const NUMBERS_PER_HATCH = 4;
|
|
25
|
+
export declare const LONGEST_TEXT = 2000;
|
|
26
|
+
export declare const CONTROL_CHARACTER: RegExp;
|
|
27
|
+
export declare const JOIN_DISTANCE = 1e-9;
|
|
28
|
+
export declare const MOST_HATCH_LINES = 200000;
|
|
29
|
+
export declare const LEAST_LOOP_CORNERS = 3;
|
|
30
|
+
export type HatchFamilyTurn = 0 | typeof QUARTER_TURN_DEGREES;
|
|
31
|
+
export declare const HATCH_FAMILIES: Readonly<Record<string, readonly (readonly [HatchFamilyTurn, number])[]>>;
|
|
32
|
+
export declare const ANCHOR_SHARES: Readonly<Record<"start" | "middle" | "end", number>>;
|
|
33
|
+
export declare const TEXT_ANCHORS: ReadonlySet<string>;
|
|
21
34
|
export declare const NUMBERS_PER_VERTEX = 4;
|
|
22
35
|
export declare const NUMBERS_PER_CURVE: Readonly<Record<"line" | "circle" | "arc" | "ellipse", number>>;
|
|
23
36
|
export interface LineTypePattern {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const SAME_POINT = 1e-10;
|
|
2
2
|
export const PERPENDICULAR_COSINE = 1e-9;
|
|
3
3
|
export const FULL_TURN_DEGREES = 360;
|
|
4
|
+
export const QUARTER_TURN_DEGREES = 90;
|
|
4
5
|
export const ARBITRARY_AXIS_LIMIT = 1 / 64;
|
|
5
6
|
export const FORBIDDEN_LAYER_CHARACTERS = /[<>/\\":;?*|=`]/;
|
|
6
7
|
export const FIRST_PRINTABLE_CODE = 32;
|
|
@@ -18,6 +19,22 @@ export const WRITER_WORK_PER_NUMBER = Math.pow(2, 14);
|
|
|
18
19
|
export const WRITER_WORK_FLOOR = Math.pow(2, 20);
|
|
19
20
|
export const WRITER_WORK_CEILING = Math.pow(2, 25);
|
|
20
21
|
export const NUMBERS_PER_PART = 1;
|
|
22
|
+
export const NUMBERS_PER_TEXT = 8;
|
|
23
|
+
export const NUMBERS_PER_CHARACTER = 64;
|
|
24
|
+
export const NUMBERS_PER_HATCH = 4;
|
|
25
|
+
export const LONGEST_TEXT = 2000;
|
|
26
|
+
export const CONTROL_CHARACTER = /\p{Cc}/u;
|
|
27
|
+
export const JOIN_DISTANCE = 1e-9;
|
|
28
|
+
export const MOST_HATCH_LINES = 200000;
|
|
29
|
+
export const LEAST_LOOP_CORNERS = 3;
|
|
30
|
+
export const HATCH_FAMILIES = {
|
|
31
|
+
solid: [],
|
|
32
|
+
ansi31: [[0, 1 / 2]],
|
|
33
|
+
ansi32: [[0, 1 / 2], [0, 5 / 6]],
|
|
34
|
+
ansi37: [[0, 1 / 2], [QUARTER_TURN_DEGREES, 1 / 2]],
|
|
35
|
+
};
|
|
36
|
+
export const ANCHOR_SHARES = { start: 0, middle: 0.5, end: 1 };
|
|
37
|
+
export const TEXT_ANCHORS = new Set(Object.keys(ANCHOR_SHARES));
|
|
21
38
|
export const NUMBERS_PER_VERTEX = 4;
|
|
22
39
|
export const NUMBERS_PER_CURVE = { line: 6, circle: 7, arc: 9, ellipse: 12 };
|
|
23
40
|
export const LINE_TYPE_PATTERNS = {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DrawingHatch, DrawingText } from "../drawing/drawing-types";
|
|
2
|
+
import type { DxfEntityContext, DxfEntityStyle } from "./dxf-entities";
|
|
3
|
+
export declare const dxfTextValue: (value: string) => string;
|
|
4
|
+
export declare const writeText: (context: DxfEntityContext, text: DrawingText, style: DxfEntityStyle) => void;
|
|
5
|
+
export declare const writeHatch: (context: DxfEntityContext, hatch: DrawingHatch, style: DxfEntityStyle, property: string) => void;
|