@bitbybit-dev/base 1.6.2 → 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 +40 -7
- package/lib/api/inputs/base-inputs.js +32 -0
- package/lib/api/inputs/io-inputs.d.ts +927 -59
- package/lib/api/inputs/io-inputs.js +769 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- 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 +2 -0
- package/lib/api/kernel-calls/index.js +2 -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 +101 -0
- package/lib/api/kernel-calls/settings.js +123 -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/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 -3
- package/lib/api/services/base-bitbybit.d.ts +12 -0
- package/lib/api/services/base-bitbybit.js +19 -3
- package/lib/api/services/color.js +2 -3
- package/lib/api/services/helpers/color/color-forms.constants.d.ts +3 -0
- package/lib/api/services/helpers/color/color-forms.constants.js +3 -0
- package/lib/api/services/helpers/color/color-forms.d.ts +1 -0
- package/lib/api/services/helpers/color/color-forms.js +4 -1
- 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 +26 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +87 -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 +34 -0
- 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 +21 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +101 -0
- 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 +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +336 -0
- 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 +117 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +41 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +46 -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-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 +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +196 -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 +97 -523
- 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.d.ts +6 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +115 -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-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 +96 -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 +134 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +95 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +446 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +29 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +248 -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 +11 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +89 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +43 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +47 -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 +132 -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 +18 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +230 -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 +14 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +14 -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/loop-fill.d.ts +2 -0
- package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
- 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/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -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 +368 -0
- package/lib/api/services/io/drawing.js +454 -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 +66 -0
- package/lib/api/services/io/svg.js +105 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- package/lib/api/services/mesh.d.ts +19 -0
- package/lib/api/services/mesh.js +40 -0
- 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 +6 -2
- package/lib/api/services/text.d.ts +7 -4
- package/lib/api/services/text.js +14 -27
- 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,532 +1,106 @@
|
|
|
1
1
|
import * as Inputs from "../../../../inputs";
|
|
2
|
-
import { InputError
|
|
3
|
-
import { checkedUnitOfLength } from "../../geometry/lengths";
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { InputError } from "../../../../kernel-calls";
|
|
3
|
+
import { checkedUnitOfLength, millimetresPerUnitOf } from "../../geometry/lengths";
|
|
4
|
+
import { drawingBounds, drawingSize, patternUnitOf } from "../drawing/drawing-geometry";
|
|
5
|
+
import { writerBudgetOf } from "../drawing/drawing-budget";
|
|
6
|
+
import { drawingPartsOf, positiveNumber } from "../drawing/drawing-model";
|
|
7
|
+
import { DEFAULT_LAYER, LEAST_TOLERANCE_SHARE, SPACE_AXES } from "../drawing/drawing.constants";
|
|
8
|
+
import { writeHatch, writeText } from "./dxf-annotations";
|
|
9
|
+
import { writeSegment } from "./dxf-entities";
|
|
10
|
+
import { dxfMeasurementOf, writeBlocks, writeClasses, writeHeader, writeObjects, writeTables } from "./dxf-tables";
|
|
11
|
+
import { DxfText } from "./dxf-text";
|
|
12
|
+
import { DXF_FIRST_HANDLE, DXF_LINE_WEIGHTS, DXF_LINE_WEIGHTS_PER_MILLIMETRE } from "./dxf.constants";
|
|
13
|
+
const VERSIONS = new Set(["AC1009", "AC1015"]);
|
|
14
|
+
const COLOR_FORMATS = new Set(["aci", "truecolor"]);
|
|
15
|
+
const layersOf = (parts) => {
|
|
16
|
+
const rows = new Map([[DEFAULT_LAYER, { name: DEFAULT_LAYER, color: "#ffffff", lineType: Inputs.IO.lineTypeEnum.continuous }]]);
|
|
17
|
+
let zeroTaken = false;
|
|
18
|
+
for (const part of parts) {
|
|
19
|
+
const key = part.layer.toUpperCase();
|
|
20
|
+
if (!rows.has(key) || (key === DEFAULT_LAYER && !zeroTaken)) {
|
|
21
|
+
rows.set(key, { name: part.layer, color: part.color, lineType: part.lineType });
|
|
22
|
+
}
|
|
23
|
+
zeroTaken = zeroTaken || key === DEFAULT_LAYER;
|
|
24
|
+
}
|
|
25
|
+
return rows;
|
|
26
|
+
};
|
|
27
|
+
const lineWeightOf = (width, millimetresPerUnit) => {
|
|
28
|
+
if (width === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const wanted = width * millimetresPerUnit * DXF_LINE_WEIGHTS_PER_MILLIMETRE;
|
|
32
|
+
return DXF_LINE_WEIGHTS.reduce((nearest, weight) => Math.abs(weight - wanted) < Math.abs(nearest - wanted) ? weight : nearest);
|
|
33
|
+
};
|
|
34
|
+
const entityStyleOf = (part, layers, millimetresPerUnit) => {
|
|
35
|
+
const continuous = Inputs.IO.lineTypeEnum.continuous;
|
|
36
|
+
const byLayer = part.lineType === continuous && layers.get(part.layer.toUpperCase()).lineType === continuous;
|
|
37
|
+
return { layer: part.layer, color: part.color, lineType: byLayer ? undefined : part.lineType, lineWeight: lineWeightOf(part.lineWeight, millimetresPerUnit) };
|
|
38
|
+
};
|
|
39
|
+
const lineTypesOf = (parts) => [...new Set(parts.map(part => part.lineType))].filter(lineType => lineType !== Inputs.IO.lineTypeEnum.continuous);
|
|
40
|
+
const versionOf = (value) => {
|
|
41
|
+
if (typeof value !== "string" || !VERSIONS.has(value)) {
|
|
42
|
+
throw new InputError("`acadVersion` must be AC1009 or AC1015.", "acadVersion");
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
const colorFormatOf = (value) => {
|
|
47
|
+
if (typeof value !== "string" || !COLOR_FORMATS.has(value)) {
|
|
48
|
+
throw new InputError("`colorFormat` must be aci or truecolor.", "colorFormat");
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
const unitOf = (value, version) => {
|
|
53
|
+
if (value === undefined) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const unit = checkedUnitOfLength(value, "unit");
|
|
57
|
+
if (version === "AC1009") {
|
|
58
|
+
throw new InputError("`unit` is given, but an AC1009 (R12) file has no place for a drawing's unit: write AC1015 to state it.", "unit");
|
|
59
|
+
}
|
|
60
|
+
return unit;
|
|
61
|
+
};
|
|
6
62
|
export class DxfGenerator {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"2",
|
|
33
|
-
"HEADER",
|
|
34
|
-
"9",
|
|
35
|
-
"$ACADVER",
|
|
36
|
-
"1",
|
|
37
|
-
this.acadVersion
|
|
38
|
-
];
|
|
39
|
-
if (this.acadVersion === "AC1009") {
|
|
40
|
-
header.push("9", "$DWGCODEPAGE", "3", "ascii", "9", "$HANDSEED", "5", "0");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
header.push("9", "$DWGCODEPAGE", "3", "ANSI_1252", "9", "$LASTSAVEDBY", "1", "bitbybit.dev", "9", "$HANDSEED", "5", "20000");
|
|
44
|
-
}
|
|
45
|
-
header.push(...this.unitHeader(unit));
|
|
46
|
-
header.push("0", "ENDSEC");
|
|
47
|
-
return header;
|
|
48
|
-
}
|
|
49
|
-
unitHeader(unit) {
|
|
50
|
-
if (unit === undefined) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const checked = checkedUnitOfLength(unit, "unit");
|
|
54
|
-
if (this.acadVersion === "AC1009") {
|
|
55
|
-
throw new InputError("`unit` is given, but an AC1009 (R12) file has no place for a drawing's unit: write AC1015 to state it.", "unit");
|
|
56
|
-
}
|
|
57
|
-
return ["9", "$INSUNITS", "70", DXF_INSUNITS[checked], "9", "$MEASUREMENT", "70", checked === "in" ? DXF_IMPERIAL_MEASUREMENT : DXF_METRIC_MEASUREMENT];
|
|
58
|
-
}
|
|
59
|
-
generateTables(dxfInputs) {
|
|
60
|
-
const tables = [
|
|
61
|
-
"0",
|
|
62
|
-
"SECTION",
|
|
63
|
-
"2",
|
|
64
|
-
"TABLES"
|
|
65
|
-
];
|
|
66
|
-
if (this.acadVersion === "AC1009") {
|
|
67
|
-
tables.push(...this.generateVportTable());
|
|
68
|
-
}
|
|
69
|
-
tables.push(...this.generateLineTypeTable());
|
|
70
|
-
tables.push(...this.generateLayerTable(dxfInputs));
|
|
71
|
-
tables.push(...this.generateStyleTable());
|
|
72
|
-
if (this.acadVersion === "AC1009") {
|
|
73
|
-
tables.push(...this.generateViewTable());
|
|
74
|
-
tables.push(...this.generateUcsTable());
|
|
75
|
-
tables.push(...this.generateAppidTable());
|
|
76
|
-
tables.push(...this.generateDimstyleTable());
|
|
77
|
-
}
|
|
78
|
-
tables.push("0", "ENDSEC");
|
|
79
|
-
return tables;
|
|
80
|
-
}
|
|
81
|
-
generateLineTypeTable() {
|
|
82
|
-
const ltype = [
|
|
83
|
-
"0",
|
|
84
|
-
"TABLE",
|
|
85
|
-
"2",
|
|
86
|
-
"LTYPE",
|
|
87
|
-
"70",
|
|
88
|
-
"1"
|
|
89
|
-
];
|
|
90
|
-
if (this.acadVersion === "AC1015") {
|
|
91
|
-
ltype.push("5", "5", "100", "AcDbSymbolTable");
|
|
92
|
-
}
|
|
93
|
-
ltype.push("0", "LTYPE", "2", "CONTINUOUS", "70", this.acadVersion === "AC1009" ? "64" : "0", "3", "Solid line", "72", "65", "73", "0", "40", "0.0");
|
|
94
|
-
if (this.acadVersion === "AC1015") {
|
|
95
|
-
ltype.splice(ltype.indexOf("LTYPE") + 1, 0, "5", "14", "100", "AcDbSymbolTableRecord", "100", "AcDbLinetypeTableRecord");
|
|
96
|
-
}
|
|
97
|
-
ltype.push("0", "ENDTAB");
|
|
98
|
-
return ltype;
|
|
99
|
-
}
|
|
100
|
-
generateStyleTable() {
|
|
101
|
-
const style = [
|
|
102
|
-
"0",
|
|
103
|
-
"TABLE",
|
|
104
|
-
"2",
|
|
105
|
-
"STYLE",
|
|
106
|
-
"70",
|
|
107
|
-
"1"
|
|
108
|
-
];
|
|
109
|
-
if (this.acadVersion === "AC1015") {
|
|
110
|
-
style.push("5", "3", "100", "AcDbSymbolTable");
|
|
111
|
-
}
|
|
112
|
-
style.push("0", "STYLE", "2", "STANDARD", "70", "0", "40", "0.0", "41", "1.0", "50", "0.0", "71", "0", "42", "0.2", "3", "txt", "4", "");
|
|
113
|
-
if (this.acadVersion === "AC1015") {
|
|
114
|
-
style.splice(style.indexOf("STYLE") + 1, 0, "5", "11", "100", "AcDbSymbolTableRecord", "100", "AcDbTextStyleTableRecord");
|
|
115
|
-
}
|
|
116
|
-
style.push("0", "ENDTAB");
|
|
117
|
-
return style;
|
|
118
|
-
}
|
|
119
|
-
generateVportTable() {
|
|
120
|
-
return [
|
|
121
|
-
"0",
|
|
122
|
-
"TABLE",
|
|
123
|
-
"2",
|
|
124
|
-
"VPORT",
|
|
125
|
-
"70",
|
|
126
|
-
"2",
|
|
127
|
-
"0",
|
|
128
|
-
"VPORT",
|
|
129
|
-
"2",
|
|
130
|
-
"*ACTIVE",
|
|
131
|
-
"70",
|
|
132
|
-
"0",
|
|
133
|
-
"10",
|
|
134
|
-
"0.0",
|
|
135
|
-
"20",
|
|
136
|
-
"0.0",
|
|
137
|
-
"11",
|
|
138
|
-
"1.0",
|
|
139
|
-
"21",
|
|
140
|
-
"1.0",
|
|
141
|
-
"12",
|
|
142
|
-
"15.0",
|
|
143
|
-
"22",
|
|
144
|
-
"11.101231",
|
|
145
|
-
"13",
|
|
146
|
-
"0.0",
|
|
147
|
-
"23",
|
|
148
|
-
"0.0",
|
|
149
|
-
"14",
|
|
150
|
-
"0.1",
|
|
151
|
-
"24",
|
|
152
|
-
"0.1",
|
|
153
|
-
"15",
|
|
154
|
-
"0.5",
|
|
155
|
-
"25",
|
|
156
|
-
"0.5",
|
|
157
|
-
"16",
|
|
158
|
-
"0.0",
|
|
159
|
-
"26",
|
|
160
|
-
"0.0",
|
|
161
|
-
"36",
|
|
162
|
-
"1.0",
|
|
163
|
-
"17",
|
|
164
|
-
"0.0",
|
|
165
|
-
"27",
|
|
166
|
-
"0.0",
|
|
167
|
-
"37",
|
|
168
|
-
"0.0",
|
|
169
|
-
"40",
|
|
170
|
-
"22.202462",
|
|
171
|
-
"41",
|
|
172
|
-
"1.351201",
|
|
173
|
-
"42",
|
|
174
|
-
"50.0",
|
|
175
|
-
"43",
|
|
176
|
-
"0.0",
|
|
177
|
-
"44",
|
|
178
|
-
"0.0",
|
|
179
|
-
"50",
|
|
180
|
-
"0.0",
|
|
181
|
-
"51",
|
|
182
|
-
"0.0",
|
|
183
|
-
"71",
|
|
184
|
-
"0",
|
|
185
|
-
"72",
|
|
186
|
-
"100",
|
|
187
|
-
"73",
|
|
188
|
-
"1",
|
|
189
|
-
"74",
|
|
190
|
-
"1",
|
|
191
|
-
"75",
|
|
192
|
-
"1",
|
|
193
|
-
"76",
|
|
194
|
-
"0",
|
|
195
|
-
"77",
|
|
196
|
-
"0",
|
|
197
|
-
"78",
|
|
198
|
-
"0",
|
|
199
|
-
"0",
|
|
200
|
-
"ENDTAB"
|
|
201
|
-
];
|
|
202
|
-
}
|
|
203
|
-
generateViewTable() {
|
|
204
|
-
return [
|
|
205
|
-
"0",
|
|
206
|
-
"TABLE",
|
|
207
|
-
"2",
|
|
208
|
-
"VIEW",
|
|
209
|
-
"70",
|
|
210
|
-
"0",
|
|
211
|
-
"0",
|
|
212
|
-
"ENDTAB"
|
|
213
|
-
];
|
|
214
|
-
}
|
|
215
|
-
generateUcsTable() {
|
|
216
|
-
return [
|
|
217
|
-
"0",
|
|
218
|
-
"TABLE",
|
|
219
|
-
"2",
|
|
220
|
-
"UCS",
|
|
221
|
-
"70",
|
|
222
|
-
"0",
|
|
223
|
-
"0",
|
|
224
|
-
"ENDTAB"
|
|
225
|
-
];
|
|
226
|
-
}
|
|
227
|
-
generateAppidTable() {
|
|
228
|
-
return [
|
|
229
|
-
"0",
|
|
230
|
-
"TABLE",
|
|
231
|
-
"2",
|
|
232
|
-
"APPID",
|
|
233
|
-
"70",
|
|
234
|
-
"1",
|
|
235
|
-
"0",
|
|
236
|
-
"APPID",
|
|
237
|
-
"2",
|
|
238
|
-
"ACAD",
|
|
239
|
-
"70",
|
|
240
|
-
"64",
|
|
241
|
-
"0",
|
|
242
|
-
"ENDTAB"
|
|
243
|
-
];
|
|
244
|
-
}
|
|
245
|
-
generateDimstyleTable() {
|
|
246
|
-
return [
|
|
247
|
-
"0",
|
|
248
|
-
"TABLE",
|
|
249
|
-
"2",
|
|
250
|
-
"DIMSTYLE",
|
|
251
|
-
"70",
|
|
252
|
-
"0",
|
|
253
|
-
"0",
|
|
254
|
-
"ENDTAB"
|
|
255
|
-
];
|
|
256
|
-
}
|
|
257
|
-
generateBlocks() {
|
|
258
|
-
return [
|
|
259
|
-
"0",
|
|
260
|
-
"SECTION",
|
|
261
|
-
"2",
|
|
262
|
-
"BLOCKS",
|
|
263
|
-
"0",
|
|
264
|
-
"ENDSEC"
|
|
265
|
-
];
|
|
266
|
-
}
|
|
267
|
-
generateLayerTable(dxfInputs) {
|
|
268
|
-
const layers = new Set();
|
|
269
|
-
if (dxfInputs.dxfPathsParts) {
|
|
270
|
-
dxfInputs.dxfPathsParts.forEach(pathsPart => {
|
|
271
|
-
const part = resolveDto(Inputs.IO.DxfPathsPartDto, pathsPart);
|
|
272
|
-
if (part.layer) {
|
|
273
|
-
layers.add(part.layer);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
if (layers.size === 0) {
|
|
278
|
-
layers.add("0");
|
|
279
|
-
}
|
|
280
|
-
const layerTable = [
|
|
281
|
-
"0",
|
|
282
|
-
"TABLE",
|
|
283
|
-
"2",
|
|
284
|
-
"LAYER",
|
|
285
|
-
"70",
|
|
286
|
-
layers.size.toString()
|
|
287
|
-
];
|
|
288
|
-
if (this.acadVersion === "AC1015") {
|
|
289
|
-
layerTable.splice(4, 0, "5", "2", "100", "AcDbSymbolTable");
|
|
290
|
-
}
|
|
291
|
-
layers.forEach(layerName => {
|
|
292
|
-
layerTable.push("0", "LAYER", "2", layerName, "70", "0", "62", "7", "6", "CONTINUOUS");
|
|
293
|
-
if (this.acadVersion === "AC1015") {
|
|
294
|
-
const insertIdx = layerTable.lastIndexOf("LAYER") + 1;
|
|
295
|
-
layerTable.splice(insertIdx, 0, "5", this.getNextHandle(), "100", "AcDbSymbolTableRecord", "100", "AcDbLayerTableRecord");
|
|
63
|
+
generateDxf(model) {
|
|
64
|
+
const version = versionOf(model.acadVersion);
|
|
65
|
+
const colorFormat = colorFormatOf(model.colorFormat);
|
|
66
|
+
const unit = unitOf(model.unit, version);
|
|
67
|
+
const givenTolerance = positiveNumber(model.curveTolerance, "curveTolerance");
|
|
68
|
+
const parts = drawingPartsOf(model.dxfPathsParts, "dxfPathsParts");
|
|
69
|
+
const text = new DxfText(DXF_FIRST_HANDLE, { budget: writerBudgetOf(parts), property: "dxfPathsParts" });
|
|
70
|
+
const bounds = drawingBounds(parts, givenTolerance, text.budget);
|
|
71
|
+
text.refuseWhenSpent();
|
|
72
|
+
const curveTolerance = Math.max(givenTolerance, LEAST_TOLERANCE_SHARE * drawingSize(bounds, SPACE_AXES));
|
|
73
|
+
const layers = layersOf(parts);
|
|
74
|
+
const patternUnit = model.lineTypeScale === undefined ? patternUnitOf(bounds) : positiveNumber(model.lineTypeScale, "lineTypeScale");
|
|
75
|
+
const millimetresPerUnit = unit === undefined ? 1 : millimetresPerUnitOf(unit);
|
|
76
|
+
const layout = { version, colorFormat, unit, bounds, layers: [...layers.values()], lineTypes: lineTypesOf(parts), patternUnit };
|
|
77
|
+
const handseed = writeHeader(text, layout);
|
|
78
|
+
writeClasses(text, layout);
|
|
79
|
+
const owners = writeTables(text, layout);
|
|
80
|
+
writeBlocks(text, layout, owners);
|
|
81
|
+
text.pair("0", "SECTION");
|
|
82
|
+
text.pair("2", "ENTITIES");
|
|
83
|
+
const context = { text, version, owner: owners.modelSpace, colorFormat, curveTolerance, measurement: dxfMeasurementOf(unit) };
|
|
84
|
+
parts.forEach((part, at) => {
|
|
85
|
+
const style = entityStyleOf(part, layers, millimetresPerUnit);
|
|
86
|
+
for (const hatch of part.hatches) {
|
|
87
|
+
writeHatch(context, hatch, style, `dxfPathsParts[${at}].hatches`);
|
|
296
88
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
generateEntities(dxfInputs) {
|
|
302
|
-
const entities = [
|
|
303
|
-
"0",
|
|
304
|
-
"SECTION",
|
|
305
|
-
"2",
|
|
306
|
-
"ENTITIES"
|
|
307
|
-
];
|
|
308
|
-
if (dxfInputs.dxfPathsParts) {
|
|
309
|
-
dxfInputs.dxfPathsParts.forEach(pathsPart => {
|
|
310
|
-
const part = resolveDto(Inputs.IO.DxfPathsPartDto, pathsPart);
|
|
311
|
-
if (part.paths) {
|
|
312
|
-
part.paths.forEach(path => {
|
|
313
|
-
if (path.segments) {
|
|
314
|
-
path.segments.forEach(segment => {
|
|
315
|
-
entities.push(...this.generateSegmentEntity(segment, part));
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
entities.push("0", "ENDSEC");
|
|
323
|
-
return entities;
|
|
324
|
-
}
|
|
325
|
-
generateSegmentEntity(segment, part) {
|
|
326
|
-
if (this.isLineSegment(segment)) {
|
|
327
|
-
return this.generateLineEntity(segment, part);
|
|
328
|
-
}
|
|
329
|
-
else if (this.isArcSegment(segment)) {
|
|
330
|
-
return this.generateArcEntity(segment, part);
|
|
331
|
-
}
|
|
332
|
-
else if (this.isCircleSegment(segment)) {
|
|
333
|
-
return this.generateCircleEntity(segment, part);
|
|
334
|
-
}
|
|
335
|
-
else if (this.isPolylineSegment(segment)) {
|
|
336
|
-
return this.generatePolylineEntity(segment, part);
|
|
337
|
-
}
|
|
338
|
-
else if (this.isSplineSegment(segment)) {
|
|
339
|
-
return this.generateSplineEntity(segment, part);
|
|
340
|
-
}
|
|
341
|
-
return [];
|
|
342
|
-
}
|
|
343
|
-
isLineSegment(segment) {
|
|
344
|
-
return segment.start !== undefined && segment.end !== undefined && segment.radius === undefined;
|
|
345
|
-
}
|
|
346
|
-
isArcSegment(segment) {
|
|
347
|
-
return segment.center !== undefined && segment.radius !== undefined && segment.startAngle !== undefined && segment.endAngle !== undefined;
|
|
348
|
-
}
|
|
349
|
-
isCircleSegment(segment) {
|
|
350
|
-
return segment.center !== undefined && segment.radius !== undefined && segment.startAngle === undefined;
|
|
351
|
-
}
|
|
352
|
-
isPolylineSegment(segment) {
|
|
353
|
-
return segment.points !== undefined && Array.isArray(segment.points);
|
|
354
|
-
}
|
|
355
|
-
isSplineSegment(segment) {
|
|
356
|
-
return segment.controlPoints !== undefined && Array.isArray(segment.controlPoints);
|
|
357
|
-
}
|
|
358
|
-
generateLineEntity(line, part) {
|
|
359
|
-
const entity = [
|
|
360
|
-
"0",
|
|
361
|
-
"LINE",
|
|
362
|
-
"8",
|
|
363
|
-
part.layer || "0"
|
|
364
|
-
];
|
|
365
|
-
const colorCodes = this.convertColorToDxf(part.color);
|
|
366
|
-
colorCodes.forEach(cc => entity.push(cc.code, cc.value));
|
|
367
|
-
entity.push("10", line.start[0].toFixed(6), "20", line.start[1].toFixed(6), "30", "0.00", "11", line.end[0].toFixed(6), "21", line.end[1].toFixed(6), "31", "0.00");
|
|
368
|
-
if (this.acadVersion === "AC1015") {
|
|
369
|
-
entity.splice(2, 0, "5", this.getNextHandle(), "100", "AcDbEntity");
|
|
370
|
-
const coordIdx = entity.indexOf("10");
|
|
371
|
-
entity.splice(coordIdx, 0, "100", "AcDbLine");
|
|
372
|
-
}
|
|
373
|
-
return entity;
|
|
374
|
-
}
|
|
375
|
-
generateCircleEntity(circle, part) {
|
|
376
|
-
const entity = [
|
|
377
|
-
"0",
|
|
378
|
-
"CIRCLE",
|
|
379
|
-
"8",
|
|
380
|
-
part.layer || "0"
|
|
381
|
-
];
|
|
382
|
-
const colorCodes = this.convertColorToDxf(part.color);
|
|
383
|
-
colorCodes.forEach(cc => entity.push(cc.code, cc.value));
|
|
384
|
-
entity.push("10", circle.center[0].toFixed(6), "20", circle.center[1].toFixed(6), "30", "0.00", "40", circle.radius.toFixed(6));
|
|
385
|
-
if (this.acadVersion === "AC1015") {
|
|
386
|
-
entity.splice(2, 0, "5", this.getNextHandle(), "100", "AcDbEntity");
|
|
387
|
-
const coordIdx = entity.indexOf("10");
|
|
388
|
-
entity.splice(coordIdx, 0, "100", "AcDbCircle");
|
|
389
|
-
}
|
|
390
|
-
return entity;
|
|
391
|
-
}
|
|
392
|
-
generateArcEntity(arc, part) {
|
|
393
|
-
const entity = [
|
|
394
|
-
"0",
|
|
395
|
-
"ARC",
|
|
396
|
-
"8",
|
|
397
|
-
part.layer || "0"
|
|
398
|
-
];
|
|
399
|
-
if (this.acadVersion === "AC1009") {
|
|
400
|
-
entity.push("6", " ");
|
|
401
|
-
}
|
|
402
|
-
const colorCodes = this.convertColorToDxf(part.color);
|
|
403
|
-
colorCodes.forEach(cc => entity.push(cc.code, cc.value));
|
|
404
|
-
entity.push("10", arc.center[0].toFixed(6), "20", arc.center[1].toFixed(6), "30", this.acadVersion === "AC1009" ? "" : "0.0", "40", arc.radius.toFixed(6), "50", arc.startAngle.toFixed(6), "51", arc.endAngle.toFixed(6));
|
|
405
|
-
if (this.acadVersion === "AC1015") {
|
|
406
|
-
entity.splice(2, 0, "5", this.getNextHandle(), "100", "AcDbEntity");
|
|
407
|
-
const coordIdx = entity.indexOf("10");
|
|
408
|
-
entity.splice(coordIdx, 0, "100", "AcDbCircle");
|
|
409
|
-
const angleIdx = entity.indexOf("50");
|
|
410
|
-
entity.splice(angleIdx, 0, "100", "AcDbArc");
|
|
411
|
-
}
|
|
412
|
-
return entity;
|
|
413
|
-
}
|
|
414
|
-
generatePolylineEntity(segment, part) {
|
|
415
|
-
const polyline = resolveDto(Inputs.IO.DxfPolylineSegmentDto, segment);
|
|
416
|
-
const entity = [
|
|
417
|
-
"0",
|
|
418
|
-
"LWPOLYLINE",
|
|
419
|
-
"8",
|
|
420
|
-
part.layer || "0"
|
|
421
|
-
];
|
|
422
|
-
const colorCodes = this.convertColorToDxf(part.color);
|
|
423
|
-
colorCodes.forEach(cc => entity.push(cc.code, cc.value));
|
|
424
|
-
const isClosed = polyline.closed || (polyline.points.length > 2 && this.isClosedPolyline(polyline.points));
|
|
425
|
-
entity.push("90", polyline.points.length.toString(), "70", isClosed ? "1" : "0");
|
|
426
|
-
if (this.acadVersion === "AC1015") {
|
|
427
|
-
entity.splice(2, 0, "5", this.getNextHandle(), "100", "AcDbEntity");
|
|
428
|
-
const pointIdx = entity.indexOf("90");
|
|
429
|
-
entity.splice(pointIdx, 0, "100", "AcDbPolyline");
|
|
430
|
-
}
|
|
431
|
-
polyline.points.forEach((point, index) => {
|
|
432
|
-
entity.push("10", point[0].toFixed(6), "20", point[1].toFixed(6));
|
|
433
|
-
if (polyline.bulges && polyline.bulges.length > index) {
|
|
434
|
-
const bulge = polyline.bulges[index];
|
|
435
|
-
if (bulge !== 0) {
|
|
436
|
-
entity.push("42", bulge.toFixed(6));
|
|
89
|
+
for (const path of part.paths) {
|
|
90
|
+
for (const segment of path.segments) {
|
|
91
|
+
writeSegment(context, segment, style);
|
|
437
92
|
}
|
|
438
93
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
generateSplineEntity(segment, part) {
|
|
443
|
-
const spline = resolveDto(Inputs.IO.DxfSplineSegmentDto, segment);
|
|
444
|
-
const entity = [
|
|
445
|
-
"0",
|
|
446
|
-
"SPLINE",
|
|
447
|
-
"8",
|
|
448
|
-
part.layer || "0"
|
|
449
|
-
];
|
|
450
|
-
const colorCodes = this.convertColorToDxf(part.color);
|
|
451
|
-
colorCodes.forEach(cc => entity.push(cc.code, cc.value));
|
|
452
|
-
const degree = spline.degree || 3;
|
|
453
|
-
const numControlPoints = spline.controlPoints.length;
|
|
454
|
-
const numKnots = numControlPoints + degree + 1;
|
|
455
|
-
const flags = spline.closed ? 9 : 8;
|
|
456
|
-
entity.push("210", "0.0", "220", "0.0", "230", "1.0", "70", flags.toString(), "71", degree.toString(), "72", numKnots.toString(), "73", numControlPoints.toString(), "74", "0");
|
|
457
|
-
if (this.acadVersion === "AC1015") {
|
|
458
|
-
entity.splice(2, 0, "5", this.getNextHandle(), "100", "AcDbEntity");
|
|
459
|
-
const normalIdx = entity.indexOf("210");
|
|
460
|
-
entity.splice(normalIdx, 0, "100", "AcDbSpline");
|
|
461
|
-
}
|
|
462
|
-
for (let i = 0; i < numKnots; i++) {
|
|
463
|
-
entity.push("40", i.toFixed(6));
|
|
464
|
-
}
|
|
465
|
-
spline.controlPoints.forEach(point => {
|
|
466
|
-
entity.push("10", point[0].toFixed(6), "20", point[1].toFixed(6), "30", "0.0");
|
|
467
|
-
});
|
|
468
|
-
return entity;
|
|
469
|
-
}
|
|
470
|
-
isClosedPolyline(points) {
|
|
471
|
-
if (points.length < 3) {
|
|
472
|
-
return false;
|
|
473
|
-
}
|
|
474
|
-
const first = points[0];
|
|
475
|
-
const last = points[points.length - 1];
|
|
476
|
-
return Math.abs(first[0] - last[0]) < CLOSED_POLYLINE_TOLERANCE &&
|
|
477
|
-
Math.abs(first[1] - last[1]) < CLOSED_POLYLINE_TOLERANCE;
|
|
478
|
-
}
|
|
479
|
-
getNextHandle() {
|
|
480
|
-
return (++this.entityHandle).toString(16).toUpperCase();
|
|
481
|
-
}
|
|
482
|
-
convertColorToDxf(color) {
|
|
483
|
-
if (color.startsWith("#")) {
|
|
484
|
-
const hex = color.substring(1);
|
|
485
|
-
if (hex.length === 6) {
|
|
486
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
487
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
488
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
489
|
-
if (this.colorFormat === "truecolor") {
|
|
490
|
-
const trueColor = (r * 65536) + (g * 256) + b;
|
|
491
|
-
return [
|
|
492
|
-
{ code: "62", value: "256" },
|
|
493
|
-
{ code: "420", value: trueColor.toString() }
|
|
494
|
-
];
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
const aciIndex = this.rgbToAciColorIndex(r, g, b);
|
|
498
|
-
return [{ code: "62", value: aciIndex.toString() }];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
return [{ code: "62", value: "7" }];
|
|
503
|
-
}
|
|
504
|
-
rgbToAciColorIndex(r, g, b) {
|
|
505
|
-
const aciColors = {
|
|
506
|
-
1: [255, 0, 0],
|
|
507
|
-
2: [255, 255, 0],
|
|
508
|
-
3: [0, 255, 0],
|
|
509
|
-
4: [0, 255, 255],
|
|
510
|
-
5: [0, 0, 255],
|
|
511
|
-
6: [255, 0, 255],
|
|
512
|
-
7: [255, 255, 255],
|
|
513
|
-
8: [128, 128, 128],
|
|
514
|
-
9: [192, 192, 192]
|
|
515
|
-
};
|
|
516
|
-
if (r < 30 && g < 30 && b < 30) {
|
|
517
|
-
return 7;
|
|
518
|
-
}
|
|
519
|
-
let nearestIndex = 7;
|
|
520
|
-
let minDistance = Infinity;
|
|
521
|
-
for (const [index, [cr, cg, cb]] of Object.entries(aciColors)) {
|
|
522
|
-
const distance = Math.sqrt(Math.pow(r - cr, 2) +
|
|
523
|
-
Math.pow(g - cg, 2) +
|
|
524
|
-
Math.pow(b - cb, 2));
|
|
525
|
-
if (distance < minDistance) {
|
|
526
|
-
minDistance = distance;
|
|
527
|
-
nearestIndex = parseInt(index);
|
|
94
|
+
for (const text of part.texts) {
|
|
95
|
+
writeText(context, text, style);
|
|
528
96
|
}
|
|
97
|
+
});
|
|
98
|
+
text.pair("0", "ENDSEC");
|
|
99
|
+
writeObjects(text, layout);
|
|
100
|
+
text.pair("0", "EOF");
|
|
101
|
+
if (handseed !== undefined) {
|
|
102
|
+
text.fill(handseed, text.peekHandle());
|
|
529
103
|
}
|
|
530
|
-
return
|
|
104
|
+
return text.joined();
|
|
531
105
|
}
|
|
532
106
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FrameAxes } from "../../geometry/frame-axes";
|
|
2
|
+
import type { DxfEntityRecord, PlanarTurn, ReadHatch, ReadText } from "./dxf-reader-types";
|
|
3
|
+
import type { DxfMeasurement } from "./dxf-tables";
|
|
4
|
+
export declare const planarTurnOf: (map: FrameAxes) => PlanarTurn | undefined;
|
|
5
|
+
export declare const plainDxfText: (value: string) => string;
|
|
6
|
+
export declare const readTextOf: (record: DxfEntityRecord) => ReadText | string | undefined;
|
|
7
|
+
export declare const placedText: (text: ReadText, turn: PlanarTurn, map: FrameAxes) => ReadText;
|
|
8
|
+
export declare const readHatchOf: (record: DxfEntityRecord, measurement: DxfMeasurement) => ReadHatch | string | undefined;
|
|
9
|
+
export declare const placedHatch: (hatch: ReadHatch, turn: PlanarTurn, map: FrameAxes, isPlaced: boolean) => ReadHatch;
|