@bitbybit-dev/base 1.5.0 → 1.6.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 (314) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/bearings/ansi-bearings.constants.d.ts +2 -0
  3. package/lib/api/bearings/ansi-bearings.constants.js +26 -0
  4. package/lib/api/bearings/ansi-bearings.d.ts +4 -0
  5. package/lib/api/bearings/ansi-bearings.js +14 -0
  6. package/lib/api/bearings/bearing-types.d.ts +25 -0
  7. package/lib/api/bearings/bearing-types.js +1 -0
  8. package/lib/api/bearings/bearings.constants.d.ts +1 -0
  9. package/lib/api/bearings/bearings.constants.js +1 -0
  10. package/lib/api/bearings/iso-bearings.constants.d.ts +2 -0
  11. package/lib/api/bearings/iso-bearings.constants.js +30 -0
  12. package/lib/api/bearings/iso-bearings.d.ts +4 -0
  13. package/lib/api/bearings/iso-bearings.js +14 -0
  14. package/lib/api/color-space.d.ts +2 -0
  15. package/lib/api/color-space.js +5 -8
  16. package/lib/api/fasteners/ansi-fasteners.constants.d.ts +16 -0
  17. package/lib/api/fasteners/ansi-fasteners.constants.js +118 -0
  18. package/lib/api/fasteners/ansi-fasteners.d.ts +8 -0
  19. package/lib/api/fasteners/ansi-fasteners.js +64 -0
  20. package/lib/api/fasteners/fastener-types.d.ts +161 -0
  21. package/lib/api/fasteners/fastener-types.js +1 -0
  22. package/lib/api/fasteners/fasteners.constants.d.ts +5 -0
  23. package/lib/api/fasteners/fasteners.constants.js +5 -0
  24. package/lib/api/fasteners/fasteners.d.ts +2 -0
  25. package/lib/api/fasteners/fasteners.js +9 -0
  26. package/lib/api/fasteners/iso-fasteners.constants.d.ts +23 -0
  27. package/lib/api/fasteners/iso-fasteners.constants.js +110 -0
  28. package/lib/api/fasteners/iso-fasteners.d.ts +9 -0
  29. package/lib/api/fasteners/iso-fasteners.js +61 -0
  30. package/lib/api/gears/bevel-gears.d.ts +6 -0
  31. package/lib/api/gears/bevel-gears.js +69 -0
  32. package/lib/api/gears/gear-checks.d.ts +8 -0
  33. package/lib/api/gears/gear-checks.js +69 -0
  34. package/lib/api/gears/gear-pairs.d.ts +4 -0
  35. package/lib/api/gears/gear-pairs.js +140 -0
  36. package/lib/api/gears/gear-types.d.ts +425 -0
  37. package/lib/api/gears/gear-types.js +1 -0
  38. package/lib/api/gears/gears.constants.d.ts +19 -0
  39. package/lib/api/gears/gears.constants.js +19 -0
  40. package/lib/api/gears/gears.d.ts +10 -0
  41. package/lib/api/gears/gears.js +156 -0
  42. package/lib/api/gears/helical-gears.d.ts +5 -0
  43. package/lib/api/gears/helical-gears.js +33 -0
  44. package/lib/api/gears/involute-flank.d.ts +26 -0
  45. package/lib/api/gears/involute-flank.js +158 -0
  46. package/lib/api/gears/racks.d.ts +3 -0
  47. package/lib/api/gears/racks.js +64 -0
  48. package/lib/api/index.d.ts +10 -1
  49. package/lib/api/index.js +0 -1
  50. package/lib/api/inputs/base-inputs.d.ts +450 -3
  51. package/lib/api/inputs/base-inputs.js +12 -0
  52. package/lib/api/inputs/color-inputs.d.ts +14 -0
  53. package/lib/api/inputs/color-inputs.js +19 -0
  54. package/lib/api/inputs/engineering-inputs.d.ts +1539 -0
  55. package/lib/api/inputs/engineering-inputs.js +2181 -0
  56. package/lib/api/inputs/index.d.ts +2 -0
  57. package/lib/api/inputs/index.js +2 -0
  58. package/lib/api/inputs/io-inputs.d.ts +8 -1
  59. package/lib/api/inputs/io-inputs.js +4 -1
  60. package/lib/api/inputs/math-inputs.d.ts +61 -0
  61. package/lib/api/inputs/math-inputs.js +85 -0
  62. package/lib/api/inputs/mesh-inputs.d.ts +170 -0
  63. package/lib/api/inputs/mesh-inputs.js +206 -0
  64. package/lib/api/inputs/point-inputs.d.ts +4 -4
  65. package/lib/api/inputs/polyline-inputs.d.ts +144 -0
  66. package/lib/api/inputs/polyline-inputs.js +151 -0
  67. package/lib/api/inputs/recipes-inputs.d.ts +76 -0
  68. package/lib/api/inputs/recipes-inputs.js +74 -0
  69. package/lib/api/inputs/transforms-inputs.d.ts +34 -0
  70. package/lib/api/inputs/transforms-inputs.js +35 -0
  71. package/lib/api/keys/ansi-keys.constants.d.ts +3 -0
  72. package/lib/api/keys/ansi-keys.constants.js +16 -0
  73. package/lib/api/keys/ansi-keys.d.ts +3 -0
  74. package/lib/api/keys/ansi-keys.js +14 -0
  75. package/lib/api/keys/din-keys.constants.d.ts +3 -0
  76. package/lib/api/keys/din-keys.constants.js +14 -0
  77. package/lib/api/keys/din-keys.d.ts +3 -0
  78. package/lib/api/keys/din-keys.js +13 -0
  79. package/lib/api/keys/key-types.d.ts +17 -0
  80. package/lib/api/keys/key-types.js +1 -0
  81. package/lib/api/keys/keys.constants.d.ts +1 -0
  82. package/lib/api/keys/keys.constants.js +1 -0
  83. package/lib/api/knurls/ansi-knurls.constants.d.ts +4 -0
  84. package/lib/api/knurls/ansi-knurls.constants.js +8 -0
  85. package/lib/api/knurls/ansi-knurls.d.ts +3 -0
  86. package/lib/api/knurls/ansi-knurls.js +20 -0
  87. package/lib/api/knurls/din-knurls.constants.d.ts +2 -0
  88. package/lib/api/knurls/din-knurls.constants.js +2 -0
  89. package/lib/api/knurls/din-knurls.d.ts +3 -0
  90. package/lib/api/knurls/din-knurls.js +19 -0
  91. package/lib/api/knurls/knurl-types.d.ts +24 -0
  92. package/lib/api/knurls/knurl-types.js +1 -0
  93. package/lib/api/knurls/knurls.constants.d.ts +1 -0
  94. package/lib/api/knurls/knurls.constants.js +1 -0
  95. package/lib/api/knurls/knurls.d.ts +2 -0
  96. package/lib/api/knurls/knurls.js +9 -0
  97. package/lib/api/recipes/checks.d.ts +15 -0
  98. package/lib/api/recipes/checks.js +85 -0
  99. package/lib/api/recipes/limits.constants.d.ts +4 -0
  100. package/lib/api/recipes/limits.constants.js +4 -0
  101. package/lib/api/recipes/sources.d.ts +0 -13
  102. package/lib/api/recipes/sources.js +3 -15
  103. package/lib/api/recipes/surface-mesh.d.ts +0 -14
  104. package/lib/api/recipes/surface-mesh.js +8 -21
  105. package/lib/api/recipes/validate-brep.d.ts +2 -0
  106. package/lib/api/recipes/validate-brep.js +330 -0
  107. package/lib/api/recipes/validate.d.ts +0 -31
  108. package/lib/api/recipes/validate.js +7 -115
  109. package/lib/api/resolved-inputs/index.d.ts +80 -0
  110. package/lib/api/retaining-rings/ansi-retaining-rings.constants.d.ts +4 -0
  111. package/lib/api/retaining-rings/ansi-retaining-rings.constants.js +93 -0
  112. package/lib/api/retaining-rings/ansi-retaining-rings.d.ts +4 -0
  113. package/lib/api/retaining-rings/ansi-retaining-rings.js +20 -0
  114. package/lib/api/retaining-rings/din-retaining-rings.constants.d.ts +3 -0
  115. package/lib/api/retaining-rings/din-retaining-rings.constants.js +115 -0
  116. package/lib/api/retaining-rings/din-retaining-rings.d.ts +4 -0
  117. package/lib/api/retaining-rings/din-retaining-rings.js +20 -0
  118. package/lib/api/retaining-rings/retaining-ring-types.d.ts +30 -0
  119. package/lib/api/retaining-rings/retaining-ring-types.js +1 -0
  120. package/lib/api/retaining-rings/retaining-rings.constants.d.ts +1 -0
  121. package/lib/api/retaining-rings/retaining-rings.constants.js +1 -0
  122. package/lib/api/retaining-rings/retaining-rings.d.ts +2 -0
  123. package/lib/api/retaining-rings/retaining-rings.js +9 -0
  124. package/lib/api/services/base-bitbybit.d.ts +42 -0
  125. package/lib/api/services/base-bitbybit.js +43 -0
  126. package/lib/api/services/color.d.ts +35 -2
  127. package/lib/api/services/color.js +48 -12
  128. package/lib/api/services/engineering/engineering.d.ts +12 -0
  129. package/lib/api/services/engineering/engineering.js +13 -0
  130. package/lib/api/services/engineering/index.d.ts +2 -0
  131. package/lib/api/services/engineering/index.js +2 -0
  132. package/lib/api/services/engineering/mechanical/bearings-ansi.d.ts +40 -0
  133. package/lib/api/services/engineering/mechanical/bearings-ansi.js +47 -0
  134. package/lib/api/services/engineering/mechanical/bearings-iso.d.ts +39 -0
  135. package/lib/api/services/engineering/mechanical/bearings-iso.js +46 -0
  136. package/lib/api/services/engineering/mechanical/bearings.d.ts +14 -0
  137. package/lib/api/services/engineering/mechanical/bearings.js +15 -0
  138. package/lib/api/services/engineering/mechanical/fasteners-ansi.d.ts +109 -0
  139. package/lib/api/services/engineering/mechanical/fasteners-ansi.js +133 -0
  140. package/lib/api/services/engineering/mechanical/fasteners-iso.d.ts +123 -0
  141. package/lib/api/services/engineering/mechanical/fasteners-iso.js +151 -0
  142. package/lib/api/services/engineering/mechanical/fasteners.d.ts +13 -0
  143. package/lib/api/services/engineering/mechanical/fasteners.js +14 -0
  144. package/lib/api/services/engineering/mechanical/gears.d.ts +267 -0
  145. package/lib/api/services/engineering/mechanical/gears.js +318 -0
  146. package/lib/api/services/engineering/mechanical/index.d.ts +24 -0
  147. package/lib/api/services/engineering/mechanical/index.js +24 -0
  148. package/lib/api/services/engineering/mechanical/keys-ansi.d.ts +27 -0
  149. package/lib/api/services/engineering/mechanical/keys-ansi.js +32 -0
  150. package/lib/api/services/engineering/mechanical/keys-din.d.ts +26 -0
  151. package/lib/api/services/engineering/mechanical/keys-din.js +31 -0
  152. package/lib/api/services/engineering/mechanical/keys.d.ts +14 -0
  153. package/lib/api/services/engineering/mechanical/keys.js +15 -0
  154. package/lib/api/services/engineering/mechanical/knurls-ansi.d.ts +26 -0
  155. package/lib/api/services/engineering/mechanical/knurls-ansi.js +31 -0
  156. package/lib/api/services/engineering/mechanical/knurls-din.d.ts +26 -0
  157. package/lib/api/services/engineering/mechanical/knurls-din.js +31 -0
  158. package/lib/api/services/engineering/mechanical/knurls.d.ts +14 -0
  159. package/lib/api/services/engineering/mechanical/knurls.js +15 -0
  160. package/lib/api/services/engineering/mechanical/mechanical.d.ts +29 -0
  161. package/lib/api/services/engineering/mechanical/mechanical.js +30 -0
  162. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.d.ts +43 -0
  163. package/lib/api/services/engineering/mechanical/retaining-rings-ansi.js +51 -0
  164. package/lib/api/services/engineering/mechanical/retaining-rings-din.d.ts +43 -0
  165. package/lib/api/services/engineering/mechanical/retaining-rings-din.js +51 -0
  166. package/lib/api/services/engineering/mechanical/retaining-rings.d.ts +13 -0
  167. package/lib/api/services/engineering/mechanical/retaining-rings.js +14 -0
  168. package/lib/api/services/engineering/mechanical/splines-ansi.d.ts +27 -0
  169. package/lib/api/services/engineering/mechanical/splines-ansi.js +32 -0
  170. package/lib/api/services/engineering/mechanical/splines-din.d.ts +26 -0
  171. package/lib/api/services/engineering/mechanical/splines-din.js +31 -0
  172. package/lib/api/services/engineering/mechanical/splines.d.ts +13 -0
  173. package/lib/api/services/engineering/mechanical/splines.js +14 -0
  174. package/lib/api/services/engineering/mechanical/springs.d.ts +27 -0
  175. package/lib/api/services/engineering/mechanical/springs.js +31 -0
  176. package/lib/api/services/engineering/mechanical/threads-ansi.d.ts +40 -0
  177. package/lib/api/services/engineering/mechanical/threads-ansi.js +48 -0
  178. package/lib/api/services/engineering/mechanical/threads-iso.d.ts +40 -0
  179. package/lib/api/services/engineering/mechanical/threads-iso.js +48 -0
  180. package/lib/api/services/engineering/mechanical/threads.d.ts +13 -0
  181. package/lib/api/services/engineering/mechanical/threads.js +14 -0
  182. package/lib/api/services/frame.js +3 -3
  183. package/lib/api/services/geometry-helper.js +8 -111
  184. package/lib/api/services/helpers/color/color-space.d.ts +2 -0
  185. package/lib/api/services/helpers/color/color-space.js +12 -0
  186. package/lib/api/services/helpers/{nurbs.d.ts → curves/nurbs.d.ts} +1 -1
  187. package/lib/api/services/helpers/{surface-triangulation.d.ts → curves/surface-triangulation.d.ts} +2 -2
  188. package/lib/api/services/helpers/{surface-triangulation.js → curves/surface-triangulation.js} +14 -8
  189. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.d.ts +2 -1
  190. package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.js +19 -5
  191. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +4 -0
  192. package/lib/api/services/helpers/files/dxf/dxf.constants.js +4 -0
  193. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.d.ts +1 -1
  194. package/lib/api/services/helpers/{dxf → files/dxf}/dxf.js +2 -2
  195. package/lib/api/services/helpers/files/glb.constants.d.ts +11 -0
  196. package/lib/api/services/helpers/files/glb.constants.js +11 -0
  197. package/lib/api/services/helpers/files/glb.d.ts +1 -0
  198. package/lib/api/services/helpers/files/glb.js +69 -0
  199. package/lib/api/services/helpers/files/gzip.constants.d.ts +11 -0
  200. package/lib/api/services/helpers/files/gzip.constants.js +11 -0
  201. package/lib/api/services/helpers/files/gzip.d.ts +2 -0
  202. package/lib/api/services/helpers/files/gzip.js +50 -0
  203. package/lib/api/services/helpers/{inflate.constants.d.ts → files/inflate.constants.d.ts} +2 -0
  204. package/lib/api/services/helpers/{inflate.constants.js → files/inflate.constants.js} +2 -0
  205. package/lib/api/services/helpers/{inflate.d.ts → files/inflate.d.ts} +2 -2
  206. package/lib/api/services/helpers/{inflate.js → files/inflate.js} +16 -7
  207. package/lib/api/services/helpers/{zip.constants.d.ts → files/zip.constants.d.ts} +8 -0
  208. package/lib/api/services/helpers/{zip.constants.js → files/zip.constants.js} +8 -0
  209. package/lib/api/services/helpers/files/zip.d.ts +8 -0
  210. package/lib/api/services/helpers/files/zip.js +226 -0
  211. package/lib/api/services/helpers/geometry/arcs.d.ts +9 -0
  212. package/lib/api/services/helpers/{arcs.js → geometry/arcs.js} +7 -0
  213. package/lib/api/services/helpers/{frame-axes.d.ts → geometry/frame-axes.d.ts} +8 -5
  214. package/lib/api/services/helpers/{frame-axes.js → geometry/frame-axes.js} +21 -9
  215. package/lib/api/services/helpers/geometry/lengths.constants.d.ts +4 -0
  216. package/lib/api/services/helpers/geometry/lengths.constants.js +3 -0
  217. package/lib/api/services/helpers/geometry/lengths.d.ts +7 -0
  218. package/lib/api/services/helpers/geometry/lengths.js +20 -0
  219. package/lib/api/services/helpers/geometry/matrices.constants.d.ts +8 -0
  220. package/lib/api/services/helpers/geometry/matrices.constants.js +7 -0
  221. package/lib/api/services/helpers/geometry/matrices.d.ts +17 -0
  222. package/lib/api/services/helpers/{matrices.js → geometry/matrices.js} +28 -17
  223. package/lib/api/services/helpers/{paths.d.ts → geometry/paths.d.ts} +2 -1
  224. package/lib/api/services/helpers/{paths.js → geometry/paths.js} +36 -30
  225. package/lib/api/services/helpers/{polygons.d.ts → geometry/polygons.d.ts} +1 -1
  226. package/lib/api/services/helpers/geometry/polygons.js +111 -0
  227. package/lib/api/services/helpers/geometry/scalars.d.ts +9 -0
  228. package/lib/api/services/helpers/geometry/scalars.js +34 -0
  229. package/lib/api/services/helpers/{triangulation.js → geometry/triangulation.js} +11 -6
  230. package/lib/api/services/helpers/geometry/vector-grid.d.ts +12 -0
  231. package/lib/api/services/helpers/geometry/vector-grid.js +149 -0
  232. package/lib/api/services/helpers/{vectors.d.ts → geometry/vectors.d.ts} +8 -1
  233. package/lib/api/services/helpers/geometry/vectors.js +43 -0
  234. package/lib/api/services/helpers/helper-types.d.ts +77 -0
  235. package/lib/api/services/helpers/mesh/mesh-normals.d.ts +21 -0
  236. package/lib/api/services/helpers/{mesh-normals.js → mesh/mesh-normals.js} +54 -65
  237. package/lib/api/services/helpers/mesh/mesh-orientation.d.ts +24 -0
  238. package/lib/api/services/helpers/mesh/mesh-orientation.js +104 -0
  239. package/lib/api/services/helpers/{mesh-primitives.d.ts → mesh/mesh-primitives.d.ts} +1 -1
  240. package/lib/api/services/helpers/{mesh-primitives.js → mesh/mesh-primitives.js} +6 -5
  241. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +7 -0
  242. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +11 -0
  243. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +11 -0
  244. package/lib/api/services/helpers/mesh/mesh-proximity.js +382 -0
  245. package/lib/api/services/index.d.ts +3 -0
  246. package/lib/api/services/index.js +3 -0
  247. package/lib/api/services/io.d.ts +1 -1
  248. package/lib/api/services/io.js +1 -1
  249. package/lib/api/services/line.js +2 -3
  250. package/lib/api/services/math.d.ts +47 -0
  251. package/lib/api/services/math.js +77 -10
  252. package/lib/api/services/mesh.d.ts +174 -2
  253. package/lib/api/services/mesh.js +305 -7
  254. package/lib/api/services/point.js +4 -10
  255. package/lib/api/services/polyline-types.d.ts +6 -0
  256. package/lib/api/services/polyline-types.js +1 -0
  257. package/lib/api/services/polyline.d.ts +163 -1
  258. package/lib/api/services/polyline.js +270 -13
  259. package/lib/api/services/recipes.d.ts +80 -0
  260. package/lib/api/services/recipes.js +107 -0
  261. package/lib/api/services/transforms.d.ts +74 -2
  262. package/lib/api/services/transforms.js +100 -3
  263. package/lib/api/services/vector.d.ts +4 -3
  264. package/lib/api/services/vector.js +14 -14
  265. package/lib/api/splines/ansi-splines.constants.d.ts +9 -0
  266. package/lib/api/splines/ansi-splines.constants.js +9 -0
  267. package/lib/api/splines/ansi-splines.d.ts +3 -0
  268. package/lib/api/splines/ansi-splines.js +28 -0
  269. package/lib/api/splines/din-splines.constants.d.ts +12 -0
  270. package/lib/api/splines/din-splines.constants.js +12 -0
  271. package/lib/api/splines/din-splines.d.ts +3 -0
  272. package/lib/api/splines/din-splines.js +38 -0
  273. package/lib/api/splines/spline-types.d.ts +32 -0
  274. package/lib/api/splines/spline-types.js +1 -0
  275. package/lib/api/splines/splines.constants.d.ts +1 -0
  276. package/lib/api/splines/splines.constants.js +1 -0
  277. package/lib/api/springs/spring-types.d.ts +26 -0
  278. package/lib/api/springs/spring-types.js +1 -0
  279. package/lib/api/springs/springs.constants.d.ts +9 -0
  280. package/lib/api/springs/springs.constants.js +9 -0
  281. package/lib/api/springs/springs.d.ts +2 -0
  282. package/lib/api/springs/springs.js +50 -0
  283. package/lib/api/threads/ansi-threads.constants.d.ts +6 -0
  284. package/lib/api/threads/ansi-threads.constants.js +27 -0
  285. package/lib/api/threads/ansi-threads.d.ts +4 -0
  286. package/lib/api/threads/ansi-threads.js +50 -0
  287. package/lib/api/threads/iso-threads.constants.d.ts +5 -0
  288. package/lib/api/threads/iso-threads.constants.js +20 -0
  289. package/lib/api/threads/iso-threads.d.ts +4 -0
  290. package/lib/api/threads/iso-threads.js +32 -0
  291. package/lib/api/threads/thread-profile.constants.d.ts +3 -0
  292. package/lib/api/threads/thread-profile.constants.js +3 -0
  293. package/lib/api/threads/thread-types.d.ts +66 -0
  294. package/lib/api/threads/thread-types.js +1 -0
  295. package/package.json +1 -1
  296. package/lib/api/recipes/index.d.ts +0 -4
  297. package/lib/api/recipes/index.js +0 -3
  298. package/lib/api/services/helpers/arcs.d.ts +0 -6
  299. package/lib/api/services/helpers/matrices.constants.d.ts +0 -2
  300. package/lib/api/services/helpers/matrices.constants.js +0 -2
  301. package/lib/api/services/helpers/matrices.d.ts +0 -25
  302. package/lib/api/services/helpers/mesh-normals.d.ts +0 -11
  303. package/lib/api/services/helpers/polygons.js +0 -59
  304. package/lib/api/services/helpers/vectors.js +0 -17
  305. package/lib/api/services/helpers/zip.d.ts +0 -4
  306. package/lib/api/services/helpers/zip.js +0 -89
  307. /package/lib/api/services/helpers/{nurbs.js → curves/nurbs.js} +0 -0
  308. /package/lib/api/services/helpers/{crc32.d.ts → files/crc32.d.ts} +0 -0
  309. /package/lib/api/services/helpers/{crc32.js → files/crc32.js} +0 -0
  310. /package/lib/api/services/helpers/{triangulation.d.ts → geometry/triangulation.d.ts} +0 -0
  311. /package/lib/api/services/helpers/{mesh-measures.d.ts → mesh/mesh-measures.d.ts} +0 -0
  312. /package/lib/api/services/helpers/{mesh-measures.js → mesh/mesh-measures.js} +0 -0
  313. /package/lib/api/services/helpers/{mesh-primitives.constants.d.ts → mesh/mesh-primitives.constants.d.ts} +0 -0
  314. /package/lib/api/services/helpers/{mesh-primitives.constants.js → mesh/mesh-primitives.constants.js} +0 -0
@@ -0,0 +1,20 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { lengthsConverted, snappedLength, tableLength } from "../services/helpers/geometry/lengths";
4
+ import { ANSI_KNURL_HELIX_ANGLE, ANSI_KNURL_PITCHES, ANSI_KNURLS } from "./ansi-knurls.constants";
5
+ import { checkedKnurlPattern } from "./knurls";
6
+ import { KNURL_LENGTHS } from "./knurls.constants";
7
+ export function ansiKnurlSizes(diameter, diametralPitch, pattern, unit) {
8
+ checkedKnurlPattern(pattern);
9
+ if (!ANSI_KNURL_PITCHES.includes(diametralPitch)) {
10
+ throw new InputError(`\`diametralPitch\` is ${String(diametralPitch)}, not one of ASME B94.6's: ${ANSI_KNURL_PITCHES.join(", ")}.`, "diametralPitch");
11
+ }
12
+ const row = ANSI_KNURLS[diametralPitch];
13
+ const inches = tableLength(diameter, unit, "in");
14
+ const grooves = Math.round(diametralPitch * inches);
15
+ if (!(grooves >= row.leastTeeth)) {
16
+ throw new InputError(`\`diameter\` is too small for a ${String(diametralPitch)} pitch knurl, which needs ${String(row.leastTeeth)} teeth round the work: make it at least ${String(snappedLength(row.leastTeeth / diametralPitch, "in", unit))}.`, "diameter");
17
+ }
18
+ const sizes = { grooves, diameter: roundedToMillionths(grooves / diametralPitch), depth: row.depth, helixAngle: pattern === "straight" ? 0 : ANSI_KNURL_HELIX_ANGLE };
19
+ return lengthsConverted(sizes, KNURL_LENGTHS, "in", unit);
20
+ }
@@ -0,0 +1,2 @@
1
+ export declare const KNURL_HELIX_ANGLE = 30;
2
+ export declare const KNURL_PITCHES: readonly number[];
@@ -0,0 +1,2 @@
1
+ export const KNURL_HELIX_ANGLE = 30;
2
+ export const KNURL_PITCHES = [0.5, 0.6, 0.8, 1, 1.2, 1.6];
@@ -0,0 +1,3 @@
1
+ import type { Base } from "../inputs/base-inputs";
2
+ import type { KnurlPattern, KnurlSizes } from "./knurl-types";
3
+ export declare function dinKnurlSizes(diameter: number, pitch: number, pattern: KnurlPattern, unit: `${Base.unitOfLengthEnum}`): KnurlSizes;
@@ -0,0 +1,19 @@
1
+ import { InputError } from "../kernel-calls/errors";
2
+ import { roundedToMillionths } from "../services/helpers/geometry/scalars";
3
+ import { lengthsConverted, snappedLength, tableLength } from "../services/helpers/geometry/lengths";
4
+ import { KNURL_HELIX_ANGLE, KNURL_PITCHES } from "./din-knurls.constants";
5
+ import { checkedKnurlPattern } from "./knurls";
6
+ import { KNURL_LENGTHS } from "./knurls.constants";
7
+ export function dinKnurlSizes(diameter, pitch, pattern, unit) {
8
+ checkedKnurlPattern(pattern);
9
+ if (!KNURL_PITCHES.includes(pitch)) {
10
+ throw new InputError(`\`pitch\` is ${String(pitch)}, not one of DIN 82's: ${KNURL_PITCHES.join(", ")}.`, "pitch");
11
+ }
12
+ const millimetres = tableLength(diameter, unit, "mm");
13
+ if (!(millimetres > 2 * pitch)) {
14
+ throw new InputError(`\`diameter\` is too small for a knurl of pitch ${String(pitch)}: make it more than ${String(snappedLength(2 * pitch, "mm", unit))}.`, "diameter");
15
+ }
16
+ const grooves = Math.round(Math.PI * millimetres / pitch);
17
+ const sizes = { grooves, diameter: roundedToMillionths(grooves * pitch / Math.PI), depth: pitch / 2, helixAngle: pattern === "straight" ? 0 : KNURL_HELIX_ANGLE };
18
+ return lengthsConverted(sizes, KNURL_LENGTHS, "mm", unit);
19
+ }
@@ -0,0 +1,24 @@
1
+ import type * as Inputs from "../inputs";
2
+ /**
3
+ * The pattern of a knurl: straight grooves along the axis, helical grooves turning left or right,
4
+ * or both crossing in a diamond.
5
+ */
6
+ export type KnurlPattern = `${Inputs.Engineering.knurlPatternEnum}`;
7
+ /**
8
+ * A knurl's grooves on a cylinder, from `knurls.din.knurlSizes` or `knurls.ansi.knurlSizes`, in the
9
+ * unit asked for.
10
+ */
11
+ export interface KnurlSizes {
12
+ /** How many grooves run round the cylinder, in each direction a diamond has. */
13
+ readonly grooves: number;
14
+ /** The diameter the grooves divide evenly, nearest the one asked for. */
15
+ readonly diameter: number;
16
+ /** How deep the grooves are. */
17
+ readonly depth: number;
18
+ /** The grooves' angle to the axis, in degrees: 0 for straight, 30 for the others. */
19
+ readonly helixAngle: number;
20
+ }
21
+ export interface AnsiKnurlRow {
22
+ readonly depth: number;
23
+ readonly leastTeeth: number;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const KNURL_LENGTHS: readonly ["diameter", "depth"];
@@ -0,0 +1 @@
1
+ export const KNURL_LENGTHS = ["diameter", "depth"];
@@ -0,0 +1,2 @@
1
+ import type { KnurlPattern } from "./knurl-types";
2
+ export declare function checkedKnurlPattern(pattern: KnurlPattern): KnurlPattern;
@@ -0,0 +1,9 @@
1
+ import * as Inputs from "../inputs";
2
+ import { InputError } from "../kernel-calls/errors";
3
+ const PATTERNS = Object.values(Inputs.Engineering.knurlPatternEnum);
4
+ export function checkedKnurlPattern(pattern) {
5
+ if (!PATTERNS.includes(pattern)) {
6
+ throw new InputError(`\`pattern\` is not one of ${PATTERNS.join(", ")}.`, "pattern");
7
+ }
8
+ return pattern;
9
+ }
@@ -0,0 +1,15 @@
1
+ import type { Base } from "../inputs/base-inputs";
2
+ import type { Checker, Kind } from "./checker-types";
3
+ import type { RecipeIssue } from "./recipe-types";
4
+ export declare const COORDINATE_RANGE = "from -1000000000 to 1000000000";
5
+ export declare function report(issues: RecipeIssue[], path: string, message: string): void;
6
+ export declare function isCoordinate(value: unknown, limit?: number): value is number;
7
+ export declare function coordinates(value: unknown, size: number, limit?: number): value is number[];
8
+ export declare function isCount(value: unknown): value is number;
9
+ export declare function isIndexBelow(value: unknown, count: number): value is number;
10
+ export declare function positive(issues: RecipeIssue[], value: unknown, path: string): void;
11
+ export declare function extent(issues: RecipeIssue[], value: unknown, path: string): void;
12
+ export declare function vector(issues: RecipeIssue[], value: unknown, path: string, nonZero: boolean): void;
13
+ export declare function range(checker: Checker, value: unknown, length: number, multiple: number, minimum: number, path: string): Base.RecipeRange | undefined;
14
+ export declare function reference(checker: Checker, value: unknown, at: number, accepted: readonly Kind[], path: string): number;
15
+ export declare function references(checker: Checker, value: unknown, at: number, accepted: readonly Kind[], path: string, allowEmpty: boolean): number;
@@ -0,0 +1,85 @@
1
+ import { MAX_ISSUES, MAX_RECIPE_COORDINATE, POINT3_SIZE } from "./limits.constants";
2
+ export const COORDINATE_RANGE = `from -${MAX_RECIPE_COORDINATE} to ${MAX_RECIPE_COORDINATE}`;
3
+ export function report(issues, path, message) {
4
+ if (issues.length < MAX_ISSUES) {
5
+ issues.push({ path, message });
6
+ }
7
+ }
8
+ export function isCoordinate(value, limit = MAX_RECIPE_COORDINATE) {
9
+ return typeof value === "number" && Math.abs(value) <= limit;
10
+ }
11
+ export function coordinates(value, size, limit = MAX_RECIPE_COORDINATE) {
12
+ if (!Array.isArray(value) || value.length !== size) {
13
+ return false;
14
+ }
15
+ for (let index = 0; index < size; index++) {
16
+ if (!isCoordinate(value[index], limit)) {
17
+ return false;
18
+ }
19
+ }
20
+ return true;
21
+ }
22
+ export function isCount(value) {
23
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
24
+ }
25
+ export function isIndexBelow(value, count) {
26
+ return isCount(value) && value < count;
27
+ }
28
+ export function positive(issues, value, path) {
29
+ if (typeof value !== "number" || !Number.isFinite(value) || !(value > 0)) {
30
+ report(issues, path, "must be a finite number above zero");
31
+ }
32
+ }
33
+ export function extent(issues, value, path) {
34
+ if (!isCoordinate(value) || !(value > 0)) {
35
+ report(issues, path, `must be a number above zero and at most ${MAX_RECIPE_COORDINATE}`);
36
+ }
37
+ }
38
+ export function vector(issues, value, path, nonZero) {
39
+ if (!coordinates(value, POINT3_SIZE)) {
40
+ report(issues, path, `must be three numbers, each ${COORDINATE_RANGE}`);
41
+ }
42
+ else if (nonZero && value.every((item) => item === 0)) {
43
+ report(issues, path, "must not be a zero vector");
44
+ }
45
+ }
46
+ export function range(checker, value, length, multiple, minimum, path) {
47
+ if (!Array.isArray(value) || value.length !== 2 || !isCount(value[0]) || !isCount(value[1])) {
48
+ report(checker.issues, path, "must be a range of two whole numbers, a start and a count");
49
+ return undefined;
50
+ }
51
+ const checked = value;
52
+ const [start, count] = checked;
53
+ if (start + count > length) {
54
+ report(checker.issues, path, `runs past the end of its buffer, which holds ${length} numbers`);
55
+ return undefined;
56
+ }
57
+ if (count % multiple !== 0 || count < minimum) {
58
+ report(checker.issues, path, `must hold a multiple of ${multiple} numbers, at least ${minimum}`);
59
+ return undefined;
60
+ }
61
+ checker.referenced += count;
62
+ return checked;
63
+ }
64
+ export function reference(checker, value, at, accepted, path) {
65
+ if (!isIndexBelow(value, at)) {
66
+ report(checker.issues, path, at === 0 ? "must be the index of an earlier node, and none comes before it" : `must be the index of an earlier node, from 0 to ${at - 1}`);
67
+ return 0;
68
+ }
69
+ const kind = checker.kinds[value];
70
+ if (kind !== undefined && !accepted.includes(kind)) {
71
+ report(checker.issues, path, `refers to a ${kind} node where ${accepted.join(" or ")} is needed`);
72
+ }
73
+ return checker.depths[value];
74
+ }
75
+ export function references(checker, value, at, accepted, path, allowEmpty) {
76
+ if (!Array.isArray(value) || (!allowEmpty && value.length === 0)) {
77
+ report(checker.issues, path, allowEmpty ? "must be a list of node indices" : "must be a list of at least one node index");
78
+ return 0;
79
+ }
80
+ let deepest = 0;
81
+ for (let index = 0; index < value.length; index++) {
82
+ deepest = Math.max(deepest, reference(checker, value[index], at, accepted, `${path}[${index}]`));
83
+ }
84
+ return deepest;
85
+ }
@@ -21,3 +21,7 @@ export declare const MAX_ISSUES = 100;
21
21
  export declare const INT32_LOWEST: number;
22
22
  export declare const INT32_HIGHEST: number;
23
23
  export declare const ISSUES_IN_MESSAGE = 3;
24
+ export declare const MAX_BREP_DEGREE = 25;
25
+ export declare const MAX_BREP_ITEMS = 10000000;
26
+ export declare const PARALLEL_SINE = 1e-9;
27
+ export declare const QUARTER_TURN: number;
@@ -21,3 +21,7 @@ export const MAX_ISSUES = 100;
21
21
  export const INT32_LOWEST = -(Math.pow(2, 31));
22
22
  export const INT32_HIGHEST = Math.pow(2, 31) - 1;
23
23
  export const ISSUES_IN_MESSAGE = 3;
24
+ export const MAX_BREP_DEGREE = 25;
25
+ export const MAX_BREP_ITEMS = 10000000;
26
+ export const PARALLEL_SINE = 1e-9;
27
+ export const QUARTER_TURN = Math.PI / 2;
@@ -1,16 +1,3 @@
1
1
  import type { Base } from "../inputs/base-inputs";
2
2
  import type { RecipeSource } from "./recipe-types";
3
- /**
4
- * The step a recipe node places, found by folding every transform step that only turns and moves
5
- * into the matrix that places it, so roots that place one step through different moves share it.
6
- *
7
- * A transform that mirrors, scales or stretches stays a step of its own.
8
- *
9
- * Experimental: the recipe format may still change before it is declared stable.
10
- * @param recipe - The recipe the node belongs to, already checked
11
- * @param node - The node to follow, such as a root's
12
- * @param matrix - What places the node, such as its root's matrix
13
- * @returns The step reached and the matrix placing it
14
- * @beta
15
- */
16
3
  export declare function recipeSourceOf(recipe: Base.Recipe, node: number, matrix: Base.TransformMatrix): RecipeSource;
@@ -1,21 +1,9 @@
1
- import { followedBy, isRigidMatrix } from "../services/helpers/matrices";
2
- /**
3
- * The step a recipe node places, found by folding every transform step that only turns and moves
4
- * into the matrix that places it, so roots that place one step through different moves share it.
5
- *
6
- * A transform that mirrors, scales or stretches stays a step of its own.
7
- *
8
- * Experimental: the recipe format may still change before it is declared stable.
9
- * @param recipe - The recipe the node belongs to, already checked
10
- * @param node - The node to follow, such as a root's
11
- * @param matrix - What places the node, such as its root's matrix
12
- * @returns The step reached and the matrix placing it
13
- * @beta
14
- */
1
+ import { followedBy, isRigidMatrix, isTransformMatrix } from "../services/helpers/geometry/matrices";
2
+ import { isIndexBelow } from "./checks";
15
3
  export function recipeSourceOf(recipe, node, matrix) {
16
4
  let source = node;
17
5
  let placed = matrix;
18
- for (let step = recipe.nodes[source]; (step === null || step === void 0 ? void 0 : step.op) === "transform" && isRigidMatrix(step.matrix); step = recipe.nodes[source]) {
6
+ for (let step = recipe.nodes[source]; (step === null || step === void 0 ? void 0 : step.op) === "transform" && isTransformMatrix(step.matrix) && isRigidMatrix(step.matrix) && isIndexBelow(step.of, source); step = recipe.nodes[source]) {
19
7
  placed = followedBy(step.matrix, placed);
20
8
  source = step.of;
21
9
  }
@@ -1,16 +1,2 @@
1
1
  import type { RecipeSurfaceMesh } from "./recipe-types";
2
- /**
3
- * The triangle meshes a recipe's roots describe, for the roots built from triangle nodes alone
4
- * (through transforms, compounds and unions), placed by their matrices; no kernel is needed. Openings cut
5
- * through such a mesh are left uncut, since a surface has no inside to cut. A root that holds any
6
- * other step, such as an extrusion or a cut, gives undefined. This is how an open mesh no solid
7
- * kernel accepts, such as a building model's furniture surfaces, can still be drawn.
8
- *
9
- * Experimental: the recipe format may still change before it is declared stable.
10
- * @param recipe - The recipe, checked as `assertRecipe` checks it
11
- * @param roots - The positions of the roots to read, all of them when left out
12
- * @param adjustZtoY - Whether `(x, y, z)` becomes `(x, z, -y)`, as a recipe build does with the same option
13
- * @returns One mesh per asked root, in the order asked, or undefined where the root is not made of triangles alone
14
- * @beta
15
- */
16
2
  export declare function recipeSurfaceMeshes(value: unknown, roots?: readonly number[], adjustZtoY?: boolean): (RecipeSurfaceMesh | undefined)[];
@@ -1,13 +1,12 @@
1
1
  import { InputError } from "../kernel-calls/errors";
2
- import { followedBy, linearDeterminant } from "../services/helpers/matrices";
2
+ import { followedBy, linearDeterminant, movedCoordinate } from "../services/helpers/geometry/matrices";
3
3
  import { POINT3_SIZE, TRIANGLE_CORNERS } from "./limits.constants";
4
4
  import { toRecipe } from "./validate";
5
+ import { isIndexBelow } from "./checks";
5
6
  const Z_TO_Y = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1];
6
7
  const X = 0;
7
8
  const Y = 1;
8
9
  const Z = 2;
9
- const COLUMN = 4;
10
- const TRANSLATION = 12;
11
10
  function collectPieces(nodes, index, matrix, pieces) {
12
11
  const node = nodes[index];
13
12
  switch (node.op) {
@@ -21,6 +20,8 @@ function collectPieces(nodes, index, matrix, pieces) {
21
20
  return node.of.every((child) => collectPieces(nodes, child, matrix, pieces));
22
21
  case "voids":
23
22
  return collectPieces(nodes, node.host, matrix, pieces);
23
+ case "brep":
24
+ return node.fallback !== undefined && collectPieces(nodes, node.fallback, matrix, pieces);
24
25
  default:
25
26
  return false;
26
27
  }
@@ -39,9 +40,9 @@ function meshOfPieces(buffers, pieces) {
39
40
  const x = buffers.f64[at + X];
40
41
  const y = buffers.f64[at + Y];
41
42
  const z = buffers.f64[at + Z];
42
- positions[vertexAt * POINT3_SIZE + X] = m[X] * x + m[COLUMN + X] * y + m[2 * COLUMN + X] * z + m[TRANSLATION + X];
43
- positions[vertexAt * POINT3_SIZE + Y] = m[Y] * x + m[COLUMN + Y] * y + m[2 * COLUMN + Y] * z + m[TRANSLATION + Y];
44
- positions[vertexAt * POINT3_SIZE + Z] = m[Z] * x + m[COLUMN + Z] * y + m[2 * COLUMN + Z] * z + m[TRANSLATION + Z];
43
+ positions[vertexAt * POINT3_SIZE + X] = movedCoordinate(m, x, y, z, X);
44
+ positions[vertexAt * POINT3_SIZE + Y] = movedCoordinate(m, x, y, z, Y);
45
+ positions[vertexAt * POINT3_SIZE + Z] = movedCoordinate(m, x, y, z, Z);
45
46
  vertexAt++;
46
47
  }
47
48
  const first = vertexAt - length / POINT3_SIZE;
@@ -56,24 +57,10 @@ function meshOfPieces(buffers, pieces) {
56
57
  }
57
58
  return { positions, indices };
58
59
  }
59
- /**
60
- * The triangle meshes a recipe's roots describe, for the roots built from triangle nodes alone
61
- * (through transforms, compounds and unions), placed by their matrices; no kernel is needed. Openings cut
62
- * through such a mesh are left uncut, since a surface has no inside to cut. A root that holds any
63
- * other step, such as an extrusion or a cut, gives undefined. This is how an open mesh no solid
64
- * kernel accepts, such as a building model's furniture surfaces, can still be drawn.
65
- *
66
- * Experimental: the recipe format may still change before it is declared stable.
67
- * @param recipe - The recipe, checked as `assertRecipe` checks it
68
- * @param roots - The positions of the roots to read, all of them when left out
69
- * @param adjustZtoY - Whether `(x, y, z)` becomes `(x, z, -y)`, as a recipe build does with the same option
70
- * @returns One mesh per asked root, in the order asked, or undefined where the root is not made of triangles alone
71
- * @beta
72
- */
73
60
  export function recipeSurfaceMeshes(value, roots, adjustZtoY = false) {
74
61
  const recipe = toRecipe(value);
75
62
  const asked = roots !== null && roots !== void 0 ? roots : recipe.roots.map((_, index) => index);
76
- const bad = asked.find((index) => !Number.isSafeInteger(index) || index < 0 || index >= recipe.roots.length);
63
+ const bad = asked.find((index) => !isIndexBelow(index, recipe.roots.length));
77
64
  if (bad !== undefined) {
78
65
  throw new InputError(`Root ${bad} is not one of the recipe's ${recipe.roots.length} roots`, "roots");
79
66
  }
@@ -0,0 +1,2 @@
1
+ import type { Checker } from "./checker-types";
2
+ export declare function checkBrep(checker: Checker, node: Record<string, unknown>, at: number, path: string): number;