@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.
Files changed (204) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +3 -1
  3. package/lib/api/GlobalCDNProvider.js +1 -1
  4. package/lib/api/inputs/base-inputs.d.ts +40 -7
  5. package/lib/api/inputs/base-inputs.js +32 -0
  6. package/lib/api/inputs/io-inputs.d.ts +927 -59
  7. package/lib/api/inputs/io-inputs.js +769 -40
  8. package/lib/api/inputs/line-inputs.d.ts +17 -0
  9. package/lib/api/inputs/line-inputs.js +15 -0
  10. package/lib/api/inputs/mesh-inputs.d.ts +20 -1
  11. package/lib/api/inputs/mesh-inputs.js +23 -0
  12. package/lib/api/inputs/recipes-inputs.d.ts +13 -5
  13. package/lib/api/inputs/recipes-inputs.js +10 -5
  14. package/lib/api/kernel-calls/index.d.ts +2 -0
  15. package/lib/api/kernel-calls/index.js +2 -0
  16. package/lib/api/kernel-calls/resolve-dto.d.ts +3 -1
  17. package/lib/api/kernel-calls/resolve-dto.js +7 -2
  18. package/lib/api/kernel-calls/settings.d.ts +101 -0
  19. package/lib/api/kernel-calls/settings.js +123 -0
  20. package/lib/api/kernel-calls/up-axis-aliases.d.ts +25 -0
  21. package/lib/api/kernel-calls/up-axis-aliases.js +70 -0
  22. package/lib/api/models/simplex.d.ts +2 -0
  23. package/lib/api/models/simplex.js +10 -1
  24. package/lib/api/recipes/surface-mesh.d.ts +2 -1
  25. package/lib/api/recipes/surface-mesh.js +5 -3
  26. package/lib/api/resolved-inputs/index.d.ts +32 -3
  27. package/lib/api/services/base-bitbybit.d.ts +12 -0
  28. package/lib/api/services/base-bitbybit.js +19 -3
  29. package/lib/api/services/color.js +2 -3
  30. package/lib/api/services/helpers/color/color-forms.constants.d.ts +3 -0
  31. package/lib/api/services/helpers/color/color-forms.constants.js +3 -0
  32. package/lib/api/services/helpers/color/color-forms.d.ts +1 -0
  33. package/lib/api/services/helpers/color/color-forms.js +4 -1
  34. package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
  35. package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
  36. package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
  37. package/lib/api/services/helpers/color/css-colors.js +61 -0
  38. package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
  39. package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
  40. package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
  41. package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
  42. package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
  43. package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
  44. package/lib/api/services/helpers/curves/conic-arcs.d.ts +26 -0
  45. package/lib/api/services/helpers/curves/conic-arcs.js +87 -0
  46. package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
  47. package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
  48. package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
  49. package/lib/api/services/helpers/curves/nurbs.js +10 -9
  50. package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
  51. package/lib/api/services/helpers/files/drawing/drawing-budget.js +34 -0
  52. package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.d.ts +14 -0
  53. package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.js +14 -0
  54. package/lib/api/services/helpers/files/drawing/drawing-dimension.d.ts +4 -0
  55. package/lib/api/services/helpers/files/drawing/drawing-dimension.js +271 -0
  56. package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +21 -0
  57. package/lib/api/services/helpers/files/drawing/drawing-geometry.js +101 -0
  58. package/lib/api/services/helpers/files/drawing/drawing-hatch.d.ts +10 -0
  59. package/lib/api/services/helpers/files/drawing/drawing-hatch.js +123 -0
  60. package/lib/api/services/helpers/files/drawing/drawing-loops.d.ts +3 -0
  61. package/lib/api/services/helpers/files/drawing/drawing-loops.js +91 -0
  62. package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +10 -0
  63. package/lib/api/services/helpers/files/drawing/drawing-model.js +336 -0
  64. package/lib/api/services/helpers/files/drawing/drawing-scale.d.ts +2 -0
  65. package/lib/api/services/helpers/files/drawing/drawing-scale.js +47 -0
  66. package/lib/api/services/helpers/files/drawing/drawing-text.d.ts +9 -0
  67. package/lib/api/services/helpers/files/drawing/drawing-text.js +25 -0
  68. package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +117 -0
  69. package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
  70. package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +41 -0
  71. package/lib/api/services/helpers/files/drawing/drawing.constants.js +46 -0
  72. package/lib/api/services/helpers/files/dxf/dxf-annotations.d.ts +5 -0
  73. package/lib/api/services/helpers/files/dxf/dxf-annotations.js +96 -0
  74. package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
  75. package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
  76. package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +21 -0
  77. package/lib/api/services/helpers/files/dxf/dxf-entities.js +196 -0
  78. package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
  79. package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
  80. package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
  81. package/lib/api/services/helpers/files/dxf/dxf-generator.js +97 -523
  82. package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.d.ts +9 -0
  83. package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.js +312 -0
  84. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
  85. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +115 -0
  86. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
  87. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
  88. package/lib/api/services/helpers/files/dxf/dxf-reader-segments.d.ts +9 -0
  89. package/lib/api/services/helpers/files/dxf/dxf-reader-segments.js +151 -0
  90. package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +96 -0
  91. package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
  92. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +134 -0
  93. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +95 -0
  94. package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
  95. package/lib/api/services/helpers/files/dxf/dxf-reader.js +446 -0
  96. package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +29 -0
  97. package/lib/api/services/helpers/files/dxf/dxf-tables.js +248 -0
  98. package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
  99. package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
  100. package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +11 -0
  101. package/lib/api/services/helpers/files/dxf/dxf-tokens.js +89 -0
  102. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +43 -1
  103. package/lib/api/services/helpers/files/dxf/dxf.constants.js +47 -1
  104. package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
  105. package/lib/api/services/helpers/files/file-bytes.js +15 -0
  106. package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
  107. package/lib/api/services/helpers/files/ground-axes.js +4 -0
  108. package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
  109. package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
  110. package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
  111. package/lib/api/services/helpers/files/stl-axes.js +22 -0
  112. package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
  113. package/lib/api/services/helpers/files/stl-types.js +1 -0
  114. package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
  115. package/lib/api/services/helpers/files/stl.constants.js +11 -0
  116. package/lib/api/services/helpers/files/stl.d.ts +3 -0
  117. package/lib/api/services/helpers/files/stl.js +93 -0
  118. package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
  119. package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
  120. package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
  121. package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
  122. package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
  123. package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
  124. package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
  125. package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
  126. package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
  127. package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
  128. package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
  129. package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
  130. package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
  131. package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
  132. package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
  133. package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
  134. package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
  135. package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
  136. package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
  137. package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
  138. package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
  139. package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
  140. package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
  141. package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
  142. package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
  143. package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
  144. package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
  145. package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
  146. package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
  147. package/lib/api/services/helpers/files/svg/svg-strokes.js +132 -0
  148. package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
  149. package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
  150. package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
  151. package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
  152. package/lib/api/services/helpers/files/svg/svg-writer.d.ts +18 -0
  153. package/lib/api/services/helpers/files/svg/svg-writer.js +230 -0
  154. package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
  155. package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
  156. package/lib/api/services/helpers/files/svg/svg.constants.d.ts +14 -0
  157. package/lib/api/services/helpers/files/svg/svg.constants.js +14 -0
  158. package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
  159. package/lib/api/services/helpers/files/work-budget.js +26 -0
  160. package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
  161. package/lib/api/services/helpers/geometry/affine2.js +18 -0
  162. package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
  163. package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
  164. package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
  165. package/lib/api/services/helpers/geometry/loop-fill.d.ts +2 -0
  166. package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
  167. package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
  168. package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
  169. package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
  170. package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
  171. package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
  172. package/lib/api/services/helpers/geometry/vectors.js +6 -0
  173. package/lib/api/services/helpers/helper-types.d.ts +33 -0
  174. package/lib/api/services/helpers/text/stroke-font.d.ts +6 -0
  175. package/lib/api/services/helpers/text/stroke-font.js +177 -0
  176. package/lib/api/services/helpers/text/stroke-letters.constants.d.ts +2 -0
  177. package/lib/api/services/helpers/text/stroke-letters.constants.js +18 -0
  178. package/lib/api/services/helpers/text/stroke-marks.constants.d.ts +14 -0
  179. package/lib/api/services/helpers/text/stroke-marks.constants.js +34 -0
  180. package/lib/api/services/io/drawing.d.ts +368 -0
  181. package/lib/api/services/io/drawing.js +454 -0
  182. package/lib/api/services/io/dxf.d.ts +134 -0
  183. package/lib/api/services/io/dxf.js +167 -0
  184. package/lib/api/services/io/index.d.ts +4 -0
  185. package/lib/api/services/io/index.js +4 -0
  186. package/lib/api/services/io/io.d.ts +14 -0
  187. package/lib/api/services/io/io.js +15 -0
  188. package/lib/api/services/io/svg.d.ts +66 -0
  189. package/lib/api/services/io/svg.js +105 -0
  190. package/lib/api/services/line.d.ts +17 -0
  191. package/lib/api/services/line.js +20 -1
  192. package/lib/api/services/mesh.d.ts +19 -0
  193. package/lib/api/services/mesh.js +40 -0
  194. package/lib/api/services/point.d.ts +4 -1
  195. package/lib/api/services/point.js +9 -4
  196. package/lib/api/services/recipes.d.ts +3 -0
  197. package/lib/api/services/recipes.js +6 -2
  198. package/lib/api/services/text.d.ts +7 -4
  199. package/lib/api/services/text.js +14 -27
  200. package/package.json +1 -1
  201. package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
  202. package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
  203. package/lib/api/services/io.d.ts +0 -9
  204. package/lib/api/services/io.js +0 -10
@@ -0,0 +1,336 @@
1
+ import * as Inputs from "../../../../inputs";
2
+ import { InputError } from "../../../../kernel-calls";
3
+ import { hexChannels, hexOfChannels } from "../../color/color-forms";
4
+ import { angleWithinTurn } from "../../curves/conic-arcs";
5
+ import { clampedForm, clampedUniformKnots, periodicUniformForm } from "../../curves/nurbs-forms";
6
+ import { unitOf } from "../../geometry/frame-axes";
7
+ import { radiansOf } from "../../geometry/scalars";
8
+ import { distance3, dot3 } from "../../geometry/vectors";
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";
12
+ import { DXF_MAX_NAME_LENGTH } from "../dxf/dxf.constants";
13
+ const PLUS_Z = [0, 0, 1];
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();
18
+ const isRecord = (value) => typeof value === "object" && value !== null;
19
+ export const isDrawable = (value) => typeof value === "number" && Math.abs(value) < LARGEST_NUMBER;
20
+ export const finiteNumber = (value, property) => {
21
+ if (!isDrawable(value)) {
22
+ throw new InputError(`\`${property}\` must be a finite number below ${LARGEST_NUMBER} in size.`, property);
23
+ }
24
+ return value;
25
+ };
26
+ export const positiveNumber = (value, property) => {
27
+ const checked = finiteNumber(value, property);
28
+ if (checked <= 0) {
29
+ throw new InputError(`\`${property}\` must be above 0; it is ${checked}.`, property);
30
+ }
31
+ return checked;
32
+ };
33
+ const pointOf = (value, property) => {
34
+ var _a;
35
+ if (!Array.isArray(value) || !POINT_SIZES.includes(value.length) || !value.every(isDrawable)) {
36
+ throw new InputError(`\`${property}\` must be a point of 2 or 3 finite numbers below ${LARGEST_NUMBER} in size.`, property);
37
+ }
38
+ return [value[0], value[1], (_a = value[2]) !== null && _a !== void 0 ? _a : 0];
39
+ };
40
+ const directionOf = (value, property) => {
41
+ if (value === undefined) {
42
+ return PLUS_Z;
43
+ }
44
+ const direction = unitOf(pointOf(value, property));
45
+ if (direction === undefined) {
46
+ throw new InputError(`\`${property}\` must not be a zero vector.`, property);
47
+ }
48
+ return direction;
49
+ };
50
+ const numbersOf = (value, property) => {
51
+ if (!Array.isArray(value)) {
52
+ throw new InputError(`\`${property}\` must be a list of numbers.`, property);
53
+ }
54
+ return value.map((entry, at) => finiteNumber(entry, `${property}[${at}]`));
55
+ };
56
+ const lineOf = (segment, property) => ({
57
+ kind: "line",
58
+ start: pointOf(segment["start"], `${property}.start`),
59
+ end: pointOf(segment["end"], `${property}.end`),
60
+ });
61
+ const circleOf = (segment, property) => ({
62
+ kind: "circle",
63
+ center: pointOf(segment["center"], `${property}.center`),
64
+ radius: positiveNumber(segment["radius"], `${property}.radius`),
65
+ normal: directionOf(segment["normal"], `${property}.normal`),
66
+ });
67
+ const arcOf = (segment, property) => {
68
+ const startDegrees = angleWithinTurn(finiteNumber(segment["startAngle"], `${property}.startAngle`), FULL_TURN_DEGREES);
69
+ const endDegrees = angleWithinTurn(finiteNumber(segment["endAngle"], `${property}.endAngle`), FULL_TURN_DEGREES);
70
+ const turn = angleWithinTurn(endDegrees - startDegrees, FULL_TURN_DEGREES);
71
+ return {
72
+ kind: "arc",
73
+ center: pointOf(segment["center"], `${property}.center`),
74
+ radius: positiveNumber(segment["radius"], `${property}.radius`),
75
+ startAngle: radiansOf(startDegrees),
76
+ endAngle: radiansOf(startDegrees + (turn === 0 ? FULL_TURN_DEGREES : turn)),
77
+ startDegrees,
78
+ endDegrees,
79
+ normal: directionOf(segment["normal"], `${property}.normal`),
80
+ };
81
+ };
82
+ const polylineOf = (segment, property) => {
83
+ const given = segment["points"];
84
+ let points = given.map((point, at) => pointOf(point, `${property}.points[${at}]`));
85
+ if (points.length < 2) {
86
+ throw new InputError(`\`${property}.points\` must hold at least 2 points; it holds ${points.length}.`, `${property}.points`);
87
+ }
88
+ let bulges = segment["bulges"] === undefined ? points.map(() => 0) : numbersOf(segment["bulges"], `${property}.bulges`);
89
+ if (bulges.length !== points.length && bulges.length !== points.length - 1) {
90
+ throw new InputError(`\`${property}.bulges\` must hold one bulge per point (${points.length}); it holds ${bulges.length}.`, `${property}.bulges`);
91
+ }
92
+ bulges = points.map((_, at) => { var _a; return (_a = bulges[at]) !== null && _a !== void 0 ? _a : 0; });
93
+ let closed = segment["closed"] === true;
94
+ if (points.length > 2 && distance3(points[0], points[points.length - 1]) <= SAME_POINT) {
95
+ points = points.slice(0, -1);
96
+ bulges = bulges.slice(0, -1);
97
+ closed = true;
98
+ }
99
+ const planar = points.every(point => point[2] === points[0][2]);
100
+ if (!planar && bulges.some(bulge => bulge !== 0)) {
101
+ throw new InputError(`\`${property}\` has bulges, so its points must share one Z; a 3D polyline takes no bulges.`, `${property}.bulges`);
102
+ }
103
+ return { kind: "polyline", points, bulges, closed, planar };
104
+ };
105
+ const checkedKnots = (knots, pointCount, degree, property) => {
106
+ if (knots.length !== pointCount + degree + 1) {
107
+ throw new InputError(`\`${property}\` must hold ${pointCount + degree + 1} knots (the control points and the degree together, plus 1); it holds ${knots.length}.`, property);
108
+ }
109
+ if (knots.some((knot, at) => at > 0 && knot < knots[at - 1])) {
110
+ throw new InputError(`\`${property}\` must never decrease.`, property);
111
+ }
112
+ if (!(knots[degree] < knots[pointCount])) {
113
+ throw new InputError(`\`${property}\` gives the curve no length: knot ${degree} must be below knot ${pointCount}.`, property);
114
+ }
115
+ let run = 0;
116
+ for (let at = degree + 1; at < pointCount; at++) {
117
+ run = knots[at] === knots[at - 1] ? run + 1 : 1;
118
+ if (run > degree && knots[at] > knots[degree] && knots[at] < knots[pointCount]) {
119
+ throw new InputError(`\`${property}\` repeats an inner knot more often than the degree, which breaks the curve apart.`, property);
120
+ }
121
+ }
122
+ return knots;
123
+ };
124
+ const splineOf = (segment, property) => {
125
+ const points = segment["controlPoints"].map((point, at) => pointOf(point, `${property}.controlPoints[${at}]`));
126
+ const degree = segment["degree"] === undefined ? DEFAULT_SPLINE_DEGREE : finiteNumber(segment["degree"], `${property}.degree`);
127
+ if (!Number.isInteger(degree) || degree < 1 || degree > HIGHEST_SPLINE_DEGREE) {
128
+ throw new InputError(`\`${property}.degree\` must be a whole number from 1 to ${HIGHEST_SPLINE_DEGREE}; it is ${degree}.`, `${property}.degree`);
129
+ }
130
+ if (points.length <= degree) {
131
+ throw new InputError(`\`${property}.controlPoints\` must hold more points than the degree (${degree}); it holds ${points.length}.`, `${property}.controlPoints`);
132
+ }
133
+ const weights = segment["weights"] === undefined ? points.map(() => 1) : numbersOf(segment["weights"], `${property}.weights`);
134
+ if (weights.length !== points.length || weights.some(weight => weight < LEAST_WEIGHT)) {
135
+ throw new InputError(`\`${property}.weights\` must hold one weight of at least ${LEAST_WEIGHT} per control point (${points.length}).`, `${property}.weights`);
136
+ }
137
+ const overweight = points.findIndex((point, at) => point.some(coordinate => !isDrawable(coordinate * weights[at])));
138
+ if (overweight >= 0) {
139
+ throw new InputError(`\`${property}.weights[${overweight}]\` scales its control point to ${LARGEST_NUMBER} or more, past what a curve can be drawn from.`, `${property}.weights`);
140
+ }
141
+ let form;
142
+ if (segment["knots"] !== undefined) {
143
+ form = { degree, points, weights, knots: checkedKnots(numbersOf(segment["knots"], `${property}.knots`), points.length, degree, `${property}.knots`) };
144
+ }
145
+ else if (segment["closed"] === true) {
146
+ form = periodicUniformForm(points, weights, degree);
147
+ }
148
+ else {
149
+ form = { degree, points, weights, knots: clampedUniformKnots(points.length, degree) };
150
+ }
151
+ return { kind: "spline", curve: clampedForm(form) };
152
+ };
153
+ const ellipseOf = (segment, property) => {
154
+ const majorAxis = pointOf(segment["majorAxis"], `${property}.majorAxis`);
155
+ const majorDirection = unitOf(majorAxis);
156
+ if (majorDirection === undefined) {
157
+ throw new InputError(`\`${property}.majorAxis\` must not be a zero vector.`, `${property}.majorAxis`);
158
+ }
159
+ const ratio = positiveNumber(segment["ratio"], `${property}.ratio`);
160
+ if (ratio > 1) {
161
+ throw new InputError(`\`${property}.ratio\` must be at most 1, the minor axis being the shorter; it is ${ratio}.`, `${property}.ratio`);
162
+ }
163
+ const normal = directionOf(segment["normal"], `${property}.normal`);
164
+ if (Math.abs(dot3(normal, majorDirection)) > PERPENDICULAR_COSINE) {
165
+ throw new InputError(`\`${property}.majorAxis\` must lie in the ellipse's plane, perpendicular to its normal.`, `${property}.majorAxis`);
166
+ }
167
+ const start = segment["startParameter"] === undefined ? 0 : angleWithinTurn(finiteNumber(segment["startParameter"], `${property}.startParameter`), 2 * Math.PI);
168
+ const end = segment["endParameter"] === undefined ? 2 * Math.PI : finiteNumber(segment["endParameter"], `${property}.endParameter`);
169
+ const turn = angleWithinTurn(end - start, 2 * Math.PI);
170
+ return {
171
+ kind: "ellipse",
172
+ center: pointOf(segment["center"], `${property}.center`),
173
+ majorAxis,
174
+ ratio,
175
+ start,
176
+ end: start + (turn === 0 ? 2 * Math.PI : turn),
177
+ normal,
178
+ };
179
+ };
180
+ export const segmentKindOf = (segment) => {
181
+ if (!isRecord(segment)) {
182
+ return undefined;
183
+ }
184
+ if (segment["majorAxis"] !== undefined) {
185
+ return "ellipse";
186
+ }
187
+ if (segment["center"] !== undefined && (segment["startAngle"] !== undefined || segment["endAngle"] !== undefined)) {
188
+ return "arc";
189
+ }
190
+ if (segment["center"] !== undefined && segment["radius"] !== undefined) {
191
+ return "circle";
192
+ }
193
+ if (segment["start"] !== undefined && segment["end"] !== undefined) {
194
+ return "line";
195
+ }
196
+ if (Array.isArray(segment["points"])) {
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);
204
+ }
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);
220
+ }
221
+ };
222
+ const layerOf = (value, property) => {
223
+ const layer = typeof value === "string" ? value.trim() : "";
224
+ if (layer === "") {
225
+ return DEFAULT_LAYER;
226
+ }
227
+ if (layer.length > DXF_MAX_NAME_LENGTH) {
228
+ throw new InputError(`\`${property}\` is ${layer.length} characters long; a layer name holds at most ${DXF_MAX_NAME_LENGTH}.`, property);
229
+ }
230
+ if (FORBIDDEN_LAYER_CHARACTERS.test(layer) || [...layer].some(character => character.charCodeAt(0) < FIRST_PRINTABLE_CODE)) {
231
+ throw new InputError(`\`${property}\` "${layer}" holds a character layer names may not: < > / \\ " : ; ? * | = \` or a control character.`, property);
232
+ }
233
+ return layer;
234
+ };
235
+ const colorOf = (value, property) => {
236
+ const channels = typeof value === "string" && value.startsWith("#") ? hexChannels(value) : undefined;
237
+ if (channels === undefined) {
238
+ throw new InputError(`\`${property}\` must be a hex color such as #ff0000.`, property);
239
+ }
240
+ return hexOfChannels(channels);
241
+ };
242
+ const lineTypeOf = (value, property) => {
243
+ if (value === undefined) {
244
+ return Inputs.IO.lineTypeEnum.continuous;
245
+ }
246
+ if (typeof value !== "string" || !LINE_TYPES.has(value)) {
247
+ throw new InputError(`\`${property}\` must be one of ${[...LINE_TYPES].join(", ")}.`, property);
248
+ }
249
+ return value;
250
+ };
251
+ export const drawingPathOf = (path, property) => {
252
+ if (typeof path !== "object" || path === null || !Array.isArray(path.segments)) {
253
+ throw new InputError(`\`${property}.segments\` must be a list of segments.`, `${property}.segments`);
254
+ }
255
+ return { segments: path.segments.map((segment, at) => segmentOf(segment, `${property}.segments[${at}]`)) };
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
+ };
315
+ export const drawingPartsOf = (parts, property) => {
316
+ if (!Array.isArray(parts)) {
317
+ throw new InputError(`\`${property}\` must be a list of path parts.`, property);
318
+ }
319
+ return parts.map((part, at) => {
320
+ var _a, _b;
321
+ const where = `${property}[${at}]`;
322
+ if (!isRecord(part) || !Array.isArray(part["paths"])) {
323
+ throw new InputError(`\`${where}.paths\` must be a list of paths.`, `${where}.paths`);
324
+ }
325
+ const paths = part["paths"];
326
+ return {
327
+ layer: layerOf((_a = part["layer"]) !== null && _a !== void 0 ? _a : DEFAULT_LAYER, `${where}.layer`),
328
+ color: colorOf((_b = part["color"]) !== null && _b !== void 0 ? _b : "#000000", `${where}.color`),
329
+ lineType: lineTypeOf(part["lineType"], `${where}.lineType`),
330
+ lineWeight: part["lineWeight"] === undefined || part["lineWeight"] === null ? undefined : positiveNumber(part["lineWeight"], `${where}.lineWeight`),
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}]`)),
334
+ };
335
+ });
336
+ };
@@ -0,0 +1,2 @@
1
+ import * as Inputs from "../../../../inputs";
2
+ export declare const scaledDrawingParts: (parts: readonly unknown[] | undefined, factor: unknown, property: string) => Inputs.IO.DrawingPartDto[];
@@ -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)));
@@ -0,0 +1,117 @@
1
+ import type * as Inputs from "../../../../inputs";
2
+ import type { NurbsCurveForm } from "../../curves/nurbs-forms";
3
+ import type { HatchFamilyTurn } from "./drawing.constants";
4
+ type Point3 = Inputs.Base.Point3;
5
+ type Vec3 = Inputs.Base.Vector3;
6
+ export interface DrawingLine {
7
+ readonly kind: "line";
8
+ readonly start: Point3;
9
+ readonly end: Point3;
10
+ }
11
+ export interface DrawingCircle {
12
+ readonly kind: "circle";
13
+ readonly center: Point3;
14
+ readonly radius: number;
15
+ readonly normal: Vec3;
16
+ }
17
+ export interface DrawingArc {
18
+ readonly kind: "arc";
19
+ readonly center: Point3;
20
+ readonly radius: number;
21
+ readonly startAngle: number;
22
+ readonly endAngle: number;
23
+ readonly startDegrees: number;
24
+ readonly endDegrees: number;
25
+ readonly normal: Vec3;
26
+ }
27
+ export interface DrawingPolyline {
28
+ readonly kind: "polyline";
29
+ readonly points: readonly Point3[];
30
+ readonly bulges: readonly number[];
31
+ readonly closed: boolean;
32
+ readonly planar: boolean;
33
+ }
34
+ export interface DrawingEllipse {
35
+ readonly kind: "ellipse";
36
+ readonly center: Point3;
37
+ readonly majorAxis: Vec3;
38
+ readonly ratio: number;
39
+ readonly start: number;
40
+ readonly end: number;
41
+ readonly normal: Vec3;
42
+ }
43
+ export interface DrawingSpline {
44
+ readonly kind: "spline";
45
+ readonly curve: NurbsCurveForm;
46
+ }
47
+ export type DrawingSegment = DrawingLine | DrawingCircle | DrawingArc | DrawingPolyline | DrawingEllipse | DrawingSpline;
48
+ export interface DrawingPath {
49
+ readonly segments: readonly DrawingSegment[];
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
+ }
79
+ export interface DrawingPart {
80
+ readonly layer: string;
81
+ readonly color: string;
82
+ readonly lineType: Inputs.IO.lineTypeEnum;
83
+ readonly lineWeight: number | undefined;
84
+ readonly paths: readonly DrawingPath[];
85
+ readonly texts: readonly DrawingText[];
86
+ readonly hatches: readonly DrawingHatch[];
87
+ }
88
+ export interface DrawingBounds {
89
+ readonly min: Point3;
90
+ readonly max: Point3;
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
+ }
117
+ export {};
@@ -0,0 +1,41 @@
1
+ export declare const SAME_POINT = 1e-10;
2
+ export declare const PERPENDICULAR_COSINE = 1e-9;
3
+ export declare const FULL_TURN_DEGREES = 360;
4
+ export declare const QUARTER_TURN_DEGREES = 90;
5
+ export declare const ARBITRARY_AXIS_LIMIT: number;
6
+ export declare const FORBIDDEN_LAYER_CHARACTERS: RegExp;
7
+ export declare const FIRST_PRINTABLE_CODE = 32;
8
+ export declare const DEFAULT_LAYER = "0";
9
+ export declare const POINT_SIZES: number[];
10
+ export declare const DEFAULT_SPLINE_DEGREE = 3;
11
+ export declare const HIGHEST_SPLINE_DEGREE = 25;
12
+ export declare const LARGEST_NUMBER = 1e+100;
13
+ export declare const LEAST_WEIGHT = 1e-100;
14
+ export declare const PATTERN_UNIT_SHARE: number;
15
+ export declare const LEAST_TOLERANCE_SHARE = 0.000001;
16
+ export declare const PLAN_AXES = 2;
17
+ export declare const SPACE_AXES = 3;
18
+ export declare const WRITER_WORK_PER_NUMBER: number;
19
+ export declare const WRITER_WORK_FLOOR: number;
20
+ export declare const WRITER_WORK_CEILING: number;
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>;
34
+ export declare const NUMBERS_PER_VERTEX = 4;
35
+ export declare const NUMBERS_PER_CURVE: Readonly<Record<"line" | "circle" | "arc" | "ellipse", number>>;
36
+ export interface LineTypePattern {
37
+ readonly name: string;
38
+ readonly description: string;
39
+ readonly elements: readonly number[];
40
+ }
41
+ export declare const LINE_TYPE_PATTERNS: Readonly<Record<string, LineTypePattern>>;
@@ -0,0 +1,46 @@
1
+ export const SAME_POINT = 1e-10;
2
+ export const PERPENDICULAR_COSINE = 1e-9;
3
+ export const FULL_TURN_DEGREES = 360;
4
+ export const QUARTER_TURN_DEGREES = 90;
5
+ export const ARBITRARY_AXIS_LIMIT = 1 / 64;
6
+ export const FORBIDDEN_LAYER_CHARACTERS = /[<>/\\":;?*|=`]/;
7
+ export const FIRST_PRINTABLE_CODE = 32;
8
+ export const DEFAULT_LAYER = "0";
9
+ export const POINT_SIZES = [2, 3];
10
+ export const DEFAULT_SPLINE_DEGREE = 3;
11
+ export const HIGHEST_SPLINE_DEGREE = 25;
12
+ export const LARGEST_NUMBER = 1e100;
13
+ export const LEAST_WEIGHT = 1e-100;
14
+ export const PATTERN_UNIT_SHARE = 1 / 200;
15
+ export const LEAST_TOLERANCE_SHARE = 1e-6;
16
+ export const PLAN_AXES = 2;
17
+ export const SPACE_AXES = 3;
18
+ export const WRITER_WORK_PER_NUMBER = Math.pow(2, 14);
19
+ export const WRITER_WORK_FLOOR = Math.pow(2, 20);
20
+ export const WRITER_WORK_CEILING = Math.pow(2, 25);
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));
38
+ export const NUMBERS_PER_VERTEX = 4;
39
+ export const NUMBERS_PER_CURVE = { line: 6, circle: 7, arc: 9, ellipse: 12 };
40
+ export const LINE_TYPE_PATTERNS = {
41
+ continuous: { name: "CONTINUOUS", description: "Solid line", elements: [] },
42
+ dashed: { name: "DASHED", description: "Dashed __ __ __ __", elements: [4, -2] },
43
+ hidden: { name: "HIDDEN", description: "Hidden _ _ _ _ _ _", elements: [2, -1] },
44
+ center: { name: "CENTER", description: "Center ____ _ ____ _", elements: [8, -1.5, 1.5, -1.5] },
45
+ dotted: { name: "DOT", description: "Dot . . . . . . .", elements: [0, -1] },
46
+ };
@@ -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;