brepjs 18.5.3 → 18.6.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 (161) hide show
  1. package/dist/2d/blueprints/blueprintOffset.d.ts.map +1 -1
  2. package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -1
  3. package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -1
  4. package/dist/2d/lib/curve2D.d.ts.map +1 -1
  5. package/dist/2d/lib/customCorners.d.ts.map +1 -1
  6. package/dist/2d/lib/stitching.d.ts.map +1 -1
  7. package/dist/2d/lib/svgPath.d.ts.map +1 -1
  8. package/dist/2d.cjs +6 -6
  9. package/dist/2d.js +6 -6
  10. package/dist/{blueprint-BKo2Z5P_.cjs → blueprint-C5LxqHCa.cjs} +16 -15
  11. package/dist/{blueprint-DXNeal2M.js → blueprint-CBairprN.js} +16 -15
  12. package/dist/{blueprintFns-DLmNAtH4.cjs → blueprintFns-CwbDuLxf.cjs} +3 -3
  13. package/dist/{blueprintFns-DwKTTALX.js → blueprintFns-D8ST0Cf4.js} +3 -3
  14. package/dist/{boolean2D-C8DlibdA.js → boolean2D-A5u9tJYl.js} +26 -24
  15. package/dist/{boolean2D-CvirfeVA.cjs → boolean2D-DxZ3Kwlq.cjs} +26 -24
  16. package/dist/{booleanFns-BTmOI2IT.cjs → booleanFns-DWQMtFDN.cjs} +9 -9
  17. package/dist/{booleanFns-BvRK1Oi2.js → booleanFns-DjZF4MJ5.js} +9 -9
  18. package/dist/brepjs.cjs +51 -41
  19. package/dist/brepjs.js +51 -41
  20. package/dist/core/errors.d.ts.map +1 -1
  21. package/dist/core.cjs +6 -6
  22. package/dist/core.js +6 -6
  23. package/dist/{cornerFinder-D3eGMa24.cjs → cornerFinder-B2CpcVV9.cjs} +3 -3
  24. package/dist/{cornerFinder-BwE0co98.js → cornerFinder-DGvOt2ab.js} +3 -3
  25. package/dist/{curveFns-CkhBj1Ot.cjs → curveFns-B8KJKr8-.cjs} +2 -2
  26. package/dist/{curveFns-DOtvwQN1.js → curveFns-DZYE3BGO.js} +2 -2
  27. package/dist/{drawFns-ChZrX59C.js → drawFns-Bl865kUL.js} +21 -20
  28. package/dist/{drawFns-CFqr2BFZ.cjs → drawFns-h8gJBx-H.cjs} +21 -20
  29. package/dist/{errors-DboJwVCf.js → errors-0fYW_YnO.js} +2 -1
  30. package/dist/{errors-CXRNVCec.cjs → errors-Dv6pfNct.cjs} +2 -1
  31. package/dist/{extrudeFns-sFXnQ0GR.cjs → extrudeFns-BlJKAnW8.cjs} +3 -3
  32. package/dist/{extrudeFns-9m-r4epC.js → extrudeFns-O2s-SFf-.js} +3 -3
  33. package/dist/{faceFns-9yuvhlzD.cjs → faceFns-B1H43mZ_.cjs} +3 -3
  34. package/dist/{faceFns-CoVqCTcx.js → faceFns-acz86gqR.js} +3 -3
  35. package/dist/{helpers-BPqm4AyF.cjs → helpers-C3smxDtp.cjs} +8 -8
  36. package/dist/{helpers-thCB-5I7.js → helpers-DL1f3xp0.js} +8 -8
  37. package/dist/{historyFns-DlyOFijD.js → historyFns-CD9qXw5j.js} +6 -6
  38. package/dist/{historyFns-C8RKuoZR.cjs → historyFns-DBdWeo7Y.cjs} +6 -6
  39. package/dist/{importFns-C9KoV6Q2.cjs → importFns-5tcN3-fK.cjs} +11 -19
  40. package/dist/{importFns-TsXZed73.js → importFns-B1p3FiGS.js} +11 -19
  41. package/dist/io/gltfExportFns.d.ts.map +1 -1
  42. package/dist/io/objExportFns.d.ts.map +1 -1
  43. package/dist/io.cjs +2 -2
  44. package/dist/io.js +2 -2
  45. package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -1
  46. package/dist/kernel/brepkit/constructionOps.d.ts +3 -2
  47. package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -1
  48. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  49. package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -1
  50. package/dist/kernel/brepkit/helpers.d.ts.map +1 -1
  51. package/dist/kernel/brepkit/internalOps.d.ts.map +1 -1
  52. package/dist/kernel/brepkit/ioOps.d.ts.map +1 -1
  53. package/dist/kernel/brepkit/kernel2dOps.d.ts.map +1 -1
  54. package/dist/kernel/brepkit/measureOps.d.ts.map +1 -1
  55. package/dist/kernel/brepkit/meshOps.d.ts.map +1 -1
  56. package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -1
  57. package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -1
  58. package/dist/kernel/occt/advancedOps.d.ts.map +1 -1
  59. package/dist/kernel/occt/booleanOps.d.ts.map +1 -1
  60. package/dist/kernel/occt/extendedConstructorOps.d.ts.map +1 -1
  61. package/dist/kernel/occt/kernel2dOps.d.ts.map +1 -1
  62. package/dist/kernel/occtWasm/adapterShims.d.ts +5 -0
  63. package/dist/kernel/occtWasm/adapterShims.d.ts.map +1 -0
  64. package/dist/kernel/occtWasm/booleanOps.d.ts +12 -0
  65. package/dist/kernel/occtWasm/booleanOps.d.ts.map +1 -0
  66. package/dist/kernel/occtWasm/constructionOps.d.ts +37 -0
  67. package/dist/kernel/occtWasm/constructionOps.d.ts.map +1 -0
  68. package/dist/kernel/occtWasm/curveOps.d.ts +24 -0
  69. package/dist/kernel/occtWasm/curveOps.d.ts.map +1 -0
  70. package/dist/kernel/occtWasm/evolutionOps.d.ts +18 -0
  71. package/dist/kernel/occtWasm/evolutionOps.d.ts.map +1 -0
  72. package/dist/kernel/occtWasm/helpers.d.ts +32 -0
  73. package/dist/kernel/occtWasm/helpers.d.ts.map +1 -0
  74. package/dist/kernel/occtWasm/hullOps.d.ts +13 -0
  75. package/dist/kernel/occtWasm/hullOps.d.ts.map +1 -0
  76. package/dist/kernel/occtWasm/ioOps.d.ts +53 -0
  77. package/dist/kernel/occtWasm/ioOps.d.ts.map +1 -0
  78. package/dist/kernel/occtWasm/kernel2dOps.d.ts +91 -0
  79. package/dist/kernel/occtWasm/kernel2dOps.d.ts.map +1 -0
  80. package/dist/kernel/occtWasm/measureOps.d.ts +32 -0
  81. package/dist/kernel/occtWasm/measureOps.d.ts.map +1 -0
  82. package/dist/kernel/occtWasm/meshOps.d.ts +7 -0
  83. package/dist/kernel/occtWasm/meshOps.d.ts.map +1 -0
  84. package/dist/kernel/occtWasm/modifierOps.d.ts +15 -0
  85. package/dist/kernel/occtWasm/modifierOps.d.ts.map +1 -0
  86. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  87. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +30 -30
  88. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts.map +1 -1
  89. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  90. package/dist/kernel/occtWasm/primitiveOps.d.ts +11 -0
  91. package/dist/kernel/occtWasm/primitiveOps.d.ts.map +1 -0
  92. package/dist/kernel/occtWasm/repairOps.d.ts +11 -0
  93. package/dist/kernel/occtWasm/repairOps.d.ts.map +1 -0
  94. package/dist/kernel/occtWasm/surfaceOps.d.ts +29 -0
  95. package/dist/kernel/occtWasm/surfaceOps.d.ts.map +1 -0
  96. package/dist/kernel/occtWasm/sweepOps.d.ts +39 -0
  97. package/dist/kernel/occtWasm/sweepOps.d.ts.map +1 -0
  98. package/dist/kernel/occtWasm/topologyOps.d.ts +15 -0
  99. package/dist/kernel/occtWasm/topologyOps.d.ts.map +1 -0
  100. package/dist/kernel/occtWasm/transformOps.d.ts +28 -0
  101. package/dist/kernel/occtWasm/transformOps.d.ts.map +1 -0
  102. package/dist/{measureFns-DXLTUwTN.cjs → measureFns-CHmy_Inq.cjs} +3 -3
  103. package/dist/{measureFns-CkhDfqzu.js → measureFns-CJi8erDL.js} +3 -3
  104. package/dist/measurement/interferenceFns.d.ts.map +1 -1
  105. package/dist/measurement.cjs +1 -1
  106. package/dist/measurement.js +1 -1
  107. package/dist/{meshFns-CAUI3r1d.js → meshFns-BkY1RAoC.js} +3 -3
  108. package/dist/{meshFns-DzGr_wxJ.cjs → meshFns-t2lR4BDS.cjs} +3 -3
  109. package/dist/occtWasmAdapter--TZGP9DX.js +4606 -0
  110. package/dist/occtWasmAdapter-C2VW-uYg.cjs +4719 -0
  111. package/dist/operations/compoundOpsFns.d.ts.map +1 -1
  112. package/dist/operations.cjs +2 -2
  113. package/dist/operations.js +2 -2
  114. package/dist/{planeOps-sTrM3dcQ.js → planeOps-4i2qEraD.js} +4 -4
  115. package/dist/{planeOps-BJOIbn4K.cjs → planeOps-CH4ruLuj.cjs} +4 -4
  116. package/dist/{primitiveFns-ClBrBsj6.cjs → primitiveFns-DwhN--zB.cjs} +7 -7
  117. package/dist/{primitiveFns-DEIibX8G.js → primitiveFns-Emvge_71.js} +7 -7
  118. package/dist/query.cjs +2 -2
  119. package/dist/query.js +2 -2
  120. package/dist/result.cjs +1 -1
  121. package/dist/result.js +1 -1
  122. package/dist/{shapeFns-c2eak2sT.cjs → shapeFns-CObBAJoQ.cjs} +4 -4
  123. package/dist/{shapeFns-Cwt0CMNm.js → shapeFns-DThjHtJI.js} +4 -4
  124. package/dist/shapeRef.cjs +1 -1
  125. package/dist/shapeRef.js +1 -1
  126. package/dist/{shapeRefFns-D-JLpn7D.cjs → shapeRefFns-I0MHjRAq.cjs} +5 -4
  127. package/dist/{shapeRefFns-Cx61pDhQ.js → shapeRefFns-WMhIFuGW.js} +5 -4
  128. package/dist/{shapeTypes-Xnk670Cd.cjs → shapeTypes-8vB31RfA.cjs} +290 -418
  129. package/dist/{shapeTypes-uibK1QHY.js → shapeTypes-AyL8vv_O.js} +290 -418
  130. package/dist/sketching.cjs +2 -2
  131. package/dist/sketching.js +2 -2
  132. package/dist/{solidBuilders-BnTtq4g1.js → solidBuilders-C7Xp_ikW.js} +3 -3
  133. package/dist/{solidBuilders-23LDxzEn.cjs → solidBuilders-Djwgx2mj.cjs} +3 -3
  134. package/dist/{surfaceBuilders-CUn-cmah.cjs → surfaceBuilders-BEnsewN9.cjs} +3 -3
  135. package/dist/{surfaceBuilders-DeNnAJb3.js → surfaceBuilders-Con0IpLf.js} +3 -3
  136. package/dist/topology/minkowskiFns.d.ts.map +1 -1
  137. package/dist/topology/shapeRef/shapeRefFns.d.ts.map +1 -1
  138. package/dist/topology/wrapperFns.d.ts.map +1 -1
  139. package/dist/topology.cjs +6 -6
  140. package/dist/topology.js +6 -6
  141. package/dist/utils/vec3.d.ts +32 -0
  142. package/dist/utils/vec3.d.ts.map +1 -0
  143. package/dist/vec3-BRj3eI54.js +25 -0
  144. package/dist/vec3-S4Oh59IX.cjs +36 -0
  145. package/dist/vectors.cjs +4 -4
  146. package/dist/vectors.js +4 -4
  147. package/dist/worker.cjs +1 -1
  148. package/dist/worker.js +1 -1
  149. package/package.json +2 -2
  150. package/dist/occtWasmAdapter-CuZRRioz.cjs +0 -3947
  151. package/dist/occtWasmAdapter-DIhUXubY.js +0 -3834
  152. /package/dist/{arrayAccess-tCIbjLs5.js → arrayAccess-2G0pRoaC.js} +0 -0
  153. /package/dist/{arrayAccess-DsnQpdSD.cjs → arrayAccess-Br-m2PP7.cjs} +0 -0
  154. /package/dist/{constants-csSEYddm.js → constants-Ci5CA3aZ.js} +0 -0
  155. /package/dist/{constants-BNP_xnBN.cjs → constants-DTorLmes.cjs} +0 -0
  156. /package/dist/{types--GD-LVc6.js → types-BIdk_GJY.js} +0 -0
  157. /package/dist/{types-gLi9wL0N.cjs → types-CDkxah-M.cjs} +0 -0
  158. /package/dist/{vecOps-CODplJp3.cjs → vecOps-D7xplSx8.cjs} +0 -0
  159. /package/dist/{vecOps-B-PCHgyB.js → vecOps-DVROrqTV.js} +0 -0
  160. /package/dist/{workerHandler-Dm0_0F8Z.js → workerHandler-BndMJVx6.js} +0 -0
  161. /package/dist/{workerHandler-C-3cFcsQ.cjs → workerHandler-sCf818XJ.cjs} +0 -0
@@ -0,0 +1,4719 @@
1
+ const require_vec3 = require("./vec3-S4Oh59IX.cjs");
2
+ //#region src/kernel/geometry2d.ts
3
+ function evaluateCurve2d$1(c, t) {
4
+ switch (c.__bk2d) {
5
+ case "line": return [c.ox + c.dx * t, c.oy + c.dy * t];
6
+ case "circle": {
7
+ const angle = c.sense ? t : -t;
8
+ return [c.cx + c.radius * Math.cos(angle), c.cy + c.radius * Math.sin(angle)];
9
+ }
10
+ case "ellipse": {
11
+ const angle = c.sense ? t : -t;
12
+ const cos = Math.cos(c.xDirAngle);
13
+ const sin = Math.sin(c.xDirAngle);
14
+ const x = c.majorRadius * Math.cos(angle);
15
+ const y = c.minorRadius * Math.sin(angle);
16
+ return [c.cx + x * cos - y * sin, c.cy + x * sin + y * cos];
17
+ }
18
+ case "bezier": return evaluateBezier(c.poles, t);
19
+ case "bspline": return evaluateBSpline2d(c, t);
20
+ case "trimmed": {
21
+ const mapped = c.tStart + t * (c.tEnd - c.tStart);
22
+ return evaluateCurve2d$1(c.basis, mapped);
23
+ }
24
+ }
25
+ }
26
+ function tangentCurve2d(c, t) {
27
+ switch (c.__bk2d) {
28
+ case "line": return [c.dx, c.dy];
29
+ case "circle": {
30
+ const angle = c.sense ? t : -t;
31
+ const sign = c.sense ? 1 : -1;
32
+ return [-c.radius * Math.sin(angle) * sign, c.radius * Math.cos(angle) * sign];
33
+ }
34
+ case "ellipse": {
35
+ const angle = c.sense ? t : -t;
36
+ const sign = c.sense ? 1 : -1;
37
+ const cos = Math.cos(c.xDirAngle);
38
+ const sin = Math.sin(c.xDirAngle);
39
+ const dx = -c.majorRadius * Math.sin(angle) * sign;
40
+ const dy = c.minorRadius * Math.cos(angle) * sign;
41
+ return [dx * cos - dy * sin, dx * sin + dy * cos];
42
+ }
43
+ case "bezier": {
44
+ const h = 1e-8;
45
+ const p0 = evaluateBezier(c.poles, Math.max(0, t - h));
46
+ const p1 = evaluateBezier(c.poles, Math.min(1, t + h));
47
+ const dt = Math.min(1, t + h) - Math.max(0, t - h);
48
+ return [(p1[0] - p0[0]) / dt, (p1[1] - p0[1]) / dt];
49
+ }
50
+ case "bspline": {
51
+ const h = 1e-8;
52
+ const kFirst = c.knots[0];
53
+ const kLast = c.knots[c.knots.length - 1];
54
+ const p0 = evaluateBSpline2d(c, Math.max(kFirst, t - h));
55
+ const p1 = evaluateBSpline2d(c, Math.min(kLast, t + h));
56
+ const dt = Math.min(kLast, t + h) - Math.max(kFirst, t - h);
57
+ return [(p1[0] - p0[0]) / dt, (p1[1] - p0[1]) / dt];
58
+ }
59
+ case "trimmed": {
60
+ const mapped = c.tStart + t * (c.tEnd - c.tStart);
61
+ const tan = tangentCurve2d(c.basis, mapped);
62
+ const scale = c.tEnd - c.tStart;
63
+ return [tan[0] * scale, tan[1] * scale];
64
+ }
65
+ }
66
+ }
67
+ function curveBounds(c) {
68
+ switch (c.__bk2d) {
69
+ case "line": return {
70
+ first: 0,
71
+ last: c.len
72
+ };
73
+ case "circle":
74
+ case "ellipse": return {
75
+ first: 0,
76
+ last: 2 * Math.PI
77
+ };
78
+ case "bezier": return {
79
+ first: 0,
80
+ last: 1
81
+ };
82
+ case "bspline": return {
83
+ first: c.knots[0],
84
+ last: c.knots[c.knots.length - 1]
85
+ };
86
+ case "trimmed": return {
87
+ first: 0,
88
+ last: 1
89
+ };
90
+ }
91
+ }
92
+ function curveTypeName(c) {
93
+ switch (c.__bk2d) {
94
+ case "line": return "LINE";
95
+ case "circle": return "CIRCLE";
96
+ case "ellipse": return "ELLIPSE";
97
+ case "bezier": return "BEZIER_CURVE";
98
+ case "bspline": return "BSPLINE_CURVE";
99
+ case "trimmed": return "TRIMMED_" + curveTypeName(c.basis);
100
+ }
101
+ }
102
+ function makeLine2d$1(x1, y1, x2, y2) {
103
+ const dx = x2 - x1;
104
+ const dy = y2 - y1;
105
+ const len = Math.sqrt(dx * dx + dy * dy);
106
+ return {
107
+ __bk2d: "line",
108
+ ox: x1,
109
+ oy: y1,
110
+ dx: len > 0 ? dx / len : 1,
111
+ dy: len > 0 ? dy / len : 0,
112
+ len
113
+ };
114
+ }
115
+ function makeCircle2d$1(cx, cy, radius, sense = true) {
116
+ return {
117
+ __bk2d: "circle",
118
+ cx,
119
+ cy,
120
+ radius,
121
+ sense
122
+ };
123
+ }
124
+ function makeEllipse2d$1(cx, cy, majorRadius, minorRadius, xDirX = 1, xDirY = 0, sense = true) {
125
+ return {
126
+ __bk2d: "ellipse",
127
+ cx,
128
+ cy,
129
+ majorRadius,
130
+ minorRadius,
131
+ xDirAngle: Math.atan2(xDirY, xDirX),
132
+ sense
133
+ };
134
+ }
135
+ function makeBezier2d$1(poles) {
136
+ return {
137
+ __bk2d: "bezier",
138
+ poles: [...poles]
139
+ };
140
+ }
141
+ function translateCurve2d$1(c, dx, dy) {
142
+ switch (c.__bk2d) {
143
+ case "line": return {
144
+ ...c,
145
+ ox: c.ox + dx,
146
+ oy: c.oy + dy
147
+ };
148
+ case "circle": return {
149
+ ...c,
150
+ cx: c.cx + dx,
151
+ cy: c.cy + dy
152
+ };
153
+ case "ellipse": return {
154
+ ...c,
155
+ cx: c.cx + dx,
156
+ cy: c.cy + dy
157
+ };
158
+ case "bezier": return {
159
+ ...c,
160
+ poles: c.poles.map(([x, y]) => [x + dx, y + dy])
161
+ };
162
+ case "bspline": return {
163
+ ...c,
164
+ poles: c.poles.map(([x, y]) => [x + dx, y + dy])
165
+ };
166
+ case "trimmed": return {
167
+ ...c,
168
+ basis: translateCurve2d$1(c.basis, dx, dy)
169
+ };
170
+ }
171
+ }
172
+ function rotateCurve2d$1(c, angle, cx, cy) {
173
+ const cos = Math.cos(angle);
174
+ const sin = Math.sin(angle);
175
+ const rotatePoint = (x, y) => {
176
+ const rx = x - cx;
177
+ const ry = y - cy;
178
+ return [cx + rx * cos - ry * sin, cy + rx * sin + ry * cos];
179
+ };
180
+ switch (c.__bk2d) {
181
+ case "line": {
182
+ const [ox, oy] = rotatePoint(c.ox, c.oy);
183
+ const ndx = c.dx * cos - c.dy * sin;
184
+ const ndy = c.dx * sin + c.dy * cos;
185
+ return {
186
+ ...c,
187
+ ox,
188
+ oy,
189
+ dx: ndx,
190
+ dy: ndy
191
+ };
192
+ }
193
+ case "circle": {
194
+ const [ncx, ncy] = rotatePoint(c.cx, c.cy);
195
+ return {
196
+ ...c,
197
+ cx: ncx,
198
+ cy: ncy
199
+ };
200
+ }
201
+ case "ellipse": {
202
+ const [ncx, ncy] = rotatePoint(c.cx, c.cy);
203
+ return {
204
+ ...c,
205
+ cx: ncx,
206
+ cy: ncy,
207
+ xDirAngle: c.xDirAngle + angle
208
+ };
209
+ }
210
+ case "bezier": return {
211
+ ...c,
212
+ poles: c.poles.map(([x, y]) => rotatePoint(x, y))
213
+ };
214
+ case "bspline": return {
215
+ ...c,
216
+ poles: c.poles.map(([x, y]) => rotatePoint(x, y))
217
+ };
218
+ case "trimmed": return {
219
+ ...c,
220
+ basis: rotateCurve2d$1(c.basis, angle, cx, cy)
221
+ };
222
+ }
223
+ }
224
+ function scaleCurve2d$1(c, factor, cx, cy) {
225
+ const scalePoint = (x, y) => [cx + (x - cx) * factor, cy + (y - cy) * factor];
226
+ switch (c.__bk2d) {
227
+ case "line": {
228
+ const [ox, oy] = scalePoint(c.ox, c.oy);
229
+ return {
230
+ ...c,
231
+ ox,
232
+ oy
233
+ };
234
+ }
235
+ case "circle": {
236
+ const [ncx, ncy] = scalePoint(c.cx, c.cy);
237
+ return {
238
+ ...c,
239
+ cx: ncx,
240
+ cy: ncy,
241
+ radius: c.radius * Math.abs(factor)
242
+ };
243
+ }
244
+ case "ellipse": {
245
+ const [ncx, ncy] = scalePoint(c.cx, c.cy);
246
+ return {
247
+ ...c,
248
+ cx: ncx,
249
+ cy: ncy,
250
+ majorRadius: c.majorRadius * Math.abs(factor),
251
+ minorRadius: c.minorRadius * Math.abs(factor)
252
+ };
253
+ }
254
+ case "bezier": return {
255
+ ...c,
256
+ poles: c.poles.map(([x, y]) => scalePoint(x, y))
257
+ };
258
+ case "bspline": return {
259
+ ...c,
260
+ poles: c.poles.map(([x, y]) => scalePoint(x, y))
261
+ };
262
+ case "trimmed": return {
263
+ ...c,
264
+ basis: scaleCurve2d$1(c.basis, factor, cx, cy)
265
+ };
266
+ }
267
+ }
268
+ function mirrorAtPoint(c, cx, cy) {
269
+ return scaleCurve2d$1(c, -1, cx, cy);
270
+ }
271
+ function mirrorAcrossAxis(c, ox, oy, dx, dy) {
272
+ const len = Math.sqrt(dx * dx + dy * dy);
273
+ const nx = dx / len;
274
+ const ny = dy / len;
275
+ const reflectPoint = (x, y) => {
276
+ const rx = x - ox;
277
+ const ry = y - oy;
278
+ const dot = rx * nx + ry * ny;
279
+ return [ox + 2 * dot * nx - rx, oy + 2 * dot * ny - ry];
280
+ };
281
+ switch (c.__bk2d) {
282
+ case "line": {
283
+ const [nox, noy] = reflectPoint(c.ox, c.oy);
284
+ const ndx = 2 * (c.dx * nx + c.dy * ny) * nx - c.dx;
285
+ const ndy = 2 * (c.dx * nx + c.dy * ny) * ny - c.dy;
286
+ return {
287
+ ...c,
288
+ ox: nox,
289
+ oy: noy,
290
+ dx: ndx,
291
+ dy: ndy
292
+ };
293
+ }
294
+ case "circle": {
295
+ const [ncx, ncy] = reflectPoint(c.cx, c.cy);
296
+ return {
297
+ ...c,
298
+ cx: ncx,
299
+ cy: ncy,
300
+ sense: !c.sense
301
+ };
302
+ }
303
+ case "ellipse": {
304
+ const [ncx, ncy] = reflectPoint(c.cx, c.cy);
305
+ const cos2 = nx * nx - ny * ny;
306
+ const sin2 = 2 * nx * ny;
307
+ const newAngle = Math.atan2(sin2 * Math.cos(c.xDirAngle) - cos2 * Math.sin(c.xDirAngle), cos2 * Math.cos(c.xDirAngle) + sin2 * Math.sin(c.xDirAngle));
308
+ return {
309
+ ...c,
310
+ cx: ncx,
311
+ cy: ncy,
312
+ xDirAngle: newAngle,
313
+ sense: !c.sense
314
+ };
315
+ }
316
+ case "bezier": return {
317
+ ...c,
318
+ poles: c.poles.map(([x, y]) => reflectPoint(x, y))
319
+ };
320
+ case "bspline": return {
321
+ ...c,
322
+ poles: c.poles.map(([x, y]) => reflectPoint(x, y))
323
+ };
324
+ case "trimmed": return {
325
+ ...c,
326
+ basis: mirrorAcrossAxis(c.basis, ox, oy, dx, dy)
327
+ };
328
+ }
329
+ }
330
+ /**
331
+ * Compute intersection points (and overlapping segments) between two 2D curves.
332
+ * Handles analytic cases (line-line, line-circle, circle-circle) and falls back
333
+ * to numerical sampling + Newton refinement for general curves.
334
+ */
335
+ function intersectCurves2dFn(c1, c2, tolerance) {
336
+ const b1 = unwrapCurve(c1);
337
+ const b2 = unwrapCurve(c2);
338
+ if (b1.__bk2d === "line" && b2.__bk2d === "line") return intersectLineLine(c1, b1, c2, b2, tolerance);
339
+ if (b1.__bk2d === "line" && b2.__bk2d === "circle") return {
340
+ points: intersectLineCircle(c1, b1, c2, b2, tolerance),
341
+ segments: []
342
+ };
343
+ if (b1.__bk2d === "circle" && b2.__bk2d === "line") return {
344
+ points: intersectLineCircle(c2, b2, c1, b1, tolerance),
345
+ segments: []
346
+ };
347
+ if (b1.__bk2d === "circle" && b2.__bk2d === "circle") return {
348
+ points: intersectCircleCircle(c1, b1, c2, b2, tolerance),
349
+ segments: []
350
+ };
351
+ return numericalIntersect(c1, c2, tolerance, c1 === c2);
352
+ }
353
+ /** Unwrap trimmed wrappers to get the basis curve type. */
354
+ function unwrapCurve(c) {
355
+ let cur = c;
356
+ while (cur.__bk2d === "trimmed") cur = cur.basis;
357
+ return cur;
358
+ }
359
+ /** Check if parameter t is within the curve's domain. */
360
+ function inDomain(c, t, tol) {
361
+ const b = curveBounds(c);
362
+ return t >= b.first - tol && t <= b.last + tol;
363
+ }
364
+ /** Find the parameter on curve c closest to point (px, py), searching near tGuess. */
365
+ function refineParam(c, px, py) {
366
+ const bounds = curveBounds(c);
367
+ if (!isFinite(bounds.first) || !isFinite(bounds.last)) return null;
368
+ const N = 80;
369
+ const dt = (bounds.last - bounds.first) / N;
370
+ let bestT = bounds.first;
371
+ let bestD = Infinity;
372
+ for (let i = 0; i <= N; i++) {
373
+ const t = bounds.first + i * dt;
374
+ const [ex, ey] = evaluateCurve2d$1(c, t);
375
+ const d = (ex - px) ** 2 + (ey - py) ** 2;
376
+ if (d < bestD) {
377
+ bestD = d;
378
+ bestT = t;
379
+ }
380
+ }
381
+ const [sx, sy] = evaluateCurve2d$1(c, bounds.first);
382
+ const [ex, ey] = evaluateCurve2d$1(c, bounds.last);
383
+ const [mx, my] = evaluateCurve2d$1(c, (bounds.first + bounds.last) / 2);
384
+ const maxDist = Math.max(Math.sqrt((ex - sx) ** 2 + (ey - sy) ** 2), Math.sqrt((mx - sx) ** 2 + (my - sy) ** 2), 1e-6) * .1;
385
+ return bestD < maxDist * maxDist ? bestT : null;
386
+ }
387
+ function intersectLineLine(c1, l1, c2, l2, tol) {
388
+ const det = l1.dx * l2.dy - l1.dy * l2.dx;
389
+ if (Math.abs(det) >= 1e-14) {
390
+ const ex = l2.ox - l1.ox;
391
+ const ey = l2.oy - l1.oy;
392
+ const t1 = (ex * l2.dy - ey * l2.dx) / det;
393
+ const t2 = (ex * l1.dy - ey * l1.dx) / det;
394
+ if (!inDomain(c1, t1, tol) || !inDomain(c2, t2, tol)) return {
395
+ points: [],
396
+ segments: []
397
+ };
398
+ return {
399
+ points: [[l1.ox + t1 * l1.dx, l1.oy + t1 * l1.dy]],
400
+ segments: []
401
+ };
402
+ }
403
+ const ex = l2.ox - l1.ox;
404
+ const ey = l2.oy - l1.oy;
405
+ const cross = ex * l1.dy - ey * l1.dx;
406
+ if (Math.abs(cross) > tol) return {
407
+ points: [],
408
+ segments: []
409
+ };
410
+ const b1 = curveBounds(c1);
411
+ const b2 = curveBounds(c2);
412
+ const p2s = evaluateCurve2d$1(c2, b2.first);
413
+ const p2e = evaluateCurve2d$1(c2, b2.last);
414
+ const t2sOn1 = (p2s[0] - l1.ox) * l1.dx + (p2s[1] - l1.oy) * l1.dy;
415
+ const t2eOn1 = (p2e[0] - l1.ox) * l1.dx + (p2e[1] - l1.oy) * l1.dy;
416
+ const overlapStart = Math.max(b1.first, Math.min(t2sOn1, t2eOn1));
417
+ const overlapEnd = Math.min(b1.last, Math.max(t2sOn1, t2eOn1));
418
+ if (overlapEnd - overlapStart < tol) return {
419
+ points: [],
420
+ segments: []
421
+ };
422
+ return {
423
+ points: [],
424
+ segments: [makeLine2d$1(l1.ox + overlapStart * l1.dx, l1.oy + overlapStart * l1.dy, l1.ox + overlapEnd * l1.dx, l1.oy + overlapEnd * l1.dy)]
425
+ };
426
+ }
427
+ function intersectLineCircle(cLine, line, cCirc, circ, tol) {
428
+ const fx = line.ox - circ.cx;
429
+ const fy = line.oy - circ.cy;
430
+ const a = line.dx * line.dx + line.dy * line.dy;
431
+ const b = 2 * (fx * line.dx + fy * line.dy);
432
+ const c = fx * fx + fy * fy - circ.radius * circ.radius;
433
+ const disc = b * b - 4 * a * c;
434
+ if (disc < -tol) return [];
435
+ const results = [];
436
+ const sqrtDisc = Math.sqrt(Math.max(0, disc));
437
+ const t1 = (-b - sqrtDisc) / (2 * a);
438
+ const t2 = (-b + sqrtDisc) / (2 * a);
439
+ for (const tLine of disc < tol * tol ? [t1] : [t1, t2]) {
440
+ if (!inDomain(cLine, tLine, tol)) continue;
441
+ const px = line.ox + tLine * line.dx;
442
+ const py = line.oy + tLine * line.dy;
443
+ const tCirc = refineParam(cCirc, px, py);
444
+ if (tCirc === null) continue;
445
+ const [cx2, cy2] = evaluateCurve2d$1(cCirc, tCirc);
446
+ if ((cx2 - px) ** 2 + (cy2 - py) ** 2 > tol * tol * 1e6) continue;
447
+ results.push([px, py]);
448
+ }
449
+ return results;
450
+ }
451
+ function intersectConcentricArcs(c1, c2, tol) {
452
+ const b1 = curveBounds(c1);
453
+ const b2 = curveBounds(c2);
454
+ const isFullCircle1 = Math.abs(b1.last - b1.first - 2 * Math.PI) < 1e-10;
455
+ const isFullCircle2 = Math.abs(b2.last - b2.first - 2 * Math.PI) < 1e-10;
456
+ if (isFullCircle1 && isFullCircle2) return [];
457
+ if (isFullCircle1) return [evaluateCurve2d$1(c2, b2.first), evaluateCurve2d$1(c2, b2.last)];
458
+ if (isFullCircle2) return [evaluateCurve2d$1(c1, b1.first), evaluateCurve2d$1(c1, b1.last)];
459
+ const pts = [];
460
+ const checks = [
461
+ [c2, evaluateCurve2d$1(c1, b1.first)],
462
+ [c2, evaluateCurve2d$1(c1, b1.last)],
463
+ [c1, evaluateCurve2d$1(c2, b2.first)],
464
+ [c1, evaluateCurve2d$1(c2, b2.last)]
465
+ ];
466
+ for (const [target, pt] of checks) {
467
+ const t = refineParam(target, pt[0], pt[1]);
468
+ if (t !== null) {
469
+ const [ex, ey] = evaluateCurve2d$1(target, t);
470
+ if ((ex - pt[0]) ** 2 + (ey - pt[1]) ** 2 < tol * tol * 100) pts.push(pt);
471
+ }
472
+ }
473
+ const deduped = [];
474
+ for (const p of pts) if (!deduped.some(([ddx, ddy]) => (ddx - p[0]) ** 2 + (ddy - p[1]) ** 2 < tol * tol * 100)) deduped.push(p);
475
+ return deduped;
476
+ }
477
+ function intersectCircleCircle(c1, circ1, c2, circ2, tol) {
478
+ const dx = circ2.cx - circ1.cx;
479
+ const dy = circ2.cy - circ1.cy;
480
+ const d = Math.sqrt(dx * dx + dy * dy);
481
+ if (d > circ1.radius + circ2.radius + tol) return [];
482
+ if (d < Math.abs(circ1.radius - circ2.radius) - tol) return [];
483
+ if (d < 1e-14) {
484
+ if (Math.abs(circ1.radius - circ2.radius) > tol) return [];
485
+ return intersectConcentricArcs(c1, c2, tol);
486
+ }
487
+ const a = (circ1.radius * circ1.radius - circ2.radius * circ2.radius + d * d) / (2 * d);
488
+ const h2 = circ1.radius * circ1.radius - a * a;
489
+ const h = Math.sqrt(Math.max(0, h2));
490
+ const mx = circ1.cx + a * dx / d;
491
+ const my = circ1.cy + a * dy / d;
492
+ const candidates = h < tol ? [[mx, my]] : [[mx + h * dy / d, my - h * dx / d], [mx - h * dy / d, my + h * dx / d]];
493
+ const results = [];
494
+ for (const [px, py] of candidates) {
495
+ const t1 = refineParam(c1, px, py);
496
+ const t2 = refineParam(c2, px, py);
497
+ if (t1 === null || t2 === null) continue;
498
+ const [x1, y1] = evaluateCurve2d$1(c1, t1);
499
+ const [x2, y2] = evaluateCurve2d$1(c2, t2);
500
+ const tolSq = (tol * 10) ** 2;
501
+ if ((x1 - px) ** 2 + (y1 - py) ** 2 > tolSq) continue;
502
+ if ((x2 - px) ** 2 + (y2 - py) ** 2 > tolSq) continue;
503
+ results.push([px, py]);
504
+ }
505
+ return results;
506
+ }
507
+ /**
508
+ * Numerical intersection via sampling + Newton refinement.
509
+ * Samples both curves densely, finds close point pairs, refines with Newton.
510
+ */
511
+ function numericalIntersect(c1, c2, tolerance, isSelf = false) {
512
+ const b1 = curveBounds(c1);
513
+ const b2 = curveBounds(c2);
514
+ if (!isFinite(b1.first) || !isFinite(b1.last) || !isFinite(b2.first) || !isFinite(b2.last)) return {
515
+ points: [],
516
+ segments: []
517
+ };
518
+ const N = 100;
519
+ const pts1 = [];
520
+ const pts2 = [];
521
+ for (let i = 0; i <= N; i++) {
522
+ const t1 = b1.first + (b1.last - b1.first) * i / N;
523
+ const [x1, y1] = evaluateCurve2d$1(c1, t1);
524
+ pts1.push({
525
+ t: t1,
526
+ x: x1,
527
+ y: y1
528
+ });
529
+ const t2 = b2.first + (b2.last - b2.first) * i / N;
530
+ const [x2, y2] = evaluateCurve2d$1(c2, t2);
531
+ pts2.push({
532
+ t: t2,
533
+ x: x2,
534
+ y: y2
535
+ });
536
+ }
537
+ const crossTol = Math.max(tolerance * 100, .5);
538
+ const seg2Bounds = new Float64Array(N * 6);
539
+ for (let j = 0; j < N; j++) {
540
+ const a = pts2[j], b = pts2[j + 1];
541
+ const off = j * 6;
542
+ seg2Bounds[off] = Math.min(a.x, b.x);
543
+ seg2Bounds[off + 1] = Math.max(a.x, b.x);
544
+ seg2Bounds[off + 2] = Math.min(a.y, b.y);
545
+ seg2Bounds[off + 3] = Math.max(a.y, b.y);
546
+ seg2Bounds[off + 4] = (a.t + b.t) / 2;
547
+ }
548
+ const candidates = [];
549
+ const selfMinSep = (b1.last - b1.first) / 5;
550
+ for (let i = 0; i < N; i++) {
551
+ const p1a = pts1[i];
552
+ const p1b = pts1[i + 1];
553
+ const x1min = Math.min(p1a.x, p1b.x) - crossTol;
554
+ const x1max = Math.max(p1a.x, p1b.x) + crossTol;
555
+ const y1min = Math.min(p1a.y, p1b.y) - crossTol;
556
+ const y1max = Math.max(p1a.y, p1b.y) + crossTol;
557
+ const t1mid = (p1a.t + p1b.t) / 2;
558
+ for (let j = 0; j < N; j++) {
559
+ const off = j * 6;
560
+ if (x1max < seg2Bounds[off] || seg2Bounds[off + 1] < x1min) continue;
561
+ if (y1max < seg2Bounds[off + 2] || seg2Bounds[off + 3] < y1min) continue;
562
+ const t2mid = seg2Bounds[off + 4];
563
+ if (isSelf && Math.abs(t1mid - t2mid) < selfMinSep) continue;
564
+ candidates.push({
565
+ t1: t1mid,
566
+ t2: t2mid
567
+ });
568
+ }
569
+ }
570
+ const tol2 = tolerance * tolerance;
571
+ const found = [];
572
+ for (const { t1: t1Init, t2: t2Init } of candidates) {
573
+ let t1 = t1Init;
574
+ let t2 = t2Init;
575
+ for (let iter = 0; iter < 20; iter++) {
576
+ const [x1, y1] = evaluateCurve2d$1(c1, t1);
577
+ const [x2, y2] = evaluateCurve2d$1(c2, t2);
578
+ const dx = x1 - x2;
579
+ const dy = y1 - y2;
580
+ if (dx * dx + dy * dy < tol2) break;
581
+ const d1 = tangentCurve2d(c1, t1);
582
+ const d2 = tangentCurve2d(c2, t2);
583
+ const det = d1[0] * -d2[1] - -d2[0] * d1[1];
584
+ if (Math.abs(det) < 1e-14) break;
585
+ const dt1 = (-dx * -d2[1] - -dy * -d2[0]) / det;
586
+ const dt2 = (d1[0] * -dy - d1[1] * -dx) / det;
587
+ t1 += dt1;
588
+ t2 += dt2;
589
+ t1 = Math.max(b1.first, Math.min(b1.last, t1));
590
+ t2 = Math.max(b2.first, Math.min(b2.last, t2));
591
+ }
592
+ const [x1, y1] = evaluateCurve2d$1(c1, t1);
593
+ const [x2, y2] = evaluateCurve2d$1(c2, t2);
594
+ if (isSelf && Math.abs(t1 - t2) < (b1.last - b1.first) * .05) continue;
595
+ if ((x1 - x2) ** 2 + (y1 - y2) ** 2 < tolerance * tolerance * 1e6) {
596
+ const px = (x1 + x2) / 2;
597
+ const py = (y1 + y2) / 2;
598
+ let dup = false;
599
+ for (const [fx, fy] of found) if ((fx - px) ** 2 + (fy - py) ** 2 < tolerance * tolerance * 1e4) {
600
+ dup = true;
601
+ break;
602
+ }
603
+ if (!dup) found.push([px, py]);
604
+ }
605
+ }
606
+ return {
607
+ points: found,
608
+ segments: []
609
+ };
610
+ }
611
+ function serializeCurve2d$1(c) {
612
+ return JSON.stringify(c);
613
+ }
614
+ function deserializeCurve2d$1(data) {
615
+ return JSON.parse(data);
616
+ }
617
+ function createBBox2d() {
618
+ return {
619
+ __bk2d_bbox: true,
620
+ xMin: Infinity,
621
+ yMin: Infinity,
622
+ xMax: -Infinity,
623
+ yMax: -Infinity
624
+ };
625
+ }
626
+ function addCurveToBBox(bbox, c, _tol) {
627
+ const basis = c.__bk2d === "trimmed" ? c.basis : c;
628
+ if (basis.__bk2d === "line") {
629
+ const bounds = curveBounds(c);
630
+ if (!isFinite(bounds.first) || !isFinite(bounds.last)) return;
631
+ const [x0, y0] = evaluateCurve2d$1(c, bounds.first);
632
+ const [x1, y1] = evaluateCurve2d$1(c, bounds.last);
633
+ bbox.xMin = Math.min(bbox.xMin, x0, x1);
634
+ bbox.yMin = Math.min(bbox.yMin, y0, y1);
635
+ bbox.xMax = Math.max(bbox.xMax, x0, x1);
636
+ bbox.yMax = Math.max(bbox.yMax, y0, y1);
637
+ return;
638
+ }
639
+ if (basis.__bk2d === "circle") {
640
+ const bounds = curveBounds(c);
641
+ if (!isFinite(bounds.first) || !isFinite(bounds.last)) return;
642
+ const { cx, cy, radius, sense } = basis;
643
+ const [x0, y0] = evaluateCurve2d$1(c, bounds.first);
644
+ const [x1, y1] = evaluateCurve2d$1(c, bounds.last);
645
+ let xMin = Math.min(x0, x1), xMax = Math.max(x0, x1);
646
+ let yMin = Math.min(y0, y1), yMax = Math.max(y0, y1);
647
+ const tStart = c.__bk2d === "trimmed" ? c.tStart : bounds.first;
648
+ const tEnd = c.__bk2d === "trimmed" ? c.tEnd : bounds.last;
649
+ for (let k = 0; k < 4; k++) {
650
+ const angle = k * Math.PI / 2;
651
+ const t = sense ? angle : -angle;
652
+ for (let wrap = 0; wrap <= 1; wrap++) {
653
+ const tt = t + wrap * 2 * Math.PI;
654
+ if (tt >= tStart - 1e-10 && tt <= tEnd + 1e-10) {
655
+ const ex = cx + radius * Math.cos(angle);
656
+ const ey = cy + radius * Math.sin(angle);
657
+ xMin = Math.min(xMin, ex);
658
+ xMax = Math.max(xMax, ex);
659
+ yMin = Math.min(yMin, ey);
660
+ yMax = Math.max(yMax, ey);
661
+ break;
662
+ }
663
+ }
664
+ }
665
+ bbox.xMin = Math.min(bbox.xMin, xMin);
666
+ bbox.yMin = Math.min(bbox.yMin, yMin);
667
+ bbox.xMax = Math.max(bbox.xMax, xMax);
668
+ bbox.yMax = Math.max(bbox.yMax, yMax);
669
+ return;
670
+ }
671
+ const bounds = curveBounds(c);
672
+ if (!isFinite(bounds.first) || !isFinite(bounds.last)) return;
673
+ const nSamples = 20;
674
+ const dt = (bounds.last - bounds.first) / nSamples;
675
+ for (let i = 0; i <= nSamples; i++) {
676
+ const [x, y] = evaluateCurve2d$1(c, bounds.first + i * dt);
677
+ if (x < bbox.xMin) bbox.xMin = x;
678
+ if (y < bbox.yMin) bbox.yMin = y;
679
+ if (x > bbox.xMax) bbox.xMax = x;
680
+ if (y > bbox.yMax) bbox.yMax = y;
681
+ }
682
+ }
683
+ function evaluateBezier(poles, t) {
684
+ const n = poles.length;
685
+ const work = poles.map(([x, y]) => [x, y]);
686
+ for (let r = 1; r < n; r++) for (let i = 0; i < n - r; i++) {
687
+ const wi = work[i];
688
+ const wi1 = work[i + 1];
689
+ wi[0] = (1 - t) * wi[0] + t * wi1[0];
690
+ wi[1] = (1 - t) * wi[1] + t * wi1[1];
691
+ }
692
+ return work[0];
693
+ }
694
+ function evaluateBSpline2d(c, t) {
695
+ const fullKnots = [];
696
+ for (let i = 0; i < c.knots.length; i++) {
697
+ const mult = c.multiplicities[i] ?? 1;
698
+ for (let j = 0; j < mult; j++) fullKnots.push(c.knots[i]);
699
+ }
700
+ const p = c.degree;
701
+ const n = c.poles.length;
702
+ const k = fullKnots.length;
703
+ const tClamped = Math.max(fullKnots[p], Math.min(fullKnots[k - p - 1], t));
704
+ let span = p;
705
+ for (let i = p; i < k - p - 1; i++) if (tClamped >= fullKnots[i] && tClamped < fullKnots[i + 1]) {
706
+ span = i;
707
+ break;
708
+ }
709
+ if (tClamped >= fullKnots[k - p - 1]) span = k - p - 2;
710
+ const d = [];
711
+ for (let j = 0; j <= p; j++) {
712
+ const idx = Math.min(span - p + j, n - 1);
713
+ const pole = c.poles[Math.max(0, idx)];
714
+ d.push([pole[0], pole[1]]);
715
+ }
716
+ for (let r = 1; r <= p; r++) for (let j = p; j >= r; j--) {
717
+ const i = span - p + j;
718
+ const left = fullKnots[i] ?? 0;
719
+ const denom = (fullKnots[i + p - r + 1] ?? 1) - left;
720
+ const alpha = denom > 1e-15 ? (tClamped - left) / denom : 0;
721
+ const dj = d[j];
722
+ const djPrev = d[j - 1];
723
+ dj[0] = (1 - alpha) * djPrev[0] + alpha * dj[0];
724
+ dj[1] = (1 - alpha) * djPrev[1] + alpha * dj[1];
725
+ }
726
+ return d[p];
727
+ }
728
+ //#endregion
729
+ //#region src/kernel/occtWasm/helpers.ts
730
+ var noop = () => {};
731
+ /** Build an opaque kernel handle for an arena-allocated WASM shape. */
732
+ function handle(type, id) {
733
+ return {
734
+ __occtWasm: true,
735
+ type,
736
+ id,
737
+ delete: noop,
738
+ HashCode(upperBound) {
739
+ return id % upperBound;
740
+ },
741
+ IsNull() {
742
+ return false;
743
+ }
744
+ };
745
+ }
746
+ function isOcctWasmHandle(shape) {
747
+ return typeof shape === "object" && shape !== null && shape.__occtWasm;
748
+ }
749
+ /** Extract the u32 id from a handle. */
750
+ function unwrap(shape) {
751
+ if (isOcctWasmHandle(shape)) return shape.id;
752
+ if (typeof shape === "number") return shape;
753
+ throw new Error("occt-wasm: expected an OcctWasmHandle or number, got " + typeof shape);
754
+ }
755
+ /** Map a WASM shape type string to our ShapeType enum. */
756
+ function mapShapeType(wasmType) {
757
+ switch (wasmType.toLowerCase()) {
758
+ case "vertex": return "vertex";
759
+ case "edge": return "edge";
760
+ case "wire": return "wire";
761
+ case "face": return "face";
762
+ case "shell": return "shell";
763
+ case "solid": return "solid";
764
+ case "compsolid": return "compsolid";
765
+ case "compound": return "compound";
766
+ default: return "compound";
767
+ }
768
+ }
769
+ /** Wrap a WASM u32 result as a typed handle, querying the kernel for type. */
770
+ function wrapResult(kernel, id) {
771
+ return handle(mapShapeType(kernel.getShapeType(id)), id);
772
+ }
773
+ function makeVecU32(Module, values) {
774
+ const vec = new Module.VectorUint32();
775
+ for (const v of values) vec.push_back(v);
776
+ return vec;
777
+ }
778
+ function makeVecInt(Module, values) {
779
+ const vec = new Module.VectorInt();
780
+ for (const v of values) vec.push_back(v);
781
+ return vec;
782
+ }
783
+ function makeVecDouble(Module, values) {
784
+ const vec = new Module.VectorDouble();
785
+ for (const v of values) vec.push_back(v);
786
+ return vec;
787
+ }
788
+ function readVecInt(vec) {
789
+ const result = [];
790
+ const n = vec.size();
791
+ for (let i = 0; i < n; i++) result.push(vec.get(i));
792
+ return result;
793
+ }
794
+ /**
795
+ * 4x4 matrix multiplication in row-major order. Used by composeTransform
796
+ * and any other transform-stack composition.
797
+ */
798
+ function multiplyMatrices4x4(a, b) {
799
+ const result = new Array(16).fill(0);
800
+ for (let i = 0; i < 4; i++) for (let j = 0; j < 4; j++) for (let k = 0; k < 4; k++) result[i * 4 + j] = result[i * 4 + j] + a[i * 4 + k] * b[k * 4 + j];
801
+ return result;
802
+ }
803
+ /**
804
+ * Resolve a callback-style radius/distance to a uniform number.
805
+ * occt-wasm's fillet/chamfer take a single radius — uniform per call.
806
+ */
807
+ function resolveUniformRadius(edges, radius) {
808
+ if (typeof radius === "number") return radius;
809
+ if (Array.isArray(radius)) return radius[0];
810
+ if (edges.length === 0) throw new Error("occt-wasm: no edges provided");
811
+ const val = radius(edges[0]);
812
+ return typeof val === "number" ? val : val[0];
813
+ }
814
+ /**
815
+ * Rotate a shape from the kernel's default Z-axis to an arbitrary direction.
816
+ * Used by primitives whose creation API only takes a Z-aligned form.
817
+ */
818
+ function rotateZToDirection(k, shapeId, dir) {
819
+ const [dx, dy, dz] = dir;
820
+ const len = Math.sqrt(dx * dx + dy * dy + dz * dz);
821
+ if (len < 1e-10) return shapeId;
822
+ const nx = dx / len, ny = dy / len, nz = dz / len;
823
+ if (Math.abs(nz - 1) < 1e-10) return shapeId;
824
+ if (Math.abs(nz + 1) < 1e-10) return k.rotate(shapeId, 0, 0, 0, 1, 0, 0, Math.PI);
825
+ const ax = -ny, ay = nx;
826
+ const axLen = Math.sqrt(ax * ax + ay * ay);
827
+ if (axLen < 1e-10) return shapeId;
828
+ const angle = Math.acos(Math.max(-1, Math.min(1, nz)));
829
+ return k.rotate(shapeId, 0, 0, 0, ax / axLen, ay / axLen, 0, angle);
830
+ }
831
+ //#endregion
832
+ //#region src/kernel/occtWasm/adapterShims.ts
833
+ function wrapKernelExceptions(kernel, mod) {
834
+ return new Proxy(kernel, { get(target, prop, receiver) {
835
+ const val = Reflect.get(target, prop, receiver);
836
+ if (typeof val !== "function") return val;
837
+ return function(...args) {
838
+ try {
839
+ return val.apply(target, args);
840
+ } catch (ex) {
841
+ const WasmException = WebAssembly.Exception;
842
+ if (WasmException && ex instanceof WasmException) try {
843
+ const [, msg] = mod.getExceptionMessage(ex);
844
+ throw new Error(msg, { cause: ex });
845
+ } catch (inner) {
846
+ if (inner instanceof Error && !(inner instanceof WasmException)) throw inner;
847
+ }
848
+ throw ex;
849
+ }
850
+ };
851
+ } });
852
+ }
853
+ function buildOcShim(module, k) {
854
+ const makeNullCtor = function() {
855
+ return handle("compound", k.makeNullShape());
856
+ };
857
+ return Object.assign(Object.create(module), {
858
+ TopoDS_Solid: makeNullCtor,
859
+ TopoDS_Face: makeNullCtor,
860
+ TopoDS_Shape: makeNullCtor,
861
+ TopoDS_Wire: makeNullCtor,
862
+ TopoDS_Edge: makeNullCtor,
863
+ TopoDS_Vertex: makeNullCtor,
864
+ TopoDS_Shell: makeNullCtor,
865
+ TopoDS_Compound: makeNullCtor,
866
+ gp_Pnt_3: function(x, y, z) {
867
+ return handle("vertex", k.makeVertex(x, y, z));
868
+ },
869
+ BRepBuilderAPI_MakeEdge_3: function(p1, p2) {
870
+ const v1 = p1;
871
+ const v2 = p2;
872
+ const pos1 = k.vertexPosition(v1.id);
873
+ const pos2 = k.vertexPosition(v2.id);
874
+ const edgeId = k.makeLineEdge(pos1.get(0), pos1.get(1), pos1.get(2), pos2.get(0), pos2.get(1), pos2.get(2));
875
+ pos1.delete();
876
+ pos2.delete();
877
+ return {
878
+ Edge: () => handle("edge", edgeId),
879
+ delete() {}
880
+ };
881
+ }
882
+ });
883
+ }
884
+ //#endregion
885
+ //#region src/kernel/occtWasm/booleanOps.ts
886
+ function fuse(k, shape, tool, _options) {
887
+ return wrapResult(k, k.fuse(unwrap(shape), unwrap(tool)));
888
+ }
889
+ function cut(k, shape, tool, _options) {
890
+ return wrapResult(k, k.cut(unwrap(shape), unwrap(tool)));
891
+ }
892
+ function intersect(k, shape, tool, _options) {
893
+ return wrapResult(k, k.intersect(unwrap(shape), unwrap(tool)));
894
+ }
895
+ function section(k, shape, plane, _approximation) {
896
+ return wrapResult(k, k.section(unwrap(shape), unwrap(plane)));
897
+ }
898
+ function fuseAll(k, Module, shapes, _options) {
899
+ const vec = makeVecU32(Module, shapes.map(unwrap));
900
+ try {
901
+ return wrapResult(k, k.fuseAll(vec));
902
+ } finally {
903
+ vec.delete();
904
+ }
905
+ }
906
+ function cutAll(k, Module, shape, tools, _options) {
907
+ const vec = makeVecU32(Module, tools.map(unwrap));
908
+ try {
909
+ return wrapResult(k, k.cutAll(unwrap(shape), vec));
910
+ } finally {
911
+ vec.delete();
912
+ }
913
+ }
914
+ function split(k, Module, shape, tools) {
915
+ const vec = makeVecU32(Module, tools.map(unwrap));
916
+ try {
917
+ return wrapResult(k, k.split(unwrap(shape), vec));
918
+ } finally {
919
+ vec.delete();
920
+ }
921
+ }
922
+ function checkBoolean(k, shape, tool, _op) {
923
+ const issues = [];
924
+ if (k.isNull(unwrap(shape))) issues.push({
925
+ operand: "base",
926
+ issue: "null-shape",
927
+ message: "Base shape is null"
928
+ });
929
+ if (k.isNull(unwrap(tool))) issues.push({
930
+ operand: "tool",
931
+ issue: "null-shape",
932
+ message: "Tool shape is null"
933
+ });
934
+ if (issues.length === 0 && !k.isValid(unwrap(shape))) issues.push({
935
+ operand: "base",
936
+ issue: "not-valid",
937
+ message: "Base shape is not valid"
938
+ });
939
+ if (issues.length === 0 && !k.isValid(unwrap(tool))) issues.push({
940
+ operand: "tool",
941
+ issue: "not-valid",
942
+ message: "Tool shape is not valid"
943
+ });
944
+ return {
945
+ valid: issues.length === 0,
946
+ issues
947
+ };
948
+ }
949
+ function meshBoolean(_positionsA, _indicesA, _positionsB, _indicesB, _op, _tolerance) {
950
+ throw new Error("occt-wasm: meshBoolean is not supported (use brepkit for mesh booleans)");
951
+ }
952
+ //#endregion
953
+ //#region src/kernel/occtWasm/primitiveOps.ts
954
+ function makeBox(k, width, height, depth) {
955
+ return handle("solid", k.makeBox(width, height, depth));
956
+ }
957
+ function makeCylinder(k, radius, height, center, direction) {
958
+ let id = k.makeCylinder(radius, height);
959
+ if (direction) id = rotateZToDirection(k, id, direction);
960
+ if (center && (center[0] !== 0 || center[1] !== 0 || center[2] !== 0)) id = k.translate(id, center[0], center[1], center[2]);
961
+ return handle("solid", id);
962
+ }
963
+ function makeSphere(k, radius, center) {
964
+ let id = k.makeSphere(radius);
965
+ if (center && (center[0] !== 0 || center[1] !== 0 || center[2] !== 0)) id = k.translate(id, center[0], center[1], center[2]);
966
+ return handle("solid", id);
967
+ }
968
+ function makeCone(k, radius1, radius2, height, center, direction) {
969
+ let id = k.makeCone(radius1, radius2, height);
970
+ if (direction) id = rotateZToDirection(k, id, direction);
971
+ if (center && (center[0] !== 0 || center[1] !== 0 || center[2] !== 0)) id = k.translate(id, center[0], center[1], center[2]);
972
+ return handle("solid", id);
973
+ }
974
+ function makeTorus(k, majorRadius, minorRadius, center, direction) {
975
+ let id = k.makeTorus(majorRadius, minorRadius);
976
+ if (direction) id = rotateZToDirection(k, id, direction);
977
+ if (center && (center[0] !== 0 || center[1] !== 0 || center[2] !== 0)) id = k.translate(id, center[0], center[1], center[2]);
978
+ return handle("solid", id);
979
+ }
980
+ function makeEllipsoid(k, aLength, bLength, cLength) {
981
+ return handle("solid", k.makeEllipsoid(aLength, bLength, cLength));
982
+ }
983
+ function makeBoxFromCorners(k, p1, p2) {
984
+ return handle("solid", k.makeBoxFromCorners(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]));
985
+ }
986
+ function makeRectangle(k, width, height) {
987
+ return handle("face", k.makeRectangle(width, height));
988
+ }
989
+ //#endregion
990
+ //#region src/kernel/occtWasm/topologyOps.ts
991
+ function iterShapes(k, shape, type) {
992
+ const vec = k.getSubShapes(unwrap(shape), type);
993
+ const results = [];
994
+ try {
995
+ const n = vec.size();
996
+ for (let i = 0; i < n; i++) results.push(handle(type, vec.get(i)));
997
+ } finally {
998
+ vec.delete();
999
+ }
1000
+ return results;
1001
+ }
1002
+ function shapeType(k, shape) {
1003
+ if (isOcctWasmHandle(shape)) return shape.type;
1004
+ return mapShapeType(k.getShapeType(unwrap(shape)));
1005
+ }
1006
+ function isSame(k, a, b) {
1007
+ return k.isSame(unwrap(a), unwrap(b));
1008
+ }
1009
+ function isEqual(k, a, b) {
1010
+ return k.isEqual(unwrap(a), unwrap(b));
1011
+ }
1012
+ function downcast(k, shape, type) {
1013
+ if (type) return handle(type, k.downcast(unwrap(shape), type));
1014
+ return shape;
1015
+ }
1016
+ function hashCode(k, shape, upperBound) {
1017
+ return k.hashCode(unwrap(shape), upperBound);
1018
+ }
1019
+ function isNull(k, shape) {
1020
+ return k.isNull(unwrap(shape));
1021
+ }
1022
+ function shapeOrientation(k, shape) {
1023
+ return k.shapeOrientation(unwrap(shape)).toLowerCase();
1024
+ }
1025
+ function edgeToFaceMap(k, shape) {
1026
+ const vec = k.edgeToFaceMap(unwrap(shape), 1e6);
1027
+ let data;
1028
+ try {
1029
+ data = readVecInt(vec);
1030
+ } finally {
1031
+ vec.delete();
1032
+ }
1033
+ const map = {};
1034
+ for (let i = 0; i + 1 < data.length; i += 2) {
1035
+ const edgeHash = require_vec3.wasmIndex(data, i);
1036
+ const faceHash = require_vec3.wasmIndex(data, i + 1);
1037
+ if (!map[edgeHash]) map[edgeHash] = [];
1038
+ map[edgeHash].push(faceHash);
1039
+ }
1040
+ return JSON.stringify(map);
1041
+ }
1042
+ function sharedEdges(k, faceA, faceB) {
1043
+ const vec = k.sharedEdges(unwrap(faceA), unwrap(faceB));
1044
+ const results = [];
1045
+ try {
1046
+ const n = vec.size();
1047
+ for (let i = 0; i < n; i++) results.push(handle("edge", vec.get(i)));
1048
+ } finally {
1049
+ vec.delete();
1050
+ }
1051
+ return results;
1052
+ }
1053
+ function adjacentFaces(k, shape, face) {
1054
+ const vec = k.adjacentFaces(unwrap(shape), unwrap(face));
1055
+ const results = [];
1056
+ try {
1057
+ const n = vec.size();
1058
+ for (let i = 0; i < n; i++) results.push(handle("face", vec.get(i)));
1059
+ } finally {
1060
+ vec.delete();
1061
+ }
1062
+ return results;
1063
+ }
1064
+ function sew(k, Module, shapes, tolerance) {
1065
+ const vec = makeVecU32(Module, shapes.map(unwrap));
1066
+ try {
1067
+ return wrapResult(k, k.sew(vec, tolerance ?? 1e-6));
1068
+ } finally {
1069
+ vec.delete();
1070
+ }
1071
+ }
1072
+ //#endregion
1073
+ //#region src/kernel/occtWasm/repairOps.ts
1074
+ var HEAL_TOLERANCE = 1e-6;
1075
+ function isValid(k, shape) {
1076
+ return k.isValid(unwrap(shape));
1077
+ }
1078
+ function healSolid(k, shape) {
1079
+ const id = k.healSolid(unwrap(shape), HEAL_TOLERANCE);
1080
+ if (id === 0) return null;
1081
+ return wrapResult(k, id);
1082
+ }
1083
+ function healFace(k, shape) {
1084
+ return wrapResult(k, k.healFace(unwrap(shape), HEAL_TOLERANCE));
1085
+ }
1086
+ function healWire(k, wire, _face) {
1087
+ return wrapResult(k, k.healWire(unwrap(wire), HEAL_TOLERANCE));
1088
+ }
1089
+ function mergeCoincidentVertices(_k, _shape, _tolerance) {
1090
+ return 0;
1091
+ }
1092
+ function removeDegenerateEdges(k, shape, _tolerance) {
1093
+ k.removeDegenerateEdges(unwrap(shape));
1094
+ return 0;
1095
+ }
1096
+ function fixFaceOrientations(k, shape) {
1097
+ k.fixFaceOrientations(unwrap(shape));
1098
+ return 0;
1099
+ }
1100
+ function fixShape(k, shape) {
1101
+ return wrapResult(k, k.fixShape(unwrap(shape)));
1102
+ }
1103
+ //#endregion
1104
+ //#region src/kernel/occtWasm/meshOps.ts
1105
+ function mesh(k, Module, shape, options) {
1106
+ const meshData = k.tessellate(unwrap(shape), options.tolerance, options.angularTolerance);
1107
+ try {
1108
+ const posCount = meshData.positionCount;
1109
+ const normCount = meshData.normalCount;
1110
+ const idxCount = meshData.indexCount;
1111
+ const posPtr = meshData.getPositionsPtr() >> 2;
1112
+ const normPtr = meshData.getNormalsPtr() >> 2;
1113
+ const idxPtr = meshData.getIndicesPtr() >> 2;
1114
+ const vertices = new Float32Array(posCount);
1115
+ for (let i = 0; i < posCount; i++) vertices[i] = Module.HEAPF32[posPtr + i] ?? 0;
1116
+ const normals = new Float32Array(normCount);
1117
+ if (!options.skipNormals) for (let i = 0; i < normCount; i++) normals[i] = Module.HEAPF32[normPtr + i] ?? 0;
1118
+ const triangles = new Uint32Array(idxCount);
1119
+ for (let i = 0; i < idxCount; i++) triangles[i] = Module.HEAPU32[idxPtr + i] ?? 0;
1120
+ const faceGroups = [];
1121
+ const fgCount = meshData.faceGroupCount;
1122
+ if (fgCount > 0) {
1123
+ const fgPtr = meshData.getFaceGroupsPtr() >> 2;
1124
+ for (let i = 0; i < fgCount; i += 3) faceGroups.push({
1125
+ start: Module.HEAP32[fgPtr + i] ?? 0,
1126
+ count: Module.HEAP32[fgPtr + i + 1] ?? 0,
1127
+ faceHash: Module.HEAP32[fgPtr + i + 2] ?? 0
1128
+ });
1129
+ }
1130
+ return {
1131
+ vertices,
1132
+ normals: options.skipNormals ? new Float32Array(0) : normals,
1133
+ triangles,
1134
+ uvs: new Float32Array(0),
1135
+ faceGroups
1136
+ };
1137
+ } finally {
1138
+ meshData.delete();
1139
+ }
1140
+ }
1141
+ function meshEdges(k, Module, shape, tolerance, _angularTolerance) {
1142
+ const edgeData = k.wireframe(unwrap(shape), tolerance);
1143
+ try {
1144
+ const pointCount = edgeData.pointCount;
1145
+ const ptr = edgeData.getPointsPtr() >> 2;
1146
+ const lines = new Float32Array(pointCount);
1147
+ for (let i = 0; i < pointCount; i++) lines[i] = Module.HEAPF32[ptr + i] ?? 0;
1148
+ const edgeGroups = [];
1149
+ const egCount = edgeData.edgeGroupCount;
1150
+ if (egCount > 0) {
1151
+ const egPtr = edgeData.getEdgeGroupsPtr() >> 2;
1152
+ for (let i = 0; i < egCount; i += 3) edgeGroups.push({
1153
+ start: Module.HEAP32[egPtr + i] ?? 0,
1154
+ count: Module.HEAP32[egPtr + i + 1] ?? 0,
1155
+ edgeHash: Module.HEAP32[egPtr + i + 2] ?? 0
1156
+ });
1157
+ }
1158
+ return {
1159
+ lines,
1160
+ edgeGroups
1161
+ };
1162
+ } finally {
1163
+ edgeData.delete();
1164
+ }
1165
+ }
1166
+ function hasTriangulation(k, shape) {
1167
+ return k.hasTriangulation(unwrap(shape));
1168
+ }
1169
+ function meshShape(k, shape, tolerance, angularTolerance) {
1170
+ k.meshShape(unwrap(shape), tolerance, angularTolerance).delete();
1171
+ }
1172
+ //#endregion
1173
+ //#region src/kernel/occtWasm/curveOps.ts
1174
+ var CURVE_TYPE_MAP = {
1175
+ line: "LINE",
1176
+ circle: "CIRCLE",
1177
+ ellipse: "ELLIPSE",
1178
+ hyperbola: "HYPERBOLA",
1179
+ parabola: "PARABOLA",
1180
+ bezier: "BEZIER_CURVE",
1181
+ bspline: "BSPLINE_CURVE",
1182
+ offset: "OFFSET_CURVE",
1183
+ other: "OTHER_CURVE"
1184
+ };
1185
+ function curveType(k, shape) {
1186
+ const t = k.curveType(unwrap(shape));
1187
+ return CURVE_TYPE_MAP[t] ?? t.toUpperCase();
1188
+ }
1189
+ function curveParameters(k, shape) {
1190
+ const vec = k.curveParameters(unwrap(shape));
1191
+ try {
1192
+ return [vec.get(0), vec.get(1)];
1193
+ } finally {
1194
+ vec.delete();
1195
+ }
1196
+ }
1197
+ function curvePointAtParam(k, shape, param) {
1198
+ const vec = k.curvePointAtParam(unwrap(shape), param);
1199
+ try {
1200
+ return [
1201
+ vec.get(0),
1202
+ vec.get(1),
1203
+ vec.get(2)
1204
+ ];
1205
+ } finally {
1206
+ vec.delete();
1207
+ }
1208
+ }
1209
+ function curveTangent(k, shape, param) {
1210
+ const tvec = k.curveTangent(unwrap(shape), param);
1211
+ try {
1212
+ const pvec = k.curvePointAtParam(unwrap(shape), param);
1213
+ try {
1214
+ return {
1215
+ point: [
1216
+ pvec.get(0),
1217
+ pvec.get(1),
1218
+ pvec.get(2)
1219
+ ],
1220
+ tangent: [
1221
+ tvec.get(0),
1222
+ tvec.get(1),
1223
+ tvec.get(2)
1224
+ ]
1225
+ };
1226
+ } finally {
1227
+ pvec.delete();
1228
+ }
1229
+ } finally {
1230
+ tvec.delete();
1231
+ }
1232
+ }
1233
+ function curveIsClosed(k, shape) {
1234
+ return k.curveIsClosed(unwrap(shape));
1235
+ }
1236
+ function curveIsPeriodic(k, shape) {
1237
+ return k.curveIsPeriodic(unwrap(shape));
1238
+ }
1239
+ function curvePeriod(_k, _shape) {
1240
+ return 2 * Math.PI;
1241
+ }
1242
+ function interpolatePoints(k, Module, points, options) {
1243
+ const flat = [];
1244
+ for (const p of points) flat.push(p[0], p[1], p[2]);
1245
+ const vec = makeVecDouble(Module, flat);
1246
+ try {
1247
+ return handle("edge", k.interpolatePoints(vec, options?.periodic ?? false));
1248
+ } finally {
1249
+ vec.delete();
1250
+ }
1251
+ }
1252
+ function approximatePoints(k, Module, points, options) {
1253
+ const flat = [];
1254
+ for (const p of points) flat.push(p[0], p[1], p[2]);
1255
+ const vec = makeVecDouble(Module, flat);
1256
+ try {
1257
+ return handle("edge", k.approximatePoints(vec, options?.tolerance ?? .001));
1258
+ } finally {
1259
+ vec.delete();
1260
+ }
1261
+ }
1262
+ function getNurbsCurveData(k, edge) {
1263
+ try {
1264
+ const data = k.getNurbsCurveData(unwrap(edge));
1265
+ try {
1266
+ const nPoles = data.poles.size() / 3;
1267
+ const poles = [];
1268
+ for (let i = 0; i < nPoles; i++) poles.push([
1269
+ data.poles.get(i * 3),
1270
+ data.poles.get(i * 3 + 1),
1271
+ data.poles.get(i * 3 + 2)
1272
+ ]);
1273
+ const knots = [];
1274
+ for (let i = 0; i < data.knots.size(); i++) knots.push(data.knots.get(i));
1275
+ const multiplicities = [];
1276
+ for (let i = 0; i < data.multiplicities.size(); i++) multiplicities.push(data.multiplicities.get(i));
1277
+ const weights = [];
1278
+ if (data.rational) for (let i = 0; i < data.weights.size(); i++) weights.push(data.weights.get(i));
1279
+ else for (let i = 0; i < nPoles; i++) weights.push(1);
1280
+ return {
1281
+ degree: data.degree,
1282
+ poles,
1283
+ weights,
1284
+ knots,
1285
+ multiplicities,
1286
+ isPeriodic: data.periodic,
1287
+ isRational: data.rational
1288
+ };
1289
+ } finally {
1290
+ data.delete();
1291
+ }
1292
+ } catch {
1293
+ return null;
1294
+ }
1295
+ }
1296
+ //#endregion
1297
+ //#region src/kernel/occtWasm/surfaceOps.ts
1298
+ function vertexPosition(k, vertex) {
1299
+ const vec = k.vertexPosition(unwrap(vertex));
1300
+ try {
1301
+ return [
1302
+ vec.get(0),
1303
+ vec.get(1),
1304
+ vec.get(2)
1305
+ ];
1306
+ } finally {
1307
+ vec.delete();
1308
+ }
1309
+ }
1310
+ function surfaceType(k, face) {
1311
+ return k.surfaceType(unwrap(face)).toLowerCase();
1312
+ }
1313
+ function uvBounds(k, face) {
1314
+ const vec = k.uvBounds(unwrap(face));
1315
+ try {
1316
+ return {
1317
+ uMin: vec.get(0),
1318
+ uMax: vec.get(1),
1319
+ vMin: vec.get(2),
1320
+ vMax: vec.get(3)
1321
+ };
1322
+ } finally {
1323
+ vec.delete();
1324
+ }
1325
+ }
1326
+ function outerWire(k, face) {
1327
+ return handle("wire", k.outerWire(unwrap(face)));
1328
+ }
1329
+ function surfaceNormal(k, face, u, v) {
1330
+ const vec = k.surfaceNormal(unwrap(face), u, v);
1331
+ try {
1332
+ return [
1333
+ vec.get(0),
1334
+ vec.get(1),
1335
+ vec.get(2)
1336
+ ];
1337
+ } finally {
1338
+ vec.delete();
1339
+ }
1340
+ }
1341
+ function pointOnSurface(k, face, u, v) {
1342
+ const vec = k.pointOnSurface(unwrap(face), u, v);
1343
+ try {
1344
+ return [
1345
+ vec.get(0),
1346
+ vec.get(1),
1347
+ vec.get(2)
1348
+ ];
1349
+ } finally {
1350
+ vec.delete();
1351
+ }
1352
+ }
1353
+ function uvFromPoint(k, face, point) {
1354
+ const vec = k.uvFromPoint(unwrap(face), point[0], point[1], point[2]);
1355
+ try {
1356
+ if (vec.size() < 2) return null;
1357
+ return [vec.get(0), vec.get(1)];
1358
+ } finally {
1359
+ vec.delete();
1360
+ }
1361
+ }
1362
+ function projectPointOnFace(k, face, point) {
1363
+ const vec = k.projectPointOnFace(unwrap(face), point[0], point[1], point[2]);
1364
+ try {
1365
+ return [
1366
+ vec.get(0),
1367
+ vec.get(1),
1368
+ vec.get(2)
1369
+ ];
1370
+ } finally {
1371
+ vec.delete();
1372
+ }
1373
+ }
1374
+ function classifyPointOnFace(k, face, u, v, _tolerance) {
1375
+ return k.classifyPointOnFace(unwrap(face), u, v).toLowerCase();
1376
+ }
1377
+ function projectEdges(k, Module, shape, cameraOrigin, cameraDirection, cameraXAxis) {
1378
+ const [ox, oy, oz] = cameraOrigin;
1379
+ const [dx, dy, dz] = cameraDirection;
1380
+ const hasXAxis = !!cameraXAxis;
1381
+ const [xx, xy, xz] = cameraXAxis ?? [
1382
+ 1,
1383
+ 0,
1384
+ 0
1385
+ ];
1386
+ const proj = k.projectEdges(unwrap(shape), ox, oy, oz, dx, dy, dz, xx, xy, xz, hasXAxis);
1387
+ const wrapOrNull = (id) => id === 0 ? handle("compound", k.makeCompound(new Module.VectorUint32())) : handle("compound", id);
1388
+ return {
1389
+ visible: {
1390
+ outline: wrapOrNull(proj.visibleOutline),
1391
+ smooth: wrapOrNull(proj.visibleSmooth),
1392
+ sharp: wrapOrNull(proj.visibleSharp)
1393
+ },
1394
+ hidden: {
1395
+ outline: wrapOrNull(proj.hiddenOutline),
1396
+ smooth: wrapOrNull(proj.hiddenSmooth),
1397
+ sharp: wrapOrNull(proj.hiddenSharp)
1398
+ }
1399
+ };
1400
+ }
1401
+ //#endregion
1402
+ //#region src/kernel/occtWasm/measureOps.ts
1403
+ function volume(k, shape) {
1404
+ return k.getVolume(unwrap(shape));
1405
+ }
1406
+ function area(k, shape) {
1407
+ return k.getSurfaceArea(unwrap(shape));
1408
+ }
1409
+ function length(k, shape) {
1410
+ return k.getLength(unwrap(shape));
1411
+ }
1412
+ function centerOfMass(k, shape) {
1413
+ const vec = k.getCenterOfMass(unwrap(shape));
1414
+ try {
1415
+ return [
1416
+ vec.get(0),
1417
+ vec.get(1),
1418
+ vec.get(2)
1419
+ ];
1420
+ } finally {
1421
+ vec.delete();
1422
+ }
1423
+ }
1424
+ function linearCenterOfMass(k, shape) {
1425
+ const vec = k.getLinearCenterOfMass(unwrap(shape));
1426
+ try {
1427
+ return [
1428
+ vec.get(0),
1429
+ vec.get(1),
1430
+ vec.get(2)
1431
+ ];
1432
+ } finally {
1433
+ vec.delete();
1434
+ }
1435
+ }
1436
+ function boundingBox(k, shape) {
1437
+ const bb = k.getBoundingBox(unwrap(shape), true);
1438
+ return {
1439
+ min: [
1440
+ bb.xmin,
1441
+ bb.ymin,
1442
+ bb.zmin
1443
+ ],
1444
+ max: [
1445
+ bb.xmax,
1446
+ bb.ymax,
1447
+ bb.zmax
1448
+ ]
1449
+ };
1450
+ }
1451
+ function surfaceCenterOfMass(k, face) {
1452
+ try {
1453
+ const v = k.getSurfaceCenterOfMass(unwrap(face));
1454
+ try {
1455
+ return [
1456
+ v.get(0),
1457
+ v.get(1),
1458
+ v.get(2)
1459
+ ];
1460
+ } finally {
1461
+ v.delete();
1462
+ }
1463
+ } catch {
1464
+ return [
1465
+ 0,
1466
+ 0,
1467
+ 0
1468
+ ];
1469
+ }
1470
+ }
1471
+ function measureBulk(k, shape, includeLinear) {
1472
+ return {
1473
+ volume: volume(k, shape),
1474
+ area: area(k, shape),
1475
+ length: includeLinear ? length(k, shape) : 0,
1476
+ centerOfMass: centerOfMass(k, shape),
1477
+ boundingBox: boundingBox(k, shape)
1478
+ };
1479
+ }
1480
+ function createDistanceQuery(k, referenceShape) {
1481
+ const refId = unwrap(referenceShape);
1482
+ return {
1483
+ distanceTo(shape) {
1484
+ return {
1485
+ value: k.distanceBetween(refId, unwrap(shape)),
1486
+ point1: [
1487
+ 0,
1488
+ 0,
1489
+ 0
1490
+ ],
1491
+ point2: [
1492
+ 0,
1493
+ 0,
1494
+ 0
1495
+ ]
1496
+ };
1497
+ },
1498
+ dispose: noop
1499
+ };
1500
+ }
1501
+ var MAX_MESH_SAMPLES = 256;
1502
+ /**
1503
+ * Collect 3D sample points from a shape for nearest-pair queries: every
1504
+ * topological vertex, plus tessellation vertices when the shape carries
1505
+ * surfaces. Used by distance() to approximate witness points.
1506
+ */
1507
+ function collectDistanceSamples(k, mod, shapeId) {
1508
+ const out = [];
1509
+ const verts = k.getSubShapes(shapeId, "vertex");
1510
+ try {
1511
+ const n = verts.size();
1512
+ for (let i = 0; i < n; i++) {
1513
+ const p = k.vertexPosition(verts.get(i));
1514
+ out.push([
1515
+ p.get(0),
1516
+ p.get(1),
1517
+ p.get(2)
1518
+ ]);
1519
+ p.delete();
1520
+ }
1521
+ } finally {
1522
+ verts.delete();
1523
+ }
1524
+ const bb = k.getBoundingBox(shapeId, true);
1525
+ const diag = Math.sqrt((bb.xmax - bb.xmin) ** 2 + (bb.ymax - bb.ymin) ** 2 + (bb.zmax - bb.zmin) ** 2);
1526
+ const linDef = Math.max(diag * .01, 1e-4);
1527
+ let mesh;
1528
+ try {
1529
+ mesh = k.tessellate(shapeId, linDef, .5);
1530
+ } catch {
1531
+ return out;
1532
+ }
1533
+ try {
1534
+ const posCount = mesh.positionCount;
1535
+ if (posCount > 0) {
1536
+ const ptr = mesh.getPositionsPtr() >> 2;
1537
+ const heap = mod.HEAPF32;
1538
+ const vertexCount = Math.floor(posCount / 3);
1539
+ const step = (vertexCount > MAX_MESH_SAMPLES ? Math.ceil(vertexCount / MAX_MESH_SAMPLES) : 1) * 3;
1540
+ for (let i = 0; i < posCount; i += step) out.push([
1541
+ heap[ptr + i] ?? 0,
1542
+ heap[ptr + i + 1] ?? 0,
1543
+ heap[ptr + i + 2] ?? 0
1544
+ ]);
1545
+ }
1546
+ } finally {
1547
+ mesh.delete();
1548
+ }
1549
+ return out;
1550
+ }
1551
+ function distance(k, mod, shape1, shape2) {
1552
+ const id1 = unwrap(shape1);
1553
+ const id2 = unwrap(shape2);
1554
+ const value = k.distanceBetween(id1, id2);
1555
+ const samples1 = collectDistanceSamples(k, mod, id1);
1556
+ const samples2 = collectDistanceSamples(k, mod, id2);
1557
+ if (samples1.length === 0 || samples2.length === 0) return {
1558
+ value,
1559
+ point1: [
1560
+ 0,
1561
+ 0,
1562
+ 0
1563
+ ],
1564
+ point2: [
1565
+ 0,
1566
+ 0,
1567
+ 0
1568
+ ]
1569
+ };
1570
+ let bestD2 = Infinity;
1571
+ let bestP1 = samples1[0] ?? [
1572
+ 0,
1573
+ 0,
1574
+ 0
1575
+ ];
1576
+ let bestP2 = samples2[0] ?? [
1577
+ 0,
1578
+ 0,
1579
+ 0
1580
+ ];
1581
+ for (const p1 of samples1) for (const p2 of samples2) {
1582
+ const dx = p2[0] - p1[0];
1583
+ const dy = p2[1] - p1[1];
1584
+ const dz = p2[2] - p1[2];
1585
+ const d2 = dx * dx + dy * dy + dz * dz;
1586
+ if (d2 < bestD2) {
1587
+ bestD2 = d2;
1588
+ bestP1 = p1;
1589
+ bestP2 = p2;
1590
+ }
1591
+ }
1592
+ return {
1593
+ value,
1594
+ point1: bestP1,
1595
+ point2: bestP2
1596
+ };
1597
+ }
1598
+ function pointAt(k, faceId, u, v) {
1599
+ const p = k.pointOnSurface(faceId, u, v);
1600
+ const r = [
1601
+ p.get(0),
1602
+ p.get(1),
1603
+ p.get(2)
1604
+ ];
1605
+ p.delete();
1606
+ return r;
1607
+ }
1608
+ /**
1609
+ * Sample a 9-point stencil around (u, v) and return central-difference
1610
+ * partial derivatives Pu, Pv, Puu, Pvv, Puv. Step size is 1e-3 of the
1611
+ * parametric range (clamped at 1e-6) — the sweet spot between truncation
1612
+ * error and float-eval noise. Near the boundary the stencil shifts inward
1613
+ * so all sample points stay in the domain.
1614
+ */
1615
+ function surfaceDerivatives(k, faceId, u, v) {
1616
+ const bounds = k.uvBounds(faceId);
1617
+ const uMin = bounds.get(0);
1618
+ const uMax = bounds.get(1);
1619
+ const vMin = bounds.get(2);
1620
+ const vMax = bounds.get(3);
1621
+ bounds.delete();
1622
+ const hu = Math.max(Math.max(uMax - uMin, 1e-12) * .001, 1e-6);
1623
+ const hv = Math.max(Math.max(vMax - vMin, 1e-12) * .001, 1e-6);
1624
+ const uc = Math.min(Math.max(u, uMin + hu), uMax - hu);
1625
+ const vc = Math.min(Math.max(v, vMin + hv), vMax - hv);
1626
+ const P = pointAt(k, faceId, uc, vc);
1627
+ const Pup = pointAt(k, faceId, uc + hu, vc);
1628
+ const Pum = pointAt(k, faceId, uc - hu, vc);
1629
+ const Pvp = pointAt(k, faceId, uc, vc + hv);
1630
+ const Pvm = pointAt(k, faceId, uc, vc - hv);
1631
+ const Ppp = pointAt(k, faceId, uc + hu, vc + hv);
1632
+ const Ppm = pointAt(k, faceId, uc + hu, vc - hv);
1633
+ const Pmp = pointAt(k, faceId, uc - hu, vc + hv);
1634
+ const Pmm = pointAt(k, faceId, uc - hu, vc - hv);
1635
+ const huu = hu * hu;
1636
+ const hvv = hv * hv;
1637
+ const huv4 = 4 * hu * hv;
1638
+ return {
1639
+ Pu: [
1640
+ (Pup[0] - Pum[0]) / (2 * hu),
1641
+ (Pup[1] - Pum[1]) / (2 * hu),
1642
+ (Pup[2] - Pum[2]) / (2 * hu)
1643
+ ],
1644
+ Pv: [
1645
+ (Pvp[0] - Pvm[0]) / (2 * hv),
1646
+ (Pvp[1] - Pvm[1]) / (2 * hv),
1647
+ (Pvp[2] - Pvm[2]) / (2 * hv)
1648
+ ],
1649
+ Puu: [
1650
+ (Pup[0] - 2 * P[0] + Pum[0]) / huu,
1651
+ (Pup[1] - 2 * P[1] + Pum[1]) / huu,
1652
+ (Pup[2] - 2 * P[2] + Pum[2]) / huu
1653
+ ],
1654
+ Pvv: [
1655
+ (Pvp[0] - 2 * P[0] + Pvm[0]) / hvv,
1656
+ (Pvp[1] - 2 * P[1] + Pvm[1]) / hvv,
1657
+ (Pvp[2] - 2 * P[2] + Pvm[2]) / hvv
1658
+ ],
1659
+ Puv: [
1660
+ (Ppp[0] - Ppm[0] - Pmp[0] + Pmm[0]) / huv4,
1661
+ (Ppp[1] - Ppm[1] - Pmp[1] + Pmm[1]) / huv4,
1662
+ (Ppp[2] - Ppm[2] - Pmp[2] + Pmm[2]) / huv4
1663
+ ]
1664
+ };
1665
+ }
1666
+ /**
1667
+ * Return a non-zero eigenvector of the singular matrix [[a,b],[c,d]] (whose
1668
+ * eigenvalue is implicit — caller has already subtracted λ from the diagonal).
1669
+ * Picks the row with the larger magnitude for numerical stability.
1670
+ */
1671
+ function eigenvector2x2(a, b, c, d) {
1672
+ if (Math.abs(a) + Math.abs(b) >= Math.abs(c) + Math.abs(d)) {
1673
+ if (Math.abs(a) + Math.abs(b) < 1e-12) return [1, 0];
1674
+ return [-b, a];
1675
+ }
1676
+ if (Math.abs(c) + Math.abs(d) < 1e-12) return [0, 1];
1677
+ return [-d, c];
1678
+ }
1679
+ function liftAndNormalize(ab, Pu, Pv) {
1680
+ const x = ab[0] * Pu[0] + ab[1] * Pv[0];
1681
+ const y = ab[0] * Pu[1] + ab[1] * Pv[1];
1682
+ const z = ab[0] * Pu[2] + ab[1] * Pv[2];
1683
+ const len = Math.sqrt(x * x + y * y + z * z);
1684
+ if (len < 1e-12) return [
1685
+ 1,
1686
+ 0,
1687
+ 0
1688
+ ];
1689
+ return [
1690
+ x / len,
1691
+ y / len,
1692
+ z / len
1693
+ ];
1694
+ }
1695
+ /**
1696
+ * Fallback when curvature is direction-degenerate: return an orthonormal
1697
+ * tangent frame derived from Pu and the Gram-Schmidt-corrected Pv.
1698
+ */
1699
+ function degenerateOrthoFrame(Pu, Pv) {
1700
+ const uLen = Math.sqrt(Pu[0] * Pu[0] + Pu[1] * Pu[1] + Pu[2] * Pu[2]);
1701
+ if (uLen < 1e-12) return {
1702
+ maxDirection: [
1703
+ 1,
1704
+ 0,
1705
+ 0
1706
+ ],
1707
+ minDirection: [
1708
+ 0,
1709
+ 1,
1710
+ 0
1711
+ ]
1712
+ };
1713
+ const ux = Pu[0] / uLen, uy = Pu[1] / uLen, uz = Pu[2] / uLen;
1714
+ const dot = ux * Pv[0] + uy * Pv[1] + uz * Pv[2];
1715
+ const vx = Pv[0] - dot * ux;
1716
+ const vy = Pv[1] - dot * uy;
1717
+ const vz = Pv[2] - dot * uz;
1718
+ const vLen = Math.sqrt(vx * vx + vy * vy + vz * vz);
1719
+ if (vLen < 1e-12) {
1720
+ const ax = Math.abs(ux) < .9 ? [
1721
+ 1,
1722
+ 0,
1723
+ 0
1724
+ ] : [
1725
+ 0,
1726
+ 1,
1727
+ 0
1728
+ ];
1729
+ const ox = uy * ax[2] - uz * ax[1];
1730
+ const oy = uz * ax[0] - ux * ax[2];
1731
+ const oz = ux * ax[1] - uy * ax[0];
1732
+ const oLen = Math.sqrt(ox * ox + oy * oy + oz * oz) || 1;
1733
+ return {
1734
+ maxDirection: [
1735
+ ux,
1736
+ uy,
1737
+ uz
1738
+ ],
1739
+ minDirection: [
1740
+ ox / oLen,
1741
+ oy / oLen,
1742
+ oz / oLen
1743
+ ]
1744
+ };
1745
+ }
1746
+ return {
1747
+ maxDirection: [
1748
+ ux,
1749
+ uy,
1750
+ uz
1751
+ ],
1752
+ minDirection: [
1753
+ vx / vLen,
1754
+ vy / vLen,
1755
+ vz / vLen
1756
+ ]
1757
+ };
1758
+ }
1759
+ /**
1760
+ * Compute principal curvature directions at (u, v) via finite-difference
1761
+ * fundamental forms. The C++ facade exposes only k1 and k2 as scalars; this
1762
+ * helper recovers the corresponding tangent directions in 3D space.
1763
+ */
1764
+ function computePrincipalDirections(k, faceId, u, v, maxK, minK) {
1765
+ const { Pu, Pv, Puu, Pvv, Puv } = surfaceDerivatives(k, faceId, u, v);
1766
+ const nx = Pu[1] * Pv[2] - Pu[2] * Pv[1];
1767
+ const ny = Pu[2] * Pv[0] - Pu[0] * Pv[2];
1768
+ const nz = Pu[0] * Pv[1] - Pu[1] * Pv[0];
1769
+ const nlen = Math.sqrt(nx * nx + ny * ny + nz * nz);
1770
+ const E = Pu[0] * Pu[0] + Pu[1] * Pu[1] + Pu[2] * Pu[2];
1771
+ const F = Pu[0] * Pv[0] + Pu[1] * Pv[1] + Pu[2] * Pv[2];
1772
+ const G = Pv[0] * Pv[0] + Pv[1] * Pv[1] + Pv[2] * Pv[2];
1773
+ if (nlen < 1e-12 || E * G - F * F < 1e-24) return degenerateOrthoFrame(Pu, Pv);
1774
+ const e = (Puu[0] * nx + Puu[1] * ny + Puu[2] * nz) / nlen;
1775
+ const f = (Puv[0] * nx + Puv[1] * ny + Puv[2] * nz) / nlen;
1776
+ const g = (Pvv[0] * nx + Pvv[1] * ny + Pvv[2] * nz) / nlen;
1777
+ const det = E * G - F * F;
1778
+ const w11 = (e * G - f * F) / det;
1779
+ const w12 = (f * G - g * F) / det;
1780
+ const w21 = (f * E - e * F) / det;
1781
+ const w22 = (g * E - f * F) / det;
1782
+ if (Math.abs(maxK - minK) < 1e-9 * (Math.abs(maxK) + Math.abs(minK) + 1)) return degenerateOrthoFrame(Pu, Pv);
1783
+ const dirMax2D = eigenvector2x2(w11 - maxK, w12, w21, w22 - maxK);
1784
+ const dirMin2D = eigenvector2x2(w11 - minK, w12, w21, w22 - minK);
1785
+ return {
1786
+ maxDirection: liftAndNormalize(dirMax2D, Pu, Pv),
1787
+ minDirection: liftAndNormalize(dirMin2D, Pu, Pv)
1788
+ };
1789
+ }
1790
+ function surfaceCurvature(k, face, u, v) {
1791
+ const faceId = unwrap(face);
1792
+ const vec = k.surfaceCurvature(faceId, u, v);
1793
+ const mean = vec.get(0);
1794
+ const gaussian = vec.get(1);
1795
+ const maxK = vec.get(2);
1796
+ const minK = vec.get(3);
1797
+ vec.delete();
1798
+ const { maxDirection, minDirection } = computePrincipalDirections(k, faceId, u, v, maxK, minK);
1799
+ return {
1800
+ gaussian,
1801
+ mean,
1802
+ max: maxK,
1803
+ min: minK,
1804
+ maxDirection,
1805
+ minDirection
1806
+ };
1807
+ }
1808
+ //#endregion
1809
+ //#region src/kernel/occtWasm/modifierOps.ts
1810
+ function fillet(k, Module, shape, edges, radius) {
1811
+ const r = resolveUniformRadius(edges, radius);
1812
+ const vec = makeVecU32(Module, edges.map(unwrap));
1813
+ try {
1814
+ return wrapResult(k, k.fillet(unwrap(shape), vec, r));
1815
+ } finally {
1816
+ vec.delete();
1817
+ }
1818
+ }
1819
+ function chamfer(k, Module, shape, edges, distance) {
1820
+ const d = resolveUniformRadius(edges, distance);
1821
+ const vec = makeVecU32(Module, edges.map(unwrap));
1822
+ try {
1823
+ return wrapResult(k, k.chamfer(unwrap(shape), vec, d));
1824
+ } finally {
1825
+ vec.delete();
1826
+ }
1827
+ }
1828
+ function chamferDistAngle(k, Module, shape, edges, distance, angleDeg) {
1829
+ const vec = makeVecU32(Module, edges.map(unwrap));
1830
+ try {
1831
+ return wrapResult(k, k.chamferDistAngle(unwrap(shape), vec, distance, angleDeg));
1832
+ } finally {
1833
+ vec.delete();
1834
+ }
1835
+ }
1836
+ function shell(k, Module, shape, faces, thickness, tolerance) {
1837
+ const vec = makeVecU32(Module, faces.map(unwrap));
1838
+ try {
1839
+ return wrapResult(k, k.shell(unwrap(shape), vec, thickness, tolerance ?? .001));
1840
+ } finally {
1841
+ vec.delete();
1842
+ }
1843
+ }
1844
+ function thicken(k, shape, thickness) {
1845
+ return wrapResult(k, k.thicken(unwrap(shape), thickness, .001));
1846
+ }
1847
+ function offset(k, shape, distance, tolerance) {
1848
+ return wrapResult(k, k.offset(unwrap(shape), distance, tolerance ?? 1e-6));
1849
+ }
1850
+ function filletVariable(k, shape, spec) {
1851
+ const parsed = JSON.parse(spec);
1852
+ if (parsed.edgeId !== void 0 && parsed.startRadius !== void 0 && parsed.endRadius !== void 0) return wrapResult(k, k.filletVariable(unwrap(shape), parsed.edgeId, parsed.startRadius, parsed.endRadius));
1853
+ throw new Error("occt-wasm: filletVariable (complex spec) not implemented");
1854
+ }
1855
+ function draft(k, shape, faces, pullDirection, _neutralPlane, angleDeg) {
1856
+ let currentId = unwrap(shape);
1857
+ for (const face of faces) {
1858
+ const angleRad = (typeof angleDeg === "function" ? angleDeg(face) : angleDeg) * Math.PI / 180;
1859
+ currentId = k.draft(currentId, unwrap(face), angleRad, pullDirection[0], pullDirection[1], pullDirection[2]);
1860
+ }
1861
+ return wrapResult(k, currentId);
1862
+ }
1863
+ function defeature(k, Module, shape, faces) {
1864
+ const vec = makeVecU32(Module, faces.map(unwrap));
1865
+ try {
1866
+ return wrapResult(k, k.defeature(unwrap(shape), vec, .001));
1867
+ } finally {
1868
+ vec.delete();
1869
+ }
1870
+ }
1871
+ function offsetWire2D(k, wire, offset, joinType) {
1872
+ let jt = 0;
1873
+ if (joinType === "intersection" || joinType === 1) jt = 1;
1874
+ else if (joinType === "tangent" || joinType === 2) jt = 2;
1875
+ else if (typeof joinType === "number") jt = joinType;
1876
+ return wrapResult(k, k.offsetWire2D(unwrap(wire), offset, jt));
1877
+ }
1878
+ function simplify(k, shape) {
1879
+ return wrapResult(k, k.simplify(unwrap(shape)));
1880
+ }
1881
+ function reverseShape(k, shape) {
1882
+ return wrapResult(k, k.reverseShape(unwrap(shape)));
1883
+ }
1884
+ //#endregion
1885
+ //#region src/kernel/occtWasm/sweepOps.ts
1886
+ function extrude(k, face, direction, length) {
1887
+ const dx = direction[0] * length;
1888
+ const dy = direction[1] * length;
1889
+ const dz = direction[2] * length;
1890
+ return wrapResult(k, k.extrude(unwrap(face), dx, dy, dz));
1891
+ }
1892
+ function revolve(k, shape, axis, angle) {
1893
+ const o = axis.origin;
1894
+ const d = axis.direction;
1895
+ return wrapResult(k, k.revolve(unwrap(shape), o.x, o.y, o.z, d.x, d.y, d.z, angle));
1896
+ }
1897
+ function loft(k, Module, wires, ruled, _startShape, _endShape) {
1898
+ const vec = makeVecU32(Module, wires.map(unwrap));
1899
+ try {
1900
+ return wrapResult(k, k.loft(vec, true, ruled ?? false));
1901
+ } finally {
1902
+ vec.delete();
1903
+ }
1904
+ }
1905
+ function sweep(k, wire, spine, options) {
1906
+ const mode = options?.transitionMode ?? 0;
1907
+ return wrapResult(k, k.sweep(unwrap(wire), unwrap(spine), mode));
1908
+ }
1909
+ function simplePipe(k, profile, spine) {
1910
+ return wrapResult(k, k.simplePipe(unwrap(profile), unwrap(spine)));
1911
+ }
1912
+ function sweepPipeShell(k, profile, spine, options) {
1913
+ const freenet = options?.frenet ?? false;
1914
+ const smooth = options?.transitionMode === "round";
1915
+ const shellMode = options?.shellMode ?? false;
1916
+ const result = wrapResult(k, k.sweepPipeShell(unwrap(profile), unwrap(spine), freenet, smooth));
1917
+ if (shellMode) {
1918
+ const edges = k.getSubShapes(unwrap(result), "wire");
1919
+ try {
1920
+ return {
1921
+ shape: result,
1922
+ firstShape: edges.size() > 0 ? wrapResult(k, edges.get(0)) : result,
1923
+ lastShape: edges.size() > 1 ? wrapResult(k, edges.get(edges.size() - 1)) : result
1924
+ };
1925
+ } finally {
1926
+ edges.delete();
1927
+ }
1928
+ }
1929
+ return result;
1930
+ }
1931
+ function loftAdvanced(k, Module, wires, options) {
1932
+ const isSolid = options?.solid ?? true;
1933
+ const ruled = options?.ruled ?? false;
1934
+ const startV = options?.startVertex ? unwrap(options.startVertex) : 0;
1935
+ const endV = options?.endVertex ? unwrap(options.endVertex) : 0;
1936
+ const vec = makeVecU32(Module, wires.map(unwrap));
1937
+ try {
1938
+ if (startV || endV) return wrapResult(k, k.loftWithVertices(vec, isSolid, ruled, startV, endV));
1939
+ return wrapResult(k, k.loft(vec, isSolid, ruled));
1940
+ } finally {
1941
+ vec.delete();
1942
+ }
1943
+ }
1944
+ function buildExtrusionLaw(_k, profile, length, endFactor) {
1945
+ const law = {
1946
+ __occtWasmLaw: true,
1947
+ profile,
1948
+ length,
1949
+ endFactor,
1950
+ Trim(first, last, _tol) {
1951
+ return {
1952
+ ...law,
1953
+ trimFirst: first,
1954
+ trimLast: last
1955
+ };
1956
+ },
1957
+ delete() {}
1958
+ };
1959
+ return law;
1960
+ }
1961
+ function revolveVec(k, shape, center, direction, angle) {
1962
+ return wrapResult(k, k.revolveVec(unwrap(shape), center[0], center[1], center[2], direction[0], direction[1], direction[2], angle));
1963
+ }
1964
+ function draftPrism(k, shape, _face, _baseFace, height, angleDeg, _fuse) {
1965
+ const h = height ?? 10;
1966
+ return wrapResult(k, k.draftPrism(unwrap(shape), 0, 0, h, angleDeg));
1967
+ }
1968
+ //#endregion
1969
+ //#region src/kernel/occtWasm/transformOps.ts
1970
+ function composeTransform(ops) {
1971
+ let matrix = [
1972
+ 1,
1973
+ 0,
1974
+ 0,
1975
+ 0,
1976
+ 0,
1977
+ 1,
1978
+ 0,
1979
+ 0,
1980
+ 0,
1981
+ 0,
1982
+ 1,
1983
+ 0,
1984
+ 0,
1985
+ 0,
1986
+ 0,
1987
+ 1
1988
+ ];
1989
+ for (const op of ops) if (op.type === "translate") matrix = multiplyMatrices4x4([
1990
+ 1,
1991
+ 0,
1992
+ 0,
1993
+ op.x,
1994
+ 0,
1995
+ 1,
1996
+ 0,
1997
+ op.y,
1998
+ 0,
1999
+ 0,
2000
+ 1,
2001
+ op.z,
2002
+ 0,
2003
+ 0,
2004
+ 0,
2005
+ 1
2006
+ ], matrix);
2007
+ else {
2008
+ const ax = op.axis ?? [
2009
+ 0,
2010
+ 0,
2011
+ 1
2012
+ ];
2013
+ const cn = op.center ?? [
2014
+ 0,
2015
+ 0,
2016
+ 0
2017
+ ];
2018
+ const rad = op.angle * Math.PI / 180;
2019
+ const c = Math.cos(rad);
2020
+ const s = Math.sin(rad);
2021
+ const t = 1 - c;
2022
+ const len = Math.sqrt(ax[0] ** 2 + ax[1] ** 2 + ax[2] ** 2);
2023
+ const [ux, uy, uz] = [
2024
+ ax[0] / len,
2025
+ ax[1] / len,
2026
+ ax[2] / len
2027
+ ];
2028
+ const r00 = t * ux * ux + c;
2029
+ const r01 = t * ux * uy - s * uz;
2030
+ const r02 = t * ux * uz + s * uy;
2031
+ const r10 = t * uy * ux + s * uz;
2032
+ const r11 = t * uy * uy + c;
2033
+ const r12 = t * uy * uz - s * ux;
2034
+ const r20 = t * uz * ux - s * uy;
2035
+ const r21 = t * uz * uy + s * ux;
2036
+ const r22 = t * uz * uz + c;
2037
+ matrix = multiplyMatrices4x4([
2038
+ r00,
2039
+ r01,
2040
+ r02,
2041
+ cn[0] - (r00 * cn[0] + r01 * cn[1] + r02 * cn[2]),
2042
+ r10,
2043
+ r11,
2044
+ r12,
2045
+ cn[1] - (r10 * cn[0] + r11 * cn[1] + r12 * cn[2]),
2046
+ r20,
2047
+ r21,
2048
+ r22,
2049
+ cn[2] - (r20 * cn[0] + r21 * cn[1] + r22 * cn[2]),
2050
+ 0,
2051
+ 0,
2052
+ 0,
2053
+ 1
2054
+ ], matrix);
2055
+ }
2056
+ return {
2057
+ handle: {
2058
+ __type: "transform_matrix",
2059
+ matrix,
2060
+ delete: noop
2061
+ },
2062
+ dispose: noop
2063
+ };
2064
+ }
2065
+ function transform(k, Module, shape, trsf) {
2066
+ const t = trsf;
2067
+ let matrix;
2068
+ if (Array.isArray(t)) matrix = t;
2069
+ else if (typeof t === "object") {
2070
+ if (Array.isArray(t["matrix"])) {
2071
+ matrix = t["matrix"];
2072
+ if (matrix.length === 16) matrix = matrix.slice(0, 12);
2073
+ } else if (Array.isArray(t["elements"])) matrix = t["elements"];
2074
+ }
2075
+ if (matrix) {
2076
+ if (matrix.length === 16) matrix = matrix.slice(0, 12);
2077
+ if (matrix.length >= 12) {
2078
+ const vec = makeVecDouble(Module, matrix);
2079
+ try {
2080
+ return wrapResult(k, k.transform(unwrap(shape), vec));
2081
+ } finally {
2082
+ vec.delete();
2083
+ }
2084
+ }
2085
+ }
2086
+ return handle(k.getShapeType(unwrap(shape)), k.copy(unwrap(shape)));
2087
+ }
2088
+ function translate(k, shape, x, y, z) {
2089
+ return wrapResult(k, k.translate(unwrap(shape), x, y, z));
2090
+ }
2091
+ function rotate(k, shape, angle, axis, center) {
2092
+ const ax = axis ?? [
2093
+ 0,
2094
+ 0,
2095
+ 1
2096
+ ];
2097
+ const cn = center ?? [
2098
+ 0,
2099
+ 0,
2100
+ 0
2101
+ ];
2102
+ return wrapResult(k, k.rotate(unwrap(shape), cn[0], cn[1], cn[2], ax[0], ax[1], ax[2], angle));
2103
+ }
2104
+ function mirror(k, shape, origin, normal) {
2105
+ return wrapResult(k, k.mirror(unwrap(shape), origin[0], origin[1], origin[2], normal[0], normal[1], normal[2]));
2106
+ }
2107
+ function scale(k, shape, center, factor) {
2108
+ return wrapResult(k, k.scale(unwrap(shape), center[0], center[1], center[2], factor));
2109
+ }
2110
+ function generalTransform(k, Module, shape, linear, translation, _isOrthogonal) {
2111
+ const vec = makeVecDouble(Module, [
2112
+ linear[0],
2113
+ linear[1],
2114
+ linear[2],
2115
+ translation[0],
2116
+ linear[3],
2117
+ linear[4],
2118
+ linear[5],
2119
+ translation[1],
2120
+ linear[6],
2121
+ linear[7],
2122
+ linear[8],
2123
+ translation[2]
2124
+ ]);
2125
+ try {
2126
+ return wrapResult(k, k.generalTransform(unwrap(shape), vec));
2127
+ } finally {
2128
+ vec.delete();
2129
+ }
2130
+ }
2131
+ function positionOnCurve(k, Module, shape, spine, param) {
2132
+ const ptVec = k.curvePointAtParam(unwrap(spine), param);
2133
+ const [px, py, pz] = (() => {
2134
+ try {
2135
+ return [
2136
+ ptVec.get(0),
2137
+ ptVec.get(1),
2138
+ ptVec.get(2)
2139
+ ];
2140
+ } finally {
2141
+ ptVec.delete();
2142
+ }
2143
+ })();
2144
+ const tgVec = k.curveTangent(unwrap(spine), param);
2145
+ const [tx, ty, tz] = (() => {
2146
+ try {
2147
+ return [
2148
+ tgVec.get(0),
2149
+ tgVec.get(1),
2150
+ tgVec.get(2)
2151
+ ];
2152
+ } finally {
2153
+ tgVec.delete();
2154
+ }
2155
+ })();
2156
+ let ux, uy, uz;
2157
+ if (Math.abs(tx) < .9) {
2158
+ ux = 0;
2159
+ uy = tz;
2160
+ uz = -ty;
2161
+ } else {
2162
+ ux = -tz;
2163
+ uy = 0;
2164
+ uz = tx;
2165
+ }
2166
+ const uLen = Math.sqrt(ux * ux + uy * uy + uz * uz);
2167
+ ux /= uLen;
2168
+ uy /= uLen;
2169
+ uz /= uLen;
2170
+ const vx = ty * uz - tz * uy;
2171
+ const vy = tz * ux - tx * uz;
2172
+ const vz = tx * uy - ty * ux;
2173
+ const mat = new Module.VectorDouble();
2174
+ mat.push_back(ux);
2175
+ mat.push_back(vx);
2176
+ mat.push_back(tx);
2177
+ mat.push_back(px);
2178
+ mat.push_back(uy);
2179
+ mat.push_back(vy);
2180
+ mat.push_back(ty);
2181
+ mat.push_back(py);
2182
+ mat.push_back(uz);
2183
+ mat.push_back(vz);
2184
+ mat.push_back(tz);
2185
+ mat.push_back(pz);
2186
+ try {
2187
+ return wrapResult(k, k.transform(unwrap(shape), mat));
2188
+ } finally {
2189
+ mat.delete();
2190
+ }
2191
+ }
2192
+ function linearPattern(k, shape, direction, spacing, count) {
2193
+ const compoundId = k.linearPattern(unwrap(shape), direction[0], direction[1], direction[2], spacing, count);
2194
+ const subVec = k.getSubShapes(compoundId, "solid");
2195
+ const results = [];
2196
+ try {
2197
+ const n = subVec.size();
2198
+ for (let i = 0; i < n; i++) results.push(handle("solid", subVec.get(i)));
2199
+ } finally {
2200
+ subVec.delete();
2201
+ }
2202
+ if (results.length === 0) {
2203
+ const iter = k.iterShapes(compoundId);
2204
+ try {
2205
+ const n2 = iter.size();
2206
+ for (let i = 0; i < n2; i++) results.push(wrapResult(k, iter.get(i)));
2207
+ } finally {
2208
+ iter.delete();
2209
+ }
2210
+ }
2211
+ return results;
2212
+ }
2213
+ function circularPattern(k, shape, center, axis, angleStep, count) {
2214
+ const compoundId = k.circularPattern(unwrap(shape), center[0], center[1], center[2], axis[0], axis[1], axis[2], angleStep, count);
2215
+ const subVec = k.getSubShapes(compoundId, "solid");
2216
+ const results = [];
2217
+ try {
2218
+ const n = subVec.size();
2219
+ for (let i = 0; i < n; i++) results.push(handle("solid", subVec.get(i)));
2220
+ } finally {
2221
+ subVec.delete();
2222
+ }
2223
+ if (results.length === 0) {
2224
+ const iter = k.iterShapes(compoundId);
2225
+ try {
2226
+ const n2 = iter.size();
2227
+ for (let i = 0; i < n2; i++) results.push(wrapResult(k, iter.get(i)));
2228
+ } finally {
2229
+ iter.delete();
2230
+ }
2231
+ }
2232
+ return results;
2233
+ }
2234
+ function transformBatch(k, entries) {
2235
+ return entries.map((entry) => {
2236
+ switch (entry.type) {
2237
+ case "translate": return translate(k, entry.shape, entry.x, entry.y, entry.z);
2238
+ case "rotate": return rotate(k, entry.shape, entry.angle, entry.axis, entry.center);
2239
+ case "scale": return scale(k, entry.shape, entry.center, entry.factor);
2240
+ case "mirror": return mirror(k, entry.shape, entry.origin, entry.normal);
2241
+ default: throw new Error("occt-wasm: transformBatch unknown type");
2242
+ }
2243
+ });
2244
+ }
2245
+ //#endregion
2246
+ //#region src/kernel/occtWasm/ioOps.ts
2247
+ function computePositionBounds(positions, vCount) {
2248
+ if (vCount === 0) return {
2249
+ min: [
2250
+ 0,
2251
+ 0,
2252
+ 0
2253
+ ],
2254
+ max: [
2255
+ 0,
2256
+ 0,
2257
+ 0
2258
+ ]
2259
+ };
2260
+ let minX = Infinity, minY = Infinity, minZ = Infinity;
2261
+ let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
2262
+ for (let i = 0; i < vCount; i++) {
2263
+ const o = i * 3;
2264
+ const x = positions[o] ?? 0;
2265
+ const y = positions[o + 1] ?? 0;
2266
+ const z = positions[o + 2] ?? 0;
2267
+ if (x < minX) minX = x;
2268
+ if (y < minY) minY = y;
2269
+ if (z < minZ) minZ = z;
2270
+ if (x > maxX) maxX = x;
2271
+ if (y > maxY) maxY = y;
2272
+ if (z > maxZ) maxZ = z;
2273
+ }
2274
+ return {
2275
+ min: [
2276
+ minX,
2277
+ minY,
2278
+ minZ
2279
+ ],
2280
+ max: [
2281
+ maxX,
2282
+ maxY,
2283
+ maxZ
2284
+ ]
2285
+ };
2286
+ }
2287
+ function buildGltfManifest(vCount, nCount, iCount, posBytes, nrmBytes, idxBytes, bufferLength, bounds) {
2288
+ return {
2289
+ asset: {
2290
+ version: "2.0",
2291
+ generator: "brepjs occt-wasm"
2292
+ },
2293
+ scene: 0,
2294
+ scenes: [{ nodes: [0] }],
2295
+ nodes: [{ mesh: 0 }],
2296
+ meshes: [{ primitives: [{
2297
+ attributes: {
2298
+ POSITION: 0,
2299
+ NORMAL: 1
2300
+ },
2301
+ indices: 2,
2302
+ mode: 4
2303
+ }] }],
2304
+ buffers: [{ byteLength: bufferLength }],
2305
+ bufferViews: [
2306
+ {
2307
+ buffer: 0,
2308
+ byteOffset: 0,
2309
+ byteLength: posBytes,
2310
+ target: 34962
2311
+ },
2312
+ {
2313
+ buffer: 0,
2314
+ byteOffset: posBytes,
2315
+ byteLength: nrmBytes,
2316
+ target: 34962
2317
+ },
2318
+ {
2319
+ buffer: 0,
2320
+ byteOffset: posBytes + nrmBytes,
2321
+ byteLength: idxBytes,
2322
+ target: 34963
2323
+ }
2324
+ ],
2325
+ accessors: [
2326
+ {
2327
+ bufferView: 0,
2328
+ componentType: 5126,
2329
+ count: vCount,
2330
+ type: "VEC3",
2331
+ min: bounds.min,
2332
+ max: bounds.max
2333
+ },
2334
+ {
2335
+ bufferView: 1,
2336
+ componentType: 5126,
2337
+ count: nCount,
2338
+ type: "VEC3"
2339
+ },
2340
+ {
2341
+ bufferView: 2,
2342
+ componentType: 5125,
2343
+ count: iCount,
2344
+ type: "SCALAR"
2345
+ }
2346
+ ]
2347
+ };
2348
+ }
2349
+ function exportSTEP(k, makeCompound, shapes) {
2350
+ if (shapes.length === 1) return k.exportStep(unwrap(shapes[0]));
2351
+ const compound = makeCompound(shapes);
2352
+ return k.exportStep(unwrap(compound));
2353
+ }
2354
+ function exportSTL(k, shape, binary) {
2355
+ const ascii = !binary;
2356
+ const result = k.exportStl(unwrap(shape), .1, ascii);
2357
+ if (binary) {
2358
+ const buf = new ArrayBuffer(result.length);
2359
+ const view = new Uint8Array(buf);
2360
+ for (let i = 0; i < result.length; i++) view[i] = result.charCodeAt(i);
2361
+ return buf;
2362
+ }
2363
+ return result;
2364
+ }
2365
+ function importSTEP(k, data) {
2366
+ const str = typeof data === "string" ? data : new TextDecoder().decode(data);
2367
+ return [wrapResult(k, k.importStep(str))];
2368
+ }
2369
+ function importSTL(k, Module, data) {
2370
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : new Uint8Array(data);
2371
+ const mod = Module;
2372
+ if (mod.FS) mod.FS.writeFile("/tmp/import.stl", bytes);
2373
+ else {
2374
+ const str = Array.from(bytes, (b) => String.fromCharCode(b)).join("");
2375
+ return wrapResult(k, k.importStl(str));
2376
+ }
2377
+ return wrapResult(k, k.importStl(""));
2378
+ }
2379
+ function exportIGES(k, makeCompound, shapes) {
2380
+ if (shapes.length === 1) return k.exportIges(unwrap(shapes[0]));
2381
+ const compound = makeCompound(shapes);
2382
+ return k.exportIges(unwrap(compound));
2383
+ }
2384
+ function importIGES(k, data) {
2385
+ const str = typeof data === "string" ? data : new TextDecoder().decode(data);
2386
+ return [wrapResult(k, k.importIges(str))];
2387
+ }
2388
+ function exportSTEPAssembly(k, Module, parts, _options) {
2389
+ if (parts.length === 0) return "";
2390
+ const doc = createXCAFDocument(k, Module, parts);
2391
+ try {
2392
+ return writeXCAFToSTEP(k, doc);
2393
+ } finally {
2394
+ doc.delete();
2395
+ }
2396
+ }
2397
+ function exportGLB(mesh, shape, tolerance) {
2398
+ const result = mesh(shape, {
2399
+ tolerance,
2400
+ angularTolerance: .5,
2401
+ skipNormals: false
2402
+ });
2403
+ const positions = result.vertices;
2404
+ const normals = result.normals;
2405
+ const indices = result.triangles;
2406
+ const vCount = positions.length / 3;
2407
+ const nCount = normals.length / 3;
2408
+ const iCount = indices.length;
2409
+ const posBytes = positions.byteLength;
2410
+ const nrmBytes = normals.byteLength;
2411
+ const idxBytes = indices.byteLength;
2412
+ const binLength = posBytes + nrmBytes + idxBytes;
2413
+ const paddedBinLength = binLength + (4 - binLength % 4) % 4;
2414
+ const manifest = buildGltfManifest(vCount, nCount, iCount, posBytes, nrmBytes, idxBytes, paddedBinLength, computePositionBounds(positions, vCount));
2415
+ const jsonBytes = new TextEncoder().encode(JSON.stringify(manifest));
2416
+ const paddedJsonLength = jsonBytes.byteLength + (4 - jsonBytes.byteLength % 4) % 4;
2417
+ const totalLength = 20 + paddedJsonLength + 8 + paddedBinLength;
2418
+ const glb = new ArrayBuffer(totalLength);
2419
+ const view = new DataView(glb);
2420
+ view.setUint32(0, 1179937895, true);
2421
+ view.setUint32(4, 2, true);
2422
+ view.setUint32(8, totalLength, true);
2423
+ view.setUint32(12, paddedJsonLength, true);
2424
+ view.setUint32(16, 1313821514, true);
2425
+ const jsonDst = new Uint8Array(glb, 20, paddedJsonLength);
2426
+ jsonDst.set(jsonBytes);
2427
+ for (let i = jsonBytes.byteLength; i < paddedJsonLength; i++) jsonDst[i] = 32;
2428
+ const binHeaderOffset = 20 + paddedJsonLength;
2429
+ view.setUint32(binHeaderOffset, paddedBinLength, true);
2430
+ view.setUint32(binHeaderOffset + 4, 5130562, true);
2431
+ const binDataOffset = binHeaderOffset + 8;
2432
+ new Uint8Array(glb, binDataOffset, posBytes).set(new Uint8Array(positions.buffer, positions.byteOffset, posBytes));
2433
+ new Uint8Array(glb, binDataOffset + posBytes, nrmBytes).set(new Uint8Array(normals.buffer, normals.byteOffset, nrmBytes));
2434
+ new Uint8Array(glb, binDataOffset + posBytes + nrmBytes, idxBytes).set(new Uint8Array(indices.buffer, indices.byteOffset, idxBytes));
2435
+ return glb;
2436
+ }
2437
+ function exportOBJ(mesh, shape, tolerance) {
2438
+ const result = mesh(shape, {
2439
+ tolerance,
2440
+ angularTolerance: .5,
2441
+ skipNormals: false
2442
+ });
2443
+ const v = result.vertices;
2444
+ const n = result.normals;
2445
+ const t = result.triangles;
2446
+ const lines = ["# brepjs OBJ export"];
2447
+ const vCount = v.length / 3;
2448
+ for (let i = 0; i < vCount; i++) {
2449
+ const o = i * 3;
2450
+ lines.push(`v ${v[o] ?? 0} ${v[o + 1] ?? 0} ${v[o + 2] ?? 0}`);
2451
+ }
2452
+ const nCount = n.length / 3;
2453
+ for (let i = 0; i < nCount; i++) {
2454
+ const o = i * 3;
2455
+ lines.push(`vn ${n[o] ?? 0} ${n[o + 1] ?? 0} ${n[o + 2] ?? 0}`);
2456
+ }
2457
+ const pushTri = (offset) => {
2458
+ const a = (t[offset] ?? 0) + 1;
2459
+ const b = (t[offset + 1] ?? 0) + 1;
2460
+ const c = (t[offset + 2] ?? 0) + 1;
2461
+ lines.push(`f ${a}//${a} ${b}//${b} ${c}//${c}`);
2462
+ };
2463
+ if (result.faceGroups.length > 0) for (const group of result.faceGroups) {
2464
+ lines.push(`g face_${group.faceHash}`);
2465
+ const count = group.count / 3;
2466
+ for (let i = 0; i < count; i++) pushTri(group.start + i * 3);
2467
+ }
2468
+ else {
2469
+ const triCount = t.length / 3;
2470
+ for (let i = 0; i < triCount; i++) pushTri(i * 3);
2471
+ }
2472
+ return new TextEncoder().encode(lines.join("\n") + "\n").buffer;
2473
+ }
2474
+ function exportPLY(mesh, shape, tolerance) {
2475
+ const result = mesh(shape, {
2476
+ tolerance,
2477
+ angularTolerance: .5,
2478
+ skipNormals: false
2479
+ });
2480
+ const v = result.vertices;
2481
+ const n = result.normals;
2482
+ const t = result.triangles;
2483
+ const vCount = v.length / 3;
2484
+ const triCount = t.length / 3;
2485
+ const hasNormals = n.length === v.length;
2486
+ const lines = [
2487
+ "ply",
2488
+ "format ascii 1.0",
2489
+ "comment brepjs PLY export",
2490
+ `element vertex ${vCount}`,
2491
+ "property float x",
2492
+ "property float y",
2493
+ "property float z"
2494
+ ];
2495
+ if (hasNormals) lines.push("property float nx", "property float ny", "property float nz");
2496
+ lines.push(`element face ${triCount}`, "property list uchar int vertex_index", "end_header");
2497
+ for (let i = 0; i < vCount; i++) {
2498
+ const o = i * 3;
2499
+ const x = v[o] ?? 0;
2500
+ const y = v[o + 1] ?? 0;
2501
+ const z = v[o + 2] ?? 0;
2502
+ if (hasNormals) {
2503
+ const nx = n[o] ?? 0;
2504
+ const ny = n[o + 1] ?? 0;
2505
+ const nz = n[o + 2] ?? 0;
2506
+ lines.push(`${x} ${y} ${z} ${nx} ${ny} ${nz}`);
2507
+ } else lines.push(`${x} ${y} ${z}`);
2508
+ }
2509
+ for (let i = 0; i < triCount; i++) {
2510
+ const a = t[i * 3] ?? 0;
2511
+ const b = t[i * 3 + 1] ?? 0;
2512
+ const c = t[i * 3 + 2] ?? 0;
2513
+ lines.push(`3 ${a} ${b} ${c}`);
2514
+ }
2515
+ return new TextEncoder().encode(lines.join("\n") + "\n").buffer;
2516
+ }
2517
+ function toBREP(k, shape) {
2518
+ return k.toBREP(unwrap(shape));
2519
+ }
2520
+ function fromBREP(k, data) {
2521
+ return wrapResult(k, k.fromBREP(data));
2522
+ }
2523
+ function createXCAFDocument(k, Module, shapes) {
2524
+ const ids = new Module.VectorUint32();
2525
+ const colors = new Module.VectorDouble();
2526
+ const nameParts = [];
2527
+ for (const entry of shapes) {
2528
+ ids.push_back(unwrap(entry.shape));
2529
+ nameParts.push(entry.name);
2530
+ const [r, g, b, a] = entry.color ?? [
2531
+ .5,
2532
+ .5,
2533
+ .5,
2534
+ 1
2535
+ ];
2536
+ colors.push_back(r);
2537
+ colors.push_back(g);
2538
+ colors.push_back(b);
2539
+ colors.push_back(a);
2540
+ }
2541
+ try {
2542
+ const joinedNames = nameParts.join("\0");
2543
+ return handle("compound", k.createXCAFDocument(ids, joinedNames, colors));
2544
+ } finally {
2545
+ ids.delete();
2546
+ colors.delete();
2547
+ }
2548
+ }
2549
+ function writeXCAFToSTEP(k, doc, _options) {
2550
+ const id = unwrap(doc);
2551
+ const subs = k.getSubShapes(id, "solid");
2552
+ if (!(() => {
2553
+ try {
2554
+ return subs.size() > 0;
2555
+ } finally {
2556
+ subs.delete();
2557
+ }
2558
+ })()) {
2559
+ const faces = k.getSubShapes(id, "face");
2560
+ if (!(() => {
2561
+ try {
2562
+ return faces.size() > 0;
2563
+ } finally {
2564
+ faces.delete();
2565
+ }
2566
+ })()) return "";
2567
+ }
2568
+ return k.writeXCAFToSTEP(id);
2569
+ }
2570
+ function exportSTEPConfigured(k, Module, shapes, _options) {
2571
+ if (shapes.length === 0) return "";
2572
+ const doc = createXCAFDocument(k, Module, shapes.map((s) => ({
2573
+ shape: s.shape,
2574
+ name: s.name ?? "",
2575
+ color: s.color
2576
+ })));
2577
+ try {
2578
+ return writeXCAFToSTEP(k, doc);
2579
+ } finally {
2580
+ doc.delete();
2581
+ }
2582
+ }
2583
+ //#endregion
2584
+ //#region src/kernel/occtWasm/constructionOps.ts
2585
+ function makeVertex(k, x, y, z) {
2586
+ return handle("vertex", k.makeVertex(x, y, z));
2587
+ }
2588
+ function makeEdge(_k, curve) {
2589
+ if (isOcctWasmHandle(curve)) throw new Error("occt-wasm: makeEdge from curve handle is not implemented");
2590
+ throw new Error("occt-wasm: makeEdge is not implemented");
2591
+ }
2592
+ function makeWire(k, Module, edges) {
2593
+ const vec = makeVecU32(Module, edges.map(unwrap));
2594
+ try {
2595
+ return handle("wire", k.makeWire(vec));
2596
+ } finally {
2597
+ vec.delete();
2598
+ }
2599
+ }
2600
+ function makeFace(k, wire, _planar) {
2601
+ return handle("face", k.makeFace(unwrap(wire)));
2602
+ }
2603
+ function makeLineEdge(k, p1, p2) {
2604
+ return handle("edge", k.makeLineEdge(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]));
2605
+ }
2606
+ function makeCircleEdge(k, center, normal, radius) {
2607
+ return handle("edge", k.makeCircleEdge(center[0], center[1], center[2], normal[0], normal[1], normal[2], radius));
2608
+ }
2609
+ function makeCircleArc(k, center, normal, radius, startAngle, endAngle) {
2610
+ return handle("edge", k.makeCircleArc(center[0], center[1], center[2], normal[0], normal[1], normal[2], radius, startAngle, endAngle));
2611
+ }
2612
+ function makeArcEdge(k, p1, p2, p3) {
2613
+ return handle("edge", k.makeArcEdge(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2], p3[0], p3[1], p3[2]));
2614
+ }
2615
+ function makeEllipseEdge(k, center, normal, majorRadius, minorRadius) {
2616
+ return handle("edge", k.makeEllipseEdge(center[0], center[1], center[2], normal[0], normal[1], normal[2], majorRadius, minorRadius));
2617
+ }
2618
+ function makeEllipseArc(k, center, normal, majorRadius, minorRadius, startAngle, endAngle) {
2619
+ return handle("edge", k.makeEllipseArc(center[0], center[1], center[2], normal[0], normal[1], normal[2], majorRadius, minorRadius, startAngle, endAngle));
2620
+ }
2621
+ function makeBezierEdge(k, Module, points) {
2622
+ const flat = [];
2623
+ for (const p of points) flat.push(p[0], p[1], p[2]);
2624
+ const vec = makeVecDouble(Module, flat);
2625
+ try {
2626
+ return handle("edge", k.makeBezierEdge(vec));
2627
+ } finally {
2628
+ vec.delete();
2629
+ }
2630
+ }
2631
+ function makeTangentArc(k, startPoint, startTangent, endPoint) {
2632
+ const [x1, y1, z1] = startPoint;
2633
+ const [tx, ty, tz] = startTangent;
2634
+ const [x2, y2, z2] = endPoint;
2635
+ return handle("edge", k.makeTangentArc(x1, y1, z1, tx, ty, tz, x2, y2, z2));
2636
+ }
2637
+ function makeHelixWire(k, pitch, height, radius, center, direction) {
2638
+ const px = center ? center[0] : 0;
2639
+ const py = center ? center[1] : 0;
2640
+ const pz = center ? center[2] : 0;
2641
+ const dx = direction ? direction[0] : 0;
2642
+ const dy = direction ? direction[1] : 0;
2643
+ const dz = direction ? direction[2] : 1;
2644
+ return handle("wire", k.makeHelixWire(px, py, pz, dx, dy, dz, pitch, height, radius));
2645
+ }
2646
+ function makeCompound(k, Module, shapes) {
2647
+ const vec = makeVecU32(Module, shapes.map(unwrap));
2648
+ try {
2649
+ return handle("compound", k.makeCompound(vec));
2650
+ } finally {
2651
+ vec.delete();
2652
+ }
2653
+ }
2654
+ function solidFromShell(k, shell) {
2655
+ return handle("solid", k.solidFromShell(unwrap(shell)));
2656
+ }
2657
+ function buildSolidFromFaces(k, Module, points, faces, tolerance) {
2658
+ const faceIds = [];
2659
+ for (const [i0, i1, i2] of faces) {
2660
+ const p0 = points[i0];
2661
+ const p1 = points[i1];
2662
+ const p2 = points[i2];
2663
+ if (!p0 || !p1 || !p2) continue;
2664
+ faceIds.push(k.buildTriFace(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z));
2665
+ }
2666
+ const vec = makeVecU32(Module, faceIds);
2667
+ try {
2668
+ let sewn = k.sewAndSolidify(vec, tolerance);
2669
+ sewn = k.fixFaceOrientations(sewn);
2670
+ return wrapResult(k, sewn);
2671
+ } finally {
2672
+ vec.delete();
2673
+ }
2674
+ }
2675
+ function makeNonPlanarFace(k, wire) {
2676
+ return handle("face", k.makeNonPlanarFace(unwrap(wire)));
2677
+ }
2678
+ function addHolesInFace(k, Module, face, holeWires) {
2679
+ const vec = makeVecU32(Module, holeWires.map(unwrap));
2680
+ try {
2681
+ return handle("face", k.addHolesInFace(unwrap(face), vec));
2682
+ } finally {
2683
+ vec.delete();
2684
+ }
2685
+ }
2686
+ function removeHolesFromFace(k, Module, face) {
2687
+ const allWires = k.getSubShapes(unwrap(face), "wire");
2688
+ const holeCount = (() => {
2689
+ try {
2690
+ return allWires.size() - 1;
2691
+ } finally {
2692
+ allWires.delete();
2693
+ }
2694
+ })();
2695
+ const indices = [];
2696
+ for (let i = 0; i < holeCount; i++) indices.push(i);
2697
+ const vec = makeVecInt(Module, indices);
2698
+ try {
2699
+ return handle("face", k.removeHolesFromFace(unwrap(face), vec));
2700
+ } finally {
2701
+ vec.delete();
2702
+ }
2703
+ }
2704
+ function makeFaceOnSurface(k, surface, wire) {
2705
+ const faceId = unwrap(surface);
2706
+ return handle("face", k.makeFaceOnSurface(faceId, unwrap(wire)));
2707
+ }
2708
+ function bsplineSurface(k, Module, points, rows, cols) {
2709
+ const vec = new Module.VectorDouble();
2710
+ for (const [x, y, z] of points) {
2711
+ vec.push_back(x);
2712
+ vec.push_back(y);
2713
+ vec.push_back(z);
2714
+ }
2715
+ try {
2716
+ return handle("face", k.bsplineSurface(vec, rows, cols));
2717
+ } finally {
2718
+ vec.delete();
2719
+ }
2720
+ }
2721
+ function triangulatedSurface(k, Module, points, rows, cols) {
2722
+ const faceIds = [];
2723
+ for (let r = 0; r < rows - 1; r++) for (let c = 0; c < cols - 1; c++) {
2724
+ const i00 = r * cols + c;
2725
+ const i10 = (r + 1) * cols + c;
2726
+ const i01 = r * cols + (c + 1);
2727
+ const i11 = (r + 1) * cols + (c + 1);
2728
+ const p00 = points[i00];
2729
+ const p10 = points[i10];
2730
+ const p01 = points[i01];
2731
+ const p11 = points[i11];
2732
+ if (p00 && p10 && p01) faceIds.push(k.buildTriFace(p00[0], p00[1], p00[2], p10[0], p10[1], p10[2], p01[0], p01[1], p01[2]));
2733
+ if (p10 && p11 && p01) faceIds.push(k.buildTriFace(p10[0], p10[1], p10[2], p11[0], p11[1], p11[2], p01[0], p01[1], p01[2]));
2734
+ }
2735
+ const vec = makeVecU32(Module, faceIds);
2736
+ try {
2737
+ return wrapResult(k, k.sewAndSolidify(vec, .001));
2738
+ } finally {
2739
+ vec.delete();
2740
+ }
2741
+ }
2742
+ function buildTriFace(k, a, b, c) {
2743
+ const id = k.buildTriFace(a[0], a[1], a[2], b[0], b[1], b[2], c[0], c[1], c[2]);
2744
+ if (id === 0) return null;
2745
+ return handle("face", id);
2746
+ }
2747
+ function sewAndSolidify(k, Module, faces, tolerance) {
2748
+ const vec = makeVecU32(Module, faces.map(unwrap));
2749
+ try {
2750
+ let sewn = k.sewAndSolidify(vec, tolerance);
2751
+ sewn = k.fixFaceOrientations(sewn);
2752
+ return handle("solid", sewn);
2753
+ } finally {
2754
+ vec.delete();
2755
+ }
2756
+ }
2757
+ function createPoint3d(x, y, z) {
2758
+ return {
2759
+ x,
2760
+ y,
2761
+ z,
2762
+ __type: "point3d",
2763
+ delete: noop
2764
+ };
2765
+ }
2766
+ function createDirection3d(x, y, z) {
2767
+ return {
2768
+ x,
2769
+ y,
2770
+ z,
2771
+ __type: "direction3d",
2772
+ delete: noop
2773
+ };
2774
+ }
2775
+ function createVector3d(x, y, z) {
2776
+ return {
2777
+ x,
2778
+ y,
2779
+ z,
2780
+ __type: "vector3d",
2781
+ delete: noop
2782
+ };
2783
+ }
2784
+ function createAxis1(cx, cy, cz, dx, dy, dz) {
2785
+ return {
2786
+ origin: {
2787
+ x: cx,
2788
+ y: cy,
2789
+ z: cz
2790
+ },
2791
+ direction: {
2792
+ x: dx,
2793
+ y: dy,
2794
+ z: dz
2795
+ },
2796
+ __type: "axis1",
2797
+ delete: noop
2798
+ };
2799
+ }
2800
+ function createAxis2(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
2801
+ return {
2802
+ origin: {
2803
+ x: ox,
2804
+ y: oy,
2805
+ z: oz
2806
+ },
2807
+ zDir: {
2808
+ x: zx,
2809
+ y: zy,
2810
+ z: zz
2811
+ },
2812
+ xDir: xx !== void 0 ? {
2813
+ x: xx,
2814
+ y: xy,
2815
+ z: xz
2816
+ } : void 0,
2817
+ __type: "axis2",
2818
+ delete: noop
2819
+ };
2820
+ }
2821
+ function createAxis3(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
2822
+ return {
2823
+ origin: {
2824
+ x: ox,
2825
+ y: oy,
2826
+ z: oz
2827
+ },
2828
+ zDir: {
2829
+ x: zx,
2830
+ y: zy,
2831
+ z: zz
2832
+ },
2833
+ xDir: xx !== void 0 ? {
2834
+ x: xx,
2835
+ y: xy,
2836
+ z: xz
2837
+ } : void 0,
2838
+ __type: "axis3",
2839
+ delete: noop
2840
+ };
2841
+ }
2842
+ //#endregion
2843
+ //#region src/kernel/occtWasm/kernel2dOps.ts
2844
+ function c2d(h) {
2845
+ return h;
2846
+ }
2847
+ function c2dWrap(obj) {
2848
+ return obj;
2849
+ }
2850
+ function createPoint2d(x, y) {
2851
+ return {
2852
+ x,
2853
+ y
2854
+ };
2855
+ }
2856
+ function createDirection2d(x, y) {
2857
+ const l = Math.sqrt(x * x + y * y);
2858
+ if (l < 1e-15) throw new Error("occt-wasm: createDirection2d called with zero-length vector");
2859
+ return {
2860
+ x: x / l,
2861
+ y: y / l
2862
+ };
2863
+ }
2864
+ function createVector2d(x, y) {
2865
+ return {
2866
+ x,
2867
+ y
2868
+ };
2869
+ }
2870
+ function createAxis2d(px, py, dx, dy) {
2871
+ return {
2872
+ px,
2873
+ py,
2874
+ dx,
2875
+ dy,
2876
+ delete() {}
2877
+ };
2878
+ }
2879
+ function wrapCurve2dHandle(h) {
2880
+ return h;
2881
+ }
2882
+ function makeLine2d(x1, y1, x2, y2) {
2883
+ return c2dWrap(makeLine2d$1(x1, y1, x2, y2));
2884
+ }
2885
+ function makeCircle2d(cx, cy, radius, sense) {
2886
+ return c2dWrap(makeCircle2d$1(cx, cy, radius, sense));
2887
+ }
2888
+ function makeArc2dThreePoints(x1, y1, xm, ym, x2, y2) {
2889
+ const d = 2 * (x1 * (ym - y2) + xm * (y2 - y1) + x2 * (y1 - ym));
2890
+ if (Math.abs(d) < 1e-12) return c2dWrap(makeLine2d$1(x1, y1, x2, y2));
2891
+ const cx = ((x1 * x1 + y1 * y1) * (ym - y2) + (xm * xm + ym * ym) * (y2 - y1) + (x2 * x2 + y2 * y2) * (y1 - ym)) / d;
2892
+ const cy = ((x1 * x1 + y1 * y1) * (x2 - xm) + (xm * xm + ym * ym) * (x1 - x2) + (x2 * x2 + y2 * y2) * (xm - x1)) / d;
2893
+ const radius = Math.sqrt((x1 - cx) ** 2 + (y1 - cy) ** 2);
2894
+ const a1 = Math.atan2(y1 - cy, x1 - cx);
2895
+ const am = Math.atan2(ym - cy, xm - cx);
2896
+ const a2 = Math.atan2(y2 - cy, x2 - cx);
2897
+ let da1m = am - a1;
2898
+ if (da1m < 0) da1m += 2 * Math.PI;
2899
+ let da12 = a2 - a1;
2900
+ if (da12 < 0) da12 += 2 * Math.PI;
2901
+ const sense = da1m < da12;
2902
+ const circle = makeCircle2d$1(cx, cy, radius, sense);
2903
+ if (!sense) {
2904
+ const tStart = -a1;
2905
+ let tEnd = -a2;
2906
+ if (tEnd < tStart - 1e-9) tEnd += 2 * Math.PI;
2907
+ return c2dWrap({
2908
+ __bk2d: "trimmed",
2909
+ basis: circle,
2910
+ tStart,
2911
+ tEnd
2912
+ });
2913
+ }
2914
+ let tEnd = a2;
2915
+ if (tEnd < a1 - 1e-9) tEnd += 2 * Math.PI;
2916
+ return c2dWrap({
2917
+ __bk2d: "trimmed",
2918
+ basis: circle,
2919
+ tStart: a1,
2920
+ tEnd
2921
+ });
2922
+ }
2923
+ function makeArc2dTangent(startX, startY, tangentX, tangentY, endX, endY) {
2924
+ const len = Math.sqrt(tangentX * tangentX + tangentY * tangentY);
2925
+ const ntx = len > 0 ? tangentX / len : 0;
2926
+ const nty = len > 0 ? tangentY / len : 0;
2927
+ const dx = startX - endX;
2928
+ const dy = startY - endY;
2929
+ const denom = 2 * (dy * ntx - dx * nty);
2930
+ if (Math.abs(denom) < 1e-12) return c2dWrap(makeLine2d$1(startX, startY, endX, endY));
2931
+ const t = -(dx * dx + dy * dy) / denom;
2932
+ const cx = startX - t * nty;
2933
+ const cy = startY + t * ntx;
2934
+ const radius = Math.abs(t);
2935
+ const a1 = Math.atan2(startY - cy, startX - cx);
2936
+ const a2 = Math.atan2(endY - cy, endX - cx);
2937
+ const ccwTanX = -(startY - cy) / radius;
2938
+ const ccwTanY = (startX - cx) / radius;
2939
+ const sense = ccwTanX * ntx + ccwTanY * nty > 0;
2940
+ const circle = makeCircle2d$1(cx, cy, radius, sense);
2941
+ if (!sense) {
2942
+ const tStart = -a1;
2943
+ let tEnd = -a2;
2944
+ if (tEnd < tStart - 1e-9) tEnd += 2 * Math.PI;
2945
+ return c2dWrap({
2946
+ __bk2d: "trimmed",
2947
+ basis: circle,
2948
+ tStart,
2949
+ tEnd
2950
+ });
2951
+ }
2952
+ let tEnd = a2;
2953
+ if (tEnd < a1 - 1e-9) tEnd += 2 * Math.PI;
2954
+ return c2dWrap({
2955
+ __bk2d: "trimmed",
2956
+ basis: circle,
2957
+ tStart: a1,
2958
+ tEnd
2959
+ });
2960
+ }
2961
+ function makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense) {
2962
+ return c2dWrap(makeEllipse2d$1(cx, cy, majorRadius, minorRadius, xDirX ?? 1, xDirY ?? 0, sense ?? true));
2963
+ }
2964
+ function makeEllipseArc2d(cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense) {
2965
+ return c2dWrap({
2966
+ ...makeEllipse2d$1(cx, cy, majorRadius, minorRadius, xDirX ?? 1, xDirY ?? 0, sense ?? true),
2967
+ __bk2d: "ellipse",
2968
+ startAngle,
2969
+ endAngle
2970
+ });
2971
+ }
2972
+ function makeBezier2d(points) {
2973
+ return c2dWrap(makeBezier2d$1(points));
2974
+ }
2975
+ function makeBSpline2d(points) {
2976
+ if (points.length <= 25) return c2dWrap(makeBezier2d$1(points));
2977
+ const step = Math.max(1, Math.floor(points.length / 24));
2978
+ return c2dWrap(makeBezier2d$1(points.filter((_, i) => i % step === 0 || i === points.length - 1)));
2979
+ }
2980
+ function evaluateCurve2d(curve, param) {
2981
+ return evaluateCurve2d$1(c2d(curve), param);
2982
+ }
2983
+ function evaluateCurve2dD1(curve, param) {
2984
+ return {
2985
+ point: evaluateCurve2d$1(c2d(curve), param),
2986
+ tangent: tangentCurve2d(c2d(curve), param)
2987
+ };
2988
+ }
2989
+ function getCurve2dBounds(curve) {
2990
+ return curveBounds(c2d(curve));
2991
+ }
2992
+ function getCurve2dType(curve) {
2993
+ let cu = c2d(curve);
2994
+ while (cu.__bk2d === "trimmed" && cu.basis) cu = cu.basis;
2995
+ return curveTypeName(cu);
2996
+ }
2997
+ function trimCurve2d(curve, start, end) {
2998
+ return c2dWrap({
2999
+ __bk2d: "trimmed",
3000
+ basis: c2d(curve),
3001
+ tStart: start,
3002
+ tEnd: end
3003
+ });
3004
+ }
3005
+ function copyCurve2d(curve) {
3006
+ return c2dWrap(JSON.parse(JSON.stringify(c2d(curve))));
3007
+ }
3008
+ function offsetCurve2d(curve, offset) {
3009
+ const c = c2d(curve);
3010
+ const bounds = curveBounds(c);
3011
+ const pts = [];
3012
+ for (let i = 0; i <= 20; i++) {
3013
+ const t = bounds.first + (bounds.last - bounds.first) * i / 20;
3014
+ const [px, py] = evaluateCurve2d$1(c, t);
3015
+ const [tx, ty] = tangentCurve2d(c, t);
3016
+ const len = Math.sqrt(tx * tx + ty * ty) || 1;
3017
+ pts.push([px - ty / len * offset, py + tx / len * offset]);
3018
+ }
3019
+ return c2dWrap(makeBezier2d$1(pts.length <= 25 ? pts : pts.filter((_, i) => i % 2 === 0 || i === pts.length - 1)));
3020
+ }
3021
+ function translateCurve2d(curve, dx, dy) {
3022
+ return c2dWrap(translateCurve2d$1(c2d(curve), dx, dy));
3023
+ }
3024
+ function rotateCurve2d(curve, angle, cx, cy) {
3025
+ return c2dWrap(rotateCurve2d$1(c2d(curve), angle, cx, cy));
3026
+ }
3027
+ function scaleCurve2d(curve, factor, cx, cy) {
3028
+ const result = scaleCurve2d$1(c2d(curve), factor, cx, cy);
3029
+ const r = result;
3030
+ if (r.__bk2d === "line" && typeof r.len === "number") r.len = r.len * Math.abs(factor);
3031
+ return c2dWrap(result);
3032
+ }
3033
+ function mirrorCurve2dAtPoint(curve, cx, cy) {
3034
+ return c2dWrap(mirrorAtPoint(c2d(curve), cx, cy));
3035
+ }
3036
+ function mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
3037
+ return c2dWrap(mirrorAcrossAxis(c2d(curve), originX, originY, dirX, dirY));
3038
+ }
3039
+ function affinityTransform2d(curve) {
3040
+ return curve;
3041
+ }
3042
+ function createIdentityGTrsf2d() {
3043
+ return {
3044
+ type: "identity2d",
3045
+ delete() {}
3046
+ };
3047
+ }
3048
+ function createAffinityGTrsf2d(originX, originY, dirX, dirY, ratio) {
3049
+ return {
3050
+ type: "affinity2d",
3051
+ axOriginX: originX,
3052
+ axOriginY: originY,
3053
+ axDirX: dirX,
3054
+ axDirY: dirY,
3055
+ ratio,
3056
+ delete() {}
3057
+ };
3058
+ }
3059
+ function createTranslationGTrsf2d(dx, dy) {
3060
+ return {
3061
+ type: "translate2d",
3062
+ dx,
3063
+ dy,
3064
+ delete() {}
3065
+ };
3066
+ }
3067
+ function createMirrorGTrsf2d(cx, cy, mode, originX, originY, dirX, dirY) {
3068
+ return {
3069
+ type: "mirror2d",
3070
+ cx,
3071
+ cy,
3072
+ mode,
3073
+ originX,
3074
+ originY,
3075
+ dirX,
3076
+ dirY,
3077
+ delete() {}
3078
+ };
3079
+ }
3080
+ function createRotationGTrsf2d(angle, cx, cy) {
3081
+ return {
3082
+ type: "rotate2d",
3083
+ angle,
3084
+ cx,
3085
+ cy,
3086
+ delete() {}
3087
+ };
3088
+ }
3089
+ function createScaleGTrsf2d(factor, cx, cy) {
3090
+ return {
3091
+ type: "scale2d",
3092
+ sx: factor,
3093
+ sy: factor,
3094
+ cx,
3095
+ cy,
3096
+ delete() {}
3097
+ };
3098
+ }
3099
+ function setGTrsf2dTranslationPart(gtrsf, dx, dy) {
3100
+ const t = gtrsf;
3101
+ t["dx"] = (Number(t["dx"]) || 0) + dx;
3102
+ t["dy"] = (Number(t["dy"]) || 0) + dy;
3103
+ }
3104
+ function multiplyGTrsf2d(base, other) {
3105
+ const b = base;
3106
+ const o = other;
3107
+ b["dx"] = (Number(b["dx"]) || 0) + (Number(o["dx"]) || 0);
3108
+ b["dy"] = (Number(b["dy"]) || 0) + (Number(o["dy"]) || 0);
3109
+ if (o["type"] === "scale2d") {
3110
+ b["type"] = "scale2d";
3111
+ b["sx"] = o["sx"];
3112
+ b["sy"] = o["sy"];
3113
+ }
3114
+ }
3115
+ function transformCurve2dGeneral(curve, gtrsf) {
3116
+ const t = gtrsf;
3117
+ if (t["type"] === "translate2d") return translateCurve2d(curve, Number(t["dx"]) || 0, Number(t["dy"]) || 0);
3118
+ if (t["type"] === "rotate2d") return rotateCurve2d(curve, Number(t["angle"]) || 0, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
3119
+ if (t["type"] === "scale2d") return scaleCurve2d(curve, Number(t["sx"]) || 1, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
3120
+ if (t["type"] === "mirror2d") return mirrorCurve2dAtPoint(curve, Number(t["ox"]) || 0, Number(t["oy"]) || 0);
3121
+ if (t["type"] === "affinity2d") return scaleCurve2d(curve, Number(t["ratio"]) || 1, Number(t["axOriginX"]) || 0, Number(t["axOriginY"]) || 0);
3122
+ if (Number(t["dx"]) || Number(t["dy"])) return translateCurve2d(curve, Number(t["dx"]) || 0, Number(t["dy"]) || 0);
3123
+ return curve;
3124
+ }
3125
+ function intersectCurves2d(c1, c2, tolerance) {
3126
+ const result = intersectCurves2dFn(c2d(c1), c2d(c2), tolerance);
3127
+ return {
3128
+ points: result.points,
3129
+ segments: result.segments.map((s) => c2dWrap(s))
3130
+ };
3131
+ }
3132
+ function projectPointOnCurve2d(curve, x, y) {
3133
+ const c = c2d(curve);
3134
+ const bounds = curveBounds(c);
3135
+ const projectOnBasis = (basis, bFirst, bLast) => {
3136
+ if (basis.__bk2d === "line") {
3137
+ const rawT = (x - basis.ox) * basis.dx + (y - basis.oy) * basis.dy;
3138
+ const t = Math.max(bFirst, Math.min(bLast, rawT));
3139
+ const [px, py] = evaluateCurve2d$1(basis, t);
3140
+ return {
3141
+ param: t,
3142
+ distance: Math.sqrt((px - x) ** 2 + (py - y) ** 2)
3143
+ };
3144
+ }
3145
+ const N = 200;
3146
+ let bestT = bFirst;
3147
+ let bestDist = Infinity;
3148
+ for (let i = 0; i <= N; i++) {
3149
+ const t = bFirst + (bLast - bFirst) * i / N;
3150
+ const [px, py] = evaluateCurve2d$1(basis, t);
3151
+ const d = (px - x) ** 2 + (py - y) ** 2;
3152
+ if (d < bestDist) {
3153
+ bestDist = d;
3154
+ bestT = t;
3155
+ }
3156
+ }
3157
+ return {
3158
+ param: bestT,
3159
+ distance: Math.sqrt(bestDist)
3160
+ };
3161
+ };
3162
+ if (c.__bk2d === "trimmed" && c.basis) {
3163
+ const tStart = c.tStart;
3164
+ const tEnd = c.tEnd;
3165
+ const basisResult = projectOnBasis(c.basis, tStart, tEnd);
3166
+ if (!basisResult) return null;
3167
+ const range = tEnd - tStart;
3168
+ const trimmedT = range > 1e-15 ? (basisResult.param - tStart) / range : 0;
3169
+ return {
3170
+ param: Math.max(0, Math.min(1, trimmedT)),
3171
+ distance: basisResult.distance
3172
+ };
3173
+ }
3174
+ return projectOnBasis(c, bounds.first, bounds.last);
3175
+ }
3176
+ function distanceBetweenCurves2d(c1, c2, p1Start, p1End, p2Start, p2End) {
3177
+ const n = 20;
3178
+ let minDist = Infinity;
3179
+ for (let i = 0; i <= n; i++) {
3180
+ const t1 = p1Start + (p1End - p1Start) * (i / n);
3181
+ const [x1, y1] = evaluateCurve2d$1(c2d(c1), t1);
3182
+ for (let j = 0; j <= n; j++) {
3183
+ const t2 = p2Start + (p2End - p2Start) * (j / n);
3184
+ const [x2, y2] = evaluateCurve2d$1(c2d(c2), t2);
3185
+ const d = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
3186
+ if (d < minDist) minDist = d;
3187
+ }
3188
+ }
3189
+ return minDist;
3190
+ }
3191
+ function approximateCurve2dAsBSpline(curve, maxSegments) {
3192
+ const cu = c2d(curve);
3193
+ const bounds = curveBounds(cu);
3194
+ const nPts = Math.min(Math.max(maxSegments + 1, 10), 100);
3195
+ const poles = [];
3196
+ for (let i = 0; i < nPts; i++) {
3197
+ const t = bounds.first + (bounds.last - bounds.first) * i / (nPts - 1);
3198
+ poles.push(evaluateCurve2d$1(cu, t));
3199
+ }
3200
+ const degree = Math.min(3, nPts - 1);
3201
+ const n = poles.length;
3202
+ const knots = [];
3203
+ const mults = [];
3204
+ const nInternalKnots = n - degree - 1;
3205
+ knots.push(0);
3206
+ mults.push(degree + 1);
3207
+ for (let i = 1; i <= nInternalKnots; i++) {
3208
+ knots.push(i / (nInternalKnots + 1));
3209
+ mults.push(1);
3210
+ }
3211
+ knots.push(1);
3212
+ mults.push(degree + 1);
3213
+ return c2dWrap({
3214
+ __bk2d: "bspline",
3215
+ poles,
3216
+ knots,
3217
+ multiplicities: mults,
3218
+ degree,
3219
+ isPeriodic: false
3220
+ });
3221
+ }
3222
+ function decomposeBSpline2dToBeziers(curve) {
3223
+ const knots = c2d(curve).knots ?? [];
3224
+ if (knots.length < 2) return [curve];
3225
+ const result = [];
3226
+ for (let i = 0; i < knots.length - 1; i++) {
3227
+ const k0 = knots[i];
3228
+ const k1 = knots[i + 1];
3229
+ if (Math.abs(k1 - k0) < 1e-15) continue;
3230
+ result.push(trimCurve2d(curve, k0, k1));
3231
+ }
3232
+ return result.length > 0 ? result : [curve];
3233
+ }
3234
+ function createBoundingBox2d() {
3235
+ return createBBox2d();
3236
+ }
3237
+ function addCurveToBBox2d(bbox, curve, tolerance) {
3238
+ addCurveToBBox(bbox, c2d(curve), tolerance);
3239
+ }
3240
+ function getBBox2dBounds(bbox) {
3241
+ return {
3242
+ xMin: bbox.xMin,
3243
+ yMin: bbox.yMin,
3244
+ xMax: bbox.xMax,
3245
+ yMax: bbox.yMax
3246
+ };
3247
+ }
3248
+ function mergeBBox2d(target, other) {
3249
+ target.xMin = Math.min(target.xMin, other.xMin);
3250
+ target.yMin = Math.min(target.yMin, other.yMin);
3251
+ target.xMax = Math.max(target.xMax, other.xMax);
3252
+ target.yMax = Math.max(target.yMax, other.yMax);
3253
+ }
3254
+ function isBBox2dOut(a, b) {
3255
+ return a.xMax < b.xMin || a.xMin > b.xMax || a.yMax < b.yMin || a.yMin > b.yMax;
3256
+ }
3257
+ function isBBox2dOutPoint(bbox, x, y) {
3258
+ return x < bbox.xMin || x > bbox.xMax || y < bbox.yMin || y > bbox.yMax;
3259
+ }
3260
+ function getCurve2dCircleData(curve) {
3261
+ let c = c2d(curve);
3262
+ while (c.__bk2d === "trimmed" && c.basis) c = c.basis;
3263
+ if (c.__bk2d === "circle") return {
3264
+ cx: c.cx,
3265
+ cy: c.cy,
3266
+ radius: c.radius,
3267
+ isDirect: c.sense !== false
3268
+ };
3269
+ return null;
3270
+ }
3271
+ function getCurve2dEllipseData(curve) {
3272
+ let c = c2d(curve);
3273
+ while (c.__bk2d === "trimmed" && c.basis) c = c.basis;
3274
+ if (c.__bk2d === "ellipse") return {
3275
+ majorRadius: c.majorRadius,
3276
+ minorRadius: c.minorRadius,
3277
+ xAxisAngle: c.xDirAngle ?? 0,
3278
+ isDirect: c.sense !== false
3279
+ };
3280
+ return null;
3281
+ }
3282
+ function getCurve2dBezierPoles(curve) {
3283
+ let c = c2d(curve);
3284
+ while (c.__bk2d === "trimmed" && c.basis) c = c.basis;
3285
+ if (c.__bk2d === "bezier" && Array.isArray(c.poles)) return c.poles;
3286
+ return null;
3287
+ }
3288
+ function getCurve2dBezierDegree(curve) {
3289
+ let c = c2d(curve);
3290
+ while (c.__bk2d === "trimmed" && c.basis) c = c.basis;
3291
+ if (c["__bk2d"] === "bezier" && Array.isArray(c["poles"])) return c["poles"].length - 1;
3292
+ return null;
3293
+ }
3294
+ function serializeCurve2d(curve) {
3295
+ return serializeCurve2d$1(c2d(curve));
3296
+ }
3297
+ function deserializeCurve2d(data) {
3298
+ return c2dWrap(deserializeCurve2d$1(data));
3299
+ }
3300
+ function splitCurve2d(curve, params) {
3301
+ const bounds = curveBounds(c2d(curve));
3302
+ const sorted = [
3303
+ bounds.first,
3304
+ ...params.sort((a, b) => a - b),
3305
+ bounds.last
3306
+ ];
3307
+ const result = [];
3308
+ for (let i = 0; i < sorted.length - 1; i++) {
3309
+ const start = sorted[i] ?? bounds.first;
3310
+ const end = sorted[i + 1] ?? bounds.last;
3311
+ result.push(trimCurve2d(curve, start, end));
3312
+ }
3313
+ return result;
3314
+ }
3315
+ function liftCurve2dToPlane(k, Module, curve, planeOrigin, planeZ, planeX) {
3316
+ const cu = c2d(curve);
3317
+ const [ox, oy, oz] = planeOrigin;
3318
+ const [zx, zy, zz] = planeZ;
3319
+ const [xx, xy, xz] = planeX;
3320
+ const yx = zy * xz - zz * xy, yy = zz * xx - zx * xz, yz = zx * xy - zy * xx;
3321
+ const lift = (u, v) => [
3322
+ ox + u * xx + v * yx,
3323
+ oy + u * xy + v * yy,
3324
+ oz + u * xz + v * yz
3325
+ ];
3326
+ const bk2dType = cu.__bk2d;
3327
+ if (bk2dType === "line") {
3328
+ const bounds = curveBounds(cu);
3329
+ const [u1, v1] = evaluateCurve2d$1(cu, bounds.first);
3330
+ const [u2, v2] = evaluateCurve2d$1(cu, bounds.last);
3331
+ const p1 = lift(u1, v1);
3332
+ const p2 = lift(u2, v2);
3333
+ return handle("edge", k.makeLineEdge(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]));
3334
+ }
3335
+ if (bk2dType === "trimmed") {
3336
+ const trimmed = cu;
3337
+ if (trimmed.basis && trimmed.basis.__bk2d === "line") {
3338
+ const [u1, v1] = evaluateCurve2d$1(cu, 0);
3339
+ const [u2, v2] = evaluateCurve2d$1(cu, 1);
3340
+ const p1 = lift(u1, v1);
3341
+ const p2 = lift(u2, v2);
3342
+ return handle("edge", k.makeLineEdge(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]));
3343
+ }
3344
+ if (trimmed.basis && trimmed.basis.__bk2d === "circle") {
3345
+ const bounds = curveBounds(cu);
3346
+ const [u1, v1] = evaluateCurve2d$1(cu, bounds.first);
3347
+ const [um, vm] = evaluateCurve2d$1(cu, (bounds.first + bounds.last) / 2);
3348
+ const [u2, v2] = evaluateCurve2d$1(cu, bounds.last);
3349
+ const p1 = lift(u1, v1);
3350
+ const pm = lift(um, vm);
3351
+ const p2 = lift(u2, v2);
3352
+ return handle("edge", k.makeArcEdge(p1[0], p1[1], p1[2], pm[0], pm[1], pm[2], p2[0], p2[1], p2[2]));
3353
+ }
3354
+ }
3355
+ if (bk2dType === "circle") {
3356
+ const circleData = cu;
3357
+ if (circleData.cx !== void 0 && circleData.radius !== void 0) {
3358
+ const [pcx, pcy, pcz] = lift(circleData.cx, circleData.cy);
3359
+ return handle("edge", k.makeCircleEdge(pcx, pcy, pcz, zx, zy, zz, circleData.radius));
3360
+ }
3361
+ const bounds = curveBounds(cu);
3362
+ const [u1, v1] = evaluateCurve2d$1(cu, bounds.first);
3363
+ const [um, vm] = evaluateCurve2d$1(cu, (bounds.first + bounds.last) / 2);
3364
+ const [u2, v2] = evaluateCurve2d$1(cu, bounds.last);
3365
+ const p1 = lift(u1, v1);
3366
+ const pm = lift(um, vm);
3367
+ const p2 = lift(u2, v2);
3368
+ return handle("edge", k.makeArcEdge(p1[0], p1[1], p1[2], pm[0], pm[1], pm[2], p2[0], p2[1], p2[2]));
3369
+ }
3370
+ const bounds = curveBounds(cu);
3371
+ const nSamples = 24;
3372
+ const dt = (bounds.last - bounds.first) / nSamples;
3373
+ const pts = [];
3374
+ for (let i = 0; i <= nSamples; i++) {
3375
+ const [u, v] = evaluateCurve2d$1(cu, bounds.first + i * dt);
3376
+ const [px, py, pz] = lift(u, v);
3377
+ pts.push(px, py, pz);
3378
+ }
3379
+ const vec = new Module.VectorDouble();
3380
+ for (const p of pts) vec.push_back(p);
3381
+ try {
3382
+ return handle("edge", k.interpolatePoints(vec, false));
3383
+ } finally {
3384
+ vec.delete();
3385
+ }
3386
+ }
3387
+ function buildEdgeOnSurface(k, Module, curve, surface) {
3388
+ const cu = c2d(curve);
3389
+ const bounds = curveBounds(cu);
3390
+ const faceId = unwrap(surface);
3391
+ const nSamples = 30;
3392
+ const vec = new Module.VectorDouble();
3393
+ for (let i = 0; i <= nSamples; i++) {
3394
+ const [u, v] = evaluateCurve2d$1(cu, bounds.first + (bounds.last - bounds.first) * i / nSamples);
3395
+ const pt = k.pointOnSurface(faceId, u, v);
3396
+ try {
3397
+ vec.push_back(pt.get(0));
3398
+ vec.push_back(pt.get(1));
3399
+ vec.push_back(pt.get(2));
3400
+ } finally {
3401
+ pt.delete();
3402
+ }
3403
+ }
3404
+ try {
3405
+ return handle("edge", k.interpolatePoints(vec, false));
3406
+ } finally {
3407
+ vec.delete();
3408
+ }
3409
+ }
3410
+ function extractSurfaceFromFace(face) {
3411
+ return face;
3412
+ }
3413
+ function extractCurve2dFromEdge() {
3414
+ return c2dWrap(makeLine2d$1(0, 0, 1, 0));
3415
+ }
3416
+ function buildCurves3d(k, wire) {
3417
+ k.buildCurves3d(unwrap(wire));
3418
+ }
3419
+ function fixWireOnFace(k, wire, face, tolerance) {
3420
+ return handle("wire", k.fixWireOnFace(unwrap(wire), unwrap(face), tolerance));
3421
+ }
3422
+ //#endregion
3423
+ //#region src/kernel/occtWasm/evolutionOps.ts
3424
+ /**
3425
+ * Parse an EvolutionData result from the WASM kernel into a ShapeEvolution.
3426
+ * The C++ facade returns flat vectors of [inputHash, count, out1, out2, ..., inputHash, count, ...].
3427
+ */
3428
+ function parseEvolution(evo) {
3429
+ try {
3430
+ const modifiedRaw = readVecInt(evo.modified);
3431
+ const generatedRaw = readVecInt(evo.generated);
3432
+ const deletedRaw = readVecInt(evo.deleted);
3433
+ const parseMap = (raw) => {
3434
+ const map = /* @__PURE__ */ new Map();
3435
+ let i = 0;
3436
+ while (i + 1 < raw.length) {
3437
+ const inputHash = raw[i] ?? 0;
3438
+ const count = raw[i + 1] ?? 0;
3439
+ i += 2;
3440
+ const outputs = [];
3441
+ for (let j = 0; j < count && i < raw.length; j++, i++) outputs.push(raw[i] ?? 0);
3442
+ map.set(inputHash, outputs);
3443
+ }
3444
+ return map;
3445
+ };
3446
+ return {
3447
+ id: evo.resultId,
3448
+ evolution: {
3449
+ modified: parseMap(modifiedRaw),
3450
+ generated: parseMap(generatedRaw),
3451
+ deleted: new Set(deletedRaw)
3452
+ }
3453
+ };
3454
+ } finally {
3455
+ evo.delete();
3456
+ }
3457
+ }
3458
+ function translateWithHistory(k, Module, shape, x, y, z, inputFaceHashes, hashUpperBound) {
3459
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3460
+ try {
3461
+ const { id, evolution } = parseEvolution(k.translateWithHistory(unwrap(shape), x, y, z, hashVec, hashUpperBound));
3462
+ return {
3463
+ shape: wrapResult(k, id),
3464
+ evolution
3465
+ };
3466
+ } finally {
3467
+ hashVec.delete();
3468
+ }
3469
+ }
3470
+ function rotateWithHistory(k, Module, shape, angle, inputFaceHashes, hashUpperBound, axis, center) {
3471
+ const ax = axis ?? [
3472
+ 0,
3473
+ 0,
3474
+ 1
3475
+ ];
3476
+ const cn = center ?? [
3477
+ 0,
3478
+ 0,
3479
+ 0
3480
+ ];
3481
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3482
+ try {
3483
+ const { id, evolution } = parseEvolution(k.rotateWithHistory(unwrap(shape), cn[0], cn[1], cn[2], ax[0], ax[1], ax[2], angle, hashVec, hashUpperBound));
3484
+ return {
3485
+ shape: wrapResult(k, id),
3486
+ evolution
3487
+ };
3488
+ } finally {
3489
+ hashVec.delete();
3490
+ }
3491
+ }
3492
+ function mirrorWithHistory(k, Module, shape, origin, normal, inputFaceHashes, hashUpperBound) {
3493
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3494
+ try {
3495
+ const { id, evolution } = parseEvolution(k.mirrorWithHistory(unwrap(shape), origin[0], origin[1], origin[2], normal[0], normal[1], normal[2], hashVec, hashUpperBound));
3496
+ return {
3497
+ shape: wrapResult(k, id),
3498
+ evolution
3499
+ };
3500
+ } finally {
3501
+ hashVec.delete();
3502
+ }
3503
+ }
3504
+ function scaleWithHistory(k, Module, shape, center, factor, inputFaceHashes, hashUpperBound) {
3505
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3506
+ try {
3507
+ const { id, evolution } = parseEvolution(k.scaleWithHistory(unwrap(shape), center[0], center[1], center[2], factor, hashVec, hashUpperBound));
3508
+ return {
3509
+ shape: wrapResult(k, id),
3510
+ evolution
3511
+ };
3512
+ } finally {
3513
+ hashVec.delete();
3514
+ }
3515
+ }
3516
+ function generalTransformWithHistory(generalTransformFn, shape, linear, translation, isOrthogonal, inputFaceHashes) {
3517
+ const result = generalTransformFn(shape, linear, translation, isOrthogonal);
3518
+ const modified = /* @__PURE__ */ new Map();
3519
+ for (const h of inputFaceHashes) modified.set(h, [h]);
3520
+ return {
3521
+ shape: result,
3522
+ evolution: {
3523
+ modified,
3524
+ generated: /* @__PURE__ */ new Map(),
3525
+ deleted: /* @__PURE__ */ new Set()
3526
+ }
3527
+ };
3528
+ }
3529
+ function fuseWithHistory(k, Module, shape, tool, inputFaceHashes, hashUpperBound, _options) {
3530
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3531
+ try {
3532
+ const { id, evolution } = parseEvolution(k.fuseWithHistory(unwrap(shape), unwrap(tool), hashVec, hashUpperBound));
3533
+ return {
3534
+ shape: wrapResult(k, id),
3535
+ evolution,
3536
+ diagnostics: {
3537
+ hasErrors: false,
3538
+ hasWarnings: false,
3539
+ messages: []
3540
+ }
3541
+ };
3542
+ } finally {
3543
+ hashVec.delete();
3544
+ }
3545
+ }
3546
+ function cutWithHistory(k, Module, shape, tool, inputFaceHashes, hashUpperBound, _options) {
3547
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3548
+ try {
3549
+ const { id, evolution } = parseEvolution(k.cutWithHistory(unwrap(shape), unwrap(tool), hashVec, hashUpperBound));
3550
+ return {
3551
+ shape: wrapResult(k, id),
3552
+ evolution,
3553
+ diagnostics: {
3554
+ hasErrors: false,
3555
+ hasWarnings: false,
3556
+ messages: []
3557
+ }
3558
+ };
3559
+ } finally {
3560
+ hashVec.delete();
3561
+ }
3562
+ }
3563
+ function intersectWithHistory(k, Module, shape, tool, inputFaceHashes, hashUpperBound, _options) {
3564
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3565
+ try {
3566
+ const { id, evolution } = parseEvolution(k.intersectWithHistory(unwrap(shape), unwrap(tool), hashVec, hashUpperBound));
3567
+ return {
3568
+ shape: wrapResult(k, id),
3569
+ evolution,
3570
+ diagnostics: {
3571
+ hasErrors: false,
3572
+ hasWarnings: false,
3573
+ messages: []
3574
+ }
3575
+ };
3576
+ } finally {
3577
+ hashVec.delete();
3578
+ }
3579
+ }
3580
+ function filletWithHistory(k, Module, shape, edges, radius, inputFaceHashes, hashUpperBound) {
3581
+ const r = resolveUniformRadius(edges, radius);
3582
+ const edgeVec = makeVecU32(Module, edges.map(unwrap));
3583
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3584
+ try {
3585
+ const { id, evolution } = parseEvolution(k.filletWithHistory(unwrap(shape), edgeVec, r, hashVec, hashUpperBound));
3586
+ return {
3587
+ shape: wrapResult(k, id),
3588
+ evolution
3589
+ };
3590
+ } finally {
3591
+ edgeVec.delete();
3592
+ hashVec.delete();
3593
+ }
3594
+ }
3595
+ function chamferWithHistory(k, Module, shape, edges, distance, inputFaceHashes, hashUpperBound) {
3596
+ const d = resolveUniformRadius(edges, distance);
3597
+ const edgeVec = makeVecU32(Module, edges.map(unwrap));
3598
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3599
+ try {
3600
+ const { id, evolution } = parseEvolution(k.chamferWithHistory(unwrap(shape), edgeVec, d, hashVec, hashUpperBound));
3601
+ return {
3602
+ shape: wrapResult(k, id),
3603
+ evolution
3604
+ };
3605
+ } finally {
3606
+ edgeVec.delete();
3607
+ hashVec.delete();
3608
+ }
3609
+ }
3610
+ function shellWithHistory(k, Module, shape, faces, thickness, inputFaceHashes, hashUpperBound, tolerance) {
3611
+ const faceVec = makeVecU32(Module, faces.map(unwrap));
3612
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3613
+ try {
3614
+ const { id, evolution } = parseEvolution(k.shellWithHistory(unwrap(shape), faceVec, thickness, tolerance ?? .001, hashVec, hashUpperBound));
3615
+ return {
3616
+ shape: wrapResult(k, id),
3617
+ evolution
3618
+ };
3619
+ } finally {
3620
+ faceVec.delete();
3621
+ hashVec.delete();
3622
+ }
3623
+ }
3624
+ function thickenWithHistory(k, Module, shape, thickness, inputFaceHashes, hashUpperBound) {
3625
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3626
+ try {
3627
+ const { id, evolution } = parseEvolution(k.thickenWithHistory(unwrap(shape), thickness, .001, hashVec, hashUpperBound));
3628
+ return {
3629
+ shape: wrapResult(k, id),
3630
+ evolution
3631
+ };
3632
+ } finally {
3633
+ hashVec.delete();
3634
+ }
3635
+ }
3636
+ function offsetWithHistory(k, Module, shape, distance, inputFaceHashes, hashUpperBound, tolerance) {
3637
+ const hashVec = makeVecInt(Module, inputFaceHashes);
3638
+ try {
3639
+ const { id, evolution } = parseEvolution(k.offsetWithHistory(unwrap(shape), distance, tolerance ?? 1e-6, hashVec, hashUpperBound));
3640
+ return {
3641
+ shape: wrapResult(k, id),
3642
+ evolution
3643
+ };
3644
+ } finally {
3645
+ hashVec.delete();
3646
+ }
3647
+ }
3648
+ function draftWithHistory(k, shape, faces, pullDirection, angleDeg) {
3649
+ const [dx, dy, dz] = pullDirection;
3650
+ let currentId = unwrap(shape);
3651
+ for (const face of faces) {
3652
+ const angleRad = (typeof angleDeg === "number" ? angleDeg : angleDeg(face)) * Math.PI / 180;
3653
+ currentId = k.draft(currentId, unwrap(face), angleRad, dx, dy, dz);
3654
+ }
3655
+ return {
3656
+ shape: wrapResult(k, currentId),
3657
+ evolution: {
3658
+ modified: /* @__PURE__ */ new Map(),
3659
+ generated: /* @__PURE__ */ new Map(),
3660
+ deleted: /* @__PURE__ */ new Set()
3661
+ }
3662
+ };
3663
+ }
3664
+ function applyComposedTransformWithHistory(transformFn, iterShapesFn, hashCodeFn, shape, transformHandle, inputFaceHashes, hashUpperBound) {
3665
+ const result = transformFn(shape, transformHandle);
3666
+ const outFaces = iterShapesFn(result, "face");
3667
+ const modified = /* @__PURE__ */ new Map();
3668
+ const limit = Math.min(inputFaceHashes.length, outFaces.length);
3669
+ for (let i = 0; i < limit; i++) {
3670
+ const outFace = outFaces[i];
3671
+ const inHash = inputFaceHashes[i];
3672
+ if (outFace !== void 0 && inHash !== void 0) modified.set(inHash, [hashCodeFn(outFace, hashUpperBound)]);
3673
+ }
3674
+ return {
3675
+ shape: result,
3676
+ evolution: {
3677
+ modified,
3678
+ generated: /* @__PURE__ */ new Map(),
3679
+ deleted: /* @__PURE__ */ new Set()
3680
+ }
3681
+ };
3682
+ }
3683
+ //#endregion
3684
+ //#region src/kernel/occtWasm/hullOps.ts
3685
+ function findHorizonEdges(faces, visible) {
3686
+ const visSet = new Set(visible);
3687
+ const horizon = [];
3688
+ for (const fi of visible) {
3689
+ const f = faces[fi];
3690
+ for (let ei = 0; ei < 3; ei++) {
3691
+ const a = f[ei], b = f[(ei + 1) % 3];
3692
+ if (faces.some((g, fj) => fj !== fi && !visSet.has(fj) && [
3693
+ 0,
3694
+ 1,
3695
+ 2
3696
+ ].some((ej) => g[ej] === b && g[(ej + 1) % 3] === a))) horizon.push([a, b]);
3697
+ }
3698
+ }
3699
+ return horizon;
3700
+ }
3701
+ function computeConvexHullFaces(pts) {
3702
+ const cross = (a, b) => ({
3703
+ x: a.y * b.z - a.z * b.y,
3704
+ y: a.z * b.x - a.x * b.z,
3705
+ z: a.x * b.y - a.y * b.x
3706
+ });
3707
+ const sub = (a, b) => ({
3708
+ x: a.x - b.x,
3709
+ y: a.y - b.y,
3710
+ z: a.z - b.z
3711
+ });
3712
+ const dot = (a, b) => a.x * b.x + a.y * b.y + a.z * b.z;
3713
+ const n = pts.length;
3714
+ const faces = [];
3715
+ const p0 = pts[0];
3716
+ let i1 = 1;
3717
+ while (i1 < n) {
3718
+ const p = require_vec3.wasmIndex(pts, i1);
3719
+ if (Math.hypot(p.x - p0.x, p.y - p0.y, p.z - p0.z) >= 1e-10) break;
3720
+ i1++;
3721
+ }
3722
+ let i2 = i1 + 1;
3723
+ const e01 = sub(pts[i1], p0);
3724
+ while (i2 < n) {
3725
+ const c = cross(e01, sub(pts[i2], p0));
3726
+ if (Math.hypot(c.x, c.y, c.z) > 1e-10) break;
3727
+ i2++;
3728
+ }
3729
+ let i3 = i2 + 1;
3730
+ const norm = cross(e01, sub(pts[i2], p0));
3731
+ while (i3 < n) {
3732
+ if (Math.abs(dot(norm, sub(pts[i3], p0))) > 1e-10) break;
3733
+ i3++;
3734
+ }
3735
+ if (i3 >= n) return [[
3736
+ 0,
3737
+ 1,
3738
+ 2
3739
+ ]];
3740
+ if (dot(cross(sub(pts[i1], p0), sub(pts[i2], p0)), sub(pts[i3], p0)) > 0) faces.push([
3741
+ 0,
3742
+ i1,
3743
+ i2
3744
+ ], [
3745
+ 0,
3746
+ i2,
3747
+ i3
3748
+ ], [
3749
+ 0,
3750
+ i3,
3751
+ i1
3752
+ ], [
3753
+ i1,
3754
+ i3,
3755
+ i2
3756
+ ]);
3757
+ else faces.push([
3758
+ 0,
3759
+ i2,
3760
+ i1
3761
+ ], [
3762
+ 0,
3763
+ i3,
3764
+ i2
3765
+ ], [
3766
+ 0,
3767
+ i1,
3768
+ i3
3769
+ ], [
3770
+ i2,
3771
+ i3,
3772
+ i1
3773
+ ]);
3774
+ const used = new Set([
3775
+ 0,
3776
+ i1,
3777
+ i2,
3778
+ i3
3779
+ ]);
3780
+ for (let pi = 0; pi < n; pi++) {
3781
+ if (used.has(pi)) continue;
3782
+ const p = pts[pi];
3783
+ const visible = [];
3784
+ for (let fi = 0; fi < faces.length; fi++) {
3785
+ const f = faces[fi];
3786
+ if (dot(cross(sub(pts[f[1]], pts[f[0]]), sub(pts[f[2]], pts[f[0]])), sub(p, pts[f[0]])) > 1e-10) visible.push(fi);
3787
+ }
3788
+ if (visible.length === 0) continue;
3789
+ const horizon = findHorizonEdges(faces, visible);
3790
+ visible.sort((a2, b2) => b2 - a2);
3791
+ for (const fi of visible) faces.splice(fi, 1);
3792
+ for (const [a, b] of horizon) faces.push([
3793
+ a,
3794
+ b,
3795
+ pi
3796
+ ]);
3797
+ }
3798
+ return faces;
3799
+ }
3800
+ function hullFromPoints(k, Module, points, tolerance) {
3801
+ if (points.length < 4) throw new Error("hullFromPoints: need at least 4 points");
3802
+ return buildSolidFromFaces(k, Module, points, computeConvexHullFaces(points), tolerance);
3803
+ }
3804
+ //#endregion
3805
+ //#region src/kernel/occtWasm/occtWasmAdapter.ts
3806
+ /**
3807
+ * Parse an EvolutionData result from the WASM kernel into a ShapeEvolution.
3808
+ *
3809
+ * The C++ facade returns flat vectors of [inputHash, outputHash, inputHash, outputHash, ...]
3810
+ * for modified and generated, and a flat vector of deleted input hashes.
3811
+ */
3812
+ function notImplemented(method) {
3813
+ throw new Error(`occt-wasm: ${method} is not yet implemented`);
3814
+ }
3815
+ var OcctWasmAdapter = class {
3816
+ oc;
3817
+ kernelId = "occt-wasm";
3818
+ Module;
3819
+ k;
3820
+ constructor(module, kernel) {
3821
+ this.Module = module;
3822
+ this.k = wrapKernelExceptions(kernel, module);
3823
+ this.oc = buildOcShim(module, this.k);
3824
+ }
3825
+ dispose(h) {
3826
+ if (isOcctWasmHandle(h)) this.k.release(h.id);
3827
+ else if (typeof h.delete === "function") h.delete();
3828
+ }
3829
+ executeBatch(_json) {
3830
+ notImplemented("executeBatch");
3831
+ }
3832
+ checkpoint() {
3833
+ notImplemented("checkpoint");
3834
+ }
3835
+ checkpointCount() {
3836
+ notImplemented("checkpointCount");
3837
+ }
3838
+ restoreCheckpoint(_cp) {
3839
+ notImplemented("restoreCheckpoint");
3840
+ }
3841
+ discardCheckpoint(_cp) {
3842
+ notImplemented("discardCheckpoint");
3843
+ }
3844
+ makeBox(width, height, depth) {
3845
+ return makeBox(this.k, width, height, depth);
3846
+ }
3847
+ makeCylinder(radius, height, center, direction) {
3848
+ return makeCylinder(this.k, radius, height, center, direction);
3849
+ }
3850
+ makeSphere(radius, center) {
3851
+ return makeSphere(this.k, radius, center);
3852
+ }
3853
+ makeCone(radius1, radius2, height, center, direction) {
3854
+ return makeCone(this.k, radius1, radius2, height, center, direction);
3855
+ }
3856
+ makeTorus(majorRadius, minorRadius, center, direction) {
3857
+ return makeTorus(this.k, majorRadius, minorRadius, center, direction);
3858
+ }
3859
+ makeEllipsoid(aLength, bLength, cLength) {
3860
+ return makeEllipsoid(this.k, aLength, bLength, cLength);
3861
+ }
3862
+ makeBoxFromCorners(p1, p2) {
3863
+ return makeBoxFromCorners(this.k, p1, p2);
3864
+ }
3865
+ makeRectangle(width, height) {
3866
+ return makeRectangle(this.k, width, height);
3867
+ }
3868
+ fuse(shape, tool, options) {
3869
+ return fuse(this.k, shape, tool, options);
3870
+ }
3871
+ cut(shape, tool, options) {
3872
+ return cut(this.k, shape, tool, options);
3873
+ }
3874
+ intersect(shape, tool, options) {
3875
+ return intersect(this.k, shape, tool, options);
3876
+ }
3877
+ section(shape, plane, approximation) {
3878
+ return section(this.k, shape, plane, approximation);
3879
+ }
3880
+ fuseAll(shapes, options) {
3881
+ return fuseAll(this.k, this.Module, shapes, options);
3882
+ }
3883
+ cutAll(shape, tools, options) {
3884
+ return cutAll(this.k, this.Module, shape, tools, options);
3885
+ }
3886
+ split(shape, tools) {
3887
+ return split(this.k, this.Module, shape, tools);
3888
+ }
3889
+ checkBoolean(shape, tool, op) {
3890
+ return checkBoolean(this.k, shape, tool, op);
3891
+ }
3892
+ meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance) {
3893
+ return meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance);
3894
+ }
3895
+ makeVertex(x, y, z) {
3896
+ return makeVertex(this.k, x, y, z);
3897
+ }
3898
+ makeEdge(curve, _start, _end) {
3899
+ return makeEdge(this.k, curve);
3900
+ }
3901
+ makeWire(edges) {
3902
+ return makeWire(this.k, this.Module, edges);
3903
+ }
3904
+ makeFace(wire, planar) {
3905
+ return makeFace(this.k, wire, planar);
3906
+ }
3907
+ makeLineEdge(p1, p2) {
3908
+ return makeLineEdge(this.k, p1, p2);
3909
+ }
3910
+ makeCircleEdge(center, normal, radius) {
3911
+ return makeCircleEdge(this.k, center, normal, radius);
3912
+ }
3913
+ makeCircleArc(center, normal, radius, startAngle, endAngle) {
3914
+ return makeCircleArc(this.k, center, normal, radius, startAngle, endAngle);
3915
+ }
3916
+ makeArcEdge(p1, p2, p3) {
3917
+ return makeArcEdge(this.k, p1, p2, p3);
3918
+ }
3919
+ makeEllipseEdge(center, normal, majorRadius, minorRadius, _xDir) {
3920
+ return makeEllipseEdge(this.k, center, normal, majorRadius, minorRadius);
3921
+ }
3922
+ makeEllipseArc(center, normal, majorRadius, minorRadius, startAngle, endAngle, _xDir) {
3923
+ return makeEllipseArc(this.k, center, normal, majorRadius, minorRadius, startAngle, endAngle);
3924
+ }
3925
+ makeBezierEdge(points) {
3926
+ return makeBezierEdge(this.k, this.Module, points);
3927
+ }
3928
+ makeTangentArc(startPoint, startTangent, endPoint) {
3929
+ return makeTangentArc(this.k, startPoint, startTangent, endPoint);
3930
+ }
3931
+ makeHelixWire(pitch, height, radius, center, direction, _leftHanded) {
3932
+ return makeHelixWire(this.k, pitch, height, radius, center, direction);
3933
+ }
3934
+ makeWireFromMixed(items) {
3935
+ return this.makeWire(items);
3936
+ }
3937
+ makeCompound(shapes) {
3938
+ return makeCompound(this.k, this.Module, shapes);
3939
+ }
3940
+ solidFromShell(shell) {
3941
+ return solidFromShell(this.k, shell);
3942
+ }
3943
+ hull(_shapes, _tolerance) {
3944
+ notImplemented("hull");
3945
+ }
3946
+ hullFromPoints(points, tolerance) {
3947
+ return hullFromPoints(this.k, this.Module, points, tolerance);
3948
+ }
3949
+ buildSolidFromFaces(points, faces, tolerance) {
3950
+ return buildSolidFromFaces(this.k, this.Module, points, faces, tolerance);
3951
+ }
3952
+ makeNonPlanarFace(wire) {
3953
+ return makeNonPlanarFace(this.k, wire);
3954
+ }
3955
+ addHolesInFace(face, holeWires) {
3956
+ return addHolesInFace(this.k, this.Module, face, holeWires);
3957
+ }
3958
+ removeHolesFromFace(face) {
3959
+ return removeHolesFromFace(this.k, this.Module, face);
3960
+ }
3961
+ makeFaceOnSurface(surface, wire) {
3962
+ return makeFaceOnSurface(this.k, surface, wire);
3963
+ }
3964
+ bsplineSurface(points, rows, cols) {
3965
+ return bsplineSurface(this.k, this.Module, points, rows, cols);
3966
+ }
3967
+ triangulatedSurface(points, rows, cols) {
3968
+ return triangulatedSurface(this.k, this.Module, points, rows, cols);
3969
+ }
3970
+ buildTriFace(a, b, c) {
3971
+ return buildTriFace(this.k, a, b, c);
3972
+ }
3973
+ sewAndSolidify(faces, tolerance) {
3974
+ return sewAndSolidify(this.k, this.Module, faces, tolerance);
3975
+ }
3976
+ createPoint3d(x, y, z) {
3977
+ return createPoint3d(x, y, z);
3978
+ }
3979
+ createDirection3d(x, y, z) {
3980
+ return createDirection3d(x, y, z);
3981
+ }
3982
+ createVector3d(x, y, z) {
3983
+ return createVector3d(x, y, z);
3984
+ }
3985
+ createAxis1(cx, cy, cz, dx, dy, dz) {
3986
+ return createAxis1(cx, cy, cz, dx, dy, dz);
3987
+ }
3988
+ createAxis2(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
3989
+ return createAxis2(ox, oy, oz, zx, zy, zz, xx, xy, xz);
3990
+ }
3991
+ createAxis3(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
3992
+ return createAxis3(ox, oy, oz, zx, zy, zz, xx, xy, xz);
3993
+ }
3994
+ extrude(face, direction, length) {
3995
+ return extrude(this.k, face, direction, length);
3996
+ }
3997
+ revolve(shape, axis, angle) {
3998
+ return revolve(this.k, shape, axis, angle);
3999
+ }
4000
+ loft(wires, ruled, startShape, endShape) {
4001
+ return loft(this.k, this.Module, wires, ruled, startShape, endShape);
4002
+ }
4003
+ sweep(wire, spine, options) {
4004
+ return sweep(this.k, wire, spine, options);
4005
+ }
4006
+ simplePipe(profile, spine) {
4007
+ return simplePipe(this.k, profile, spine);
4008
+ }
4009
+ helicalSweep(_profile, _axisOrigin, _axisDirection, _radius, _pitch, _turns) {
4010
+ throw new Error("helicalSweep on occt-wasm requires profile positioning+orientation logic not yet implemented; brepkit has a native implementation");
4011
+ }
4012
+ sweepWithOptions(_profile, _pathEdge, _contactMode, _scaleValues, _segments) {
4013
+ notImplemented("sweepWithOptions");
4014
+ }
4015
+ sweepPipeShell(profile, spine, options) {
4016
+ return sweepPipeShell(this.k, profile, spine, options);
4017
+ }
4018
+ loftAdvanced(wires, options) {
4019
+ return loftAdvanced(this.k, this.Module, wires, options);
4020
+ }
4021
+ buildExtrusionLaw(profile, length, endFactor) {
4022
+ return buildExtrusionLaw(this.k, profile, length, endFactor);
4023
+ }
4024
+ revolveVec(shape, center, direction, angle) {
4025
+ return revolveVec(this.k, shape, center, direction, angle);
4026
+ }
4027
+ draftPrism(shape, face, baseFace, height, angleDeg, fuse) {
4028
+ return draftPrism(this.k, shape, face, baseFace, height, angleDeg, fuse);
4029
+ }
4030
+ fillet(shape, edges, radius) {
4031
+ return fillet(this.k, this.Module, shape, edges, radius);
4032
+ }
4033
+ chamfer(shape, edges, distance) {
4034
+ return chamfer(this.k, this.Module, shape, edges, distance);
4035
+ }
4036
+ chamferDistAngle(shape, edges, distance, angleDeg) {
4037
+ return chamferDistAngle(this.k, this.Module, shape, edges, distance, angleDeg);
4038
+ }
4039
+ shell(shape, faces, thickness, tolerance) {
4040
+ return shell(this.k, this.Module, shape, faces, thickness, tolerance);
4041
+ }
4042
+ thicken(shape, thickness) {
4043
+ return thicken(this.k, shape, thickness);
4044
+ }
4045
+ offset(shape, distance, tolerance) {
4046
+ return offset(this.k, shape, distance, tolerance);
4047
+ }
4048
+ filletVariable(shape, spec) {
4049
+ return filletVariable(this.k, shape, spec);
4050
+ }
4051
+ draft(shape, faces, pullDirection, neutralPlane, angleDeg) {
4052
+ return draft(this.k, shape, faces, pullDirection, neutralPlane, angleDeg);
4053
+ }
4054
+ defeature(shape, faces) {
4055
+ return defeature(this.k, this.Module, shape, faces);
4056
+ }
4057
+ offsetWire2D(wire, offset, joinType) {
4058
+ return offsetWire2D(this.k, wire, offset, joinType);
4059
+ }
4060
+ simplify(shape) {
4061
+ return simplify(this.k, shape);
4062
+ }
4063
+ reverseShape(shape) {
4064
+ return reverseShape(this.k, shape);
4065
+ }
4066
+ composeTransform(ops) {
4067
+ return composeTransform(ops);
4068
+ }
4069
+ transform(shape, trsf) {
4070
+ return transform(this.k, this.Module, shape, trsf);
4071
+ }
4072
+ translate(shape, x, y, z) {
4073
+ return translate(this.k, shape, x, y, z);
4074
+ }
4075
+ rotate(shape, angle, axis, center) {
4076
+ return rotate(this.k, shape, angle, axis, center);
4077
+ }
4078
+ mirror(shape, origin, normal) {
4079
+ return mirror(this.k, shape, origin, normal);
4080
+ }
4081
+ scale(shape, center, factor) {
4082
+ return scale(this.k, shape, center, factor);
4083
+ }
4084
+ generalTransform(shape, linear, translation, isOrthogonal) {
4085
+ return generalTransform(this.k, this.Module, shape, linear, translation, isOrthogonal);
4086
+ }
4087
+ generalTransformNonOrthogonal(shape, linear, translation) {
4088
+ return generalTransform(this.k, this.Module, shape, linear, translation, false);
4089
+ }
4090
+ positionOnCurve(shape, spine, param) {
4091
+ return positionOnCurve(this.k, this.Module, shape, spine, param);
4092
+ }
4093
+ linearPattern(shape, direction, spacing, count) {
4094
+ return linearPattern(this.k, shape, direction, spacing, count);
4095
+ }
4096
+ circularPattern(shape, center, axis, angleStep, count) {
4097
+ return circularPattern(this.k, shape, center, axis, angleStep, count);
4098
+ }
4099
+ transformBatch(entries) {
4100
+ return transformBatch(this.k, entries);
4101
+ }
4102
+ translateWithHistory(shape, x, y, z, inputFaceHashes, hashUpperBound) {
4103
+ return translateWithHistory(this.k, this.Module, shape, x, y, z, inputFaceHashes, hashUpperBound);
4104
+ }
4105
+ rotateWithHistory(shape, angle, inputFaceHashes, hashUpperBound, axis, center) {
4106
+ return rotateWithHistory(this.k, this.Module, shape, angle, inputFaceHashes, hashUpperBound, axis, center);
4107
+ }
4108
+ mirrorWithHistory(shape, origin, normal, inputFaceHashes, hashUpperBound) {
4109
+ return mirrorWithHistory(this.k, this.Module, shape, origin, normal, inputFaceHashes, hashUpperBound);
4110
+ }
4111
+ scaleWithHistory(shape, center, factor, inputFaceHashes, hashUpperBound) {
4112
+ return scaleWithHistory(this.k, this.Module, shape, center, factor, inputFaceHashes, hashUpperBound);
4113
+ }
4114
+ generalTransformWithHistory(shape, linear, translation, isOrthogonal, inputFaceHashes, _hashUpperBound) {
4115
+ return generalTransformWithHistory((s, l, t, o) => this.generalTransform(s, l, t, o), shape, linear, translation, isOrthogonal, inputFaceHashes);
4116
+ }
4117
+ fuseWithHistory(shape, tool, inputFaceHashes, hashUpperBound, options) {
4118
+ return fuseWithHistory(this.k, this.Module, shape, tool, inputFaceHashes, hashUpperBound, options);
4119
+ }
4120
+ cutWithHistory(shape, tool, inputFaceHashes, hashUpperBound, options) {
4121
+ return cutWithHistory(this.k, this.Module, shape, tool, inputFaceHashes, hashUpperBound, options);
4122
+ }
4123
+ intersectWithHistory(shape, tool, inputFaceHashes, hashUpperBound, options) {
4124
+ return intersectWithHistory(this.k, this.Module, shape, tool, inputFaceHashes, hashUpperBound, options);
4125
+ }
4126
+ filletWithHistory(shape, edges, radius, inputFaceHashes, hashUpperBound) {
4127
+ return filletWithHistory(this.k, this.Module, shape, edges, radius, inputFaceHashes, hashUpperBound);
4128
+ }
4129
+ chamferWithHistory(shape, edges, distance, inputFaceHashes, hashUpperBound) {
4130
+ return chamferWithHistory(this.k, this.Module, shape, edges, distance, inputFaceHashes, hashUpperBound);
4131
+ }
4132
+ shellWithHistory(shape, faces, thickness, inputFaceHashes, hashUpperBound, tolerance) {
4133
+ return shellWithHistory(this.k, this.Module, shape, faces, thickness, inputFaceHashes, hashUpperBound, tolerance);
4134
+ }
4135
+ thickenWithHistory(shape, thickness, inputFaceHashes, hashUpperBound) {
4136
+ return thickenWithHistory(this.k, this.Module, shape, thickness, inputFaceHashes, hashUpperBound);
4137
+ }
4138
+ offsetWithHistory(shape, distance, inputFaceHashes, hashUpperBound, tolerance) {
4139
+ return offsetWithHistory(this.k, this.Module, shape, distance, inputFaceHashes, hashUpperBound, tolerance);
4140
+ }
4141
+ draftWithHistory(shape, faces, pullDirection, _neutralPlane, angleDeg, _inputFaceHashes, _hashUpperBound) {
4142
+ return draftWithHistory(this.k, shape, faces, pullDirection, angleDeg);
4143
+ }
4144
+ applyComposedTransformWithHistory(shape, transformHandle, inputFaceHashes, hashUpperBound) {
4145
+ return applyComposedTransformWithHistory((s, t) => this.transform(s, t), (s, t) => this.iterShapes(s, t), (s, ub) => this.hashCode(s, ub), shape, transformHandle, inputFaceHashes, hashUpperBound);
4146
+ }
4147
+ mesh(shape, options) {
4148
+ return mesh(this.k, this.Module, shape, options);
4149
+ }
4150
+ meshEdges(shape, tolerance, angularTolerance) {
4151
+ return meshEdges(this.k, this.Module, shape, tolerance, angularTolerance);
4152
+ }
4153
+ hasTriangulation(shape) {
4154
+ return hasTriangulation(this.k, shape);
4155
+ }
4156
+ meshShape(shape, tolerance, angularTolerance) {
4157
+ meshShape(this.k, shape, tolerance, angularTolerance);
4158
+ }
4159
+ exportSTEP(shapes) {
4160
+ return exportSTEP(this.k, this.makeCompound.bind(this), shapes);
4161
+ }
4162
+ exportSTL(shape, binary) {
4163
+ return exportSTL(this.k, shape, binary);
4164
+ }
4165
+ importSTEP(data) {
4166
+ return importSTEP(this.k, data);
4167
+ }
4168
+ importSTL(data) {
4169
+ return importSTL(this.k, this.Module, data);
4170
+ }
4171
+ exportIGES(shapes) {
4172
+ return exportIGES(this.k, this.makeCompound.bind(this), shapes);
4173
+ }
4174
+ importIGES(data) {
4175
+ return importIGES(this.k, data);
4176
+ }
4177
+ exportSTEPAssembly(parts, options) {
4178
+ return exportSTEPAssembly(this.k, this.Module, parts, options);
4179
+ }
4180
+ export3MF(_shape, _tolerance) {
4181
+ throw new Error("export3MF is only available with the brepkit kernel");
4182
+ }
4183
+ exportGLB(shape, tolerance) {
4184
+ return exportGLB(this.mesh.bind(this), shape, tolerance);
4185
+ }
4186
+ exportOBJ(shape, tolerance) {
4187
+ return exportOBJ(this.mesh.bind(this), shape, tolerance);
4188
+ }
4189
+ exportPLY(shape, tolerance) {
4190
+ return exportPLY(this.mesh.bind(this), shape, tolerance);
4191
+ }
4192
+ import3MF(_data) {
4193
+ throw new Error("import3MF is only available with the brepkit kernel");
4194
+ }
4195
+ importOBJ(_data) {
4196
+ throw new Error("importOBJ is only available with the brepkit kernel");
4197
+ }
4198
+ importGLB(_data) {
4199
+ throw new Error("importGLB is only available with the brepkit kernel");
4200
+ }
4201
+ toBREP(shape) {
4202
+ return toBREP(this.k, shape);
4203
+ }
4204
+ fromBREP(data) {
4205
+ return fromBREP(this.k, data);
4206
+ }
4207
+ createXCAFDocument(shapes) {
4208
+ return createXCAFDocument(this.k, this.Module, shapes);
4209
+ }
4210
+ writeXCAFToSTEP(doc, options) {
4211
+ return writeXCAFToSTEP(this.k, doc, options);
4212
+ }
4213
+ exportSTEPConfigured(shapes, options) {
4214
+ return exportSTEPConfigured(this.k, this.Module, shapes, options);
4215
+ }
4216
+ volume(shape) {
4217
+ return volume(this.k, shape);
4218
+ }
4219
+ area(shape) {
4220
+ return area(this.k, shape);
4221
+ }
4222
+ length(shape) {
4223
+ return length(this.k, shape);
4224
+ }
4225
+ centerOfMass(shape) {
4226
+ return centerOfMass(this.k, shape);
4227
+ }
4228
+ linearCenterOfMass(shape) {
4229
+ return linearCenterOfMass(this.k, shape);
4230
+ }
4231
+ boundingBox(shape) {
4232
+ return boundingBox(this.k, shape);
4233
+ }
4234
+ distance(shape1, shape2) {
4235
+ return distance(this.k, this.Module, shape1, shape2);
4236
+ }
4237
+ surfaceCurvature(face, u, v) {
4238
+ return surfaceCurvature(this.k, face, u, v);
4239
+ }
4240
+ surfaceCenterOfMass(face) {
4241
+ return surfaceCenterOfMass(this.k, face);
4242
+ }
4243
+ measureBulk(shape, includeLinear) {
4244
+ return measureBulk(this.k, shape, includeLinear);
4245
+ }
4246
+ createDistanceQuery(referenceShape) {
4247
+ return createDistanceQuery(this.k, referenceShape);
4248
+ }
4249
+ iterShapes(shape, type) {
4250
+ return iterShapes(this.k, shape, type);
4251
+ }
4252
+ iterShapeList(_list, _callback) {
4253
+ throw new Error("iterShapeList is not applicable to occt-wasm: the arena model has no TopTools_ListOfShape handles");
4254
+ }
4255
+ shapeType(shape) {
4256
+ return shapeType(this.k, shape);
4257
+ }
4258
+ isSame(a, b) {
4259
+ return isSame(this.k, a, b);
4260
+ }
4261
+ isEqual(a, b) {
4262
+ return isEqual(this.k, a, b);
4263
+ }
4264
+ downcast(shape, type) {
4265
+ return downcast(this.k, shape, type);
4266
+ }
4267
+ hashCode(shape, upperBound) {
4268
+ return hashCode(this.k, shape, upperBound);
4269
+ }
4270
+ isNull(shape) {
4271
+ return isNull(this.k, shape);
4272
+ }
4273
+ shapeOrientation(shape) {
4274
+ return shapeOrientation(this.k, shape);
4275
+ }
4276
+ edgeToFaceMap(shape) {
4277
+ return edgeToFaceMap(this.k, shape);
4278
+ }
4279
+ sharedEdges(faceA, faceB) {
4280
+ return sharedEdges(this.k, faceA, faceB);
4281
+ }
4282
+ adjacentFaces(shape, face) {
4283
+ return adjacentFaces(this.k, shape, face);
4284
+ }
4285
+ sew(shapes, tolerance) {
4286
+ return sew(this.k, this.Module, shapes, tolerance);
4287
+ }
4288
+ curveType(shape) {
4289
+ return curveType(this.k, shape);
4290
+ }
4291
+ curveParameters(shape) {
4292
+ return curveParameters(this.k, shape);
4293
+ }
4294
+ curvePointAtParam(shape, param) {
4295
+ return curvePointAtParam(this.k, shape, param);
4296
+ }
4297
+ curveTangent(shape, param) {
4298
+ return curveTangent(this.k, shape, param);
4299
+ }
4300
+ curveIsClosed(shape) {
4301
+ return curveIsClosed(this.k, shape);
4302
+ }
4303
+ curveIsPeriodic(shape) {
4304
+ return curveIsPeriodic(this.k, shape);
4305
+ }
4306
+ curvePeriod(shape) {
4307
+ return curvePeriod(this.k, shape);
4308
+ }
4309
+ interpolatePoints(points, options) {
4310
+ return interpolatePoints(this.k, this.Module, points, options);
4311
+ }
4312
+ approximatePoints(points, options) {
4313
+ return approximatePoints(this.k, this.Module, points, options);
4314
+ }
4315
+ curveDegreeElevate(_edge, _elevateBy) {
4316
+ notImplemented("curveDegreeElevate");
4317
+ }
4318
+ curveKnotInsert(_edge, _knot, _times) {
4319
+ notImplemented("curveKnotInsert");
4320
+ }
4321
+ curveKnotRemove(_edge, _knot, _tolerance) {
4322
+ notImplemented("curveKnotRemove");
4323
+ }
4324
+ curveSplit(_edge, _param) {
4325
+ notImplemented("curveSplit");
4326
+ }
4327
+ createCurveAdaptor(_shape) {
4328
+ notImplemented("createCurveAdaptor");
4329
+ }
4330
+ getBezierPenultimatePole(_edge) {
4331
+ notImplemented("getBezierPenultimatePole");
4332
+ }
4333
+ vertexPosition(vertex) {
4334
+ return vertexPosition(this.k, vertex);
4335
+ }
4336
+ surfaceType(face) {
4337
+ return surfaceType(this.k, face);
4338
+ }
4339
+ uvBounds(face) {
4340
+ return uvBounds(this.k, face);
4341
+ }
4342
+ outerWire(face) {
4343
+ return outerWire(this.k, face);
4344
+ }
4345
+ surfaceNormal(face, u, v) {
4346
+ return surfaceNormal(this.k, face, u, v);
4347
+ }
4348
+ pointOnSurface(face, u, v) {
4349
+ return pointOnSurface(this.k, face, u, v);
4350
+ }
4351
+ uvFromPoint(face, point) {
4352
+ return uvFromPoint(this.k, face, point);
4353
+ }
4354
+ projectPointOnFace(face, point) {
4355
+ return projectPointOnFace(this.k, face, point);
4356
+ }
4357
+ classifyPointOnFace(face, u, v, tolerance) {
4358
+ return classifyPointOnFace(this.k, face, u, v, tolerance);
4359
+ }
4360
+ classifyPointRobust(_shape, _point, _tolerance) {
4361
+ notImplemented("classifyPointRobust");
4362
+ }
4363
+ classifyPointWinding(_shape, _point, _tolerance) {
4364
+ notImplemented("classifyPointWinding");
4365
+ }
4366
+ approximateSurfaceLspia(_coords, _rows, _cols, _degreeU, _degreeV, _numCpsU, _numCpsV, _tolerance, _maxIterations) {
4367
+ notImplemented("approximateSurfaceLspia");
4368
+ }
4369
+ untrimFace(_face, _samplesPerCurve, _interiorSamples) {
4370
+ notImplemented("untrimFace");
4371
+ }
4372
+ getSurfaceCylinderData(_surface) {
4373
+ notImplemented("getSurfaceCylinderData");
4374
+ }
4375
+ reverseSurfaceU(_surface) {
4376
+ notImplemented("reverseSurfaceU");
4377
+ }
4378
+ detectSmallFeatures(_shape, _areaThreshold, _tolerance) {
4379
+ notImplemented("detectSmallFeatures");
4380
+ }
4381
+ recognizeFeatures(_shape, _tolerance) {
4382
+ notImplemented("recognizeFeatures");
4383
+ }
4384
+ projectEdges(shape, cameraOrigin, cameraDirection, cameraXAxis) {
4385
+ return projectEdges(this.k, this.Module, shape, cameraOrigin, cameraDirection, cameraXAxis);
4386
+ }
4387
+ isValid(shape) {
4388
+ return isValid(this.k, shape);
4389
+ }
4390
+ healSolid(shape) {
4391
+ return healSolid(this.k, shape);
4392
+ }
4393
+ healFace(shape) {
4394
+ return healFace(this.k, shape);
4395
+ }
4396
+ healWire(wire, face) {
4397
+ return healWire(this.k, wire, face);
4398
+ }
4399
+ mergeCoincidentVertices(shape, tolerance) {
4400
+ return mergeCoincidentVertices(this.k, shape, tolerance);
4401
+ }
4402
+ removeDegenerateEdges(shape, tolerance) {
4403
+ return removeDegenerateEdges(this.k, shape, tolerance);
4404
+ }
4405
+ fixFaceOrientations(shape) {
4406
+ return fixFaceOrientations(this.k, shape);
4407
+ }
4408
+ fixShape(shape) {
4409
+ return fixShape(this.k, shape);
4410
+ }
4411
+ fixSelfIntersection(_wire) {
4412
+ notImplemented("fixSelfIntersection");
4413
+ }
4414
+ createPoint2d(x, y) {
4415
+ return createPoint2d(x, y);
4416
+ }
4417
+ createDirection2d(x, y) {
4418
+ return createDirection2d(x, y);
4419
+ }
4420
+ createVector2d(x, y) {
4421
+ return createVector2d(x, y);
4422
+ }
4423
+ createAxis2d(px, py, dx, dy) {
4424
+ return createAxis2d(px, py, dx, dy);
4425
+ }
4426
+ wrapCurve2dHandle(h) {
4427
+ return wrapCurve2dHandle(h);
4428
+ }
4429
+ createCurve2dAdaptor(_handle) {
4430
+ notImplemented("createCurve2dAdaptor");
4431
+ }
4432
+ makeLine2d(x1, y1, x2, y2) {
4433
+ return makeLine2d(x1, y1, x2, y2);
4434
+ }
4435
+ makeCircle2d(cx, cy, radius, sense) {
4436
+ return makeCircle2d(cx, cy, radius, sense);
4437
+ }
4438
+ makeArc2dThreePoints(x1, y1, xm, ym, x2, y2) {
4439
+ return makeArc2dThreePoints(x1, y1, xm, ym, x2, y2);
4440
+ }
4441
+ makeArc2dTangent(startX, startY, tangentX, tangentY, endX, endY) {
4442
+ return makeArc2dTangent(startX, startY, tangentX, tangentY, endX, endY);
4443
+ }
4444
+ makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense) {
4445
+ return makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense);
4446
+ }
4447
+ makeEllipseArc2d(cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense) {
4448
+ return makeEllipseArc2d(cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense);
4449
+ }
4450
+ makeBezier2d(points) {
4451
+ return makeBezier2d(points);
4452
+ }
4453
+ makeBSpline2d(points, _options) {
4454
+ return makeBSpline2d(points);
4455
+ }
4456
+ evaluateCurve2d(curve, param) {
4457
+ return evaluateCurve2d(curve, param);
4458
+ }
4459
+ evaluateCurve2dD1(curve, param) {
4460
+ return evaluateCurve2dD1(curve, param);
4461
+ }
4462
+ getCurve2dBounds(curve) {
4463
+ return getCurve2dBounds(curve);
4464
+ }
4465
+ getCurve2dType(curve) {
4466
+ return getCurve2dType(curve);
4467
+ }
4468
+ trimCurve2d(curve, start, end) {
4469
+ return trimCurve2d(curve, start, end);
4470
+ }
4471
+ reverseCurve2d(curve) {}
4472
+ copyCurve2d(curve) {
4473
+ return copyCurve2d(curve);
4474
+ }
4475
+ offsetCurve2d(curve, offset) {
4476
+ return offsetCurve2d(curve, offset);
4477
+ }
4478
+ translateCurve2d(curve, dx, dy) {
4479
+ return translateCurve2d(curve, dx, dy);
4480
+ }
4481
+ rotateCurve2d(curve, angle, cx, cy) {
4482
+ return rotateCurve2d(curve, angle, cx, cy);
4483
+ }
4484
+ scaleCurve2d(curve, factor, cx, cy) {
4485
+ return scaleCurve2d(curve, factor, cx, cy);
4486
+ }
4487
+ mirrorCurve2dAtPoint(curve, cx, cy) {
4488
+ return mirrorCurve2dAtPoint(curve, cx, cy);
4489
+ }
4490
+ mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
4491
+ return mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY);
4492
+ }
4493
+ affinityTransform2d(curve, _axisOriginX, _axisOriginY, _axisDirX, _axisDirY, _ratio) {
4494
+ return affinityTransform2d(curve);
4495
+ }
4496
+ createIdentityGTrsf2d() {
4497
+ return createIdentityGTrsf2d();
4498
+ }
4499
+ createAffinityGTrsf2d(originX, originY, dirX, dirY, ratio) {
4500
+ return createAffinityGTrsf2d(originX, originY, dirX, dirY, ratio);
4501
+ }
4502
+ createTranslationGTrsf2d(dx, dy) {
4503
+ return createTranslationGTrsf2d(dx, dy);
4504
+ }
4505
+ createMirrorGTrsf2d(cx, cy, mode, originX, originY, dirX, dirY) {
4506
+ return createMirrorGTrsf2d(cx, cy, mode, originX, originY, dirX, dirY);
4507
+ }
4508
+ createRotationGTrsf2d(angle, cx, cy) {
4509
+ return createRotationGTrsf2d(angle, cx, cy);
4510
+ }
4511
+ createScaleGTrsf2d(factor, cx, cy) {
4512
+ return createScaleGTrsf2d(factor, cx, cy);
4513
+ }
4514
+ setGTrsf2dTranslationPart(gtrsf, dx, dy) {
4515
+ setGTrsf2dTranslationPart(gtrsf, dx, dy);
4516
+ }
4517
+ multiplyGTrsf2d(base, other) {
4518
+ multiplyGTrsf2d(base, other);
4519
+ }
4520
+ transformCurve2dGeneral(curve, gtrsf) {
4521
+ return transformCurve2dGeneral(curve, gtrsf);
4522
+ }
4523
+ intersectCurves2d(c1, c2, tolerance) {
4524
+ return intersectCurves2d(c1, c2, tolerance);
4525
+ }
4526
+ projectPointOnCurve2d(curve, x, y) {
4527
+ return projectPointOnCurve2d(curve, x, y);
4528
+ }
4529
+ distanceBetweenCurves2d(c1, c2, p1Start, p1End, p2Start, p2End) {
4530
+ return distanceBetweenCurves2d(c1, c2, p1Start, p1End, p2Start, p2End);
4531
+ }
4532
+ approximateCurve2dAsBSpline(curve, _tolerance, _continuity, maxSegments) {
4533
+ return approximateCurve2dAsBSpline(curve, maxSegments);
4534
+ }
4535
+ decomposeBSpline2dToBeziers(curve) {
4536
+ return decomposeBSpline2dToBeziers(curve);
4537
+ }
4538
+ createBoundingBox2d() {
4539
+ return createBoundingBox2d();
4540
+ }
4541
+ addCurveToBBox2d(bbox, curve, tolerance) {
4542
+ addCurveToBBox2d(bbox, curve, tolerance);
4543
+ }
4544
+ getBBox2dBounds(bbox) {
4545
+ return getBBox2dBounds(bbox);
4546
+ }
4547
+ mergeBBox2d(target, other) {
4548
+ mergeBBox2d(target, other);
4549
+ }
4550
+ isBBox2dOut(a, b) {
4551
+ return isBBox2dOut(a, b);
4552
+ }
4553
+ isBBox2dOutPoint(bbox, x, y) {
4554
+ return isBBox2dOutPoint(bbox, x, y);
4555
+ }
4556
+ getCurve2dCircleData(curve) {
4557
+ return getCurve2dCircleData(curve);
4558
+ }
4559
+ getCurve2dEllipseData(curve) {
4560
+ return getCurve2dEllipseData(curve);
4561
+ }
4562
+ getCurve2dBezierPoles(curve) {
4563
+ return getCurve2dBezierPoles(curve);
4564
+ }
4565
+ getCurve2dBezierDegree(curve) {
4566
+ return getCurve2dBezierDegree(curve);
4567
+ }
4568
+ getCurve2dBSplineData(_curve) {
4569
+ notImplemented("getCurve2dBSplineData");
4570
+ }
4571
+ serializeCurve2d(curve) {
4572
+ return serializeCurve2d(curve);
4573
+ }
4574
+ deserializeCurve2d(data) {
4575
+ return deserializeCurve2d(data);
4576
+ }
4577
+ splitCurve2d(curve, params) {
4578
+ return splitCurve2d(curve, params);
4579
+ }
4580
+ liftCurve2dToPlane(curve, planeOrigin, planeZ, planeX) {
4581
+ return liftCurve2dToPlane(this.k, this.Module, curve, planeOrigin, planeZ, planeX);
4582
+ }
4583
+ buildEdgeOnSurface(curve, surface) {
4584
+ return buildEdgeOnSurface(this.k, this.Module, curve, surface);
4585
+ }
4586
+ extractSurfaceFromFace(face) {
4587
+ return extractSurfaceFromFace(face);
4588
+ }
4589
+ extractCurve2dFromEdge(_edge, _face) {
4590
+ return extractCurve2dFromEdge();
4591
+ }
4592
+ buildCurves3d(wire) {
4593
+ buildCurves3d(this.k, wire);
4594
+ }
4595
+ fixWireOnFace(wire, face, tolerance) {
4596
+ return fixWireOnFace(this.k, wire, face, tolerance);
4597
+ }
4598
+ fillSurface(_wires, _options) {
4599
+ notImplemented("fillSurface");
4600
+ }
4601
+ getNurbsCurveData(edge) {
4602
+ return getNurbsCurveData(this.k, edge);
4603
+ }
4604
+ };
4605
+ //#endregion
4606
+ Object.defineProperty(exports, "OcctWasmAdapter", {
4607
+ enumerable: true,
4608
+ get: function() {
4609
+ return OcctWasmAdapter;
4610
+ }
4611
+ });
4612
+ Object.defineProperty(exports, "addCurveToBBox", {
4613
+ enumerable: true,
4614
+ get: function() {
4615
+ return addCurveToBBox;
4616
+ }
4617
+ });
4618
+ Object.defineProperty(exports, "createBBox2d", {
4619
+ enumerable: true,
4620
+ get: function() {
4621
+ return createBBox2d;
4622
+ }
4623
+ });
4624
+ Object.defineProperty(exports, "curveBounds", {
4625
+ enumerable: true,
4626
+ get: function() {
4627
+ return curveBounds;
4628
+ }
4629
+ });
4630
+ Object.defineProperty(exports, "curveTypeName", {
4631
+ enumerable: true,
4632
+ get: function() {
4633
+ return curveTypeName;
4634
+ }
4635
+ });
4636
+ Object.defineProperty(exports, "deserializeCurve2d", {
4637
+ enumerable: true,
4638
+ get: function() {
4639
+ return deserializeCurve2d$1;
4640
+ }
4641
+ });
4642
+ Object.defineProperty(exports, "evaluateCurve2d", {
4643
+ enumerable: true,
4644
+ get: function() {
4645
+ return evaluateCurve2d$1;
4646
+ }
4647
+ });
4648
+ Object.defineProperty(exports, "intersectCurves2dFn", {
4649
+ enumerable: true,
4650
+ get: function() {
4651
+ return intersectCurves2dFn;
4652
+ }
4653
+ });
4654
+ Object.defineProperty(exports, "makeBezier2d", {
4655
+ enumerable: true,
4656
+ get: function() {
4657
+ return makeBezier2d$1;
4658
+ }
4659
+ });
4660
+ Object.defineProperty(exports, "makeCircle2d", {
4661
+ enumerable: true,
4662
+ get: function() {
4663
+ return makeCircle2d$1;
4664
+ }
4665
+ });
4666
+ Object.defineProperty(exports, "makeEllipse2d", {
4667
+ enumerable: true,
4668
+ get: function() {
4669
+ return makeEllipse2d$1;
4670
+ }
4671
+ });
4672
+ Object.defineProperty(exports, "makeLine2d", {
4673
+ enumerable: true,
4674
+ get: function() {
4675
+ return makeLine2d$1;
4676
+ }
4677
+ });
4678
+ Object.defineProperty(exports, "mirrorAcrossAxis", {
4679
+ enumerable: true,
4680
+ get: function() {
4681
+ return mirrorAcrossAxis;
4682
+ }
4683
+ });
4684
+ Object.defineProperty(exports, "mirrorAtPoint", {
4685
+ enumerable: true,
4686
+ get: function() {
4687
+ return mirrorAtPoint;
4688
+ }
4689
+ });
4690
+ Object.defineProperty(exports, "rotateCurve2d", {
4691
+ enumerable: true,
4692
+ get: function() {
4693
+ return rotateCurve2d$1;
4694
+ }
4695
+ });
4696
+ Object.defineProperty(exports, "scaleCurve2d", {
4697
+ enumerable: true,
4698
+ get: function() {
4699
+ return scaleCurve2d$1;
4700
+ }
4701
+ });
4702
+ Object.defineProperty(exports, "serializeCurve2d", {
4703
+ enumerable: true,
4704
+ get: function() {
4705
+ return serializeCurve2d$1;
4706
+ }
4707
+ });
4708
+ Object.defineProperty(exports, "tangentCurve2d", {
4709
+ enumerable: true,
4710
+ get: function() {
4711
+ return tangentCurve2d;
4712
+ }
4713
+ });
4714
+ Object.defineProperty(exports, "translateCurve2d", {
4715
+ enumerable: true,
4716
+ get: function() {
4717
+ return translateCurve2d$1;
4718
+ }
4719
+ });