@bitbybit-dev/base 1.6.2 → 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 +20 -7
- package/lib/api/inputs/base-inputs.js +10 -0
- 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/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 +22 -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.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 +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/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -0
- 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/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/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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { unitOf } from "../../geometry/frame-axes";
|
|
2
|
+
import { degreesOf } from "../../geometry/scalars";
|
|
3
|
+
import { dot3, length3 } from "../../geometry/vectors";
|
|
4
|
+
import { ocsAxesOf } from "../drawing/drawing-geometry";
|
|
5
|
+
import { polylineSegments, principalConicOf } from "./dxf-reader-geometry";
|
|
6
|
+
import { DXF_TURN_SLACK } from "./dxf.constants";
|
|
7
|
+
const AXIS_SLACK = 1e-12;
|
|
8
|
+
const ROUND_SHARE = 1e-12;
|
|
9
|
+
const alongZ = (normal) => (Math.abs(normal[0]) <= AXIS_SLACK && Math.abs(normal[1]) <= AXIS_SLACK ? Math.sign(normal[2]) : 0);
|
|
10
|
+
export const conicSegmentDto = (conic) => {
|
|
11
|
+
const principal = principalConicOf(conic);
|
|
12
|
+
if (principal === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const majorLength = length3(principal.major);
|
|
16
|
+
const normal = alongZ(principal.normal) > 0 ? {} : { normal: principal.normal };
|
|
17
|
+
if (Math.abs(principal.minor - majorLength) <= ROUND_SHARE * majorLength) {
|
|
18
|
+
if (principal.end - principal.start >= 2 * Math.PI - DXF_TURN_SLACK) {
|
|
19
|
+
return Object.assign({ center: principal.center, radius: majorLength }, normal);
|
|
20
|
+
}
|
|
21
|
+
const axes = ocsAxesOf(principal.normal);
|
|
22
|
+
const direction = unitOf(principal.major);
|
|
23
|
+
const offset = Math.atan2(dot3(direction, axes.y), dot3(direction, axes.x));
|
|
24
|
+
return Object.assign({ center: principal.center, radius: majorLength, startAngle: degreesOf(offset + principal.start), endAngle: degreesOf(offset + principal.end) }, normal);
|
|
25
|
+
}
|
|
26
|
+
return Object.assign({ center: principal.center, majorAxis: principal.major, ratio: principal.minor / majorLength, startParameter: principal.start, endParameter: principal.end }, normal);
|
|
27
|
+
};
|
|
28
|
+
const polylineDtos = (polyline) => {
|
|
29
|
+
const facing = alongZ(polyline.normal);
|
|
30
|
+
if (polyline.bulges.every(bulge => bulge === 0)) {
|
|
31
|
+
return [{ points: [...polyline.points], bulges: [...polyline.bulges], closed: polyline.closed }];
|
|
32
|
+
}
|
|
33
|
+
if (facing !== 0) {
|
|
34
|
+
const height = polyline.points[0][2];
|
|
35
|
+
return [{ points: polyline.points.map((point) => [point[0], point[1], height]), bulges: polyline.bulges.map(bulge => (bulge === 0 ? 0 : facing * bulge)), closed: polyline.closed }];
|
|
36
|
+
}
|
|
37
|
+
return polylineSegments(polyline).flatMap(segmentDtos);
|
|
38
|
+
};
|
|
39
|
+
const segmentDtos = (segment) => {
|
|
40
|
+
switch (segment.kind) {
|
|
41
|
+
case "line":
|
|
42
|
+
return [{ start: segment.start, end: segment.end }];
|
|
43
|
+
case "conic":
|
|
44
|
+
return [conicSegmentDto(segment)];
|
|
45
|
+
case "polyline":
|
|
46
|
+
return polylineDtos(segment);
|
|
47
|
+
case "spline": {
|
|
48
|
+
const rational = segment.curve.weights.some(weight => weight !== 1);
|
|
49
|
+
const spline = { controlPoints: [...segment.curve.points], degree: segment.curve.degree, knots: [...segment.curve.knots] };
|
|
50
|
+
return [rational ? Object.assign(Object.assign({}, spline), { weights: [...segment.curve.weights] }) : spline];
|
|
51
|
+
}
|
|
52
|
+
case "fit":
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const drawingDtoOf = (drawing) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const parts = new Map();
|
|
59
|
+
let fitSplines = 0;
|
|
60
|
+
let flatArcs = 0;
|
|
61
|
+
for (const entity of drawing.entities) {
|
|
62
|
+
const key = `${entity.style.layer}\n${entity.style.color}\n${entity.style.lineType}`;
|
|
63
|
+
const part = (_a = parts.get(key)) !== null && _a !== void 0 ? _a : { layer: entity.style.layer, color: entity.style.color, lineType: entity.style.lineType, paths: [] };
|
|
64
|
+
parts.set(key, part);
|
|
65
|
+
fitSplines += entity.segments.filter(segment => segment.kind === "fit").length;
|
|
66
|
+
const dtos = entity.segments.flatMap(segmentDtos);
|
|
67
|
+
const segments = dtos.filter((dto) => dto !== undefined);
|
|
68
|
+
flatArcs += dtos.length - segments.length;
|
|
69
|
+
if (segments.length > 0) {
|
|
70
|
+
part.paths.push({ segments });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const fitWarning = `${fitSplines} ${fitSplines === 1 ? "spline is" : "splines are"} given only by fit points, which need a kernel to interpolate; they were left out here, and occt.io.loadDxf reads them.`;
|
|
74
|
+
const flatWarning = `${flatArcs} ${flatArcs === 1 ? "arc" : "arcs"} could not be drawn: a radius, a plane or a sweep is missing.`;
|
|
75
|
+
return {
|
|
76
|
+
parts: [...parts.values()].filter(part => part.paths.length > 0),
|
|
77
|
+
unit: drawing.unit,
|
|
78
|
+
version: drawing.version,
|
|
79
|
+
warnings: [...drawing.warnings, ...(fitSplines === 0 ? [] : [fitWarning]), ...(flatArcs === 0 ? [] : [flatWarning])],
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as Inputs from "../../../../inputs";
|
|
2
|
+
import type { FrameAxes } from "../../geometry/frame-axes";
|
|
3
|
+
import type { ReadConic, ReadPolyline, ReadSegment } from "./dxf-reader-types";
|
|
4
|
+
type Point3 = Inputs.Base.Point3;
|
|
5
|
+
type Vec3 = Inputs.Base.Vector3;
|
|
6
|
+
export interface PrincipalConic {
|
|
7
|
+
readonly center: Point3;
|
|
8
|
+
readonly normal: Vec3;
|
|
9
|
+
readonly major: Vec3;
|
|
10
|
+
readonly minor: number;
|
|
11
|
+
readonly start: number;
|
|
12
|
+
readonly end: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const translation: (offset: Vec3) => FrameAxes;
|
|
15
|
+
export declare const scaling: (x: number, y: number, z: number) => FrameAxes;
|
|
16
|
+
export declare const rotationAboutZ: (radians: number) => FrameAxes;
|
|
17
|
+
export declare const positiveConic: (conic: ReadConic) => ReadConic;
|
|
18
|
+
export declare const polylineSegments: (polyline: ReadPolyline) => ReadSegment[];
|
|
19
|
+
export declare const mappedSegments: (map: FrameAxes, segment: ReadSegment) => ReadSegment[];
|
|
20
|
+
export declare const principalConicOf: (conic: ReadConic) => PrincipalConic | undefined;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { bulgeArcOf, principalArcOf } from "../../curves/conic-arcs";
|
|
2
|
+
import { pointToWorld, unitOf, vectorToLocal, vectorToWorld, WORLD_AXES } from "../../geometry/frame-axes";
|
|
3
|
+
import { cross3, dot3, length3, scale3 } from "../../geometry/vectors";
|
|
4
|
+
import { ocsAxesOf } from "../drawing/drawing-geometry";
|
|
5
|
+
import { SAME_SCALE } from "./dxf-reader.constants";
|
|
6
|
+
export const translation = (offset) => (Object.assign(Object.assign({}, WORLD_AXES), { origin: offset }));
|
|
7
|
+
export const scaling = (x, y, z) => ({ origin: [0, 0, 0], x: [x, 0, 0], y: [0, y, 0], z: [0, 0, z] });
|
|
8
|
+
export const rotationAboutZ = (radians) => {
|
|
9
|
+
const cos = Math.cos(radians);
|
|
10
|
+
const sin = Math.sin(radians);
|
|
11
|
+
return { origin: [0, 0, 0], x: [cos, sin, 0], y: [-sin, cos, 0], z: [0, 0, 1] };
|
|
12
|
+
};
|
|
13
|
+
const determinantOf = (map) => dot3(map.x, cross3(map.y, map.z));
|
|
14
|
+
const isSimilarity = (map) => {
|
|
15
|
+
const size = length3(map.x);
|
|
16
|
+
const close = (a, b) => Math.abs(a - b) <= SAME_SCALE * Math.max(1, size * size);
|
|
17
|
+
return close(length3(map.y) * length3(map.y), size * size) && close(length3(map.z) * length3(map.z), size * size)
|
|
18
|
+
&& close(dot3(map.x, map.y), 0) && close(dot3(map.y, map.z), 0) && close(dot3(map.z, map.x), 0);
|
|
19
|
+
};
|
|
20
|
+
export const positiveConic = (conic) => conic.sweep >= 0 ? conic : Object.assign(Object.assign({}, conic), { yAxis: scale3(conic.yAxis, -1), start: -conic.start, sweep: -conic.sweep });
|
|
21
|
+
export const polylineSegments = (polyline) => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const axes = ocsAxesOf((_a = unitOf(polyline.normal)) !== null && _a !== void 0 ? _a : [0, 0, 1]);
|
|
24
|
+
const spans = polyline.closed ? polyline.points.length : polyline.points.length - 1;
|
|
25
|
+
const segments = [];
|
|
26
|
+
for (let span = 0; span < spans; span++) {
|
|
27
|
+
const start = polyline.points[span];
|
|
28
|
+
const end = polyline.points[(span + 1) % polyline.points.length];
|
|
29
|
+
const bulge = (_b = polyline.bulges[span]) !== null && _b !== void 0 ? _b : 0;
|
|
30
|
+
if (bulge === 0) {
|
|
31
|
+
segments.push({ kind: "line", start, end });
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const arc = bulgeArcOf(vectorToLocal(axes, start), vectorToLocal(axes, end), bulge);
|
|
35
|
+
const radius = arc.frame.xAxis[0];
|
|
36
|
+
segments.push(positiveConic({ kind: "conic", center: vectorToWorld(axes, arc.frame.center), xAxis: scale3(axes.x, radius), yAxis: scale3(axes.y, radius), start: arc.start, sweep: arc.sweep }));
|
|
37
|
+
}
|
|
38
|
+
return segments;
|
|
39
|
+
};
|
|
40
|
+
export const mappedSegments = (map, segment) => {
|
|
41
|
+
var _a;
|
|
42
|
+
switch (segment.kind) {
|
|
43
|
+
case "line":
|
|
44
|
+
return [{ kind: "line", start: pointToWorld(map, segment.start), end: pointToWorld(map, segment.end) }];
|
|
45
|
+
case "conic":
|
|
46
|
+
return [Object.assign(Object.assign({}, segment), { center: pointToWorld(map, segment.center), xAxis: vectorToWorld(map, segment.xAxis), yAxis: vectorToWorld(map, segment.yAxis) })];
|
|
47
|
+
case "polyline": {
|
|
48
|
+
if (!isSimilarity(map)) {
|
|
49
|
+
return polylineSegments(segment).flatMap(part => mappedSegments(map, part));
|
|
50
|
+
}
|
|
51
|
+
const normal = (_a = unitOf(vectorToWorld(map, segment.normal))) !== null && _a !== void 0 ? _a : [0, 0, 1];
|
|
52
|
+
return [Object.assign(Object.assign({}, segment), { points: segment.points.map(point => pointToWorld(map, point)), normal: determinantOf(map) < 0 ? scale3(normal, -1) : normal })];
|
|
53
|
+
}
|
|
54
|
+
case "spline":
|
|
55
|
+
return [{ kind: "spline", curve: Object.assign(Object.assign({}, segment.curve), { points: segment.curve.points.map(point => pointToWorld(map, point)) }) }];
|
|
56
|
+
case "fit":
|
|
57
|
+
return [Object.assign(Object.assign({}, segment), { points: segment.points.map(point => pointToWorld(map, point)), startTangent: segment.startTangent === undefined ? undefined : vectorToWorld(map, segment.startTangent), endTangent: segment.endTangent === undefined ? undefined : vectorToWorld(map, segment.endTangent) })];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export const principalConicOf = (conic) => {
|
|
61
|
+
const normal = unitOf(cross3(conic.xAxis, conic.yAxis));
|
|
62
|
+
if (normal === undefined) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const principal = principalArcOf({ frame: { center: conic.center, xAxis: conic.xAxis, yAxis: conic.yAxis }, start: conic.start, sweep: conic.sweep });
|
|
66
|
+
return { center: conic.center, normal, major: principal.frame.xAxis, minor: length3(principal.frame.yAxis), start: principal.start, end: principal.start + conic.sweep };
|
|
67
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type * as Inputs from "../../../../inputs";
|
|
2
|
+
import type { NurbsCurveForm } from "../../curves/nurbs-forms";
|
|
3
|
+
type Point3 = Inputs.Base.Point3;
|
|
4
|
+
type Vec3 = Inputs.Base.Vector3;
|
|
5
|
+
export interface DxfGroup {
|
|
6
|
+
readonly code: number;
|
|
7
|
+
readonly value: string;
|
|
8
|
+
readonly line: number;
|
|
9
|
+
}
|
|
10
|
+
export interface DxfEntityRecord {
|
|
11
|
+
readonly type: string;
|
|
12
|
+
readonly groups: readonly DxfGroup[];
|
|
13
|
+
readonly vertices: readonly DxfEntityRecord[];
|
|
14
|
+
}
|
|
15
|
+
export interface ReadLine {
|
|
16
|
+
readonly kind: "line";
|
|
17
|
+
readonly start: Point3;
|
|
18
|
+
readonly end: Point3;
|
|
19
|
+
}
|
|
20
|
+
export interface ReadConic {
|
|
21
|
+
readonly kind: "conic";
|
|
22
|
+
readonly center: Point3;
|
|
23
|
+
readonly xAxis: Vec3;
|
|
24
|
+
readonly yAxis: Vec3;
|
|
25
|
+
readonly start: number;
|
|
26
|
+
readonly sweep: number;
|
|
27
|
+
}
|
|
28
|
+
export interface ReadPolyline {
|
|
29
|
+
readonly kind: "polyline";
|
|
30
|
+
readonly points: readonly Point3[];
|
|
31
|
+
readonly bulges: readonly number[];
|
|
32
|
+
readonly closed: boolean;
|
|
33
|
+
readonly normal: Vec3;
|
|
34
|
+
}
|
|
35
|
+
export interface ReadSpline {
|
|
36
|
+
readonly kind: "spline";
|
|
37
|
+
readonly curve: NurbsCurveForm;
|
|
38
|
+
}
|
|
39
|
+
export interface ReadFitSpline {
|
|
40
|
+
readonly kind: "fit";
|
|
41
|
+
readonly points: readonly Point3[];
|
|
42
|
+
readonly startTangent: Vec3 | undefined;
|
|
43
|
+
readonly endTangent: Vec3 | undefined;
|
|
44
|
+
readonly closed: boolean;
|
|
45
|
+
}
|
|
46
|
+
export type ReadSegment = ReadLine | ReadConic | ReadPolyline | ReadSpline | ReadFitSpline;
|
|
47
|
+
export interface ReadStyle {
|
|
48
|
+
readonly layer: string;
|
|
49
|
+
readonly color: string;
|
|
50
|
+
readonly lineType: Inputs.IO.lineTypeEnum;
|
|
51
|
+
}
|
|
52
|
+
export interface ReadEntity {
|
|
53
|
+
readonly style: ReadStyle;
|
|
54
|
+
readonly segments: readonly ReadSegment[];
|
|
55
|
+
}
|
|
56
|
+
export interface ReadLayer {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly color: string;
|
|
59
|
+
readonly lineType: Inputs.IO.lineTypeEnum;
|
|
60
|
+
readonly hidden: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ReadDrawing {
|
|
63
|
+
readonly version: string;
|
|
64
|
+
readonly unit: Inputs.Base.unitOfLengthEnum | undefined;
|
|
65
|
+
readonly layers: readonly ReadLayer[];
|
|
66
|
+
readonly entities: readonly ReadEntity[];
|
|
67
|
+
readonly warnings: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Inputs from "../../../../inputs";
|
|
2
|
+
export declare const BINARY_SENTINEL = "AutoCAD Binary DXF";
|
|
3
|
+
export declare const QUOTED_LENGTH = 40;
|
|
4
|
+
export declare const MAX_INSERT_DEPTH = 16;
|
|
5
|
+
export declare const INSERT_WORK_PER_CHARACTER = 16;
|
|
6
|
+
export declare const INSERT_WORK_FLOOR = 500000;
|
|
7
|
+
export declare const INSERT_WORK_CEILING = 1000000;
|
|
8
|
+
export declare const ENTITY_WORK = 2;
|
|
9
|
+
export declare const COPY_WORK = 1;
|
|
10
|
+
export declare const LINE_WORK = 2;
|
|
11
|
+
export declare const CONIC_WORK = 2;
|
|
12
|
+
export declare const MAX_SPLINE_DEGREE = 25;
|
|
13
|
+
export declare const MAX_FIT_POINTS = 10000;
|
|
14
|
+
export declare const MAX_LISTED_NAMES = 5;
|
|
15
|
+
export declare const PAPER_SPACE = "1";
|
|
16
|
+
export declare const FROZEN_FLAG = 1;
|
|
17
|
+
export declare const XREF_FLAGS: number;
|
|
18
|
+
export declare const PERIODIC_FLAG = 2;
|
|
19
|
+
export declare const POLYFACE_FLAG = 64;
|
|
20
|
+
export declare const MESH_FLAG = 16;
|
|
21
|
+
export declare const SPLINE_FRAME_VERTEX_FLAG = 16;
|
|
22
|
+
export declare const BY_BLOCK = 0;
|
|
23
|
+
export declare const BY_LAYER = 256;
|
|
24
|
+
export declare const BLACK = "#000000";
|
|
25
|
+
export declare const BYTE = 255;
|
|
26
|
+
export declare const RED_SHIFT = 16;
|
|
27
|
+
export declare const GREEN_SHIFT = 8;
|
|
28
|
+
export declare const DEGREES_PER_TURN = 360;
|
|
29
|
+
export declare const SAME_SCALE = 1e-9;
|
|
30
|
+
export declare const UNIT_CODES: ReadonlyMap<number, Inputs.Base.unitOfLengthEnum>;
|
|
31
|
+
export declare const UNIT_NAMES: ReadonlyMap<number, string>;
|
|
32
|
+
export declare const DRAWN_ENTITIES: Set<string>;
|
|
33
|
+
export declare const Y_OFFSET = 10;
|
|
34
|
+
export declare const Z_OFFSET = 20;
|
|
35
|
+
export declare const GROUP: {
|
|
36
|
+
readonly name: 2;
|
|
37
|
+
readonly variable: 9;
|
|
38
|
+
readonly x: 10;
|
|
39
|
+
readonly y: 20;
|
|
40
|
+
readonly elevationZ: 30;
|
|
41
|
+
readonly otherX: 11;
|
|
42
|
+
readonly fitX: 11;
|
|
43
|
+
readonly startTangentX: 12;
|
|
44
|
+
readonly endTangentX: 13;
|
|
45
|
+
readonly controlX: 10;
|
|
46
|
+
readonly radius: 40;
|
|
47
|
+
readonly ratio: 40;
|
|
48
|
+
readonly knot: 40;
|
|
49
|
+
readonly weight: 41;
|
|
50
|
+
readonly startParameter: 41;
|
|
51
|
+
readonly endParameter: 42;
|
|
52
|
+
readonly bulge: 42;
|
|
53
|
+
readonly scaleX: 41;
|
|
54
|
+
readonly scaleY: 42;
|
|
55
|
+
readonly scaleZ: 43;
|
|
56
|
+
readonly columnStep: 44;
|
|
57
|
+
readonly rowStep: 45;
|
|
58
|
+
readonly startAngle: 50;
|
|
59
|
+
readonly rotation: 50;
|
|
60
|
+
readonly endAngle: 51;
|
|
61
|
+
readonly lineType: 6;
|
|
62
|
+
readonly layer: 8;
|
|
63
|
+
readonly color: 62;
|
|
64
|
+
readonly trueColor: 420;
|
|
65
|
+
readonly flags: 70;
|
|
66
|
+
readonly columns: 70;
|
|
67
|
+
readonly degree: 71;
|
|
68
|
+
readonly rows: 71;
|
|
69
|
+
readonly elevation: 38;
|
|
70
|
+
readonly space: 67;
|
|
71
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as Inputs from "../../../../inputs";
|
|
2
|
+
export const BINARY_SENTINEL = "AutoCAD Binary DXF";
|
|
3
|
+
export const QUOTED_LENGTH = 40;
|
|
4
|
+
export const MAX_INSERT_DEPTH = 16;
|
|
5
|
+
export const INSERT_WORK_PER_CHARACTER = 16;
|
|
6
|
+
export const INSERT_WORK_FLOOR = 500000;
|
|
7
|
+
export const INSERT_WORK_CEILING = 1000000;
|
|
8
|
+
export const ENTITY_WORK = 2;
|
|
9
|
+
export const COPY_WORK = 1;
|
|
10
|
+
export const LINE_WORK = 2;
|
|
11
|
+
export const CONIC_WORK = 2;
|
|
12
|
+
export const MAX_SPLINE_DEGREE = 25;
|
|
13
|
+
export const MAX_FIT_POINTS = 10000;
|
|
14
|
+
export const MAX_LISTED_NAMES = 5;
|
|
15
|
+
export const PAPER_SPACE = "1";
|
|
16
|
+
export const FROZEN_FLAG = 1;
|
|
17
|
+
export const XREF_FLAGS = 4 | 8;
|
|
18
|
+
export const PERIODIC_FLAG = 2;
|
|
19
|
+
export const POLYFACE_FLAG = 64;
|
|
20
|
+
export const MESH_FLAG = 16;
|
|
21
|
+
export const SPLINE_FRAME_VERTEX_FLAG = 16;
|
|
22
|
+
export const BY_BLOCK = 0;
|
|
23
|
+
export const BY_LAYER = 256;
|
|
24
|
+
export const BLACK = "#000000";
|
|
25
|
+
export const BYTE = 255;
|
|
26
|
+
export const RED_SHIFT = 16;
|
|
27
|
+
export const GREEN_SHIFT = 8;
|
|
28
|
+
export const DEGREES_PER_TURN = 360;
|
|
29
|
+
export const SAME_SCALE = 1e-9;
|
|
30
|
+
export const UNIT_CODES = new Map([
|
|
31
|
+
[1, Inputs.Base.unitOfLengthEnum.inch],
|
|
32
|
+
[4, Inputs.Base.unitOfLengthEnum.millimetre],
|
|
33
|
+
[5, Inputs.Base.unitOfLengthEnum.centimetre],
|
|
34
|
+
[6, Inputs.Base.unitOfLengthEnum.metre],
|
|
35
|
+
]);
|
|
36
|
+
export const UNIT_NAMES = new Map([
|
|
37
|
+
[2, "feet"], [3, "miles"], [7, "kilometres"], [8, "microinches"], [9, "mils"], [10, "yards"], [11, "angstroms"], [12, "nanometres"], [13, "microns"], [14, "decimetres"],
|
|
38
|
+
]);
|
|
39
|
+
export const DRAWN_ENTITIES = new Set(["LINE", "ARC", "CIRCLE", "ELLIPSE", "LWPOLYLINE", "POLYLINE", "SPLINE", "INSERT"]);
|
|
40
|
+
export const Y_OFFSET = 10;
|
|
41
|
+
export const Z_OFFSET = 20;
|
|
42
|
+
export const GROUP = {
|
|
43
|
+
name: 2,
|
|
44
|
+
variable: 9,
|
|
45
|
+
x: 10,
|
|
46
|
+
y: 20,
|
|
47
|
+
elevationZ: 30,
|
|
48
|
+
otherX: 11,
|
|
49
|
+
fitX: 11,
|
|
50
|
+
startTangentX: 12,
|
|
51
|
+
endTangentX: 13,
|
|
52
|
+
controlX: 10,
|
|
53
|
+
radius: 40,
|
|
54
|
+
ratio: 40,
|
|
55
|
+
knot: 40,
|
|
56
|
+
weight: 41,
|
|
57
|
+
startParameter: 41,
|
|
58
|
+
endParameter: 42,
|
|
59
|
+
bulge: 42,
|
|
60
|
+
scaleX: 41,
|
|
61
|
+
scaleY: 42,
|
|
62
|
+
scaleZ: 43,
|
|
63
|
+
columnStep: 44,
|
|
64
|
+
rowStep: 45,
|
|
65
|
+
startAngle: 50,
|
|
66
|
+
rotation: 50,
|
|
67
|
+
endAngle: 51,
|
|
68
|
+
lineType: 6,
|
|
69
|
+
layer: 8,
|
|
70
|
+
color: 62,
|
|
71
|
+
trueColor: 420,
|
|
72
|
+
flags: 70,
|
|
73
|
+
columns: 70,
|
|
74
|
+
degree: 71,
|
|
75
|
+
rows: 71,
|
|
76
|
+
elevation: 38,
|
|
77
|
+
space: 67,
|
|
78
|
+
};
|