brepjs 12.8.2 → 12.9.1

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 (225) hide show
  1. package/dist/2d/lib/svgPath.d.ts.map +1 -1
  2. package/dist/2d/lib/vectorOperations.d.ts +4 -1
  3. package/dist/2d/lib/vectorOperations.d.ts.map +1 -1
  4. package/dist/2d.cjs +2 -2
  5. package/dist/2d.js +5 -5
  6. package/dist/{Blueprint-DbVaf6k7.js → Blueprint-1HGbugaC.js} +33 -63
  7. package/dist/{Blueprint-CQ28WJhz.cjs → Blueprint-CUyXM6CV.cjs} +15 -45
  8. package/dist/{boolean2D-0blbVtJ8.cjs → boolean2D-9OnbotKT.cjs} +9 -9
  9. package/dist/{boolean2D-y3E92F0u.js → boolean2D-CR4efa35.js} +11 -11
  10. package/dist/{booleanFns-gmsX3Cv2.cjs → booleanFns-BBd2oTvv.cjs} +43 -40
  11. package/dist/{booleanFns-BCTjYZAg.js → booleanFns-Br2KdGJq.js} +53 -50
  12. package/dist/brepjs.cjs +379 -284
  13. package/dist/brepjs.js +1437 -1341
  14. package/dist/core/definitionMaps.d.ts +2 -7
  15. package/dist/core/definitionMaps.d.ts.map +1 -1
  16. package/dist/core/dimensionTypes.d.ts +52 -0
  17. package/dist/core/dimensionTypes.d.ts.map +1 -0
  18. package/dist/core/disposal.d.ts +18 -0
  19. package/dist/core/disposal.d.ts.map +1 -1
  20. package/dist/core/errors.d.ts +1 -8
  21. package/dist/core/errors.d.ts.map +1 -1
  22. package/dist/core/kernelErrorTranslation.d.ts +15 -0
  23. package/dist/core/kernelErrorTranslation.d.ts.map +1 -0
  24. package/dist/core/planeOps.d.ts +14 -0
  25. package/dist/core/planeOps.d.ts.map +1 -1
  26. package/dist/core/result.d.ts +4 -0
  27. package/dist/core/result.d.ts.map +1 -1
  28. package/dist/core/shapeTypes.d.ts +14 -146
  29. package/dist/core/shapeTypes.d.ts.map +1 -1
  30. package/dist/core/typeDiscriminants.d.ts +14 -0
  31. package/dist/core/typeDiscriminants.d.ts.map +1 -0
  32. package/dist/core/validityTypes.d.ts +100 -0
  33. package/dist/core/validityTypes.d.ts.map +1 -0
  34. package/dist/core.cjs +52 -11
  35. package/dist/core.d.ts +1 -1
  36. package/dist/core.d.ts.map +1 -1
  37. package/dist/core.js +118 -75
  38. package/dist/{curveFns-mROFhiuG.js → curveFns-1u0oZ0u0.js} +14 -14
  39. package/dist/{curveFns-BZngcnQ1.cjs → curveFns-BwLvO_Ia.cjs} +2 -2
  40. package/dist/{drawFns-Bwakrq7w.js → drawFns-B0na6sbo.js} +16 -16
  41. package/dist/{drawFns-CjRc1NfQ.cjs → drawFns-CzlEePor.cjs} +18 -18
  42. package/dist/{faceFns-DB1Fc5gy.cjs → faceFns-BAKkZG6D.cjs} +2 -2
  43. package/dist/{faceFns-B8GnxjdY.js → faceFns-DGMp47Os.js} +3 -3
  44. package/dist/{helpers-C8NoT0Wu.cjs → helpers-DVdscQxW.cjs} +73 -8
  45. package/dist/{helpers-X0juxnwj.js → helpers-sJjnIXDA.js} +85 -20
  46. package/dist/index.d.ts +10 -11
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/io.cjs +4 -4
  49. package/dist/io.js +4 -4
  50. package/dist/kernel/brepkit/booleanOps.d.ts +23 -0
  51. package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -0
  52. package/dist/kernel/brepkit/constructionOps.d.ts +51 -0
  53. package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -0
  54. package/dist/kernel/brepkit/evolutionOps.d.ts +31 -0
  55. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -0
  56. package/dist/kernel/brepkit/geometryOps.d.ts +56 -0
  57. package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -0
  58. package/dist/kernel/brepkit/helpers.d.ts +84 -0
  59. package/dist/kernel/brepkit/helpers.d.ts.map +1 -0
  60. package/dist/kernel/brepkit/internalOps.d.ts +28 -0
  61. package/dist/kernel/brepkit/internalOps.d.ts.map +1 -0
  62. package/dist/kernel/brepkit/ioOps.d.ts +43 -0
  63. package/dist/kernel/brepkit/ioOps.d.ts.map +1 -0
  64. package/dist/kernel/brepkit/measureOps.d.ts +30 -0
  65. package/dist/kernel/brepkit/measureOps.d.ts.map +1 -0
  66. package/dist/kernel/brepkit/meshOps.d.ts +7 -0
  67. package/dist/kernel/brepkit/meshOps.d.ts.map +1 -0
  68. package/dist/kernel/brepkit/modifierOps.d.ts +15 -0
  69. package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -0
  70. package/dist/kernel/brepkit/repairOps.d.ts +14 -0
  71. package/dist/kernel/brepkit/repairOps.d.ts.map +1 -0
  72. package/dist/kernel/brepkit/sweepOps.d.ts +27 -0
  73. package/dist/kernel/brepkit/sweepOps.d.ts.map +1 -0
  74. package/dist/kernel/brepkit/topologyOps.d.ts +16 -0
  75. package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -0
  76. package/dist/kernel/brepkit/transformOps.d.ts +14 -0
  77. package/dist/kernel/brepkit/transformOps.d.ts.map +1 -0
  78. package/dist/kernel/brepkitAdapter.d.ts +1 -1
  79. package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
  80. package/dist/kernel/brepkitWasmTypes.d.ts +8 -0
  81. package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
  82. package/dist/kernel/defaultAdapter.d.ts.map +1 -1
  83. package/dist/kernel/extendedConstructorOps.d.ts +9 -1
  84. package/dist/kernel/extendedConstructorOps.d.ts.map +1 -1
  85. package/dist/kernel/index.d.ts +1 -0
  86. package/dist/kernel/index.d.ts.map +1 -1
  87. package/dist/kernel/interfaces/boolean-ops.d.ts +25 -0
  88. package/dist/kernel/interfaces/boolean-ops.d.ts.map +1 -0
  89. package/dist/kernel/interfaces/construction-ops.d.ts +76 -0
  90. package/dist/kernel/interfaces/construction-ops.d.ts.map +1 -0
  91. package/dist/kernel/interfaces/core.d.ts +45 -0
  92. package/dist/kernel/interfaces/core.d.ts.map +1 -0
  93. package/dist/kernel/interfaces/evolution-ops.d.ts +19 -0
  94. package/dist/kernel/interfaces/evolution-ops.d.ts.map +1 -0
  95. package/dist/kernel/interfaces/geometry-ops.d.ts +77 -0
  96. package/dist/kernel/interfaces/geometry-ops.d.ts.map +1 -0
  97. package/dist/kernel/interfaces/index.d.ts +29 -0
  98. package/dist/kernel/interfaces/index.d.ts.map +1 -0
  99. package/dist/kernel/interfaces/io-ops.d.ts +66 -0
  100. package/dist/kernel/interfaces/io-ops.d.ts.map +1 -0
  101. package/dist/kernel/interfaces/measure-ops.d.ts +35 -0
  102. package/dist/kernel/interfaces/measure-ops.d.ts.map +1 -0
  103. package/dist/kernel/interfaces/mesh-ops.d.ts +21 -0
  104. package/dist/kernel/interfaces/mesh-ops.d.ts.map +1 -0
  105. package/dist/kernel/interfaces/modifier-ops.d.ts +22 -0
  106. package/dist/kernel/interfaces/modifier-ops.d.ts.map +1 -0
  107. package/dist/kernel/interfaces/repair-ops.d.ts +36 -0
  108. package/dist/kernel/interfaces/repair-ops.d.ts.map +1 -0
  109. package/dist/kernel/interfaces/sweep-ops.d.ts +49 -0
  110. package/dist/kernel/interfaces/sweep-ops.d.ts.map +1 -0
  111. package/dist/kernel/interfaces/topology-ops.d.ts +30 -0
  112. package/dist/kernel/interfaces/topology-ops.d.ts.map +1 -0
  113. package/dist/kernel/interfaces/transform-ops.d.ts +20 -0
  114. package/dist/kernel/interfaces/transform-ops.d.ts.map +1 -0
  115. package/dist/kernel/modifierOps.d.ts +2 -2
  116. package/dist/kernel/modifierOps.d.ts.map +1 -1
  117. package/dist/kernel/types.d.ts +2 -446
  118. package/dist/kernel/types.d.ts.map +1 -1
  119. package/dist/{loft-hp3pc1M7.cjs → loft-BNvBZzqe.cjs} +5 -5
  120. package/dist/{loft-Bhw-FMoL.js → loft-D0aCZRaB.js} +7 -7
  121. package/dist/measurement/measureFns.d.ts +2 -2
  122. package/dist/measurement/measureFns.d.ts.map +1 -1
  123. package/dist/{measurement-D8EJ694A.js → measurement-C7o5jE6G.js} +2 -2
  124. package/dist/{measurement-BoNTUBAp.cjs → measurement-DZcaxo1A.cjs} +2 -2
  125. package/dist/measurement.cjs +1 -1
  126. package/dist/measurement.js +1 -1
  127. package/dist/{meshFns-BnV0ZR8w.cjs → meshFns-7dgZgNYK.cjs} +4 -4
  128. package/dist/{meshFns-nQjK38EC.js → meshFns-CtUl9fGY.js} +3 -3
  129. package/dist/operations/compoundOpsFns.d.ts +38 -0
  130. package/dist/operations/compoundOpsFns.d.ts.map +1 -0
  131. package/dist/operations/extrude.d.ts +2 -12
  132. package/dist/operations/extrude.d.ts.map +1 -1
  133. package/dist/operations/extrudeFns.d.ts +2 -93
  134. package/dist/operations/extrudeFns.d.ts.map +1 -1
  135. package/dist/operations/guidedSweepFns.d.ts +3 -22
  136. package/dist/operations/guidedSweepFns.d.ts.map +1 -1
  137. package/dist/operations/loft.d.ts +2 -16
  138. package/dist/operations/loft.d.ts.map +1 -1
  139. package/dist/operations/multiSweepFns.d.ts +3 -29
  140. package/dist/operations/multiSweepFns.d.ts.map +1 -1
  141. package/dist/operations/roofFns.d.ts +2 -2
  142. package/dist/operations/roofFns.d.ts.map +1 -1
  143. package/dist/operations/sweepFns.d.ts +121 -0
  144. package/dist/operations/sweepFns.d.ts.map +1 -0
  145. package/dist/{operations-BfbkK6DU.js → operations-DisJ5F8s.js} +110 -57
  146. package/dist/{operations-CYpmLSC4.cjs → operations-DwZ-RBO1.cjs} +97 -44
  147. package/dist/operations.cjs +2 -2
  148. package/dist/operations.js +14 -14
  149. package/dist/originTrackingFns-NJ1dWoiF.js +137 -0
  150. package/dist/originTrackingFns-dhaCe8Yb.cjs +136 -0
  151. package/dist/query/edgeFinder.d.ts +4 -14
  152. package/dist/query/edgeFinder.d.ts.map +1 -1
  153. package/dist/query/faceFinder.d.ts +4 -14
  154. package/dist/query/faceFinder.d.ts.map +1 -1
  155. package/dist/query/finderCore.d.ts +6 -0
  156. package/dist/query/finderCore.d.ts.map +1 -1
  157. package/dist/query/shapeFinders.d.ts +32 -0
  158. package/dist/query/shapeFinders.d.ts.map +1 -0
  159. package/dist/query/wireFinder.d.ts +4 -9
  160. package/dist/query/wireFinder.d.ts.map +1 -1
  161. package/dist/query.cjs +54 -32
  162. package/dist/query.js +56 -34
  163. package/dist/{result-fAX0OZzI.cjs → result-DJAAj1yb.cjs} +8 -59
  164. package/dist/{result-BaSD1fqR.js → result-DtuwWSUD.js} +38 -89
  165. package/dist/result.cjs +1 -1
  166. package/dist/result.js +22 -22
  167. package/dist/shapeFns-BJbua5kT.js +34 -0
  168. package/dist/shapeFns-w9tWELHX.cjs +33 -0
  169. package/dist/{shapeTypes-CpSaBLDv.js → shapeTypes-CAEAyk8j.js} +233 -172
  170. package/dist/{shapeTypes-7xEam9Ri.cjs → shapeTypes-owrg2MNK.cjs} +421 -360
  171. package/dist/sketching/Sketcher.d.ts.map +1 -1
  172. package/dist/sketching.cjs +2 -2
  173. package/dist/sketching.js +2 -2
  174. package/dist/{solidBuilders-994_MQwB.cjs → solidBuilders-BLQ4I6Ig.cjs} +3 -3
  175. package/dist/{solidBuilders-DmwhTCCd.js → solidBuilders-BS-1220W.js} +3 -3
  176. package/dist/{surfaceBuilders-nQdJ56fe.js → surfaceBuilders-Dj6AjhOv.js} +7 -7
  177. package/dist/{surfaceBuilders-5VA34a3_.cjs → surfaceBuilders-KU_7OD2q.cjs} +3 -3
  178. package/dist/topology/booleanFns.d.ts.map +1 -1
  179. package/dist/topology/compoundOpsFns.d.ts +3 -35
  180. package/dist/topology/compoundOpsFns.d.ts.map +1 -1
  181. package/dist/topology/index.d.ts +0 -1
  182. package/dist/topology/index.d.ts.map +1 -1
  183. package/dist/topology/metadataPropagation.d.ts +30 -0
  184. package/dist/topology/metadataPropagation.d.ts.map +1 -0
  185. package/dist/topology/modifierFns.d.ts.map +1 -1
  186. package/dist/topology/originTrackingFns.d.ts +23 -0
  187. package/dist/topology/originTrackingFns.d.ts.map +1 -0
  188. package/dist/topology/shapeFns.d.ts +6 -120
  189. package/dist/topology/shapeFns.d.ts.map +1 -1
  190. package/dist/topology/topologyQueryFns.d.ts +67 -0
  191. package/dist/topology/topologyQueryFns.d.ts.map +1 -0
  192. package/dist/topology/transformFns.d.ts +49 -0
  193. package/dist/topology/transformFns.d.ts.map +1 -0
  194. package/dist/topology/wrapperFns.d.ts.map +1 -1
  195. package/dist/{topology-ANwCzGL8.cjs → topology-CyPHYYjV.cjs} +205 -20
  196. package/dist/{topology-C7x98OVn.js → topology-D6LeuhI_.js} +235 -50
  197. package/dist/topology.cjs +18 -17
  198. package/dist/topology.js +92 -91
  199. package/dist/topologyQueryFns-De439iBP.js +119 -0
  200. package/dist/topologyQueryFns-fz5kz5e1.cjs +118 -0
  201. package/dist/{types-CWDdqcrq.js → types-CcKqsmd0.js} +2 -2
  202. package/dist/utils/precisionRound.d.ts +4 -0
  203. package/dist/utils/precisionRound.d.ts.map +1 -1
  204. package/dist/utils/vec2d.d.ts +5 -0
  205. package/dist/utils/vec2d.d.ts.map +1 -1
  206. package/dist/{vecOps-ZDdZWbwT.js → vecOps-LTN--A58.js} +15 -15
  207. package/dist/{vectors-D_IiZx0q.cjs → vectors-C8N_QeEX.cjs} +9 -1
  208. package/dist/{vectors-Bx8wkNui.js → vectors-DTREgnVp.js} +15 -7
  209. package/dist/vectors.cjs +1 -1
  210. package/dist/vectors.js +23 -23
  211. package/package.json +3 -3
  212. package/dist/core/geometryHelpers.d.ts +0 -30
  213. package/dist/core/geometryHelpers.d.ts.map +0 -1
  214. package/dist/core/memory.d.ts +0 -6
  215. package/dist/core/memory.d.ts.map +0 -1
  216. package/dist/core/typeErrors.d.ts +0 -17
  217. package/dist/core/typeErrors.d.ts.map +0 -1
  218. package/dist/cornerFinder-Ckz-mPHE.js +0 -59
  219. package/dist/cornerFinder-ZmOyOOsh.cjs +0 -58
  220. package/dist/shapeFns-C2SnNvdH.cjs +0 -468
  221. package/dist/shapeFns-FDuKkrDR.js +0 -469
  222. package/dist/utils/round2.d.ts +0 -3
  223. package/dist/utils/round2.d.ts.map +0 -1
  224. package/dist/utils/round5.d.ts +0 -3
  225. package/dist/utils/round5.d.ts.map +0 -1
@@ -1,469 +0,0 @@
1
- import { B as getKernel, c as castShape, g as getShapeKind } from "./shapeTypes-CpSaBLDv.js";
2
- import { H as HASH_CODE_MAX, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
3
- import { i as iterTopo, d as downcast } from "./faceFns-B8GnxjdY.js";
4
- import { v as unwrap } from "./result-BaSD1fqR.js";
5
- function clone(shape) {
6
- return castShape(unwrap(downcast(shape.wrapped)));
7
- }
8
- function toBREP(shape) {
9
- return getKernel().toBREP(shape.wrapped);
10
- }
11
- function getHashCode(shape) {
12
- return getKernel().hashCode(shape.wrapped, HASH_CODE_MAX);
13
- }
14
- function isEmpty(shape) {
15
- return getKernel().isNull(shape.wrapped);
16
- }
17
- function isSameShape(a, b) {
18
- return getKernel().isSame(a.wrapped, b.wrapped);
19
- }
20
- function isEqualShape(a, b) {
21
- return getKernel().isEqual(a.wrapped, b.wrapped);
22
- }
23
- function simplify(shape) {
24
- return castShape(getKernel().simplify(shape.wrapped));
25
- }
26
- function collectInputFaceHashes(inputs) {
27
- const hashes = [];
28
- for (const input of inputs) {
29
- const origins = getFaceOrigins(input);
30
- if (!origins) continue;
31
- for (const hash of origins.keys()) {
32
- hashes.push(hash);
33
- }
34
- }
35
- return hashes;
36
- }
37
- function translate(shape, v) {
38
- const inputFaceHashes = collectInputFaceHashes([shape]);
39
- const { shape: resultShape, evolution } = getKernel().translateWithHistory(
40
- shape.wrapped,
41
- v[0],
42
- v[1],
43
- v[2],
44
- inputFaceHashes,
45
- HASH_CODE_MAX
46
- );
47
- const result = castShape(resultShape);
48
- propagateOriginsFromEvolution(evolution, [shape], result);
49
- return result;
50
- }
51
- function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
52
- const inputFaceHashes = collectInputFaceHashes([shape]);
53
- const { shape: resultShape, evolution } = getKernel().rotateWithHistory(
54
- shape.wrapped,
55
- angle * DEG2RAD,
56
- inputFaceHashes,
57
- HASH_CODE_MAX,
58
- direction,
59
- position
60
- );
61
- const result = castShape(resultShape);
62
- propagateOriginsFromEvolution(evolution, [shape], result);
63
- return result;
64
- }
65
- function mirror(shape, planeNormal = [0, 1, 0], planeOrigin = [0, 0, 0]) {
66
- const inputFaceHashes = collectInputFaceHashes([shape]);
67
- const { shape: resultShape, evolution } = getKernel().mirrorWithHistory(
68
- shape.wrapped,
69
- planeOrigin,
70
- planeNormal,
71
- inputFaceHashes,
72
- HASH_CODE_MAX
73
- );
74
- const result = castShape(resultShape);
75
- propagateOriginsFromEvolution(evolution, [shape], result);
76
- return result;
77
- }
78
- function scale(shape, factor, center = [0, 0, 0]) {
79
- const inputFaceHashes = collectInputFaceHashes([shape]);
80
- const { shape: resultShape, evolution } = getKernel().scaleWithHistory(
81
- shape.wrapped,
82
- center,
83
- factor,
84
- inputFaceHashes,
85
- HASH_CODE_MAX
86
- );
87
- const result = castShape(resultShape);
88
- propagateOriginsFromEvolution(evolution, [shape], result);
89
- return result;
90
- }
91
- function resize(shape, dimensions, options) {
92
- const bbox = getKernel().boundingBox(shape.wrapped);
93
- const size = [
94
- bbox.max[0] - bbox.min[0],
95
- bbox.max[1] - bbox.min[1],
96
- bbox.max[2] - bbox.min[2]
97
- ];
98
- const auto = options?.auto === true;
99
- function factor(dim, sz, baseFactor) {
100
- if (dim !== void 0 && sz > 1e-12) return dim / sz;
101
- if (dim === void 0 && auto) return baseFactor;
102
- return 1;
103
- }
104
- let autoFactor = 1;
105
- if (auto) {
106
- if (dimensions[0] !== void 0 && size[0] > 1e-12) autoFactor = dimensions[0] / size[0];
107
- else if (dimensions[1] !== void 0 && size[1] > 1e-12) autoFactor = dimensions[1] / size[1];
108
- else if (dimensions[2] !== void 0 && size[2] > 1e-12) autoFactor = dimensions[2] / size[2];
109
- }
110
- const factors = [
111
- factor(dimensions[0], size[0], autoFactor),
112
- factor(dimensions[1], size[1], autoFactor),
113
- factor(dimensions[2], size[2], autoFactor)
114
- ];
115
- const isUniform = Math.abs(factors[0] - factors[1]) < 1e-6 && Math.abs(factors[1] - factors[2]) < 1e-6;
116
- if (!isUniform) {
117
- throw new Error(
118
- "resize: non-uniform scaling is not supported (WASM build lacks BRepBuilderAPI_GTransform). Use auto: true to scale proportionally, or set all three dimensions to achieve uniform scaling."
119
- );
120
- }
121
- return scale(shape, factors[0]);
122
- }
123
- function parseMatrixInput(input) {
124
- if ("linear" in input) {
125
- return { linear: input.linear, translation: input.translation };
126
- }
127
- const [r0, r1, r2, r3] = input;
128
- const TOL = 1e-10;
129
- if (Math.abs(r3[0]) > TOL || Math.abs(r3[1]) > TOL || Math.abs(r3[2]) > TOL || Math.abs(r3[3] - 1) > TOL) {
130
- throw new Error(
131
- `applyMatrix: invalid bottom row [${String(r3[0])}, ${String(r3[1])}, ${String(r3[2])}, ${String(r3[3])}]. Must be [0, 0, 0, 1] for an affine transform.`
132
- );
133
- }
134
- return {
135
- linear: [r0[0], r0[1], r0[2], r1[0], r1[1], r1[2], r2[0], r2[1], r2[2]],
136
- translation: [r0[3], r1[3], r2[3]]
137
- };
138
- }
139
- function det3x3(m) {
140
- return m[0] * (m[4] * m[8] - m[5] * m[7]) - m[1] * (m[3] * m[8] - m[5] * m[6]) + m[2] * (m[3] * m[7] - m[4] * m[6]);
141
- }
142
- function isOrthogonalMatrix(m) {
143
- const TOL = 1e-8;
144
- const d00 = m[0] * m[0] + m[3] * m[3] + m[6] * m[6];
145
- const d11 = m[1] * m[1] + m[4] * m[4] + m[7] * m[7];
146
- const d22 = m[2] * m[2] + m[5] * m[5] + m[8] * m[8];
147
- const d01 = m[0] * m[1] + m[3] * m[4] + m[6] * m[7];
148
- const d02 = m[0] * m[2] + m[3] * m[5] + m[6] * m[8];
149
- const d12 = m[1] * m[2] + m[4] * m[5] + m[7] * m[8];
150
- if (Math.abs(d01) > TOL) return false;
151
- if (Math.abs(d02) > TOL) return false;
152
- if (Math.abs(d12) > TOL) return false;
153
- if (Math.abs(d00 - d11) > TOL) return false;
154
- if (Math.abs(d00 - d22) > TOL) return false;
155
- return true;
156
- }
157
- function applyMatrix(shape, matrix) {
158
- const { linear, translation } = parseMatrixInput(matrix);
159
- const d = det3x3(linear);
160
- if (Math.abs(d) < 1e-12) {
161
- throw new Error(
162
- "applyMatrix: singular matrix (determinant ≈ 0). Cannot apply a non-invertible transform."
163
- );
164
- }
165
- const orthogonal = isOrthogonalMatrix(linear);
166
- if (orthogonal) {
167
- const inputFaceHashes = collectInputFaceHashes([shape]);
168
- const { shape: resultShape2, evolution } = getKernel().generalTransformWithHistory(
169
- shape.wrapped,
170
- linear,
171
- translation,
172
- true,
173
- inputFaceHashes,
174
- HASH_CODE_MAX
175
- );
176
- const result2 = castShape(resultShape2);
177
- propagateOriginsFromEvolution(evolution, [shape], result2);
178
- return result2;
179
- }
180
- const resultShape = getKernel().generalTransformNonOrthogonal(shape.wrapped, linear, translation);
181
- const result = castShape(resultShape);
182
- propagateOriginsByHash([shape], result);
183
- return result;
184
- }
185
- function composeTransforms(ops) {
186
- const kernelOps = ops.map((op) => {
187
- if (op.type === "translate") {
188
- return { type: "translate", x: op.v[0], y: op.v[1], z: op.v[2] };
189
- }
190
- return {
191
- type: "rotate",
192
- angle: op.angle,
193
- axis: op.axis,
194
- center: op.center
195
- };
196
- });
197
- const { handle, dispose } = getKernel().composeTransform(kernelOps);
198
- return { trsf: handle, cleanup: dispose };
199
- }
200
- function transformCopy(shape, composed) {
201
- const inputFaceHashes = collectInputFaceHashes([shape]);
202
- const { shape: resultShape, evolution } = getKernel().applyComposedTransformWithHistory(
203
- shape.wrapped,
204
- composed.trsf,
205
- inputFaceHashes,
206
- HASH_CODE_MAX
207
- );
208
- const result = castShape(resultShape);
209
- propagateOriginsFromEvolution(evolution, [shape], result);
210
- return result;
211
- }
212
- const topoCache = /* @__PURE__ */ new WeakMap();
213
- function getOrCreateCache(shape) {
214
- let entry = topoCache.get(shape.wrapped);
215
- if (!entry) {
216
- entry = {};
217
- topoCache.set(shape.wrapped, entry);
218
- }
219
- return entry;
220
- }
221
- function invalidateShapeCache(shape) {
222
- topoCache.delete(shape.wrapped);
223
- }
224
- function getEdges(shape) {
225
- const cache = getOrCreateCache(shape);
226
- if (cache.edges) return cache.edges;
227
- const edges = Array.from(iterTopo(shape.wrapped, "edge")).map(
228
- (e) => castShape(unwrap(downcast(e)))
229
- );
230
- cache.edges = edges;
231
- return edges;
232
- }
233
- function getFaces(shape) {
234
- const cache = getOrCreateCache(shape);
235
- if (cache.faces) return cache.faces;
236
- const faces = Array.from(iterTopo(shape.wrapped, "face")).map(
237
- (e) => castShape(unwrap(downcast(e)))
238
- );
239
- cache.faces = faces;
240
- return faces;
241
- }
242
- function getWires(shape) {
243
- const cache = getOrCreateCache(shape);
244
- if (cache.wires) return cache.wires;
245
- const wires = Array.from(iterTopo(shape.wrapped, "wire")).map(
246
- (e) => castShape(unwrap(downcast(e)))
247
- );
248
- cache.wires = wires;
249
- return wires;
250
- }
251
- function setShapeOrigin(shape, origin) {
252
- const cache = getOrCreateCache(shape);
253
- const map = /* @__PURE__ */ new Map();
254
- for (const f of getFaces(shape)) {
255
- map.set(getKernel().hashCode(f.wrapped, HASH_CODE_MAX), origin);
256
- }
257
- cache.faceOrigins = map;
258
- }
259
- function getFaceOrigins(shape) {
260
- return topoCache.get(shape.wrapped)?.faceOrigins;
261
- }
262
- function propagateOriginsFromEvolution(evolution, inputs, result) {
263
- const inputOrigins = /* @__PURE__ */ new Map();
264
- for (const input of inputs) {
265
- const origins = getFaceOrigins(input);
266
- if (!origins) continue;
267
- for (const [hash, origin] of origins) {
268
- inputOrigins.set(hash, origin);
269
- }
270
- }
271
- if (inputOrigins.size === 0) return;
272
- const resultMap = /* @__PURE__ */ new Map();
273
- for (const [hash, origin] of inputOrigins) {
274
- if (evolution.deleted.has(hash)) continue;
275
- const modifiedHashes = evolution.modified.get(hash);
276
- if (modifiedHashes && modifiedHashes.length > 0) {
277
- for (const modHash of modifiedHashes) {
278
- resultMap.set(modHash, origin);
279
- }
280
- } else {
281
- resultMap.set(hash, origin);
282
- }
283
- const generatedHashes = evolution.generated.get(hash);
284
- if (generatedHashes) {
285
- for (const genHash of generatedHashes) {
286
- if (!resultMap.has(genHash)) {
287
- resultMap.set(genHash, 0);
288
- }
289
- }
290
- }
291
- }
292
- if (resultMap.size > 0) {
293
- const cache = getOrCreateCache(result);
294
- cache.faceOrigins = resultMap;
295
- }
296
- }
297
- function propagateOriginsByHash(inputs, result) {
298
- const lookup = /* @__PURE__ */ new Map();
299
- for (const input of inputs) {
300
- const origins = getFaceOrigins(input);
301
- if (!origins) continue;
302
- for (const [hash, origin] of origins) {
303
- lookup.set(hash, origin);
304
- }
305
- }
306
- if (lookup.size === 0) return;
307
- const kernel = getKernel();
308
- const resultMap = /* @__PURE__ */ new Map();
309
- const resultFaces = getFaces(result);
310
- for (const f of resultFaces) {
311
- const hash = kernel.hashCode(f.wrapped, HASH_CODE_MAX);
312
- const origin = lookup.get(hash);
313
- if (origin !== void 0) {
314
- resultMap.set(hash, origin);
315
- }
316
- }
317
- if (resultMap.size === 0) {
318
- const inputSigs = [];
319
- for (const input of inputs) {
320
- const origins = getFaceOrigins(input);
321
- if (!origins) continue;
322
- for (const f of getFaces(input)) {
323
- const hash = kernel.hashCode(f.wrapped, HASH_CODE_MAX);
324
- const origin = origins.get(hash);
325
- if (origin === void 0) continue;
326
- try {
327
- const bounds = kernel.uvBounds(f.wrapped);
328
- const normal = kernel.surfaceNormal(
329
- f.wrapped,
330
- 0.5 * (bounds.uMin + bounds.uMax),
331
- 0.5 * (bounds.vMin + bounds.vMax)
332
- );
333
- const centroid = kernel.surfaceCenterOfMass(f.wrapped);
334
- inputSigs.push({ origin, normal, centroid });
335
- } catch {
336
- }
337
- }
338
- }
339
- if (inputSigs.length > 0) {
340
- for (const f of resultFaces) {
341
- const hash = kernel.hashCode(f.wrapped, HASH_CODE_MAX);
342
- try {
343
- const outBounds = kernel.uvBounds(f.wrapped);
344
- const outNormal = kernel.surfaceNormal(
345
- f.wrapped,
346
- 0.5 * (outBounds.uMin + outBounds.uMax),
347
- 0.5 * (outBounds.vMin + outBounds.vMax)
348
- );
349
- const outCentroid = kernel.surfaceCenterOfMass(f.wrapped);
350
- let bestScore = -Infinity;
351
- let bestOrigin;
352
- for (const inp of inputSigs) {
353
- const dot = outNormal[0] * inp.normal[0] + outNormal[1] * inp.normal[1] + outNormal[2] * inp.normal[2];
354
- if (dot < 0.707) continue;
355
- const dx = outCentroid[0] - inp.centroid[0];
356
- const dy = outCentroid[1] - inp.centroid[1];
357
- const dz = outCentroid[2] - inp.centroid[2];
358
- const distSq = dx * dx + dy * dy + dz * dz;
359
- if (distSq > 100) continue;
360
- const score = dot - distSq / 100;
361
- if (score > bestScore) {
362
- bestScore = score;
363
- bestOrigin = inp.origin;
364
- }
365
- }
366
- if (bestOrigin !== void 0) {
367
- resultMap.set(hash, bestOrigin);
368
- }
369
- } catch {
370
- }
371
- }
372
- }
373
- }
374
- if (resultMap.size > 0) {
375
- const cache = getOrCreateCache(result);
376
- cache.faceOrigins = resultMap;
377
- }
378
- }
379
- function getVertices(shape) {
380
- const cache = getOrCreateCache(shape);
381
- if (cache.vertices) return cache.vertices;
382
- const vertices = Array.from(iterTopo(shape.wrapped, "vertex")).map(
383
- (e) => castShape(unwrap(downcast(e)))
384
- );
385
- cache.vertices = vertices;
386
- return vertices;
387
- }
388
- function* iterEdges(shape) {
389
- for (const e of iterTopo(shape.wrapped, "edge")) {
390
- yield castShape(unwrap(downcast(e)));
391
- }
392
- }
393
- function* iterFaces(shape) {
394
- for (const f of iterTopo(shape.wrapped, "face")) {
395
- yield castShape(unwrap(downcast(f)));
396
- }
397
- }
398
- function* iterWires(shape) {
399
- for (const w of iterTopo(shape.wrapped, "wire")) {
400
- yield castShape(unwrap(downcast(w)));
401
- }
402
- }
403
- function* iterVertices(shape) {
404
- for (const v of iterTopo(shape.wrapped, "vertex")) {
405
- yield castShape(unwrap(downcast(v)));
406
- }
407
- }
408
- function getBounds(shape) {
409
- const cache = getOrCreateCache(shape);
410
- if (cache.bounds) return cache.bounds;
411
- const { min, max } = getKernel().boundingBox(shape.wrapped);
412
- const bounds = {
413
- xMin: min[0],
414
- xMax: max[0],
415
- yMin: min[1],
416
- yMax: max[1],
417
- zMin: min[2],
418
- zMax: max[2]
419
- };
420
- cache.bounds = bounds;
421
- return bounds;
422
- }
423
- function describe(shape) {
424
- return {
425
- kind: getShapeKind(shape),
426
- faceCount: getFaces(shape).length,
427
- edgeCount: getEdges(shape).length,
428
- wireCount: getWires(shape).length,
429
- vertexCount: getVertices(shape).length,
430
- valid: getKernel().isValid(shape.wrapped),
431
- bounds: getBounds(shape)
432
- };
433
- }
434
- function vertexPosition(vertex) {
435
- return getKernel().vertexPosition(vertex.wrapped);
436
- }
437
- export {
438
- iterFaces as A,
439
- iterVertices as B,
440
- iterWires as C,
441
- resize as D,
442
- setShapeOrigin as E,
443
- getFaces as a,
444
- propagateOriginsFromEvolution as b,
445
- getWires as c,
446
- getEdges as d,
447
- getVertices as e,
448
- getHashCode as f,
449
- getFaceOrigins as g,
450
- getBounds as h,
451
- isSameShape as i,
452
- applyMatrix as j,
453
- clone as k,
454
- describe as l,
455
- isEmpty as m,
456
- mirror as n,
457
- simplify as o,
458
- propagateOriginsByHash as p,
459
- transformCopy as q,
460
- rotate as r,
461
- scale as s,
462
- toBREP as t,
463
- translate as u,
464
- vertexPosition as v,
465
- composeTransforms as w,
466
- invalidateShapeCache as x,
467
- isEqualShape as y,
468
- iterEdges as z
469
- };
@@ -1,3 +0,0 @@
1
- /** Round a number to 2 decimal places. */
2
- export default function round2(v: number): number;
3
- //# sourceMappingURL=round2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"round2.d.ts","sourceRoot":"","sources":["../../src/utils/round2.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
@@ -1,3 +0,0 @@
1
- /** Round a number to 5 decimal places. */
2
- export default function round5(v: number): number;
3
- //# sourceMappingURL=round5.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"round5.d.ts","sourceRoot":"","sources":["../../src/utils/round5.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}