brepkit-wasm 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brepkit_wasm.d.ts +39 -0
- package/brepkit_wasm_bg.js +88 -0
- package/brepkit_wasm_bg.wasm +0 -0
- package/brepkit_wasm_node.js +4039 -0
- package/package.json +15 -5
|
@@ -0,0 +1,4039 @@
|
|
|
1
|
+
/* @ts-self-types="./brepkit_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The B-Rep modeling kernel.
|
|
5
|
+
*
|
|
6
|
+
* Owns all topological state. JavaScript holds this reference and
|
|
7
|
+
* invokes methods to create, transform, and query geometry.
|
|
8
|
+
*/
|
|
9
|
+
class BrepKernel {
|
|
10
|
+
__destroy_into_raw() {
|
|
11
|
+
const ptr = this.__wbg_ptr;
|
|
12
|
+
this.__wbg_ptr = 0;
|
|
13
|
+
BrepKernelFinalization.unregister(this);
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
free() {
|
|
17
|
+
const ptr = this.__destroy_into_raw();
|
|
18
|
+
wasm.__wbg_brepkernel_free(ptr, 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Add hole wires to an existing face, creating a new face with the same
|
|
22
|
+
* surface but additional inner wires.
|
|
23
|
+
*
|
|
24
|
+
* Returns a new face handle (`u32`).
|
|
25
|
+
* @param {number} face
|
|
26
|
+
* @param {Uint32Array} hole_wire_handles
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
addHolesToFace(face, hole_wire_handles) {
|
|
30
|
+
const ptr0 = passArray32ToWasm0(hole_wire_handles, wasm.__wbindgen_malloc);
|
|
31
|
+
const len0 = WASM_VECTOR_LEN;
|
|
32
|
+
const ret = wasm.brepkernel_addHolesToFace(this.__wbg_ptr, face, ptr0, len0);
|
|
33
|
+
if (ret[2]) {
|
|
34
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
35
|
+
}
|
|
36
|
+
return ret[0] >>> 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get faces adjacent to a given face within a solid.
|
|
40
|
+
*
|
|
41
|
+
* Returns an array of face handles.
|
|
42
|
+
* @param {number} solid
|
|
43
|
+
* @param {number} face
|
|
44
|
+
* @returns {Uint32Array}
|
|
45
|
+
*/
|
|
46
|
+
adjacentFaces(solid, face) {
|
|
47
|
+
const ret = wasm.brepkernel_adjacentFaces(this.__wbg_ptr, solid, face);
|
|
48
|
+
if (ret[3]) {
|
|
49
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
50
|
+
}
|
|
51
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
52
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
53
|
+
return v1;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Approximate a curve through points (least-squares).
|
|
57
|
+
*
|
|
58
|
+
* Returns an edge handle.
|
|
59
|
+
* @param {Float64Array} coords
|
|
60
|
+
* @param {number} degree
|
|
61
|
+
* @param {number} num_control_points
|
|
62
|
+
* @returns {number}
|
|
63
|
+
*/
|
|
64
|
+
approximateCurve(coords, degree, num_control_points) {
|
|
65
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
66
|
+
const len0 = WASM_VECTOR_LEN;
|
|
67
|
+
const ret = wasm.brepkernel_approximateCurve(this.__wbg_ptr, ptr0, len0, degree, num_control_points);
|
|
68
|
+
if (ret[2]) {
|
|
69
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
70
|
+
}
|
|
71
|
+
return ret[0] >>> 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Approximate a curve through points using LSPIA (progressive iteration).
|
|
75
|
+
*
|
|
76
|
+
* Returns an edge handle.
|
|
77
|
+
* @param {Float64Array} coords
|
|
78
|
+
* @param {number} degree
|
|
79
|
+
* @param {number} num_control_points
|
|
80
|
+
* @param {number} tolerance
|
|
81
|
+
* @param {number} max_iterations
|
|
82
|
+
* @returns {number}
|
|
83
|
+
*/
|
|
84
|
+
approximateCurveLspia(coords, degree, num_control_points, tolerance, max_iterations) {
|
|
85
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
const ret = wasm.brepkernel_approximateCurveLspia(this.__wbg_ptr, ptr0, len0, degree, num_control_points, tolerance, max_iterations);
|
|
88
|
+
if (ret[2]) {
|
|
89
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
90
|
+
}
|
|
91
|
+
return ret[0] >>> 0;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Approximate a grid of points into a NURBS surface using LSPIA.
|
|
95
|
+
*
|
|
96
|
+
* Returns a face handle.
|
|
97
|
+
* @param {Float64Array} coords
|
|
98
|
+
* @param {number} rows
|
|
99
|
+
* @param {number} cols
|
|
100
|
+
* @param {number} degree_u
|
|
101
|
+
* @param {number} degree_v
|
|
102
|
+
* @param {number} num_cps_u
|
|
103
|
+
* @param {number} num_cps_v
|
|
104
|
+
* @param {number} tolerance
|
|
105
|
+
* @param {number} max_iterations
|
|
106
|
+
* @returns {number}
|
|
107
|
+
*/
|
|
108
|
+
approximateSurfaceLspia(coords, rows, cols, degree_u, degree_v, num_cps_u, num_cps_v, tolerance, max_iterations) {
|
|
109
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
const ret = wasm.brepkernel_approximateSurfaceLspia(this.__wbg_ptr, ptr0, len0, rows, cols, degree_u, degree_v, num_cps_u, num_cps_v, tolerance, max_iterations);
|
|
112
|
+
if (ret[2]) {
|
|
113
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
114
|
+
}
|
|
115
|
+
return ret[0] >>> 0;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Add a child component to a parent in an assembly.
|
|
119
|
+
*
|
|
120
|
+
* Returns the component ID.
|
|
121
|
+
* @param {number} assembly
|
|
122
|
+
* @param {number} parent
|
|
123
|
+
* @param {string} name
|
|
124
|
+
* @param {number} solid
|
|
125
|
+
* @param {Float64Array} matrix
|
|
126
|
+
* @returns {number}
|
|
127
|
+
*/
|
|
128
|
+
assemblyAddChild(assembly, parent, name, solid, matrix) {
|
|
129
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
132
|
+
const len1 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.brepkernel_assemblyAddChild(this.__wbg_ptr, assembly, parent, ptr0, len0, solid, ptr1, len1);
|
|
134
|
+
if (ret[2]) {
|
|
135
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
136
|
+
}
|
|
137
|
+
return ret[0] >>> 0;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Add a root component to an assembly.
|
|
141
|
+
*
|
|
142
|
+
* Returns the component ID.
|
|
143
|
+
* @param {number} assembly
|
|
144
|
+
* @param {string} name
|
|
145
|
+
* @param {number} solid
|
|
146
|
+
* @param {Float64Array} matrix
|
|
147
|
+
* @returns {number}
|
|
148
|
+
*/
|
|
149
|
+
assemblyAddRoot(assembly, name, solid, matrix) {
|
|
150
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
+
const len0 = WASM_VECTOR_LEN;
|
|
152
|
+
const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
153
|
+
const len1 = WASM_VECTOR_LEN;
|
|
154
|
+
const ret = wasm.brepkernel_assemblyAddRoot(this.__wbg_ptr, assembly, ptr0, len0, solid, ptr1, len1);
|
|
155
|
+
if (ret[2]) {
|
|
156
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
157
|
+
}
|
|
158
|
+
return ret[0] >>> 0;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the bill of materials for an assembly.
|
|
162
|
+
*
|
|
163
|
+
* Returns a JSON string: `[{"name": "...", "solidIndex": n, "instanceCount": n}, ...]`.
|
|
164
|
+
* @param {number} assembly
|
|
165
|
+
* @returns {string}
|
|
166
|
+
*/
|
|
167
|
+
assemblyBom(assembly) {
|
|
168
|
+
let deferred2_0;
|
|
169
|
+
let deferred2_1;
|
|
170
|
+
try {
|
|
171
|
+
const ret = wasm.brepkernel_assemblyBom(this.__wbg_ptr, assembly);
|
|
172
|
+
var ptr1 = ret[0];
|
|
173
|
+
var len1 = ret[1];
|
|
174
|
+
if (ret[3]) {
|
|
175
|
+
ptr1 = 0; len1 = 0;
|
|
176
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
177
|
+
}
|
|
178
|
+
deferred2_0 = ptr1;
|
|
179
|
+
deferred2_1 = len1;
|
|
180
|
+
return getStringFromWasm0(ptr1, len1);
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Flatten an assembly into `[(solid, matrix), ...]`.
|
|
187
|
+
*
|
|
188
|
+
* Returns a JSON string: `[{"solid": u32, "matrix": [16 floats]}, ...]`.
|
|
189
|
+
* @param {number} assembly
|
|
190
|
+
* @returns {string}
|
|
191
|
+
*/
|
|
192
|
+
assemblyFlatten(assembly) {
|
|
193
|
+
let deferred2_0;
|
|
194
|
+
let deferred2_1;
|
|
195
|
+
try {
|
|
196
|
+
const ret = wasm.brepkernel_assemblyFlatten(this.__wbg_ptr, assembly);
|
|
197
|
+
var ptr1 = ret[0];
|
|
198
|
+
var len1 = ret[1];
|
|
199
|
+
if (ret[3]) {
|
|
200
|
+
ptr1 = 0; len1 = 0;
|
|
201
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
202
|
+
}
|
|
203
|
+
deferred2_0 = ptr1;
|
|
204
|
+
deferred2_1 = len1;
|
|
205
|
+
return getStringFromWasm0(ptr1, len1);
|
|
206
|
+
} finally {
|
|
207
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create a new empty assembly. Returns an assembly index.
|
|
212
|
+
* @param {string} name
|
|
213
|
+
* @returns {number}
|
|
214
|
+
*/
|
|
215
|
+
assemblyNew(name) {
|
|
216
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
const ret = wasm.brepkernel_assemblyNew(this.__wbg_ptr, ptr0, len0);
|
|
219
|
+
return ret >>> 0;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Compute the axis-aligned bounding box of a solid.
|
|
223
|
+
*
|
|
224
|
+
* Returns `[min_x, min_y, min_z, max_x, max_y, max_z]`.
|
|
225
|
+
*
|
|
226
|
+
* # Errors
|
|
227
|
+
*
|
|
228
|
+
* Returns an error if the solid handle is invalid or has no vertices.
|
|
229
|
+
* @param {number} solid
|
|
230
|
+
* @returns {Float64Array}
|
|
231
|
+
*/
|
|
232
|
+
boundingBox(solid) {
|
|
233
|
+
const ret = wasm.brepkernel_boundingBox(this.__wbg_ptr, solid);
|
|
234
|
+
if (ret[3]) {
|
|
235
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
236
|
+
}
|
|
237
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
238
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
239
|
+
return v1;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Compute the center of mass of a solid (uniform density).
|
|
243
|
+
*
|
|
244
|
+
* Returns `[x, y, z]`.
|
|
245
|
+
*
|
|
246
|
+
* # Errors
|
|
247
|
+
*
|
|
248
|
+
* Returns an error if the solid has zero volume or tessellation fails.
|
|
249
|
+
* @param {number} solid
|
|
250
|
+
* @param {number} deflection
|
|
251
|
+
* @returns {Float64Array}
|
|
252
|
+
*/
|
|
253
|
+
centerOfMass(solid, deflection) {
|
|
254
|
+
const ret = wasm.brepkernel_centerOfMass(this.__wbg_ptr, solid, deflection);
|
|
255
|
+
if (ret[3]) {
|
|
256
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
257
|
+
}
|
|
258
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
259
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
260
|
+
return v1;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Chamfer edges of a solid.
|
|
264
|
+
*
|
|
265
|
+
* `edge_handles` is an array of edge handles. Returns a solid handle.
|
|
266
|
+
*
|
|
267
|
+
* # Errors
|
|
268
|
+
*
|
|
269
|
+
* Returns an error if distance is non-positive or edges are invalid.
|
|
270
|
+
* @param {number} solid
|
|
271
|
+
* @param {Uint32Array} edge_handles
|
|
272
|
+
* @param {number} distance
|
|
273
|
+
* @returns {number}
|
|
274
|
+
*/
|
|
275
|
+
chamfer(solid, edge_handles, distance) {
|
|
276
|
+
const ptr0 = passArray32ToWasm0(edge_handles, wasm.__wbindgen_malloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
278
|
+
const ret = wasm.brepkernel_chamfer(this.__wbg_ptr, solid, ptr0, len0, distance);
|
|
279
|
+
if (ret[2]) {
|
|
280
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
281
|
+
}
|
|
282
|
+
return ret[0] >>> 0;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Cut corners of a 2D polygon with flat bevels.
|
|
286
|
+
*
|
|
287
|
+
* `coords` is a flat array `[x,y, x,y, ...]`.
|
|
288
|
+
* `distance` is the chamfer distance from each corner.
|
|
289
|
+
* Returns a flat array of the chamfered polygon coordinates.
|
|
290
|
+
* @param {Float64Array} coords
|
|
291
|
+
* @param {number} distance
|
|
292
|
+
* @returns {Float64Array}
|
|
293
|
+
*/
|
|
294
|
+
chamfer2d(coords, distance) {
|
|
295
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
296
|
+
const len0 = WASM_VECTOR_LEN;
|
|
297
|
+
const ret = wasm.brepkernel_chamfer2d(this.__wbg_ptr, ptr0, len0, distance);
|
|
298
|
+
if (ret[3]) {
|
|
299
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
300
|
+
}
|
|
301
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
302
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
303
|
+
return v2;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Create a circular pattern of a solid around an axis.
|
|
307
|
+
*
|
|
308
|
+
* Returns a compound handle.
|
|
309
|
+
* @param {number} solid
|
|
310
|
+
* @param {number} ax
|
|
311
|
+
* @param {number} ay
|
|
312
|
+
* @param {number} az
|
|
313
|
+
* @param {number} count
|
|
314
|
+
* @returns {number}
|
|
315
|
+
*/
|
|
316
|
+
circularPattern(solid, ax, ay, az, count) {
|
|
317
|
+
const ret = wasm.brepkernel_circularPattern(this.__wbg_ptr, solid, ax, ay, az, count);
|
|
318
|
+
if (ret[2]) {
|
|
319
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
320
|
+
}
|
|
321
|
+
return ret[0] >>> 0;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Classify a point relative to a solid: inside, outside, or on boundary.
|
|
325
|
+
*
|
|
326
|
+
* Returns `"inside"`, `"outside"`, or `"boundary"`.
|
|
327
|
+
*
|
|
328
|
+
* # Errors
|
|
329
|
+
*
|
|
330
|
+
* Returns an error if the solid handle is invalid.
|
|
331
|
+
* @param {number} solid
|
|
332
|
+
* @param {number} x
|
|
333
|
+
* @param {number} y
|
|
334
|
+
* @param {number} z
|
|
335
|
+
* @param {number} tolerance
|
|
336
|
+
* @returns {string}
|
|
337
|
+
*/
|
|
338
|
+
classifyPoint(solid, x, y, z, tolerance) {
|
|
339
|
+
let deferred2_0;
|
|
340
|
+
let deferred2_1;
|
|
341
|
+
try {
|
|
342
|
+
const ret = wasm.brepkernel_classifyPoint(this.__wbg_ptr, solid, x, y, z, tolerance);
|
|
343
|
+
var ptr1 = ret[0];
|
|
344
|
+
var len1 = ret[1];
|
|
345
|
+
if (ret[3]) {
|
|
346
|
+
ptr1 = 0; len1 = 0;
|
|
347
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
348
|
+
}
|
|
349
|
+
deferred2_0 = ptr1;
|
|
350
|
+
deferred2_1 = len1;
|
|
351
|
+
return getStringFromWasm0(ptr1, len1);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Classify a point using robust dual-method (winding + ray casting).
|
|
358
|
+
*
|
|
359
|
+
* Returns "inside", "outside", or "boundary".
|
|
360
|
+
* @param {number} solid
|
|
361
|
+
* @param {number} x
|
|
362
|
+
* @param {number} y
|
|
363
|
+
* @param {number} z
|
|
364
|
+
* @param {number} tolerance
|
|
365
|
+
* @returns {string}
|
|
366
|
+
*/
|
|
367
|
+
classifyPointRobust(solid, x, y, z, tolerance) {
|
|
368
|
+
let deferred2_0;
|
|
369
|
+
let deferred2_1;
|
|
370
|
+
try {
|
|
371
|
+
const ret = wasm.brepkernel_classifyPointRobust(this.__wbg_ptr, solid, x, y, z, tolerance);
|
|
372
|
+
var ptr1 = ret[0];
|
|
373
|
+
var len1 = ret[1];
|
|
374
|
+
if (ret[3]) {
|
|
375
|
+
ptr1 = 0; len1 = 0;
|
|
376
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
377
|
+
}
|
|
378
|
+
deferred2_0 = ptr1;
|
|
379
|
+
deferred2_1 = len1;
|
|
380
|
+
return getStringFromWasm0(ptr1, len1);
|
|
381
|
+
} finally {
|
|
382
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Classify a point relative to a solid using generalized winding numbers.
|
|
387
|
+
*
|
|
388
|
+
* Returns "inside", "outside", or "boundary".
|
|
389
|
+
* @param {number} solid
|
|
390
|
+
* @param {number} x
|
|
391
|
+
* @param {number} y
|
|
392
|
+
* @param {number} z
|
|
393
|
+
* @param {number} tolerance
|
|
394
|
+
* @returns {string}
|
|
395
|
+
*/
|
|
396
|
+
classifyPointWinding(solid, x, y, z, tolerance) {
|
|
397
|
+
let deferred2_0;
|
|
398
|
+
let deferred2_1;
|
|
399
|
+
try {
|
|
400
|
+
const ret = wasm.brepkernel_classifyPointWinding(this.__wbg_ptr, solid, x, y, z, tolerance);
|
|
401
|
+
var ptr1 = ret[0];
|
|
402
|
+
var len1 = ret[1];
|
|
403
|
+
if (ret[3]) {
|
|
404
|
+
ptr1 = 0; len1 = 0;
|
|
405
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
406
|
+
}
|
|
407
|
+
deferred2_0 = ptr1;
|
|
408
|
+
deferred2_1 = len1;
|
|
409
|
+
return getStringFromWasm0(ptr1, len1);
|
|
410
|
+
} finally {
|
|
411
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Find common (shared) edges between two adjacent 2D polygons.
|
|
416
|
+
*
|
|
417
|
+
* Both polygons are flat arrays `[x,y, x,y, ...]`.
|
|
418
|
+
* Returns a flat array of common segment endpoints `[x1,y1, x2,y2, ...]`,
|
|
419
|
+
* or an empty array if no common segments exist.
|
|
420
|
+
* @param {Float64Array} coords_a
|
|
421
|
+
* @param {Float64Array} coords_b
|
|
422
|
+
* @returns {Float64Array}
|
|
423
|
+
*/
|
|
424
|
+
commonSegment2d(coords_a, coords_b) {
|
|
425
|
+
const ptr0 = passArrayF64ToWasm0(coords_a, wasm.__wbindgen_malloc);
|
|
426
|
+
const len0 = WASM_VECTOR_LEN;
|
|
427
|
+
const ptr1 = passArrayF64ToWasm0(coords_b, wasm.__wbindgen_malloc);
|
|
428
|
+
const len1 = WASM_VECTOR_LEN;
|
|
429
|
+
const ret = wasm.brepkernel_commonSegment2d(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
430
|
+
if (ret[3]) {
|
|
431
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
432
|
+
}
|
|
433
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
434
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
435
|
+
return v3;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Compose (multiply) two 4x4 transformation matrices.
|
|
439
|
+
*
|
|
440
|
+
* Returns the composed matrix as a flat 16-element array (row-major).
|
|
441
|
+
* This computes `a * b`, meaning `b` is applied first, then `a`.
|
|
442
|
+
*
|
|
443
|
+
* # Errors
|
|
444
|
+
*
|
|
445
|
+
* Returns an error if either matrix doesn't have 16 elements.
|
|
446
|
+
* @param {Float64Array} matrix_a
|
|
447
|
+
* @param {Float64Array} matrix_b
|
|
448
|
+
* @returns {Float64Array}
|
|
449
|
+
*/
|
|
450
|
+
composeTransforms(matrix_a, matrix_b) {
|
|
451
|
+
const ptr0 = passArrayF64ToWasm0(matrix_a, wasm.__wbindgen_malloc);
|
|
452
|
+
const len0 = WASM_VECTOR_LEN;
|
|
453
|
+
const ptr1 = passArrayF64ToWasm0(matrix_b, wasm.__wbindgen_malloc);
|
|
454
|
+
const len1 = WASM_VECTOR_LEN;
|
|
455
|
+
const ret = wasm.brepkernel_composeTransforms(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
456
|
+
if (ret[3]) {
|
|
457
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
458
|
+
}
|
|
459
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
460
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
461
|
+
return v3;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Build a convex hull solid from a point cloud.
|
|
465
|
+
*
|
|
466
|
+
* Uses a simple Quickhull-inspired algorithm for 3D point sets.
|
|
467
|
+
*
|
|
468
|
+
* Returns a solid handle (`u32`).
|
|
469
|
+
*
|
|
470
|
+
* # Errors
|
|
471
|
+
*
|
|
472
|
+
* Returns an error if fewer than 4 points are provided.
|
|
473
|
+
* @param {Float64Array} coords
|
|
474
|
+
* @returns {number}
|
|
475
|
+
*/
|
|
476
|
+
convexHull(coords) {
|
|
477
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
479
|
+
const ret = wasm.brepkernel_convexHull(this.__wbg_ptr, ptr0, len0);
|
|
480
|
+
if (ret[2]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
482
|
+
}
|
|
483
|
+
return ret[0] >>> 0;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Copy a solid and apply a 4×4 row-major affine transform in one pass.
|
|
487
|
+
*
|
|
488
|
+
* Equivalent to `copySolid` + `transformSolid` but performs both in a
|
|
489
|
+
* single topology traversal, avoiding redundant NURBS clones.
|
|
490
|
+
*
|
|
491
|
+
* # Errors
|
|
492
|
+
*
|
|
493
|
+
* Returns an error if the solid handle is invalid, the matrix doesn't
|
|
494
|
+
* have 16 elements, or the matrix is singular.
|
|
495
|
+
* @param {number} solid
|
|
496
|
+
* @param {Float64Array} matrix
|
|
497
|
+
* @returns {number}
|
|
498
|
+
*/
|
|
499
|
+
copyAndTransformSolid(solid, matrix) {
|
|
500
|
+
const ptr0 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
501
|
+
const len0 = WASM_VECTOR_LEN;
|
|
502
|
+
const ret = wasm.brepkernel_copyAndTransformSolid(this.__wbg_ptr, solid, ptr0, len0);
|
|
503
|
+
if (ret[2]) {
|
|
504
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
505
|
+
}
|
|
506
|
+
return ret[0] >>> 0;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Deep copy a solid, returning a new independent solid handle.
|
|
510
|
+
*
|
|
511
|
+
* # Errors
|
|
512
|
+
*
|
|
513
|
+
* Returns an error if the solid handle is invalid.
|
|
514
|
+
* @param {number} solid
|
|
515
|
+
* @returns {number}
|
|
516
|
+
*/
|
|
517
|
+
copySolid(solid) {
|
|
518
|
+
const ret = wasm.brepkernel_copySolid(this.__wbg_ptr, solid);
|
|
519
|
+
if (ret[2]) {
|
|
520
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
521
|
+
}
|
|
522
|
+
return ret[0] >>> 0;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Deep copy a wire, returning a new independent wire handle.
|
|
526
|
+
*
|
|
527
|
+
* # Errors
|
|
528
|
+
*
|
|
529
|
+
* Returns an error if the wire handle is invalid.
|
|
530
|
+
* @param {number} wire
|
|
531
|
+
* @returns {number}
|
|
532
|
+
*/
|
|
533
|
+
copyWire(wire) {
|
|
534
|
+
const ret = wasm.brepkernel_copyWire(this.__wbg_ptr, wire);
|
|
535
|
+
if (ret[2]) {
|
|
536
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
537
|
+
}
|
|
538
|
+
return ret[0] >>> 0;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Elevate the degree of an edge's NURBS curve.
|
|
542
|
+
*
|
|
543
|
+
* Returns a new edge handle.
|
|
544
|
+
* @param {number} edge
|
|
545
|
+
* @param {number} elevate_by
|
|
546
|
+
* @returns {number}
|
|
547
|
+
*/
|
|
548
|
+
curveDegreeElevate(edge, elevate_by) {
|
|
549
|
+
const ret = wasm.brepkernel_curveDegreeElevate(this.__wbg_ptr, edge, elevate_by);
|
|
550
|
+
if (ret[2]) {
|
|
551
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
552
|
+
}
|
|
553
|
+
return ret[0] >>> 0;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Insert a knot into an edge's NURBS curve.
|
|
557
|
+
*
|
|
558
|
+
* Returns a new edge handle with the refined curve.
|
|
559
|
+
* @param {number} edge
|
|
560
|
+
* @param {number} knot
|
|
561
|
+
* @param {number} times
|
|
562
|
+
* @returns {number}
|
|
563
|
+
*/
|
|
564
|
+
curveKnotInsert(edge, knot, times) {
|
|
565
|
+
const ret = wasm.brepkernel_curveKnotInsert(this.__wbg_ptr, edge, knot, times);
|
|
566
|
+
if (ret[2]) {
|
|
567
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
568
|
+
}
|
|
569
|
+
return ret[0] >>> 0;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Remove a knot from an edge's NURBS curve.
|
|
573
|
+
*
|
|
574
|
+
* Returns a new edge handle with the simplified curve.
|
|
575
|
+
* @param {number} edge
|
|
576
|
+
* @param {number} knot
|
|
577
|
+
* @param {number} tolerance
|
|
578
|
+
* @returns {number}
|
|
579
|
+
*/
|
|
580
|
+
curveKnotRemove(edge, knot, tolerance) {
|
|
581
|
+
const ret = wasm.brepkernel_curveKnotRemove(this.__wbg_ptr, edge, knot, tolerance);
|
|
582
|
+
if (ret[2]) {
|
|
583
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
584
|
+
}
|
|
585
|
+
return ret[0] >>> 0;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Split an edge's NURBS curve at a parameter value.
|
|
589
|
+
*
|
|
590
|
+
* Returns two edge handles as `[u32; 2]`.
|
|
591
|
+
* @param {number} edge
|
|
592
|
+
* @param {number} u
|
|
593
|
+
* @returns {Uint32Array}
|
|
594
|
+
*/
|
|
595
|
+
curveSplit(edge, u) {
|
|
596
|
+
const ret = wasm.brepkernel_curveSplit(this.__wbg_ptr, edge, u);
|
|
597
|
+
if (ret[3]) {
|
|
598
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
599
|
+
}
|
|
600
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
601
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
602
|
+
return v1;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Cut (subtract) solid `b` from solid `a`.
|
|
606
|
+
*
|
|
607
|
+
* Returns a new solid handle (`u32`).
|
|
608
|
+
*
|
|
609
|
+
* # Errors
|
|
610
|
+
*
|
|
611
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
612
|
+
* produces an empty or non-manifold result.
|
|
613
|
+
* @param {number} a
|
|
614
|
+
* @param {number} b
|
|
615
|
+
* @returns {number}
|
|
616
|
+
*/
|
|
617
|
+
cut(a, b) {
|
|
618
|
+
const ret = wasm.brepkernel_cut(this.__wbg_ptr, a, b);
|
|
619
|
+
if (ret[2]) {
|
|
620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
621
|
+
}
|
|
622
|
+
return ret[0] >>> 0;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Cut (subtract) solid `b` from solid `a` and return evolution tracking data.
|
|
626
|
+
*
|
|
627
|
+
* Returns a JSON string: `{"solid": <u32>, "evolution": {...}}`.
|
|
628
|
+
*
|
|
629
|
+
* # Errors
|
|
630
|
+
*
|
|
631
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
632
|
+
* produces an empty or non-manifold result.
|
|
633
|
+
* @param {number} a
|
|
634
|
+
* @param {number} b
|
|
635
|
+
* @returns {any}
|
|
636
|
+
*/
|
|
637
|
+
cutWithEvolution(a, b) {
|
|
638
|
+
const ret = wasm.brepkernel_cutWithEvolution(this.__wbg_ptr, a, b);
|
|
639
|
+
if (ret[2]) {
|
|
640
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
641
|
+
}
|
|
642
|
+
return takeFromExternrefTable0(ret[0]);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Remove specified faces from a solid (defeaturing).
|
|
646
|
+
*
|
|
647
|
+
* `face_handles` is an array of face handles to remove.
|
|
648
|
+
* Returns a new solid handle.
|
|
649
|
+
* @param {number} solid
|
|
650
|
+
* @param {Uint32Array} face_handles
|
|
651
|
+
* @returns {number}
|
|
652
|
+
*/
|
|
653
|
+
defeature(solid, face_handles) {
|
|
654
|
+
const ptr0 = passArray32ToWasm0(face_handles, wasm.__wbindgen_malloc);
|
|
655
|
+
const len0 = WASM_VECTOR_LEN;
|
|
656
|
+
const ret = wasm.brepkernel_defeature(this.__wbg_ptr, solid, ptr0, len0);
|
|
657
|
+
if (ret[2]) {
|
|
658
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
659
|
+
}
|
|
660
|
+
return ret[0] >>> 0;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Detect small features (faces below an area threshold).
|
|
664
|
+
*
|
|
665
|
+
* Returns an array of face handles.
|
|
666
|
+
* @param {number} solid
|
|
667
|
+
* @param {number} area_threshold
|
|
668
|
+
* @param {number} deflection
|
|
669
|
+
* @returns {Uint32Array}
|
|
670
|
+
*/
|
|
671
|
+
detectSmallFeatures(solid, area_threshold, deflection) {
|
|
672
|
+
const ret = wasm.brepkernel_detectSmallFeatures(this.__wbg_ptr, solid, area_threshold, deflection);
|
|
673
|
+
if (ret[3]) {
|
|
674
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
675
|
+
}
|
|
676
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
677
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
678
|
+
return v1;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Apply draft angle to faces of a solid.
|
|
682
|
+
*
|
|
683
|
+
* `face_handles` is an array of face handles to draft.
|
|
684
|
+
* Returns a solid handle.
|
|
685
|
+
*
|
|
686
|
+
* # Errors
|
|
687
|
+
*
|
|
688
|
+
* Returns an error if angle is zero or faces are invalid.
|
|
689
|
+
* @param {number} solid
|
|
690
|
+
* @param {Uint32Array} face_handles
|
|
691
|
+
* @param {number} pull_x
|
|
692
|
+
* @param {number} pull_y
|
|
693
|
+
* @param {number} pull_z
|
|
694
|
+
* @param {number} neutral_x
|
|
695
|
+
* @param {number} neutral_y
|
|
696
|
+
* @param {number} neutral_z
|
|
697
|
+
* @param {number} angle_degrees
|
|
698
|
+
* @returns {number}
|
|
699
|
+
*/
|
|
700
|
+
draft(solid, face_handles, pull_x, pull_y, pull_z, neutral_x, neutral_y, neutral_z, angle_degrees) {
|
|
701
|
+
const ptr0 = passArray32ToWasm0(face_handles, wasm.__wbindgen_malloc);
|
|
702
|
+
const len0 = WASM_VECTOR_LEN;
|
|
703
|
+
const ret = wasm.brepkernel_draft(this.__wbg_ptr, solid, ptr0, len0, pull_x, pull_y, pull_z, neutral_x, neutral_y, neutral_z, angle_degrees);
|
|
704
|
+
if (ret[2]) {
|
|
705
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
706
|
+
}
|
|
707
|
+
return ret[0] >>> 0;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Compute the length of an edge.
|
|
711
|
+
*
|
|
712
|
+
* # Errors
|
|
713
|
+
*
|
|
714
|
+
* Returns an error if the edge handle is invalid.
|
|
715
|
+
* @param {number} edge
|
|
716
|
+
* @returns {number}
|
|
717
|
+
*/
|
|
718
|
+
edgeLength(edge) {
|
|
719
|
+
const ret = wasm.brepkernel_edgeLength(this.__wbg_ptr, edge);
|
|
720
|
+
if (ret[2]) {
|
|
721
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
722
|
+
}
|
|
723
|
+
return ret[0];
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Get the edge-to-face adjacency map for a solid.
|
|
727
|
+
*
|
|
728
|
+
* Returns a JSON string: `{"edgeId": [faceId, ...], ...}`.
|
|
729
|
+
* @param {number} solid
|
|
730
|
+
* @returns {string}
|
|
731
|
+
*/
|
|
732
|
+
edgeToFaceMap(solid) {
|
|
733
|
+
let deferred2_0;
|
|
734
|
+
let deferred2_1;
|
|
735
|
+
try {
|
|
736
|
+
const ret = wasm.brepkernel_edgeToFaceMap(this.__wbg_ptr, solid);
|
|
737
|
+
var ptr1 = ret[0];
|
|
738
|
+
var len1 = ret[1];
|
|
739
|
+
if (ret[3]) {
|
|
740
|
+
ptr1 = 0; len1 = 0;
|
|
741
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
742
|
+
}
|
|
743
|
+
deferred2_0 = ptr1;
|
|
744
|
+
deferred2_1 = len1;
|
|
745
|
+
return getStringFromWasm0(ptr1, len1);
|
|
746
|
+
} finally {
|
|
747
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Evaluate a point on an edge curve at parameter `t`.
|
|
752
|
+
*
|
|
753
|
+
* Returns `[x, y, z]`.
|
|
754
|
+
* @param {number} edge
|
|
755
|
+
* @param {number} t
|
|
756
|
+
* @returns {Float64Array}
|
|
757
|
+
*/
|
|
758
|
+
evaluateEdgeCurve(edge, t) {
|
|
759
|
+
const ret = wasm.brepkernel_evaluateEdgeCurve(this.__wbg_ptr, edge, t);
|
|
760
|
+
if (ret[3]) {
|
|
761
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
762
|
+
}
|
|
763
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
764
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
765
|
+
return v1;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Evaluate a point and tangent on an edge curve at parameter `t`.
|
|
769
|
+
*
|
|
770
|
+
* Returns `[px, py, pz, tx, ty, tz]`.
|
|
771
|
+
* @param {number} edge
|
|
772
|
+
* @param {number} t
|
|
773
|
+
* @returns {Float64Array}
|
|
774
|
+
*/
|
|
775
|
+
evaluateEdgeCurveD1(edge, t) {
|
|
776
|
+
const ret = wasm.brepkernel_evaluateEdgeCurveD1(this.__wbg_ptr, edge, t);
|
|
777
|
+
if (ret[3]) {
|
|
778
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
779
|
+
}
|
|
780
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
781
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
782
|
+
return v1;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Evaluate a point on a face surface at (u, v).
|
|
786
|
+
*
|
|
787
|
+
* Returns `[x, y, z]`.
|
|
788
|
+
* @param {number} face
|
|
789
|
+
* @param {number} u
|
|
790
|
+
* @param {number} v
|
|
791
|
+
* @returns {Float64Array}
|
|
792
|
+
*/
|
|
793
|
+
evaluateSurface(face, u, v) {
|
|
794
|
+
const ret = wasm.brepkernel_evaluateSurface(this.__wbg_ptr, face, u, v);
|
|
795
|
+
if (ret[3]) {
|
|
796
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
797
|
+
}
|
|
798
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
799
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
800
|
+
return v1;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Evaluate a surface normal at (u, v) on a face.
|
|
804
|
+
*
|
|
805
|
+
* Returns `[nx, ny, nz]`.
|
|
806
|
+
* @param {number} face
|
|
807
|
+
* @param {number} u
|
|
808
|
+
* @param {number} v
|
|
809
|
+
* @returns {Float64Array}
|
|
810
|
+
*/
|
|
811
|
+
evaluateSurfaceNormal(face, u, v) {
|
|
812
|
+
const ret = wasm.brepkernel_evaluateSurfaceNormal(this.__wbg_ptr, face, u, v);
|
|
813
|
+
if (ret[3]) {
|
|
814
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
815
|
+
}
|
|
816
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
817
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
818
|
+
return v1;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Execute a batch of operations, crossing the JS/WASM boundary once.
|
|
822
|
+
*
|
|
823
|
+
* Accepts a JSON string containing an array of operation objects:
|
|
824
|
+
* ```json
|
|
825
|
+
* [
|
|
826
|
+
* {"op": "makeBox", "args": {"width": 2.0, "height": 2.0, "depth": 2.0}},
|
|
827
|
+
* {"op": "fuse", "args": {"solidA": 0, "solidB": 1}},
|
|
828
|
+
* {"op": "volume", "args": {"solid": 2, "deflection": 0.1}}
|
|
829
|
+
* ]
|
|
830
|
+
* ```
|
|
831
|
+
*
|
|
832
|
+
* Returns a JSON string with an array of results:
|
|
833
|
+
* ```json
|
|
834
|
+
* [
|
|
835
|
+
* {"ok": 0},
|
|
836
|
+
* {"ok": 2},
|
|
837
|
+
* {"error": "invalid solid id"}
|
|
838
|
+
* ]
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* Operations are executed sequentially; an error in one does not
|
|
842
|
+
* prevent execution of subsequent operations.
|
|
843
|
+
* @param {string} json
|
|
844
|
+
* @returns {string}
|
|
845
|
+
*/
|
|
846
|
+
executeBatch(json) {
|
|
847
|
+
let deferred2_0;
|
|
848
|
+
let deferred2_1;
|
|
849
|
+
try {
|
|
850
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
851
|
+
const len0 = WASM_VECTOR_LEN;
|
|
852
|
+
const ret = wasm.brepkernel_executeBatch(this.__wbg_ptr, ptr0, len0);
|
|
853
|
+
deferred2_0 = ret[0];
|
|
854
|
+
deferred2_1 = ret[1];
|
|
855
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
856
|
+
} finally {
|
|
857
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Export a solid to 3MF format (ZIP archive as bytes).
|
|
862
|
+
*
|
|
863
|
+
* Returns a `Uint8Array` in JavaScript containing the `.3mf` file.
|
|
864
|
+
*
|
|
865
|
+
* # Errors
|
|
866
|
+
*
|
|
867
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
868
|
+
* @param {number} solid
|
|
869
|
+
* @param {number} deflection
|
|
870
|
+
* @returns {Uint8Array}
|
|
871
|
+
*/
|
|
872
|
+
export3mf(solid, deflection) {
|
|
873
|
+
const ret = wasm.brepkernel_export3mf(this.__wbg_ptr, solid, deflection);
|
|
874
|
+
if (ret[3]) {
|
|
875
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
876
|
+
}
|
|
877
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
878
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
879
|
+
return v1;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Export a solid to glTF binary (.glb) format.
|
|
883
|
+
*
|
|
884
|
+
* # Errors
|
|
885
|
+
*
|
|
886
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
887
|
+
* @param {number} solid
|
|
888
|
+
* @param {number} deflection
|
|
889
|
+
* @returns {Uint8Array}
|
|
890
|
+
*/
|
|
891
|
+
exportGlb(solid, deflection) {
|
|
892
|
+
const ret = wasm.brepkernel_exportGlb(this.__wbg_ptr, solid, deflection);
|
|
893
|
+
if (ret[3]) {
|
|
894
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
895
|
+
}
|
|
896
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
897
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
898
|
+
return v1;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Export a solid to IGES format.
|
|
902
|
+
*
|
|
903
|
+
* Returns the IGES file as a UTF-8 encoded byte vector.
|
|
904
|
+
*
|
|
905
|
+
* # Errors
|
|
906
|
+
*
|
|
907
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
908
|
+
* @param {number} solid
|
|
909
|
+
* @returns {Uint8Array}
|
|
910
|
+
*/
|
|
911
|
+
exportIges(solid) {
|
|
912
|
+
const ret = wasm.brepkernel_exportIges(this.__wbg_ptr, solid);
|
|
913
|
+
if (ret[3]) {
|
|
914
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
915
|
+
}
|
|
916
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
917
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
918
|
+
return v1;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Export a solid to OBJ format (UTF-8 string as bytes).
|
|
922
|
+
*
|
|
923
|
+
* # Errors
|
|
924
|
+
*
|
|
925
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
926
|
+
* @param {number} solid
|
|
927
|
+
* @param {number} deflection
|
|
928
|
+
* @returns {Uint8Array}
|
|
929
|
+
*/
|
|
930
|
+
exportObj(solid, deflection) {
|
|
931
|
+
const ret = wasm.brepkernel_exportObj(this.__wbg_ptr, solid, deflection);
|
|
932
|
+
if (ret[3]) {
|
|
933
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
934
|
+
}
|
|
935
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
936
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
937
|
+
return v1;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Export a solid to PLY format (binary little-endian).
|
|
941
|
+
*
|
|
942
|
+
* # Errors
|
|
943
|
+
*
|
|
944
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
945
|
+
* @param {number} solid
|
|
946
|
+
* @param {number} deflection
|
|
947
|
+
* @returns {Uint8Array}
|
|
948
|
+
*/
|
|
949
|
+
exportPly(solid, deflection) {
|
|
950
|
+
const ret = wasm.brepkernel_exportPly(this.__wbg_ptr, solid, deflection);
|
|
951
|
+
if (ret[3]) {
|
|
952
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
953
|
+
}
|
|
954
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
955
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
956
|
+
return v1;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Export a solid to STEP AP203 format.
|
|
960
|
+
*
|
|
961
|
+
* Returns the STEP file as a UTF-8 encoded byte vector.
|
|
962
|
+
*
|
|
963
|
+
* # Errors
|
|
964
|
+
*
|
|
965
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
966
|
+
* @param {number} solid
|
|
967
|
+
* @returns {Uint8Array}
|
|
968
|
+
*/
|
|
969
|
+
exportStep(solid) {
|
|
970
|
+
const ret = wasm.brepkernel_exportStep(this.__wbg_ptr, solid);
|
|
971
|
+
if (ret[3]) {
|
|
972
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
973
|
+
}
|
|
974
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
975
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
976
|
+
return v1;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Export a solid to binary STL format.
|
|
980
|
+
*
|
|
981
|
+
* Returns a `Uint8Array` containing the `.stl` file.
|
|
982
|
+
*
|
|
983
|
+
* # Errors
|
|
984
|
+
*
|
|
985
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
986
|
+
* @param {number} solid
|
|
987
|
+
* @param {number} deflection
|
|
988
|
+
* @returns {Uint8Array}
|
|
989
|
+
*/
|
|
990
|
+
exportStl(solid, deflection) {
|
|
991
|
+
const ret = wasm.brepkernel_exportStl(this.__wbg_ptr, solid, deflection);
|
|
992
|
+
if (ret[3]) {
|
|
993
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
994
|
+
}
|
|
995
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
996
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
997
|
+
return v1;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Export a solid to STL ASCII format.
|
|
1001
|
+
*
|
|
1002
|
+
* Returns the ASCII STL as UTF-8 bytes.
|
|
1003
|
+
*
|
|
1004
|
+
* # Errors
|
|
1005
|
+
*
|
|
1006
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
1007
|
+
* @param {number} solid
|
|
1008
|
+
* @param {number} deflection
|
|
1009
|
+
* @returns {Uint8Array}
|
|
1010
|
+
*/
|
|
1011
|
+
exportStlAscii(solid, deflection) {
|
|
1012
|
+
const ret = wasm.brepkernel_exportStlAscii(this.__wbg_ptr, solid, deflection);
|
|
1013
|
+
if (ret[3]) {
|
|
1014
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1015
|
+
}
|
|
1016
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1017
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1018
|
+
return v1;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Extrude a planar face along a direction vector to create a solid.
|
|
1022
|
+
*
|
|
1023
|
+
* Returns a solid handle (`u32`).
|
|
1024
|
+
*
|
|
1025
|
+
* # Errors
|
|
1026
|
+
*
|
|
1027
|
+
* Returns an error if the face handle is invalid or the extrusion fails.
|
|
1028
|
+
* @param {number} face
|
|
1029
|
+
* @param {number} dir_x
|
|
1030
|
+
* @param {number} dir_y
|
|
1031
|
+
* @param {number} dir_z
|
|
1032
|
+
* @param {number} distance
|
|
1033
|
+
* @returns {number}
|
|
1034
|
+
*/
|
|
1035
|
+
extrude(face, dir_x, dir_y, dir_z, distance) {
|
|
1036
|
+
const ret = wasm.brepkernel_extrude(this.__wbg_ptr, face, dir_x, dir_y, dir_z, distance);
|
|
1037
|
+
if (ret[2]) {
|
|
1038
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1039
|
+
}
|
|
1040
|
+
return ret[0] >>> 0;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Compute the area of a single face.
|
|
1044
|
+
*
|
|
1045
|
+
* # Errors
|
|
1046
|
+
*
|
|
1047
|
+
* Returns an error if the face handle is invalid or tessellation fails.
|
|
1048
|
+
* @param {number} face
|
|
1049
|
+
* @param {number} deflection
|
|
1050
|
+
* @returns {number}
|
|
1051
|
+
*/
|
|
1052
|
+
faceArea(face, deflection) {
|
|
1053
|
+
const ret = wasm.brepkernel_faceArea(this.__wbg_ptr, face, deflection);
|
|
1054
|
+
if (ret[2]) {
|
|
1055
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1056
|
+
}
|
|
1057
|
+
return ret[0];
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Compute the perimeter of a face.
|
|
1061
|
+
*
|
|
1062
|
+
* # Errors
|
|
1063
|
+
*
|
|
1064
|
+
* Returns an error if the face handle is invalid.
|
|
1065
|
+
* @param {number} face
|
|
1066
|
+
* @returns {number}
|
|
1067
|
+
*/
|
|
1068
|
+
facePerimeter(face) {
|
|
1069
|
+
const ret = wasm.brepkernel_facePerimeter(this.__wbg_ptr, face);
|
|
1070
|
+
if (ret[2]) {
|
|
1071
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1072
|
+
}
|
|
1073
|
+
return ret[0];
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Get the wires (outer + inner) of a face.
|
|
1077
|
+
*
|
|
1078
|
+
* Returns an array of wire handles.
|
|
1079
|
+
* @param {number} face
|
|
1080
|
+
* @returns {Uint32Array}
|
|
1081
|
+
*/
|
|
1082
|
+
faceWires(face) {
|
|
1083
|
+
const ret = wasm.brepkernel_faceWires(this.__wbg_ptr, face);
|
|
1084
|
+
if (ret[3]) {
|
|
1085
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1086
|
+
}
|
|
1087
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1088
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1089
|
+
return v1;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Fill a 4-sided boundary with a Coons patch surface.
|
|
1093
|
+
*
|
|
1094
|
+
* `boundary_coords` is flat `[x,y,z, ...]` for all 4 curves concatenated.
|
|
1095
|
+
* `curve_lengths` is `[n0, n1, n2, n3]` — number of points per curve.
|
|
1096
|
+
* Returns a face handle.
|
|
1097
|
+
* @param {Float64Array} boundary_coords
|
|
1098
|
+
* @param {Uint32Array} curve_lengths
|
|
1099
|
+
* @returns {number}
|
|
1100
|
+
*/
|
|
1101
|
+
fillCoonsPatch(boundary_coords, curve_lengths) {
|
|
1102
|
+
const ptr0 = passArrayF64ToWasm0(boundary_coords, wasm.__wbindgen_malloc);
|
|
1103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1104
|
+
const ptr1 = passArray32ToWasm0(curve_lengths, wasm.__wbindgen_malloc);
|
|
1105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1106
|
+
const ret = wasm.brepkernel_fillCoonsPatch(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1107
|
+
if (ret[2]) {
|
|
1108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1109
|
+
}
|
|
1110
|
+
return ret[0] >>> 0;
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Fillet (round) edges of a solid.
|
|
1114
|
+
*
|
|
1115
|
+
* `edge_handles` is an array of edge handles. Returns a solid handle.
|
|
1116
|
+
*
|
|
1117
|
+
* # Errors
|
|
1118
|
+
*
|
|
1119
|
+
* Returns an error if radius is non-positive or edges are invalid.
|
|
1120
|
+
* @param {number} solid
|
|
1121
|
+
* @param {Uint32Array} edge_handles
|
|
1122
|
+
* @param {number} radius
|
|
1123
|
+
* @returns {number}
|
|
1124
|
+
*/
|
|
1125
|
+
fillet(solid, edge_handles, radius) {
|
|
1126
|
+
const ptr0 = passArray32ToWasm0(edge_handles, wasm.__wbindgen_malloc);
|
|
1127
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1128
|
+
const ret = wasm.brepkernel_fillet(this.__wbg_ptr, solid, ptr0, len0, radius);
|
|
1129
|
+
if (ret[2]) {
|
|
1130
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1131
|
+
}
|
|
1132
|
+
return ret[0] >>> 0;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Round corners of a 2D polygon by inserting arc-approximation vertices.
|
|
1136
|
+
*
|
|
1137
|
+
* `coords` is a flat array `[x,y, x,y, ...]`.
|
|
1138
|
+
* `radius` is the fillet radius.
|
|
1139
|
+
* Returns a flat array of the filleted polygon coordinates.
|
|
1140
|
+
* @param {Float64Array} coords
|
|
1141
|
+
* @param {number} radius
|
|
1142
|
+
* @returns {Float64Array}
|
|
1143
|
+
*/
|
|
1144
|
+
fillet2d(coords, radius) {
|
|
1145
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1146
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1147
|
+
const ret = wasm.brepkernel_fillet2d(this.__wbg_ptr, ptr0, len0, radius);
|
|
1148
|
+
if (ret[3]) {
|
|
1149
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1150
|
+
}
|
|
1151
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1152
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1153
|
+
return v2;
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Apply variable-radius fillets to edges.
|
|
1157
|
+
*
|
|
1158
|
+
* `json` is a JSON string: `[{"edge": u32, "law": "constant"|"linear"|"scurve", "start": f64, "end": f64}]`
|
|
1159
|
+
* Returns a new solid handle.
|
|
1160
|
+
* @param {number} solid
|
|
1161
|
+
* @param {string} json
|
|
1162
|
+
* @returns {number}
|
|
1163
|
+
*/
|
|
1164
|
+
filletVariable(solid, json) {
|
|
1165
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1166
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1167
|
+
const ret = wasm.brepkernel_filletVariable(this.__wbg_ptr, solid, ptr0, len0);
|
|
1168
|
+
if (ret[2]) {
|
|
1169
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1170
|
+
}
|
|
1171
|
+
return ret[0] >>> 0;
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Fix face orientations to ensure consistent outward normals.
|
|
1175
|
+
*
|
|
1176
|
+
* Returns the number of faces fixed.
|
|
1177
|
+
* @param {number} solid
|
|
1178
|
+
* @returns {number}
|
|
1179
|
+
*/
|
|
1180
|
+
fixFaceOrientations(solid) {
|
|
1181
|
+
const ret = wasm.brepkernel_fixFaceOrientations(this.__wbg_ptr, solid);
|
|
1182
|
+
if (ret[2]) {
|
|
1183
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1184
|
+
}
|
|
1185
|
+
return ret[0] >>> 0;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Fuse (union) two solids into one.
|
|
1189
|
+
*
|
|
1190
|
+
* Returns a new solid handle (`u32`).
|
|
1191
|
+
*
|
|
1192
|
+
* # Errors
|
|
1193
|
+
*
|
|
1194
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
1195
|
+
* produces an empty or non-manifold result.
|
|
1196
|
+
* @param {number} a
|
|
1197
|
+
* @param {number} b
|
|
1198
|
+
* @returns {number}
|
|
1199
|
+
*/
|
|
1200
|
+
fuse(a, b) {
|
|
1201
|
+
const ret = wasm.brepkernel_fuse(this.__wbg_ptr, a, b);
|
|
1202
|
+
if (ret[2]) {
|
|
1203
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1204
|
+
}
|
|
1205
|
+
return ret[0] >>> 0;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Fuse (union) two solids and return evolution tracking data.
|
|
1209
|
+
*
|
|
1210
|
+
* Returns a JSON string: `{"solid": <u32>, "evolution": {...}}`.
|
|
1211
|
+
*
|
|
1212
|
+
* # Errors
|
|
1213
|
+
*
|
|
1214
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
1215
|
+
* produces an empty or non-manifold result.
|
|
1216
|
+
* @param {number} a
|
|
1217
|
+
* @param {number} b
|
|
1218
|
+
* @returns {any}
|
|
1219
|
+
*/
|
|
1220
|
+
fuseWithEvolution(a, b) {
|
|
1221
|
+
const ret = wasm.brepkernel_fuseWithEvolution(this.__wbg_ptr, a, b);
|
|
1222
|
+
if (ret[2]) {
|
|
1223
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1224
|
+
}
|
|
1225
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Get analytic surface parameters for a face.
|
|
1229
|
+
*
|
|
1230
|
+
* Returns a JSON string with type-dependent fields.
|
|
1231
|
+
* @param {number} face
|
|
1232
|
+
* @returns {string}
|
|
1233
|
+
*/
|
|
1234
|
+
getAnalyticSurfaceParams(face) {
|
|
1235
|
+
let deferred2_0;
|
|
1236
|
+
let deferred2_1;
|
|
1237
|
+
try {
|
|
1238
|
+
const ret = wasm.brepkernel_getAnalyticSurfaceParams(this.__wbg_ptr, face);
|
|
1239
|
+
var ptr1 = ret[0];
|
|
1240
|
+
var len1 = ret[1];
|
|
1241
|
+
if (ret[3]) {
|
|
1242
|
+
ptr1 = 0; len1 = 0;
|
|
1243
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1244
|
+
}
|
|
1245
|
+
deferred2_0 = ptr1;
|
|
1246
|
+
deferred2_1 = len1;
|
|
1247
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1248
|
+
} finally {
|
|
1249
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Get the solid handles within a compound.
|
|
1254
|
+
*
|
|
1255
|
+
* Returns an array of solid handles (`u32[]`).
|
|
1256
|
+
*
|
|
1257
|
+
* # Errors
|
|
1258
|
+
*
|
|
1259
|
+
* Returns an error if the compound handle is invalid.
|
|
1260
|
+
* @param {number} compound
|
|
1261
|
+
* @returns {Uint32Array}
|
|
1262
|
+
*/
|
|
1263
|
+
getCompoundSolids(compound) {
|
|
1264
|
+
const ret = wasm.brepkernel_getCompoundSolids(this.__wbg_ptr, compound);
|
|
1265
|
+
if (ret[3]) {
|
|
1266
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1267
|
+
}
|
|
1268
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1269
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1270
|
+
return v1;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Get the parameter domain of an edge curve.
|
|
1274
|
+
*
|
|
1275
|
+
* Returns `[t_start, t_end]`.
|
|
1276
|
+
* For line edges: `[0.0, length]`.
|
|
1277
|
+
* For NURBS edges: knot domain.
|
|
1278
|
+
* @param {number} edge
|
|
1279
|
+
* @returns {Float64Array}
|
|
1280
|
+
*/
|
|
1281
|
+
getEdgeCurveParameters(edge) {
|
|
1282
|
+
const ret = wasm.brepkernel_getEdgeCurveParameters(this.__wbg_ptr, edge);
|
|
1283
|
+
if (ret[3]) {
|
|
1284
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1285
|
+
}
|
|
1286
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1287
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1288
|
+
return v1;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Get the curve type of an edge.
|
|
1292
|
+
*
|
|
1293
|
+
* Returns `"LINE"`, `"BSPLINE_CURVE"`, `"CIRCLE"`, or `"ELLIPSE"`.
|
|
1294
|
+
*
|
|
1295
|
+
* For NURBS curves that exactly represent analytic curves, this
|
|
1296
|
+
* returns the underlying analytic type (e.g. `"CIRCLE"` for a
|
|
1297
|
+
* rational NURBS circle).
|
|
1298
|
+
* @param {number} edge
|
|
1299
|
+
* @returns {string}
|
|
1300
|
+
*/
|
|
1301
|
+
getEdgeCurveType(edge) {
|
|
1302
|
+
let deferred2_0;
|
|
1303
|
+
let deferred2_1;
|
|
1304
|
+
try {
|
|
1305
|
+
const ret = wasm.brepkernel_getEdgeCurveType(this.__wbg_ptr, edge);
|
|
1306
|
+
var ptr1 = ret[0];
|
|
1307
|
+
var len1 = ret[1];
|
|
1308
|
+
if (ret[3]) {
|
|
1309
|
+
ptr1 = 0; len1 = 0;
|
|
1310
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1311
|
+
}
|
|
1312
|
+
deferred2_0 = ptr1;
|
|
1313
|
+
deferred2_1 = len1;
|
|
1314
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1315
|
+
} finally {
|
|
1316
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Build an edge's NURBS curve data for JS consumption.
|
|
1321
|
+
*
|
|
1322
|
+
* Returns `null` for line edges, or a JSON string with
|
|
1323
|
+
* `{degree, knots, controlPoints, weights}` for NURBS edges.
|
|
1324
|
+
* @param {number} edge
|
|
1325
|
+
* @returns {any}
|
|
1326
|
+
*/
|
|
1327
|
+
getEdgeNurbsData(edge) {
|
|
1328
|
+
const ret = wasm.brepkernel_getEdgeNurbsData(this.__wbg_ptr, edge);
|
|
1329
|
+
if (ret[2]) {
|
|
1330
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1331
|
+
}
|
|
1332
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Get the vertex *handles* (not positions) of an edge.
|
|
1336
|
+
*
|
|
1337
|
+
* Returns `[start_vertex_handle, end_vertex_handle]`.
|
|
1338
|
+
*
|
|
1339
|
+
* # Errors
|
|
1340
|
+
*
|
|
1341
|
+
* Returns an error if the edge handle is invalid.
|
|
1342
|
+
* @param {number} edge
|
|
1343
|
+
* @returns {Uint32Array}
|
|
1344
|
+
*/
|
|
1345
|
+
getEdgeVertexHandles(edge) {
|
|
1346
|
+
const ret = wasm.brepkernel_getEdgeVertexHandles(this.__wbg_ptr, edge);
|
|
1347
|
+
if (ret[3]) {
|
|
1348
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1349
|
+
}
|
|
1350
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1351
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1352
|
+
return v1;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Get the vertex positions of an edge.
|
|
1356
|
+
*
|
|
1357
|
+
* Returns `[start_x, start_y, start_z, end_x, end_y, end_z]`.
|
|
1358
|
+
*
|
|
1359
|
+
* # Errors
|
|
1360
|
+
*
|
|
1361
|
+
* Returns an error if the edge handle is invalid.
|
|
1362
|
+
* @param {number} edge
|
|
1363
|
+
* @returns {Float64Array}
|
|
1364
|
+
*/
|
|
1365
|
+
getEdgeVertices(edge) {
|
|
1366
|
+
const ret = wasm.brepkernel_getEdgeVertices(this.__wbg_ptr, edge);
|
|
1367
|
+
if (ret[3]) {
|
|
1368
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1369
|
+
}
|
|
1370
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1371
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1372
|
+
return v1;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Get entity counts of a solid: `[faces, edges, vertices]`.
|
|
1376
|
+
*
|
|
1377
|
+
* # Errors
|
|
1378
|
+
*
|
|
1379
|
+
* Returns an error if the solid handle is invalid.
|
|
1380
|
+
* @param {number} solid
|
|
1381
|
+
* @returns {Uint32Array}
|
|
1382
|
+
*/
|
|
1383
|
+
getEntityCounts(solid) {
|
|
1384
|
+
const ret = wasm.brepkernel_getEntityCounts(this.__wbg_ptr, solid);
|
|
1385
|
+
if (ret[3]) {
|
|
1386
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1387
|
+
}
|
|
1388
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1389
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1390
|
+
return v1;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Get the edge handles of a face.
|
|
1394
|
+
*
|
|
1395
|
+
* Returns an array of edge handles (`u32[]`).
|
|
1396
|
+
* @param {number} face
|
|
1397
|
+
* @returns {Uint32Array}
|
|
1398
|
+
*/
|
|
1399
|
+
getFaceEdges(face) {
|
|
1400
|
+
const ret = wasm.brepkernel_getFaceEdges(this.__wbg_ptr, face);
|
|
1401
|
+
if (ret[3]) {
|
|
1402
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1403
|
+
}
|
|
1404
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1405
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1406
|
+
return v1;
|
|
1407
|
+
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Get the face normal of a planar face.
|
|
1410
|
+
*
|
|
1411
|
+
* Returns `[nx, ny, nz]`.
|
|
1412
|
+
*
|
|
1413
|
+
* # Errors
|
|
1414
|
+
*
|
|
1415
|
+
* Returns an error if the face is invalid or NURBS.
|
|
1416
|
+
* @param {number} face
|
|
1417
|
+
* @returns {Float64Array}
|
|
1418
|
+
*/
|
|
1419
|
+
getFaceNormal(face) {
|
|
1420
|
+
const ret = wasm.brepkernel_getFaceNormal(this.__wbg_ptr, face);
|
|
1421
|
+
if (ret[3]) {
|
|
1422
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1423
|
+
}
|
|
1424
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1425
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1426
|
+
return v1;
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Get the outer wire handle of a face.
|
|
1430
|
+
*
|
|
1431
|
+
* Returns a wire handle (`u32`).
|
|
1432
|
+
* @param {number} face
|
|
1433
|
+
* @returns {number}
|
|
1434
|
+
*/
|
|
1435
|
+
getFaceOuterWire(face) {
|
|
1436
|
+
const ret = wasm.brepkernel_getFaceOuterWire(this.__wbg_ptr, face);
|
|
1437
|
+
if (ret[2]) {
|
|
1438
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1439
|
+
}
|
|
1440
|
+
return ret[0] >>> 0;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Get the vertex handles of a face.
|
|
1444
|
+
*
|
|
1445
|
+
* Returns an array of vertex handles (`u32[]`).
|
|
1446
|
+
* @param {number} face
|
|
1447
|
+
* @returns {Uint32Array}
|
|
1448
|
+
*/
|
|
1449
|
+
getFaceVertices(face) {
|
|
1450
|
+
const ret = wasm.brepkernel_getFaceVertices(this.__wbg_ptr, face);
|
|
1451
|
+
if (ret[3]) {
|
|
1452
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1453
|
+
}
|
|
1454
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1455
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1456
|
+
return v1;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Get all wires of a face (outer wire first, then inner/hole wires).
|
|
1460
|
+
*
|
|
1461
|
+
* # Errors
|
|
1462
|
+
* Returns an error if the face handle is invalid.
|
|
1463
|
+
* @param {number} face
|
|
1464
|
+
* @returns {Uint32Array}
|
|
1465
|
+
*/
|
|
1466
|
+
getFaceWires(face) {
|
|
1467
|
+
const ret = wasm.brepkernel_getFaceWires(this.__wbg_ptr, face);
|
|
1468
|
+
if (ret[3]) {
|
|
1469
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1470
|
+
}
|
|
1471
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1472
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1473
|
+
return v1;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Get the orientation of a shape.
|
|
1477
|
+
*
|
|
1478
|
+
* Returns `"forward"` for all faces (brepkit faces don't have an
|
|
1479
|
+
* independent orientation flag; the normal direction is canonical).
|
|
1480
|
+
* @param {number} _id
|
|
1481
|
+
* @returns {string}
|
|
1482
|
+
*/
|
|
1483
|
+
getShapeOrientation(_id) {
|
|
1484
|
+
let deferred1_0;
|
|
1485
|
+
let deferred1_1;
|
|
1486
|
+
try {
|
|
1487
|
+
const ret = wasm.brepkernel_getShapeOrientation(this.__wbg_ptr, _id);
|
|
1488
|
+
deferred1_0 = ret[0];
|
|
1489
|
+
deferred1_1 = ret[1];
|
|
1490
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1491
|
+
} finally {
|
|
1492
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Get the face handles of a shell.
|
|
1497
|
+
*
|
|
1498
|
+
* Returns an array of face handles (`u32[]`).
|
|
1499
|
+
*
|
|
1500
|
+
* # Errors
|
|
1501
|
+
*
|
|
1502
|
+
* Returns an error if the shell handle is invalid.
|
|
1503
|
+
* @param {number} shell
|
|
1504
|
+
* @returns {Uint32Array}
|
|
1505
|
+
*/
|
|
1506
|
+
getShellFaces(shell) {
|
|
1507
|
+
const ret = wasm.brepkernel_getShellFaces(this.__wbg_ptr, shell);
|
|
1508
|
+
if (ret[3]) {
|
|
1509
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1510
|
+
}
|
|
1511
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1512
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1513
|
+
return v1;
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Get all edge handles of a solid.
|
|
1517
|
+
*
|
|
1518
|
+
* Returns an array of unique edge handles (`u32[]`).
|
|
1519
|
+
*
|
|
1520
|
+
* # Errors
|
|
1521
|
+
*
|
|
1522
|
+
* Returns an error if the solid handle is invalid.
|
|
1523
|
+
* @param {number} solid
|
|
1524
|
+
* @returns {Uint32Array}
|
|
1525
|
+
*/
|
|
1526
|
+
getSolidEdges(solid) {
|
|
1527
|
+
const ret = wasm.brepkernel_getSolidEdges(this.__wbg_ptr, solid);
|
|
1528
|
+
if (ret[3]) {
|
|
1529
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1530
|
+
}
|
|
1531
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1532
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1533
|
+
return v1;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Get all face handles of a solid.
|
|
1537
|
+
*
|
|
1538
|
+
* Returns an array of face handles (`u32[]`).
|
|
1539
|
+
*
|
|
1540
|
+
* # Errors
|
|
1541
|
+
*
|
|
1542
|
+
* Returns an error if the solid handle is invalid.
|
|
1543
|
+
* @param {number} solid
|
|
1544
|
+
* @returns {Uint32Array}
|
|
1545
|
+
*/
|
|
1546
|
+
getSolidFaces(solid) {
|
|
1547
|
+
const ret = wasm.brepkernel_getSolidFaces(this.__wbg_ptr, solid);
|
|
1548
|
+
if (ret[3]) {
|
|
1549
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1550
|
+
}
|
|
1551
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1552
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1553
|
+
return v1;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Get all vertex handles of a solid.
|
|
1557
|
+
*
|
|
1558
|
+
* Returns an array of unique vertex handles (`u32[]`).
|
|
1559
|
+
*
|
|
1560
|
+
* # Errors
|
|
1561
|
+
*
|
|
1562
|
+
* Returns an error if the solid handle is invalid.
|
|
1563
|
+
* @param {number} solid
|
|
1564
|
+
* @returns {Uint32Array}
|
|
1565
|
+
*/
|
|
1566
|
+
getSolidVertices(solid) {
|
|
1567
|
+
const ret = wasm.brepkernel_getSolidVertices(this.__wbg_ptr, solid);
|
|
1568
|
+
if (ret[3]) {
|
|
1569
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1570
|
+
}
|
|
1571
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1572
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1573
|
+
return v1;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Get the UV parameter domain of a face's surface.
|
|
1577
|
+
*
|
|
1578
|
+
* Returns `[u_min, u_max, v_min, v_max]`.
|
|
1579
|
+
* @param {number} face
|
|
1580
|
+
* @returns {Float64Array}
|
|
1581
|
+
*/
|
|
1582
|
+
getSurfaceDomain(face) {
|
|
1583
|
+
const ret = wasm.brepkernel_getSurfaceDomain(this.__wbg_ptr, face);
|
|
1584
|
+
if (ret[3]) {
|
|
1585
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1586
|
+
}
|
|
1587
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1588
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1589
|
+
return v1;
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Get the surface type of a face.
|
|
1593
|
+
*
|
|
1594
|
+
* Returns one of: `"plane"`, `"cylinder"`, `"cone"`, `"sphere"`,
|
|
1595
|
+
* `"torus"`, `"bspline"`.
|
|
1596
|
+
*
|
|
1597
|
+
* For NURBS surfaces that exactly represent analytic shapes, this
|
|
1598
|
+
* returns the underlying analytic type (e.g. `"sphere"` for a NURBS
|
|
1599
|
+
* sphere patch).
|
|
1600
|
+
* @param {number} face
|
|
1601
|
+
* @returns {string}
|
|
1602
|
+
*/
|
|
1603
|
+
getSurfaceType(face) {
|
|
1604
|
+
let deferred2_0;
|
|
1605
|
+
let deferred2_1;
|
|
1606
|
+
try {
|
|
1607
|
+
const ret = wasm.brepkernel_getSurfaceType(this.__wbg_ptr, face);
|
|
1608
|
+
var ptr1 = ret[0];
|
|
1609
|
+
var len1 = ret[1];
|
|
1610
|
+
if (ret[3]) {
|
|
1611
|
+
ptr1 = 0; len1 = 0;
|
|
1612
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1613
|
+
}
|
|
1614
|
+
deferred2_0 = ptr1;
|
|
1615
|
+
deferred2_1 = len1;
|
|
1616
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1617
|
+
} finally {
|
|
1618
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Get the position of a vertex.
|
|
1623
|
+
*
|
|
1624
|
+
* Returns `[x, y, z]`.
|
|
1625
|
+
*
|
|
1626
|
+
* # Errors
|
|
1627
|
+
*
|
|
1628
|
+
* Returns an error if the vertex handle is invalid.
|
|
1629
|
+
* @param {number} vertex
|
|
1630
|
+
* @returns {Float64Array}
|
|
1631
|
+
*/
|
|
1632
|
+
getVertexPosition(vertex) {
|
|
1633
|
+
const ret = wasm.brepkernel_getVertexPosition(this.__wbg_ptr, vertex);
|
|
1634
|
+
if (ret[3]) {
|
|
1635
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1636
|
+
}
|
|
1637
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1638
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1639
|
+
return v1;
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Get the edge handles of a wire.
|
|
1643
|
+
*
|
|
1644
|
+
* Returns an array of unique edge handles (`u32[]`).
|
|
1645
|
+
*
|
|
1646
|
+
* # Errors
|
|
1647
|
+
*
|
|
1648
|
+
* Returns an error if the wire handle is invalid.
|
|
1649
|
+
* @param {number} wire
|
|
1650
|
+
* @returns {Uint32Array}
|
|
1651
|
+
*/
|
|
1652
|
+
getWireEdges(wire) {
|
|
1653
|
+
const ret = wasm.brepkernel_getWireEdges(this.__wbg_ptr, wire);
|
|
1654
|
+
if (ret[3]) {
|
|
1655
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1656
|
+
}
|
|
1657
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1658
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1659
|
+
return v1;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Create a 2D grid pattern of a solid.
|
|
1663
|
+
*
|
|
1664
|
+
* Produces `count_x × count_y` copies arranged in a rectangular grid.
|
|
1665
|
+
* @param {number} solid
|
|
1666
|
+
* @param {number} dir_x_x
|
|
1667
|
+
* @param {number} dir_x_y
|
|
1668
|
+
* @param {number} dir_x_z
|
|
1669
|
+
* @param {number} dir_y_x
|
|
1670
|
+
* @param {number} dir_y_y
|
|
1671
|
+
* @param {number} dir_y_z
|
|
1672
|
+
* @param {number} spacing_x
|
|
1673
|
+
* @param {number} spacing_y
|
|
1674
|
+
* @param {number} count_x
|
|
1675
|
+
* @param {number} count_y
|
|
1676
|
+
* @returns {number}
|
|
1677
|
+
*/
|
|
1678
|
+
gridPattern(solid, dir_x_x, dir_x_y, dir_x_z, dir_y_x, dir_y_y, dir_y_z, spacing_x, spacing_y, count_x, count_y) {
|
|
1679
|
+
const ret = wasm.brepkernel_gridPattern(this.__wbg_ptr, solid, dir_x_x, dir_x_y, dir_x_z, dir_y_x, dir_y_y, dir_y_z, spacing_x, spacing_y, count_x, count_y);
|
|
1680
|
+
if (ret[2]) {
|
|
1681
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1682
|
+
}
|
|
1683
|
+
return ret[0] >>> 0;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Heal a solid topology.
|
|
1687
|
+
*
|
|
1688
|
+
* Returns the number of issues fixed.
|
|
1689
|
+
* @param {number} solid
|
|
1690
|
+
* @returns {number}
|
|
1691
|
+
*/
|
|
1692
|
+
healSolid(solid) {
|
|
1693
|
+
const ret = wasm.brepkernel_healSolid(this.__wbg_ptr, solid);
|
|
1694
|
+
if (ret[2]) {
|
|
1695
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1696
|
+
}
|
|
1697
|
+
return ret[0] >>> 0;
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Create a helical sweep of a profile face.
|
|
1701
|
+
*
|
|
1702
|
+
* Sweeps the profile along a helix defined by axis, radius, pitch,
|
|
1703
|
+
* and number of turns. Used for generating thread geometry.
|
|
1704
|
+
*
|
|
1705
|
+
* # Errors
|
|
1706
|
+
*
|
|
1707
|
+
* Returns an error if parameters are invalid or the sweep fails.
|
|
1708
|
+
* @param {number} profile
|
|
1709
|
+
* @param {number} axis_origin_x
|
|
1710
|
+
* @param {number} axis_origin_y
|
|
1711
|
+
* @param {number} axis_origin_z
|
|
1712
|
+
* @param {number} axis_dir_x
|
|
1713
|
+
* @param {number} axis_dir_y
|
|
1714
|
+
* @param {number} axis_dir_z
|
|
1715
|
+
* @param {number} radius
|
|
1716
|
+
* @param {number} pitch
|
|
1717
|
+
* @param {number} turns
|
|
1718
|
+
* @returns {number}
|
|
1719
|
+
*/
|
|
1720
|
+
helicalSweep(profile, axis_origin_x, axis_origin_y, axis_origin_z, axis_dir_x, axis_dir_y, axis_dir_z, radius, pitch, turns) {
|
|
1721
|
+
const ret = wasm.brepkernel_helicalSweep(this.__wbg_ptr, profile, axis_origin_x, axis_origin_y, axis_origin_z, axis_dir_x, axis_dir_y, axis_dir_z, radius, pitch, turns);
|
|
1722
|
+
if (ret[2]) {
|
|
1723
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1724
|
+
}
|
|
1725
|
+
return ret[0] >>> 0;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Import a 3MF file and return solid handles.
|
|
1729
|
+
*
|
|
1730
|
+
* Returns handles for each object found in the 3MF archive.
|
|
1731
|
+
*
|
|
1732
|
+
* # Errors
|
|
1733
|
+
*
|
|
1734
|
+
* Returns an error if the 3MF data is malformed.
|
|
1735
|
+
* @param {Uint8Array} data
|
|
1736
|
+
* @returns {Uint32Array}
|
|
1737
|
+
*/
|
|
1738
|
+
import3mf(data) {
|
|
1739
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1740
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1741
|
+
const ret = wasm.brepkernel_import3mf(this.__wbg_ptr, ptr0, len0);
|
|
1742
|
+
if (ret[3]) {
|
|
1743
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1744
|
+
}
|
|
1745
|
+
var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1746
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1747
|
+
return v2;
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Import a GLB (glTF binary) file and return a solid handle.
|
|
1751
|
+
*
|
|
1752
|
+
* # Errors
|
|
1753
|
+
*
|
|
1754
|
+
* Returns an error if the file is malformed or mesh import fails.
|
|
1755
|
+
* @param {Uint8Array} data
|
|
1756
|
+
* @returns {number}
|
|
1757
|
+
*/
|
|
1758
|
+
importGlb(data) {
|
|
1759
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1760
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1761
|
+
const ret = wasm.brepkernel_importGlb(this.__wbg_ptr, ptr0, len0);
|
|
1762
|
+
if (ret[2]) {
|
|
1763
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1764
|
+
}
|
|
1765
|
+
return ret[0] >>> 0;
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Import an IGES file and return solid handles.
|
|
1769
|
+
*
|
|
1770
|
+
* # Errors
|
|
1771
|
+
*
|
|
1772
|
+
* Returns an error if the IGES data is malformed.
|
|
1773
|
+
* @param {Uint8Array} data
|
|
1774
|
+
* @returns {Uint32Array}
|
|
1775
|
+
*/
|
|
1776
|
+
importIges(data) {
|
|
1777
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1778
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1779
|
+
const ret = wasm.brepkernel_importIges(this.__wbg_ptr, ptr0, len0);
|
|
1780
|
+
if (ret[3]) {
|
|
1781
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1782
|
+
}
|
|
1783
|
+
var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1784
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1785
|
+
return v2;
|
|
1786
|
+
}
|
|
1787
|
+
/**
|
|
1788
|
+
* Import a triangle mesh from flat vertex/index arrays.
|
|
1789
|
+
*
|
|
1790
|
+
* `positions` is a flat `[x0,y0,z0, x1,y1,z1, ...]` array.
|
|
1791
|
+
* `indices` is a flat `[i0,i1,i2, i3,i4,i5, ...]` array of triangle
|
|
1792
|
+
* vertex indices. Returns a solid handle.
|
|
1793
|
+
*
|
|
1794
|
+
* # Errors
|
|
1795
|
+
*
|
|
1796
|
+
* Returns an error if the arrays are malformed or mesh import fails.
|
|
1797
|
+
* @param {Float64Array} positions
|
|
1798
|
+
* @param {Uint32Array} indices
|
|
1799
|
+
* @returns {number}
|
|
1800
|
+
*/
|
|
1801
|
+
importIndexedMesh(positions, indices) {
|
|
1802
|
+
const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
1803
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1804
|
+
const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
1805
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1806
|
+
const ret = wasm.brepkernel_importIndexedMesh(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1807
|
+
if (ret[2]) {
|
|
1808
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1809
|
+
}
|
|
1810
|
+
return ret[0] >>> 0;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Import an OBJ file and return a solid handle.
|
|
1814
|
+
*
|
|
1815
|
+
* # Errors
|
|
1816
|
+
*
|
|
1817
|
+
* Returns an error if the file is malformed or mesh import fails.
|
|
1818
|
+
* @param {Uint8Array} data
|
|
1819
|
+
* @returns {number}
|
|
1820
|
+
*/
|
|
1821
|
+
importObj(data) {
|
|
1822
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1823
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1824
|
+
const ret = wasm.brepkernel_importObj(this.__wbg_ptr, ptr0, len0);
|
|
1825
|
+
if (ret[2]) {
|
|
1826
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1827
|
+
}
|
|
1828
|
+
return ret[0] >>> 0;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Import a STEP file and return solid handles.
|
|
1832
|
+
*
|
|
1833
|
+
* Returns handles for each solid found in the STEP file.
|
|
1834
|
+
*
|
|
1835
|
+
* # Errors
|
|
1836
|
+
*
|
|
1837
|
+
* Returns an error if the STEP data is malformed.
|
|
1838
|
+
* @param {Uint8Array} data
|
|
1839
|
+
* @returns {Uint32Array}
|
|
1840
|
+
*/
|
|
1841
|
+
importStep(data) {
|
|
1842
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1843
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1844
|
+
const ret = wasm.brepkernel_importStep(this.__wbg_ptr, ptr0, len0);
|
|
1845
|
+
if (ret[3]) {
|
|
1846
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1847
|
+
}
|
|
1848
|
+
var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1849
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1850
|
+
return v2;
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Import an STL file (binary or ASCII) and return a solid handle.
|
|
1854
|
+
*
|
|
1855
|
+
* The mesh triangles are converted to planar B-Rep faces with
|
|
1856
|
+
* vertex merging.
|
|
1857
|
+
*
|
|
1858
|
+
* # Errors
|
|
1859
|
+
*
|
|
1860
|
+
* Returns an error if the STL data is malformed or empty.
|
|
1861
|
+
* @param {Uint8Array} data
|
|
1862
|
+
* @returns {number}
|
|
1863
|
+
*/
|
|
1864
|
+
importStl(data) {
|
|
1865
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
1866
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1867
|
+
const ret = wasm.brepkernel_importStl(this.__wbg_ptr, ptr0, len0);
|
|
1868
|
+
if (ret[2]) {
|
|
1869
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1870
|
+
}
|
|
1871
|
+
return ret[0] >>> 0;
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Interpolate a NURBS curve through points and create an edge.
|
|
1875
|
+
*
|
|
1876
|
+
* Uses chord-length parameterization with the given degree.
|
|
1877
|
+
* Returns an edge handle (`u32`).
|
|
1878
|
+
* @param {Float64Array} coords
|
|
1879
|
+
* @param {number} degree
|
|
1880
|
+
* @returns {number}
|
|
1881
|
+
*/
|
|
1882
|
+
interpolatePoints(coords, degree) {
|
|
1883
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1884
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1885
|
+
const ret = wasm.brepkernel_interpolatePoints(this.__wbg_ptr, ptr0, len0, degree);
|
|
1886
|
+
if (ret[2]) {
|
|
1887
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1888
|
+
}
|
|
1889
|
+
return ret[0] >>> 0;
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Interpolate a grid of points into a NURBS surface.
|
|
1893
|
+
*
|
|
1894
|
+
* `coords` is a flat array `[x,y,z, ...]` of `rows * cols` points.
|
|
1895
|
+
* Returns a face handle.
|
|
1896
|
+
* @param {Float64Array} coords
|
|
1897
|
+
* @param {number} rows
|
|
1898
|
+
* @param {number} cols
|
|
1899
|
+
* @param {number} degree_u
|
|
1900
|
+
* @param {number} degree_v
|
|
1901
|
+
* @returns {number}
|
|
1902
|
+
*/
|
|
1903
|
+
interpolateSurface(coords, rows, cols, degree_u, degree_v) {
|
|
1904
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
1905
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1906
|
+
const ret = wasm.brepkernel_interpolateSurface(this.__wbg_ptr, ptr0, len0, rows, cols, degree_u, degree_v);
|
|
1907
|
+
if (ret[2]) {
|
|
1908
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1909
|
+
}
|
|
1910
|
+
return ret[0] >>> 0;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Intersect two solids, keeping only their common volume.
|
|
1914
|
+
*
|
|
1915
|
+
* Returns a new solid handle (`u32`).
|
|
1916
|
+
*
|
|
1917
|
+
* # Errors
|
|
1918
|
+
*
|
|
1919
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
1920
|
+
* produces an empty result.
|
|
1921
|
+
* @param {number} a
|
|
1922
|
+
* @param {number} b
|
|
1923
|
+
* @returns {number}
|
|
1924
|
+
*/
|
|
1925
|
+
intersect(a, b) {
|
|
1926
|
+
const ret = wasm.brepkernel_intersect(this.__wbg_ptr, a, b);
|
|
1927
|
+
if (ret[2]) {
|
|
1928
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1929
|
+
}
|
|
1930
|
+
return ret[0] >>> 0;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Compute the boolean intersection of two 2D polygons.
|
|
1934
|
+
*
|
|
1935
|
+
* Both polygons are flat arrays `[x,y, x,y, ...]`.
|
|
1936
|
+
* Returns a flat array of the intersection polygon coordinates,
|
|
1937
|
+
* or an empty array if they don't intersect.
|
|
1938
|
+
*
|
|
1939
|
+
* Uses the Sutherland-Hodgman algorithm (convex clipper).
|
|
1940
|
+
* @param {Float64Array} coords_a
|
|
1941
|
+
* @param {Float64Array} coords_b
|
|
1942
|
+
* @returns {Float64Array}
|
|
1943
|
+
*/
|
|
1944
|
+
intersectPolygons2d(coords_a, coords_b) {
|
|
1945
|
+
const ptr0 = passArrayF64ToWasm0(coords_a, wasm.__wbindgen_malloc);
|
|
1946
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1947
|
+
const ptr1 = passArrayF64ToWasm0(coords_b, wasm.__wbindgen_malloc);
|
|
1948
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1949
|
+
const ret = wasm.brepkernel_intersectPolygons2d(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1950
|
+
if (ret[3]) {
|
|
1951
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1952
|
+
}
|
|
1953
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1954
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1955
|
+
return v3;
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Intersect two solids and return evolution tracking data.
|
|
1959
|
+
*
|
|
1960
|
+
* Returns a JSON string: `{"solid": <u32>, "evolution": {...}}`.
|
|
1961
|
+
*
|
|
1962
|
+
* # Errors
|
|
1963
|
+
*
|
|
1964
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
1965
|
+
* produces an empty result.
|
|
1966
|
+
* @param {number} a
|
|
1967
|
+
* @param {number} b
|
|
1968
|
+
* @returns {any}
|
|
1969
|
+
*/
|
|
1970
|
+
intersectWithEvolution(a, b) {
|
|
1971
|
+
const ret = wasm.brepkernel_intersectWithEvolution(this.__wbg_ptr, a, b);
|
|
1972
|
+
if (ret[2]) {
|
|
1973
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1974
|
+
}
|
|
1975
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Check if an edge is forward-oriented in a given wire.
|
|
1979
|
+
*
|
|
1980
|
+
* Returns `true` if the edge is forward in the wire, `false` if reversed.
|
|
1981
|
+
* @param {number} edge
|
|
1982
|
+
* @param {number} wire
|
|
1983
|
+
* @returns {boolean}
|
|
1984
|
+
*/
|
|
1985
|
+
isEdgeForwardInWire(edge, wire) {
|
|
1986
|
+
const ret = wasm.brepkernel_isEdgeForwardInWire(this.__wbg_ptr, edge, wire);
|
|
1987
|
+
if (ret[2]) {
|
|
1988
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1989
|
+
}
|
|
1990
|
+
return ret[0] !== 0;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Check whether a wire is closed (last edge connects back to first).
|
|
1994
|
+
* @param {number} wire
|
|
1995
|
+
* @returns {boolean}
|
|
1996
|
+
*/
|
|
1997
|
+
isWireClosed(wire) {
|
|
1998
|
+
const ret = wasm.brepkernel_isWireClosed(this.__wbg_ptr, wire);
|
|
1999
|
+
if (ret[2]) {
|
|
2000
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2001
|
+
}
|
|
2002
|
+
return ret[0] !== 0;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Create a linear pattern of a solid.
|
|
2006
|
+
*
|
|
2007
|
+
* Returns a compound handle containing all copies.
|
|
2008
|
+
*
|
|
2009
|
+
* # Errors
|
|
2010
|
+
*
|
|
2011
|
+
* Returns an error if inputs are invalid.
|
|
2012
|
+
* @param {number} solid
|
|
2013
|
+
* @param {number} dx
|
|
2014
|
+
* @param {number} dy
|
|
2015
|
+
* @param {number} dz
|
|
2016
|
+
* @param {number} spacing
|
|
2017
|
+
* @param {number} count
|
|
2018
|
+
* @returns {number}
|
|
2019
|
+
*/
|
|
2020
|
+
linearPattern(solid, dx, dy, dz, spacing, count) {
|
|
2021
|
+
const ret = wasm.brepkernel_linearPattern(this.__wbg_ptr, solid, dx, dy, dz, spacing, count);
|
|
2022
|
+
if (ret[2]) {
|
|
2023
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2024
|
+
}
|
|
2025
|
+
return ret[0] >>> 0;
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Loft two or more profile faces into a solid.
|
|
2029
|
+
*
|
|
2030
|
+
* Takes an array of face handles. Returns a solid handle (`u32`).
|
|
2031
|
+
*
|
|
2032
|
+
* # Errors
|
|
2033
|
+
*
|
|
2034
|
+
* Returns an error if fewer than 2 faces or profiles have
|
|
2035
|
+
* different vertex counts.
|
|
2036
|
+
* @param {Uint32Array} faces
|
|
2037
|
+
* @returns {number}
|
|
2038
|
+
*/
|
|
2039
|
+
loft(faces) {
|
|
2040
|
+
const ptr0 = passArray32ToWasm0(faces, wasm.__wbindgen_malloc);
|
|
2041
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2042
|
+
const ret = wasm.brepkernel_loft(this.__wbg_ptr, ptr0, len0);
|
|
2043
|
+
if (ret[2]) {
|
|
2044
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2045
|
+
}
|
|
2046
|
+
return ret[0] >>> 0;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Loft profiles with smooth NURBS interpolation.
|
|
2050
|
+
*
|
|
2051
|
+
* Like `loft()`, but produces smooth NURBS side surfaces for 3+
|
|
2052
|
+
* profiles instead of piecewise-planar quads. The surfaces
|
|
2053
|
+
* interpolate through all intermediate profiles with C1+ continuity.
|
|
2054
|
+
*
|
|
2055
|
+
* Returns a solid handle (`u32`).
|
|
2056
|
+
*
|
|
2057
|
+
* # Errors
|
|
2058
|
+
*
|
|
2059
|
+
* Returns an error if fewer than 2 profiles are given, profiles have
|
|
2060
|
+
* different vertex counts, or surface fitting fails.
|
|
2061
|
+
* @param {Uint32Array} faces
|
|
2062
|
+
* @returns {number}
|
|
2063
|
+
*/
|
|
2064
|
+
loftSmooth(faces) {
|
|
2065
|
+
const ptr0 = passArray32ToWasm0(faces, wasm.__wbindgen_malloc);
|
|
2066
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2067
|
+
const ret = wasm.brepkernel_loftSmooth(this.__wbg_ptr, ptr0, len0);
|
|
2068
|
+
if (ret[2]) {
|
|
2069
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2070
|
+
}
|
|
2071
|
+
return ret[0] >>> 0;
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* Loft profiles with options for start/end points and ruled mode.
|
|
2075
|
+
*
|
|
2076
|
+
* `options` is a JSON string with optional fields:
|
|
2077
|
+
* - `startPoint: [x, y, z]` — apex point before first profile
|
|
2078
|
+
* - `endPoint: [x, y, z]` — apex point after last profile
|
|
2079
|
+
* - `ruled: bool` — true for ruled (linear) surfaces (default), false for smooth
|
|
2080
|
+
* @param {Uint32Array} faces
|
|
2081
|
+
* @param {string} options
|
|
2082
|
+
* @returns {number}
|
|
2083
|
+
*/
|
|
2084
|
+
loftWithOptions(faces, options) {
|
|
2085
|
+
const ptr0 = passArray32ToWasm0(faces, wasm.__wbindgen_malloc);
|
|
2086
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2087
|
+
const ptr1 = passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2088
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2089
|
+
const ret = wasm.brepkernel_loftWithOptions(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2090
|
+
if (ret[2]) {
|
|
2091
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2092
|
+
}
|
|
2093
|
+
return ret[0] >>> 0;
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Create a box solid with the given dimensions, centered at the origin.
|
|
2097
|
+
*
|
|
2098
|
+
* Returns a solid handle (`u32`).
|
|
2099
|
+
*
|
|
2100
|
+
* # Errors
|
|
2101
|
+
*
|
|
2102
|
+
* Returns an error if any dimension is non-positive or non-finite.
|
|
2103
|
+
* @param {number} dx
|
|
2104
|
+
* @param {number} dy
|
|
2105
|
+
* @param {number} dz
|
|
2106
|
+
* @returns {number}
|
|
2107
|
+
*/
|
|
2108
|
+
makeBox(dx, dy, dz) {
|
|
2109
|
+
const ret = wasm.brepkernel_makeBox(this.__wbg_ptr, dx, dy, dz);
|
|
2110
|
+
if (ret[2]) {
|
|
2111
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2112
|
+
}
|
|
2113
|
+
return ret[0] >>> 0;
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Create a circular polygon approximation on the XY plane.
|
|
2117
|
+
*
|
|
2118
|
+
* The circle is centered at the origin with the given `radius`,
|
|
2119
|
+
* approximated by `segments` straight edges.
|
|
2120
|
+
* Returns a face handle (`u32`).
|
|
2121
|
+
*
|
|
2122
|
+
* # Errors
|
|
2123
|
+
*
|
|
2124
|
+
* Returns an error if fewer than 3 segments are specified.
|
|
2125
|
+
* @param {number} radius
|
|
2126
|
+
* @param {number} segments
|
|
2127
|
+
* @returns {number}
|
|
2128
|
+
*/
|
|
2129
|
+
makeCircle(radius, segments) {
|
|
2130
|
+
const ret = wasm.brepkernel_makeCircle(this.__wbg_ptr, radius, segments);
|
|
2131
|
+
if (ret[2]) {
|
|
2132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2133
|
+
}
|
|
2134
|
+
return ret[0] >>> 0;
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Create a circular face on the XY plane (using NURBS arcs).
|
|
2138
|
+
*
|
|
2139
|
+
* Returns a face handle.
|
|
2140
|
+
* @param {number} radius
|
|
2141
|
+
* @param {number} segments
|
|
2142
|
+
* @returns {number}
|
|
2143
|
+
*/
|
|
2144
|
+
makeCircleFace(radius, segments) {
|
|
2145
|
+
const ret = wasm.brepkernel_makeCircleFace(this.__wbg_ptr, radius, segments);
|
|
2146
|
+
if (ret[2]) {
|
|
2147
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2148
|
+
}
|
|
2149
|
+
return ret[0] >>> 0;
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Create a compound from multiple solid handles.
|
|
2153
|
+
*
|
|
2154
|
+
* Returns a compound handle (stored as `u32`).
|
|
2155
|
+
* @param {Uint32Array} solid_handles
|
|
2156
|
+
* @returns {number}
|
|
2157
|
+
*/
|
|
2158
|
+
makeCompound(solid_handles) {
|
|
2159
|
+
const ptr0 = passArray32ToWasm0(solid_handles, wasm.__wbindgen_malloc);
|
|
2160
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2161
|
+
const ret = wasm.brepkernel_makeCompound(this.__wbg_ptr, ptr0, len0);
|
|
2162
|
+
if (ret[2]) {
|
|
2163
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2164
|
+
}
|
|
2165
|
+
return ret[0] >>> 0;
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Create a cone or frustum solid centered at the origin, axis along +Z.
|
|
2169
|
+
*
|
|
2170
|
+
* Returns a solid handle (`u32`).
|
|
2171
|
+
*
|
|
2172
|
+
* # Errors
|
|
2173
|
+
*
|
|
2174
|
+
* Returns an error if height is non-positive or both radii are zero.
|
|
2175
|
+
* @param {number} bottom_radius
|
|
2176
|
+
* @param {number} top_radius
|
|
2177
|
+
* @param {number} height
|
|
2178
|
+
* @returns {number}
|
|
2179
|
+
*/
|
|
2180
|
+
makeCone(bottom_radius, top_radius, height) {
|
|
2181
|
+
const ret = wasm.brepkernel_makeCone(this.__wbg_ptr, bottom_radius, top_radius, height);
|
|
2182
|
+
if (ret[2]) {
|
|
2183
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2184
|
+
}
|
|
2185
|
+
return ret[0] >>> 0;
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Create a cylinder solid centered at the origin, axis along +Z.
|
|
2189
|
+
*
|
|
2190
|
+
* Returns a solid handle (`u32`).
|
|
2191
|
+
*
|
|
2192
|
+
* # Errors
|
|
2193
|
+
*
|
|
2194
|
+
* Returns an error if radius or height is non-positive.
|
|
2195
|
+
* @param {number} radius
|
|
2196
|
+
* @param {number} height
|
|
2197
|
+
* @returns {number}
|
|
2198
|
+
*/
|
|
2199
|
+
makeCylinder(radius, height) {
|
|
2200
|
+
const ret = wasm.brepkernel_makeCylinder(this.__wbg_ptr, radius, height);
|
|
2201
|
+
if (ret[2]) {
|
|
2202
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2203
|
+
}
|
|
2204
|
+
return ret[0] >>> 0;
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Create an ellipsoid solid centered at the origin.
|
|
2208
|
+
*
|
|
2209
|
+
* Built by creating a unit sphere and scaling it by `(rx, ry, rz)`.
|
|
2210
|
+
*
|
|
2211
|
+
* # Errors
|
|
2212
|
+
*
|
|
2213
|
+
* Returns an error if any radius is non-positive.
|
|
2214
|
+
* @param {number} rx
|
|
2215
|
+
* @param {number} ry
|
|
2216
|
+
* @param {number} rz
|
|
2217
|
+
* @returns {number}
|
|
2218
|
+
*/
|
|
2219
|
+
makeEllipsoid(rx, ry, rz) {
|
|
2220
|
+
const ret = wasm.brepkernel_makeEllipsoid(this.__wbg_ptr, rx, ry, rz);
|
|
2221
|
+
if (ret[2]) {
|
|
2222
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2223
|
+
}
|
|
2224
|
+
return ret[0] >>> 0;
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Create a planar face from a wire (computes normal from first 3 vertices).
|
|
2228
|
+
*
|
|
2229
|
+
* Returns a face handle (`u32`).
|
|
2230
|
+
* @param {number} wire
|
|
2231
|
+
* @returns {number}
|
|
2232
|
+
*/
|
|
2233
|
+
makeFaceFromWire(wire) {
|
|
2234
|
+
const ret = wasm.brepkernel_makeFaceFromWire(this.__wbg_ptr, wire);
|
|
2235
|
+
if (ret[2]) {
|
|
2236
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2237
|
+
}
|
|
2238
|
+
return ret[0] >>> 0;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Create a straight-line edge between two points.
|
|
2242
|
+
*
|
|
2243
|
+
* Returns an edge handle (`u32`).
|
|
2244
|
+
* @param {number} x1
|
|
2245
|
+
* @param {number} y1
|
|
2246
|
+
* @param {number} z1
|
|
2247
|
+
* @param {number} x2
|
|
2248
|
+
* @param {number} y2
|
|
2249
|
+
* @param {number} z2
|
|
2250
|
+
* @returns {number}
|
|
2251
|
+
*/
|
|
2252
|
+
makeLineEdge(x1, y1, z1, x2, y2, z2) {
|
|
2253
|
+
const ret = wasm.brepkernel_makeLineEdge(this.__wbg_ptr, x1, y1, z1, x2, y2, z2);
|
|
2254
|
+
if (ret[2]) {
|
|
2255
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2256
|
+
}
|
|
2257
|
+
return ret[0] >>> 0;
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Create a NURBS curve edge.
|
|
2261
|
+
*
|
|
2262
|
+
* Returns an edge handle (`u32`).
|
|
2263
|
+
* @param {number} start_x
|
|
2264
|
+
* @param {number} start_y
|
|
2265
|
+
* @param {number} start_z
|
|
2266
|
+
* @param {number} end_x
|
|
2267
|
+
* @param {number} end_y
|
|
2268
|
+
* @param {number} end_z
|
|
2269
|
+
* @param {number} degree
|
|
2270
|
+
* @param {Float64Array} knots
|
|
2271
|
+
* @param {Float64Array} control_points
|
|
2272
|
+
* @param {Float64Array} weights
|
|
2273
|
+
* @returns {number}
|
|
2274
|
+
*/
|
|
2275
|
+
makeNurbsEdge(start_x, start_y, start_z, end_x, end_y, end_z, degree, knots, control_points, weights) {
|
|
2276
|
+
const ptr0 = passArrayF64ToWasm0(knots, wasm.__wbindgen_malloc);
|
|
2277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2278
|
+
const ptr1 = passArrayF64ToWasm0(control_points, wasm.__wbindgen_malloc);
|
|
2279
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2280
|
+
const ptr2 = passArrayF64ToWasm0(weights, wasm.__wbindgen_malloc);
|
|
2281
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2282
|
+
const ret = wasm.brepkernel_makeNurbsEdge(this.__wbg_ptr, start_x, start_y, start_z, end_x, end_y, end_z, degree, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2283
|
+
if (ret[2]) {
|
|
2284
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2285
|
+
}
|
|
2286
|
+
return ret[0] >>> 0;
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Create a polygonal face from flat coordinate triples `[x,y,z, ...]`.
|
|
2290
|
+
*
|
|
2291
|
+
* Requires at least 3 points (9 `f64` values).
|
|
2292
|
+
* Returns a face handle (`u32`).
|
|
2293
|
+
*
|
|
2294
|
+
* # Errors
|
|
2295
|
+
*
|
|
2296
|
+
* Returns an error if `coords` length is not a multiple of 3,
|
|
2297
|
+
* fewer than 3 points are provided, or the face normal is degenerate.
|
|
2298
|
+
* @param {Float64Array} coords
|
|
2299
|
+
* @returns {number}
|
|
2300
|
+
*/
|
|
2301
|
+
makePolygon(coords) {
|
|
2302
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
2303
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2304
|
+
const ret = wasm.brepkernel_makePolygon(this.__wbg_ptr, ptr0, len0);
|
|
2305
|
+
if (ret[2]) {
|
|
2306
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2307
|
+
}
|
|
2308
|
+
return ret[0] >>> 0;
|
|
2309
|
+
}
|
|
2310
|
+
/**
|
|
2311
|
+
* Create a closed polygon wire from flat coordinates.
|
|
2312
|
+
*
|
|
2313
|
+
* Returns a wire handle.
|
|
2314
|
+
* @param {Float64Array} coords
|
|
2315
|
+
* @returns {number}
|
|
2316
|
+
*/
|
|
2317
|
+
makePolygonWire(coords) {
|
|
2318
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
2319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2320
|
+
const ret = wasm.brepkernel_makePolygonWire(this.__wbg_ptr, ptr0, len0);
|
|
2321
|
+
if (ret[2]) {
|
|
2322
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2323
|
+
}
|
|
2324
|
+
return ret[0] >>> 0;
|
|
2325
|
+
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Create a rectangular face on the XY plane centered at the origin.
|
|
2328
|
+
*
|
|
2329
|
+
* Returns a face handle (`u32`).
|
|
2330
|
+
*
|
|
2331
|
+
* # Errors
|
|
2332
|
+
*
|
|
2333
|
+
* Returns an error if `width` or `height` is non-positive, NaN,
|
|
2334
|
+
* or infinite, or if the face geometry cannot be constructed.
|
|
2335
|
+
* @param {number} width
|
|
2336
|
+
* @param {number} height
|
|
2337
|
+
* @returns {number}
|
|
2338
|
+
*/
|
|
2339
|
+
makeRectangle(width, height) {
|
|
2340
|
+
const ret = wasm.brepkernel_makeRectangle(this.__wbg_ptr, width, height);
|
|
2341
|
+
if (ret[2]) {
|
|
2342
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2343
|
+
}
|
|
2344
|
+
return ret[0] >>> 0;
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Create a regular polygon wire on the XY plane.
|
|
2348
|
+
*
|
|
2349
|
+
* Returns a wire handle.
|
|
2350
|
+
* @param {number} radius
|
|
2351
|
+
* @param {number} n_sides
|
|
2352
|
+
* @returns {number}
|
|
2353
|
+
*/
|
|
2354
|
+
makeRegularPolygonWire(radius, n_sides) {
|
|
2355
|
+
const ret = wasm.brepkernel_makeRegularPolygonWire(this.__wbg_ptr, radius, n_sides);
|
|
2356
|
+
if (ret[2]) {
|
|
2357
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2358
|
+
}
|
|
2359
|
+
return ret[0] >>> 0;
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Create a solid from a set of faces by sewing them together.
|
|
2363
|
+
*
|
|
2364
|
+
* Alias for `sewFaces` with a default tolerance. This is the equivalent
|
|
2365
|
+
* of OCCT's `BRepBuilderAPI_MakeSolid`.
|
|
2366
|
+
* @param {Uint32Array} face_handles
|
|
2367
|
+
* @returns {number}
|
|
2368
|
+
*/
|
|
2369
|
+
makeSolid(face_handles) {
|
|
2370
|
+
const ptr0 = passArray32ToWasm0(face_handles, wasm.__wbindgen_malloc);
|
|
2371
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2372
|
+
const ret = wasm.brepkernel_makeSolid(this.__wbg_ptr, ptr0, len0);
|
|
2373
|
+
if (ret[2]) {
|
|
2374
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2375
|
+
}
|
|
2376
|
+
return ret[0] >>> 0;
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Create a sphere solid centered at the origin.
|
|
2380
|
+
*
|
|
2381
|
+
* Returns a solid handle (`u32`).
|
|
2382
|
+
*
|
|
2383
|
+
* # Errors
|
|
2384
|
+
*
|
|
2385
|
+
* Returns an error if radius is non-positive or segments < 4.
|
|
2386
|
+
* @param {number} radius
|
|
2387
|
+
* @param {number} segments
|
|
2388
|
+
* @returns {number}
|
|
2389
|
+
*/
|
|
2390
|
+
makeSphere(radius, segments) {
|
|
2391
|
+
const ret = wasm.brepkernel_makeSphere(this.__wbg_ptr, radius, segments);
|
|
2392
|
+
if (ret[2]) {
|
|
2393
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2394
|
+
}
|
|
2395
|
+
return ret[0] >>> 0;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Create a torus solid centered at the origin in the XY plane.
|
|
2399
|
+
*
|
|
2400
|
+
* Returns a solid handle (`u32`).
|
|
2401
|
+
*
|
|
2402
|
+
* # Errors
|
|
2403
|
+
*
|
|
2404
|
+
* Returns an error if radii are non-positive or minor >= major.
|
|
2405
|
+
* @param {number} major_radius
|
|
2406
|
+
* @param {number} minor_radius
|
|
2407
|
+
* @param {number} segments
|
|
2408
|
+
* @returns {number}
|
|
2409
|
+
*/
|
|
2410
|
+
makeTorus(major_radius, minor_radius, segments) {
|
|
2411
|
+
const ret = wasm.brepkernel_makeTorus(this.__wbg_ptr, major_radius, minor_radius, segments);
|
|
2412
|
+
if (ret[2]) {
|
|
2413
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2414
|
+
}
|
|
2415
|
+
return ret[0] >>> 0;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Create a vertex at the given position.
|
|
2419
|
+
*
|
|
2420
|
+
* Returns a vertex handle (`u32`).
|
|
2421
|
+
* @param {number} x
|
|
2422
|
+
* @param {number} y
|
|
2423
|
+
* @param {number} z
|
|
2424
|
+
* @returns {number}
|
|
2425
|
+
*/
|
|
2426
|
+
makeVertex(x, y, z) {
|
|
2427
|
+
const ret = wasm.brepkernel_makeVertex(this.__wbg_ptr, x, y, z);
|
|
2428
|
+
if (ret[2]) {
|
|
2429
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2430
|
+
}
|
|
2431
|
+
return ret[0] >>> 0;
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Create a closed wire from an ordered array of edge handles.
|
|
2435
|
+
*
|
|
2436
|
+
* Returns a wire handle (`u32`).
|
|
2437
|
+
* @param {Uint32Array} edge_handles
|
|
2438
|
+
* @param {boolean} closed
|
|
2439
|
+
* @returns {number}
|
|
2440
|
+
*/
|
|
2441
|
+
makeWire(edge_handles, closed) {
|
|
2442
|
+
const ptr0 = passArray32ToWasm0(edge_handles, wasm.__wbindgen_malloc);
|
|
2443
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2444
|
+
const ret = wasm.brepkernel_makeWire(this.__wbg_ptr, ptr0, len0, closed);
|
|
2445
|
+
if (ret[2]) {
|
|
2446
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2447
|
+
}
|
|
2448
|
+
return ret[0] >>> 0;
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Measure curvature of an edge curve at parameter `t`.
|
|
2452
|
+
*
|
|
2453
|
+
* Returns `[curvature, tangent_x, tangent_y, tangent_z, normal_x, normal_y, normal_z]`.
|
|
2454
|
+
* Curvature is 1/radius. For lines, curvature is 0.
|
|
2455
|
+
* @param {number} edge
|
|
2456
|
+
* @param {number} t
|
|
2457
|
+
* @returns {Float64Array}
|
|
2458
|
+
*/
|
|
2459
|
+
measureCurvatureAtEdge(edge, t) {
|
|
2460
|
+
const ret = wasm.brepkernel_measureCurvatureAtEdge(this.__wbg_ptr, edge, t);
|
|
2461
|
+
if (ret[3]) {
|
|
2462
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2463
|
+
}
|
|
2464
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2465
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2466
|
+
return v1;
|
|
2467
|
+
}
|
|
2468
|
+
/**
|
|
2469
|
+
* Measure principal curvatures at (u, v) on a face surface.
|
|
2470
|
+
*
|
|
2471
|
+
* Returns `[k1, k2, d1x, d1y, d1z, d2x, d2y, d2z]` where k1/k2 are
|
|
2472
|
+
* principal curvatures and d1/d2 are the corresponding direction vectors.
|
|
2473
|
+
* @param {number} face
|
|
2474
|
+
* @param {number} u
|
|
2475
|
+
* @param {number} v
|
|
2476
|
+
* @returns {Float64Array}
|
|
2477
|
+
*/
|
|
2478
|
+
measureCurvatureAtSurface(face, u, v) {
|
|
2479
|
+
const ret = wasm.brepkernel_measureCurvatureAtSurface(this.__wbg_ptr, face, u, v);
|
|
2480
|
+
if (ret[3]) {
|
|
2481
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2482
|
+
}
|
|
2483
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2484
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2485
|
+
return v1;
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Merge coincident vertices in a solid.
|
|
2489
|
+
*
|
|
2490
|
+
* Returns the number of vertices merged.
|
|
2491
|
+
* @param {number} solid
|
|
2492
|
+
* @param {number} tolerance
|
|
2493
|
+
* @returns {number}
|
|
2494
|
+
*/
|
|
2495
|
+
mergeCoincidentVertices(solid, tolerance) {
|
|
2496
|
+
const ret = wasm.brepkernel_mergeCoincidentVertices(this.__wbg_ptr, solid, tolerance);
|
|
2497
|
+
if (ret[2]) {
|
|
2498
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2499
|
+
}
|
|
2500
|
+
return ret[0] >>> 0;
|
|
2501
|
+
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Perform a mesh boolean on raw triangle data.
|
|
2504
|
+
*
|
|
2505
|
+
* Returns a `JsMesh` with the result.
|
|
2506
|
+
* @param {Float64Array} positions_a
|
|
2507
|
+
* @param {Uint32Array} indices_a
|
|
2508
|
+
* @param {Float64Array} positions_b
|
|
2509
|
+
* @param {Uint32Array} indices_b
|
|
2510
|
+
* @param {string} op
|
|
2511
|
+
* @param {number} tolerance
|
|
2512
|
+
* @returns {JsMesh}
|
|
2513
|
+
*/
|
|
2514
|
+
meshBoolean(positions_a, indices_a, positions_b, indices_b, op, tolerance) {
|
|
2515
|
+
const ptr0 = passArrayF64ToWasm0(positions_a, wasm.__wbindgen_malloc);
|
|
2516
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2517
|
+
const ptr1 = passArray32ToWasm0(indices_a, wasm.__wbindgen_malloc);
|
|
2518
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2519
|
+
const ptr2 = passArrayF64ToWasm0(positions_b, wasm.__wbindgen_malloc);
|
|
2520
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2521
|
+
const ptr3 = passArray32ToWasm0(indices_b, wasm.__wbindgen_malloc);
|
|
2522
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2523
|
+
const ptr4 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2524
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2525
|
+
const ret = wasm.brepkernel_meshBoolean(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, tolerance);
|
|
2526
|
+
if (ret[2]) {
|
|
2527
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2528
|
+
}
|
|
2529
|
+
return JsMesh.__wrap(ret[0]);
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Sample all edges of a solid into polylines for wireframe rendering.
|
|
2533
|
+
*
|
|
2534
|
+
* Returns a `JsEdgeLines` containing flattened positions and per-edge
|
|
2535
|
+
* offset indices. The `deflection` parameter controls sampling density.
|
|
2536
|
+
* @param {number} solid
|
|
2537
|
+
* @param {number} deflection
|
|
2538
|
+
* @returns {JsEdgeLines}
|
|
2539
|
+
*/
|
|
2540
|
+
meshEdges(solid, deflection) {
|
|
2541
|
+
const ret = wasm.brepkernel_meshEdges(this.__wbg_ptr, solid, deflection);
|
|
2542
|
+
if (ret[2]) {
|
|
2543
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2544
|
+
}
|
|
2545
|
+
return JsEdgeLines.__wrap(ret[0]);
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Mirror a solid across a plane.
|
|
2549
|
+
*
|
|
2550
|
+
* Returns a new solid handle.
|
|
2551
|
+
*
|
|
2552
|
+
* # Errors
|
|
2553
|
+
*
|
|
2554
|
+
* Returns an error if the solid handle is invalid or the normal is zero.
|
|
2555
|
+
* @param {number} solid
|
|
2556
|
+
* @param {number} px
|
|
2557
|
+
* @param {number} py
|
|
2558
|
+
* @param {number} pz
|
|
2559
|
+
* @param {number} nx
|
|
2560
|
+
* @param {number} ny
|
|
2561
|
+
* @param {number} nz
|
|
2562
|
+
* @returns {number}
|
|
2563
|
+
*/
|
|
2564
|
+
mirror(solid, px, py, pz, nx, ny, nz) {
|
|
2565
|
+
const ret = wasm.brepkernel_mirror(this.__wbg_ptr, solid, px, py, pz, nx, ny, nz);
|
|
2566
|
+
if (ret[2]) {
|
|
2567
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2568
|
+
}
|
|
2569
|
+
return ret[0] >>> 0;
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Create a new, empty kernel.
|
|
2573
|
+
*/
|
|
2574
|
+
constructor() {
|
|
2575
|
+
const ret = wasm.brepkernel_new();
|
|
2576
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2577
|
+
BrepKernelFinalization.register(this, this.__wbg_ptr, this);
|
|
2578
|
+
return this;
|
|
2579
|
+
}
|
|
2580
|
+
/**
|
|
2581
|
+
* Offset a face by a distance along its surface normal.
|
|
2582
|
+
*
|
|
2583
|
+
* Returns the new offset face handle.
|
|
2584
|
+
*
|
|
2585
|
+
* # Errors
|
|
2586
|
+
*
|
|
2587
|
+
* Returns an error if the face handle is invalid or the operation fails.
|
|
2588
|
+
* @param {number} face
|
|
2589
|
+
* @param {number} distance
|
|
2590
|
+
* @param {number} samples
|
|
2591
|
+
* @returns {number}
|
|
2592
|
+
*/
|
|
2593
|
+
offsetFace(face, distance, samples) {
|
|
2594
|
+
const ret = wasm.brepkernel_offsetFace(this.__wbg_ptr, face, distance, samples);
|
|
2595
|
+
if (ret[2]) {
|
|
2596
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2597
|
+
}
|
|
2598
|
+
return ret[0] >>> 0;
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Offset a 2D polygon by a signed distance.
|
|
2602
|
+
*
|
|
2603
|
+
* `coords` is a flat array `[x,y, x,y, ...]` of 2D points.
|
|
2604
|
+
* Returns a flat array of offset polygon coordinates.
|
|
2605
|
+
* @param {Float64Array} coords
|
|
2606
|
+
* @param {number} distance
|
|
2607
|
+
* @param {number} tolerance
|
|
2608
|
+
* @returns {Float64Array}
|
|
2609
|
+
*/
|
|
2610
|
+
offsetPolygon2d(coords, distance, tolerance) {
|
|
2611
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
2612
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2613
|
+
const ret = wasm.brepkernel_offsetPolygon2d(this.__wbg_ptr, ptr0, len0, distance, tolerance);
|
|
2614
|
+
if (ret[3]) {
|
|
2615
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2616
|
+
}
|
|
2617
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2618
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2619
|
+
return v2;
|
|
2620
|
+
}
|
|
2621
|
+
/**
|
|
2622
|
+
* Offset (shell) a solid by a distance.
|
|
2623
|
+
*
|
|
2624
|
+
* Returns a new solid handle.
|
|
2625
|
+
*
|
|
2626
|
+
* # Errors
|
|
2627
|
+
*
|
|
2628
|
+
* Returns an error if the distance is zero or the solid is invalid.
|
|
2629
|
+
* @param {number} solid
|
|
2630
|
+
* @param {number} distance
|
|
2631
|
+
* @returns {number}
|
|
2632
|
+
*/
|
|
2633
|
+
offsetSolid(solid, distance) {
|
|
2634
|
+
const ret = wasm.brepkernel_offsetSolid(this.__wbg_ptr, solid, distance);
|
|
2635
|
+
if (ret[2]) {
|
|
2636
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2637
|
+
}
|
|
2638
|
+
return ret[0] >>> 0;
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* Offset a wire on a planar face.
|
|
2642
|
+
*
|
|
2643
|
+
* Returns a new wire handle.
|
|
2644
|
+
* @param {number} face
|
|
2645
|
+
* @param {number} distance
|
|
2646
|
+
* @returns {number}
|
|
2647
|
+
*/
|
|
2648
|
+
offsetWire(face, distance) {
|
|
2649
|
+
const ret = wasm.brepkernel_offsetWire(this.__wbg_ptr, face, distance);
|
|
2650
|
+
if (ret[2]) {
|
|
2651
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2652
|
+
}
|
|
2653
|
+
return ret[0] >>> 0;
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* Pipe sweep: sweep a profile along a NURBS path (no guide).
|
|
2657
|
+
*
|
|
2658
|
+
* Returns a solid handle.
|
|
2659
|
+
*
|
|
2660
|
+
* # Errors
|
|
2661
|
+
*
|
|
2662
|
+
* Returns an error if the face or path is invalid.
|
|
2663
|
+
* @param {number} face
|
|
2664
|
+
* @param {number} path_degree
|
|
2665
|
+
* @param {Float64Array} path_knots
|
|
2666
|
+
* @param {Float64Array} path_control_points
|
|
2667
|
+
* @param {Float64Array} path_weights
|
|
2668
|
+
* @returns {number}
|
|
2669
|
+
*/
|
|
2670
|
+
pipe(face, path_degree, path_knots, path_control_points, path_weights) {
|
|
2671
|
+
const ptr0 = passArrayF64ToWasm0(path_knots, wasm.__wbindgen_malloc);
|
|
2672
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2673
|
+
const ptr1 = passArrayF64ToWasm0(path_control_points, wasm.__wbindgen_malloc);
|
|
2674
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2675
|
+
const ptr2 = passArrayF64ToWasm0(path_weights, wasm.__wbindgen_malloc);
|
|
2676
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2677
|
+
const ret = wasm.brepkernel_pipe(this.__wbg_ptr, face, path_degree, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2678
|
+
if (ret[2]) {
|
|
2679
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2680
|
+
}
|
|
2681
|
+
return ret[0] >>> 0;
|
|
2682
|
+
}
|
|
2683
|
+
/**
|
|
2684
|
+
* Test if a 2D point is inside a closed polygon.
|
|
2685
|
+
*
|
|
2686
|
+
* `polygon_coords` is a flat array `[x,y, x,y, ...]`.
|
|
2687
|
+
* Returns `true` if the point is inside the polygon (winding number test).
|
|
2688
|
+
* @param {Float64Array} polygon_coords
|
|
2689
|
+
* @param {number} px
|
|
2690
|
+
* @param {number} py
|
|
2691
|
+
* @returns {boolean}
|
|
2692
|
+
*/
|
|
2693
|
+
pointInPolygon2d(polygon_coords, px, py) {
|
|
2694
|
+
const ptr0 = passArrayF64ToWasm0(polygon_coords, wasm.__wbindgen_malloc);
|
|
2695
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2696
|
+
const ret = wasm.brepkernel_pointInPolygon2d(this.__wbg_ptr, ptr0, len0, px, py);
|
|
2697
|
+
if (ret[2]) {
|
|
2698
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2699
|
+
}
|
|
2700
|
+
return ret[0] !== 0;
|
|
2701
|
+
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Compute minimum distance from a point to an edge.
|
|
2704
|
+
*
|
|
2705
|
+
* Returns `[distance, closest_x, closest_y, closest_z]`.
|
|
2706
|
+
*
|
|
2707
|
+
* # Errors
|
|
2708
|
+
*
|
|
2709
|
+
* Returns an error if the edge handle is invalid.
|
|
2710
|
+
* @param {number} px
|
|
2711
|
+
* @param {number} py
|
|
2712
|
+
* @param {number} pz
|
|
2713
|
+
* @param {number} edge
|
|
2714
|
+
* @returns {Float64Array}
|
|
2715
|
+
*/
|
|
2716
|
+
pointToEdgeDistance(px, py, pz, edge) {
|
|
2717
|
+
const ret = wasm.brepkernel_pointToEdgeDistance(this.__wbg_ptr, px, py, pz, edge);
|
|
2718
|
+
if (ret[3]) {
|
|
2719
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2720
|
+
}
|
|
2721
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2722
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2723
|
+
return v1;
|
|
2724
|
+
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Compute minimum distance from a point to a face.
|
|
2727
|
+
*
|
|
2728
|
+
* Returns `[distance, closest_x, closest_y, closest_z]`.
|
|
2729
|
+
*
|
|
2730
|
+
* # Errors
|
|
2731
|
+
*
|
|
2732
|
+
* Returns an error if the face handle is invalid.
|
|
2733
|
+
* @param {number} px
|
|
2734
|
+
* @param {number} py
|
|
2735
|
+
* @param {number} pz
|
|
2736
|
+
* @param {number} face
|
|
2737
|
+
* @returns {Float64Array}
|
|
2738
|
+
*/
|
|
2739
|
+
pointToFaceDistance(px, py, pz, face) {
|
|
2740
|
+
const ret = wasm.brepkernel_pointToFaceDistance(this.__wbg_ptr, px, py, pz, face);
|
|
2741
|
+
if (ret[3]) {
|
|
2742
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2743
|
+
}
|
|
2744
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2745
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2746
|
+
return v1;
|
|
2747
|
+
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Compute minimum distance from a point to a solid.
|
|
2750
|
+
*
|
|
2751
|
+
* Returns `[distance, closest_x, closest_y, closest_z]`.
|
|
2752
|
+
*
|
|
2753
|
+
* # Errors
|
|
2754
|
+
*
|
|
2755
|
+
* Returns an error if the solid handle is invalid.
|
|
2756
|
+
* @param {number} px
|
|
2757
|
+
* @param {number} py
|
|
2758
|
+
* @param {number} pz
|
|
2759
|
+
* @param {number} solid
|
|
2760
|
+
* @returns {Float64Array}
|
|
2761
|
+
*/
|
|
2762
|
+
pointToSolidDistance(px, py, pz, solid) {
|
|
2763
|
+
const ret = wasm.brepkernel_pointToSolidDistance(this.__wbg_ptr, px, py, pz, solid);
|
|
2764
|
+
if (ret[3]) {
|
|
2765
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2766
|
+
}
|
|
2767
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2768
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2769
|
+
return v1;
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Test if two 2D polygons intersect (overlap).
|
|
2773
|
+
*
|
|
2774
|
+
* Both polygons are flat arrays `[x,y, x,y, ...]`.
|
|
2775
|
+
* Returns `true` if any vertex of one polygon is inside the other
|
|
2776
|
+
* or if any edges cross.
|
|
2777
|
+
* @param {Float64Array} coords_a
|
|
2778
|
+
* @param {Float64Array} coords_b
|
|
2779
|
+
* @returns {boolean}
|
|
2780
|
+
*/
|
|
2781
|
+
polygonsIntersect2d(coords_a, coords_b) {
|
|
2782
|
+
const ptr0 = passArrayF64ToWasm0(coords_a, wasm.__wbindgen_malloc);
|
|
2783
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2784
|
+
const ptr1 = passArrayF64ToWasm0(coords_b, wasm.__wbindgen_malloc);
|
|
2785
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2786
|
+
const ret = wasm.brepkernel_polygonsIntersect2d(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2787
|
+
if (ret[2]) {
|
|
2788
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2789
|
+
}
|
|
2790
|
+
return ret[0] !== 0;
|
|
2791
|
+
}
|
|
2792
|
+
/**
|
|
2793
|
+
* Project a 3D point onto a face surface using Newton iteration.
|
|
2794
|
+
*
|
|
2795
|
+
* Returns `[u, v, px, py, pz, distance]`.
|
|
2796
|
+
* @param {number} face
|
|
2797
|
+
* @param {number} px
|
|
2798
|
+
* @param {number} py
|
|
2799
|
+
* @param {number} pz
|
|
2800
|
+
* @returns {Float64Array}
|
|
2801
|
+
*/
|
|
2802
|
+
projectPointOnSurface(face, px, py, pz) {
|
|
2803
|
+
const ret = wasm.brepkernel_projectPointOnSurface(this.__wbg_ptr, face, px, py, pz);
|
|
2804
|
+
if (ret[3]) {
|
|
2805
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2806
|
+
}
|
|
2807
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2808
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2809
|
+
return v1;
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Recognize geometric features in a solid.
|
|
2813
|
+
*
|
|
2814
|
+
* Returns a JSON string describing the recognized features.
|
|
2815
|
+
* @param {number} solid
|
|
2816
|
+
* @param {number} deflection
|
|
2817
|
+
* @returns {string}
|
|
2818
|
+
*/
|
|
2819
|
+
recognizeFeatures(solid, deflection) {
|
|
2820
|
+
let deferred2_0;
|
|
2821
|
+
let deferred2_1;
|
|
2822
|
+
try {
|
|
2823
|
+
const ret = wasm.brepkernel_recognizeFeatures(this.__wbg_ptr, solid, deflection);
|
|
2824
|
+
var ptr1 = ret[0];
|
|
2825
|
+
var len1 = ret[1];
|
|
2826
|
+
if (ret[3]) {
|
|
2827
|
+
ptr1 = 0; len1 = 0;
|
|
2828
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2829
|
+
}
|
|
2830
|
+
deferred2_0 = ptr1;
|
|
2831
|
+
deferred2_1 = len1;
|
|
2832
|
+
return getStringFromWasm0(ptr1, len1);
|
|
2833
|
+
} finally {
|
|
2834
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Remove degenerate (zero-length) edges from a solid.
|
|
2839
|
+
*
|
|
2840
|
+
* Returns the number of edges removed.
|
|
2841
|
+
* @param {number} solid
|
|
2842
|
+
* @param {number} tolerance
|
|
2843
|
+
* @returns {number}
|
|
2844
|
+
*/
|
|
2845
|
+
removeDegenerateEdges(solid, tolerance) {
|
|
2846
|
+
const ret = wasm.brepkernel_removeDegenerateEdges(this.__wbg_ptr, solid, tolerance);
|
|
2847
|
+
if (ret[2]) {
|
|
2848
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2849
|
+
}
|
|
2850
|
+
return ret[0] >>> 0;
|
|
2851
|
+
}
|
|
2852
|
+
/**
|
|
2853
|
+
* Remove all holes from a face, returning a new face with only the outer wire.
|
|
2854
|
+
* @param {number} face
|
|
2855
|
+
* @returns {number}
|
|
2856
|
+
*/
|
|
2857
|
+
removeHolesFromFace(face) {
|
|
2858
|
+
const ret = wasm.brepkernel_removeHolesFromFace(this.__wbg_ptr, face);
|
|
2859
|
+
if (ret[2]) {
|
|
2860
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2861
|
+
}
|
|
2862
|
+
return ret[0] >>> 0;
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Validate, heal, and re-validate a solid in one pass.
|
|
2866
|
+
*
|
|
2867
|
+
* Returns the number of remaining validation errors after repair.
|
|
2868
|
+
* A return value of 0 means the solid is valid after repair.
|
|
2869
|
+
*
|
|
2870
|
+
* # Errors
|
|
2871
|
+
*
|
|
2872
|
+
* Returns an error if the solid handle is invalid.
|
|
2873
|
+
* @param {number} solid
|
|
2874
|
+
* @returns {number}
|
|
2875
|
+
*/
|
|
2876
|
+
repairSolid(solid) {
|
|
2877
|
+
const ret = wasm.brepkernel_repairSolid(this.__wbg_ptr, solid);
|
|
2878
|
+
if (ret[2]) {
|
|
2879
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2880
|
+
}
|
|
2881
|
+
return ret[0] >>> 0;
|
|
2882
|
+
}
|
|
2883
|
+
/**
|
|
2884
|
+
* Reverse the orientation of a face or edge.
|
|
2885
|
+
*
|
|
2886
|
+
* For faces: creates a new face with negated plane normal.
|
|
2887
|
+
* For edges: creates a new edge with swapped start/end vertices.
|
|
2888
|
+
* Returns the handle of the new reversed shape.
|
|
2889
|
+
*
|
|
2890
|
+
* # Errors
|
|
2891
|
+
*
|
|
2892
|
+
* Returns an error if the handle is neither a valid face nor edge.
|
|
2893
|
+
* @param {number} id
|
|
2894
|
+
* @returns {number}
|
|
2895
|
+
*/
|
|
2896
|
+
reverseShape(id) {
|
|
2897
|
+
const ret = wasm.brepkernel_reverseShape(this.__wbg_ptr, id);
|
|
2898
|
+
if (ret[2]) {
|
|
2899
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2900
|
+
}
|
|
2901
|
+
return ret[0] >>> 0;
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2904
|
+
* Revolve a planar face around an axis to create a solid of revolution.
|
|
2905
|
+
*
|
|
2906
|
+
* The axis is defined by an origin point `(ox, oy, oz)` and a direction
|
|
2907
|
+
* `(dx, dy, dz)`. The angle is in degrees and must be in (0, 360].
|
|
2908
|
+
*
|
|
2909
|
+
* Returns a solid handle (`u32`).
|
|
2910
|
+
*
|
|
2911
|
+
* # Errors
|
|
2912
|
+
*
|
|
2913
|
+
* Returns an error if any input is non-finite, the face handle is
|
|
2914
|
+
* invalid, or the revolve operation fails.
|
|
2915
|
+
* @param {number} face
|
|
2916
|
+
* @param {number} ox
|
|
2917
|
+
* @param {number} oy
|
|
2918
|
+
* @param {number} oz
|
|
2919
|
+
* @param {number} dx
|
|
2920
|
+
* @param {number} dy
|
|
2921
|
+
* @param {number} dz
|
|
2922
|
+
* @param {number} angle_degrees
|
|
2923
|
+
* @returns {number}
|
|
2924
|
+
*/
|
|
2925
|
+
revolve(face, ox, oy, oz, dx, dy, dz, angle_degrees) {
|
|
2926
|
+
const ret = wasm.brepkernel_revolve(this.__wbg_ptr, face, ox, oy, oz, dx, dy, dz, angle_degrees);
|
|
2927
|
+
if (ret[2]) {
|
|
2928
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2929
|
+
}
|
|
2930
|
+
return ret[0] >>> 0;
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* Section a solid with a plane, returning cross-section face handles.
|
|
2934
|
+
*
|
|
2935
|
+
* Returns an array of face handles (`u32[]`).
|
|
2936
|
+
*
|
|
2937
|
+
* # Errors
|
|
2938
|
+
*
|
|
2939
|
+
* Returns an error if the solid handle is invalid or the plane doesn't
|
|
2940
|
+
* intersect the solid.
|
|
2941
|
+
* @param {number} solid
|
|
2942
|
+
* @param {number} px
|
|
2943
|
+
* @param {number} py
|
|
2944
|
+
* @param {number} pz
|
|
2945
|
+
* @param {number} nx
|
|
2946
|
+
* @param {number} ny
|
|
2947
|
+
* @param {number} nz
|
|
2948
|
+
* @returns {Uint32Array}
|
|
2949
|
+
*/
|
|
2950
|
+
section(solid, px, py, pz, nx, ny, nz) {
|
|
2951
|
+
const ret = wasm.brepkernel_section(this.__wbg_ptr, solid, px, py, pz, nx, ny, nz);
|
|
2952
|
+
if (ret[3]) {
|
|
2953
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2954
|
+
}
|
|
2955
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2956
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2957
|
+
return v1;
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Sew loose faces into a connected solid.
|
|
2961
|
+
*
|
|
2962
|
+
* `face_handles` is an array of face handles. Returns a solid handle.
|
|
2963
|
+
*
|
|
2964
|
+
* # Errors
|
|
2965
|
+
*
|
|
2966
|
+
* Returns an error if fewer than 2 faces or sewing fails.
|
|
2967
|
+
* @param {Uint32Array} face_handles
|
|
2968
|
+
* @param {number} tolerance
|
|
2969
|
+
* @returns {number}
|
|
2970
|
+
*/
|
|
2971
|
+
sewFaces(face_handles, tolerance) {
|
|
2972
|
+
const ptr0 = passArray32ToWasm0(face_handles, wasm.__wbindgen_malloc);
|
|
2973
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2974
|
+
const ret = wasm.brepkernel_sewFaces(this.__wbg_ptr, ptr0, len0, tolerance);
|
|
2975
|
+
if (ret[2]) {
|
|
2976
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2977
|
+
}
|
|
2978
|
+
return ret[0] >>> 0;
|
|
2979
|
+
}
|
|
2980
|
+
/**
|
|
2981
|
+
* Get edges shared between two faces.
|
|
2982
|
+
*
|
|
2983
|
+
* Returns an array of edge handles.
|
|
2984
|
+
* @param {number} face_a
|
|
2985
|
+
* @param {number} face_b
|
|
2986
|
+
* @returns {Uint32Array}
|
|
2987
|
+
*/
|
|
2988
|
+
sharedEdges(face_a, face_b) {
|
|
2989
|
+
const ret = wasm.brepkernel_sharedEdges(this.__wbg_ptr, face_a, face_b);
|
|
2990
|
+
if (ret[3]) {
|
|
2991
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2992
|
+
}
|
|
2993
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2994
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2995
|
+
return v1;
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Hollow a solid with uniform wall thickness.
|
|
2999
|
+
*
|
|
3000
|
+
* `open_faces` is an array of face handles to remove (creating openings).
|
|
3001
|
+
* Returns a solid handle (`u32`).
|
|
3002
|
+
*
|
|
3003
|
+
* # Errors
|
|
3004
|
+
*
|
|
3005
|
+
* Returns an error if thickness is non-positive or the solid is invalid.
|
|
3006
|
+
* @param {number} solid
|
|
3007
|
+
* @param {number} thickness
|
|
3008
|
+
* @param {Uint32Array} open_faces
|
|
3009
|
+
* @returns {number}
|
|
3010
|
+
*/
|
|
3011
|
+
shell(solid, thickness, open_faces) {
|
|
3012
|
+
const ptr0 = passArray32ToWasm0(open_faces, wasm.__wbindgen_malloc);
|
|
3013
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3014
|
+
const ret = wasm.brepkernel_shell(this.__wbg_ptr, solid, thickness, ptr0, len0);
|
|
3015
|
+
if (ret[2]) {
|
|
3016
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3017
|
+
}
|
|
3018
|
+
return ret[0] >>> 0;
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Add a constraint to a sketch from a JSON string.
|
|
3022
|
+
*
|
|
3023
|
+
* Formats: `{"type":"coincident","p1":0,"p2":1}`,
|
|
3024
|
+
* `{"type":"distance","p1":0,"p2":1,"value":5.0}`,
|
|
3025
|
+
* `{"type":"fixX","point":0,"value":1.0}`, etc.
|
|
3026
|
+
* @param {number} sketch
|
|
3027
|
+
* @param {string} json
|
|
3028
|
+
*/
|
|
3029
|
+
sketchAddConstraint(sketch, json) {
|
|
3030
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3031
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3032
|
+
const ret = wasm.brepkernel_sketchAddConstraint(this.__wbg_ptr, sketch, ptr0, len0);
|
|
3033
|
+
if (ret[1]) {
|
|
3034
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
/**
|
|
3038
|
+
* Add a point to a sketch. Returns the point index.
|
|
3039
|
+
* @param {number} sketch
|
|
3040
|
+
* @param {number} x
|
|
3041
|
+
* @param {number} y
|
|
3042
|
+
* @param {boolean} fixed
|
|
3043
|
+
* @returns {number}
|
|
3044
|
+
*/
|
|
3045
|
+
sketchAddPoint(sketch, x, y, fixed) {
|
|
3046
|
+
const ret = wasm.brepkernel_sketchAddPoint(this.__wbg_ptr, sketch, x, y, fixed);
|
|
3047
|
+
if (ret[2]) {
|
|
3048
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3049
|
+
}
|
|
3050
|
+
return ret[0] >>> 0;
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Create a new empty sketch. Returns a sketch index.
|
|
3054
|
+
* @returns {number}
|
|
3055
|
+
*/
|
|
3056
|
+
sketchNew() {
|
|
3057
|
+
const ret = wasm.brepkernel_sketchNew(this.__wbg_ptr);
|
|
3058
|
+
return ret >>> 0;
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Solve the sketch constraints.
|
|
3062
|
+
*
|
|
3063
|
+
* Returns a JSON string: `{"converged": bool, "iterations": n, "maxResidual": f, "points": [[x,y], ...]}`.
|
|
3064
|
+
* @param {number} sketch
|
|
3065
|
+
* @param {number} max_iterations
|
|
3066
|
+
* @param {number} tolerance
|
|
3067
|
+
* @returns {string}
|
|
3068
|
+
*/
|
|
3069
|
+
sketchSolve(sketch, max_iterations, tolerance) {
|
|
3070
|
+
let deferred2_0;
|
|
3071
|
+
let deferred2_1;
|
|
3072
|
+
try {
|
|
3073
|
+
const ret = wasm.brepkernel_sketchSolve(this.__wbg_ptr, sketch, max_iterations, tolerance);
|
|
3074
|
+
var ptr1 = ret[0];
|
|
3075
|
+
var len1 = ret[1];
|
|
3076
|
+
if (ret[3]) {
|
|
3077
|
+
ptr1 = 0; len1 = 0;
|
|
3078
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3079
|
+
}
|
|
3080
|
+
deferred2_0 = ptr1;
|
|
3081
|
+
deferred2_1 = len1;
|
|
3082
|
+
return getStringFromWasm0(ptr1, len1);
|
|
3083
|
+
} finally {
|
|
3084
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Create a solid from a shell.
|
|
3089
|
+
*
|
|
3090
|
+
* Returns a solid handle (`u32`).
|
|
3091
|
+
* @param {number} shell
|
|
3092
|
+
* @returns {number}
|
|
3093
|
+
*/
|
|
3094
|
+
solidFromShell(shell) {
|
|
3095
|
+
const ret = wasm.brepkernel_solidFromShell(this.__wbg_ptr, shell);
|
|
3096
|
+
if (ret[2]) {
|
|
3097
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3098
|
+
}
|
|
3099
|
+
return ret[0] >>> 0;
|
|
3100
|
+
}
|
|
3101
|
+
/**
|
|
3102
|
+
* Compute minimum distance between two solids.
|
|
3103
|
+
*
|
|
3104
|
+
* Returns `[distance]`.
|
|
3105
|
+
*
|
|
3106
|
+
* # Errors
|
|
3107
|
+
*
|
|
3108
|
+
* Returns an error if either solid handle is invalid.
|
|
3109
|
+
* @param {number} a
|
|
3110
|
+
* @param {number} b
|
|
3111
|
+
* @returns {number}
|
|
3112
|
+
*/
|
|
3113
|
+
solidToSolidDistance(a, b) {
|
|
3114
|
+
const ret = wasm.brepkernel_solidToSolidDistance(this.__wbg_ptr, a, b);
|
|
3115
|
+
if (ret[2]) {
|
|
3116
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3117
|
+
}
|
|
3118
|
+
return ret[0];
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Split a solid into two halves along a plane.
|
|
3122
|
+
*
|
|
3123
|
+
* Returns `[positive_solid_handle, negative_solid_handle]`.
|
|
3124
|
+
*
|
|
3125
|
+
* # Errors
|
|
3126
|
+
*
|
|
3127
|
+
* Returns an error if the plane doesn't intersect the solid.
|
|
3128
|
+
* @param {number} solid
|
|
3129
|
+
* @param {number} px
|
|
3130
|
+
* @param {number} py
|
|
3131
|
+
* @param {number} pz
|
|
3132
|
+
* @param {number} nx
|
|
3133
|
+
* @param {number} ny
|
|
3134
|
+
* @param {number} nz
|
|
3135
|
+
* @returns {Uint32Array}
|
|
3136
|
+
*/
|
|
3137
|
+
split(solid, px, py, pz, nx, ny, nz) {
|
|
3138
|
+
const ret = wasm.brepkernel_split(this.__wbg_ptr, solid, px, py, pz, nx, ny, nz);
|
|
3139
|
+
if (ret[3]) {
|
|
3140
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3141
|
+
}
|
|
3142
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3143
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3144
|
+
return v1;
|
|
3145
|
+
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Compute the total surface area of a solid.
|
|
3148
|
+
*
|
|
3149
|
+
* # Errors
|
|
3150
|
+
*
|
|
3151
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
3152
|
+
* @param {number} solid
|
|
3153
|
+
* @param {number} deflection
|
|
3154
|
+
* @returns {number}
|
|
3155
|
+
*/
|
|
3156
|
+
surfaceArea(solid, deflection) {
|
|
3157
|
+
const ret = wasm.brepkernel_surfaceArea(this.__wbg_ptr, solid, deflection);
|
|
3158
|
+
if (ret[2]) {
|
|
3159
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3160
|
+
}
|
|
3161
|
+
return ret[0];
|
|
3162
|
+
}
|
|
3163
|
+
/**
|
|
3164
|
+
* Sweep a planar face along a NURBS curve path to create a solid.
|
|
3165
|
+
*
|
|
3166
|
+
* The path is specified as flat arrays for JS interop:
|
|
3167
|
+
* - `path_degree` — polynomial degree of the path curve
|
|
3168
|
+
* - `path_knots` — knot vector
|
|
3169
|
+
* - `path_control_points` — flat `[x,y,z, ...]` control point coordinates
|
|
3170
|
+
* - `path_weights` — per-control-point weights
|
|
3171
|
+
*
|
|
3172
|
+
* Returns a solid handle (`u32`).
|
|
3173
|
+
*
|
|
3174
|
+
* # Errors
|
|
3175
|
+
*
|
|
3176
|
+
* Returns an error if the face handle is invalid, the NURBS arrays have
|
|
3177
|
+
* inconsistent lengths, or the sweep operation fails.
|
|
3178
|
+
* @param {number} face
|
|
3179
|
+
* @param {number} path_degree
|
|
3180
|
+
* @param {Float64Array} path_knots
|
|
3181
|
+
* @param {Float64Array} path_control_points
|
|
3182
|
+
* @param {Float64Array} path_weights
|
|
3183
|
+
* @returns {number}
|
|
3184
|
+
*/
|
|
3185
|
+
sweep(face, path_degree, path_knots, path_control_points, path_weights) {
|
|
3186
|
+
const ptr0 = passArrayF64ToWasm0(path_knots, wasm.__wbindgen_malloc);
|
|
3187
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3188
|
+
const ptr1 = passArrayF64ToWasm0(path_control_points, wasm.__wbindgen_malloc);
|
|
3189
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3190
|
+
const ptr2 = passArrayF64ToWasm0(path_weights, wasm.__wbindgen_malloc);
|
|
3191
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3192
|
+
const ret = wasm.brepkernel_sweep(this.__wbg_ptr, face, path_degree, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3193
|
+
if (ret[2]) {
|
|
3194
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3195
|
+
}
|
|
3196
|
+
return ret[0] >>> 0;
|
|
3197
|
+
}
|
|
3198
|
+
/**
|
|
3199
|
+
* Sweep a face along a path defined by a chain of edges.
|
|
3200
|
+
*
|
|
3201
|
+
* Collects points from the edges, fits an interpolating NURBS curve,
|
|
3202
|
+
* then sweeps the profile along that curve.
|
|
3203
|
+
*
|
|
3204
|
+
* Returns a solid handle (`u32`).
|
|
3205
|
+
*
|
|
3206
|
+
* # Errors
|
|
3207
|
+
*
|
|
3208
|
+
* Returns an error if fewer than 2 edges or the fit fails.
|
|
3209
|
+
* @param {number} face
|
|
3210
|
+
* @param {Uint32Array} edge_handles
|
|
3211
|
+
* @returns {number}
|
|
3212
|
+
*/
|
|
3213
|
+
sweepAlongEdges(face, edge_handles) {
|
|
3214
|
+
const ptr0 = passArray32ToWasm0(edge_handles, wasm.__wbindgen_malloc);
|
|
3215
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3216
|
+
const ret = wasm.brepkernel_sweepAlongEdges(this.__wbg_ptr, face, ptr0, len0);
|
|
3217
|
+
if (ret[2]) {
|
|
3218
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3219
|
+
}
|
|
3220
|
+
return ret[0] >>> 0;
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Sweep a face along a path with smooth NURBS side surfaces.
|
|
3224
|
+
*
|
|
3225
|
+
* Like `sweep()`, but produces a single NURBS surface per edge strip
|
|
3226
|
+
* instead of multiple flat quads, giving smooth geometry that
|
|
3227
|
+
* tessellates to arbitrary quality.
|
|
3228
|
+
*
|
|
3229
|
+
* Returns a solid handle (`u32`).
|
|
3230
|
+
*
|
|
3231
|
+
* # Errors
|
|
3232
|
+
*
|
|
3233
|
+
* Returns an error if the face or path is invalid, or surface fitting fails.
|
|
3234
|
+
* @param {number} face
|
|
3235
|
+
* @param {number} path_degree
|
|
3236
|
+
* @param {Float64Array} path_knots
|
|
3237
|
+
* @param {Float64Array} path_control_points
|
|
3238
|
+
* @param {Float64Array} path_weights
|
|
3239
|
+
* @returns {number}
|
|
3240
|
+
*/
|
|
3241
|
+
sweepSmooth(face, path_degree, path_knots, path_control_points, path_weights) {
|
|
3242
|
+
const ptr0 = passArrayF64ToWasm0(path_knots, wasm.__wbindgen_malloc);
|
|
3243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3244
|
+
const ptr1 = passArrayF64ToWasm0(path_control_points, wasm.__wbindgen_malloc);
|
|
3245
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3246
|
+
const ptr2 = passArrayF64ToWasm0(path_weights, wasm.__wbindgen_malloc);
|
|
3247
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3248
|
+
const ret = wasm.brepkernel_sweepSmooth(this.__wbg_ptr, face, path_degree, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3249
|
+
if (ret[2]) {
|
|
3250
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3251
|
+
}
|
|
3252
|
+
return ret[0] >>> 0;
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* Sweep a face along a NURBS path with advanced options.
|
|
3256
|
+
*
|
|
3257
|
+
* `contact_mode`: "rmf" (default), "fixed", or "constantNormal:x,y,z"
|
|
3258
|
+
* `scale_values`: flat `[t0,s0,t1,s1,...]` pairs for piecewise-linear scale law.
|
|
3259
|
+
* Returns a solid handle.
|
|
3260
|
+
* @param {number} profile
|
|
3261
|
+
* @param {number} path_edge
|
|
3262
|
+
* @param {string} contact_mode
|
|
3263
|
+
* @param {Float64Array} scale_values
|
|
3264
|
+
* @param {number} segments
|
|
3265
|
+
* @returns {number}
|
|
3266
|
+
*/
|
|
3267
|
+
sweepWithOptions(profile, path_edge, contact_mode, scale_values, segments) {
|
|
3268
|
+
const ptr0 = passStringToWasm0(contact_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3269
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3270
|
+
const ptr1 = passArrayF64ToWasm0(scale_values, wasm.__wbindgen_malloc);
|
|
3271
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3272
|
+
const ret = wasm.brepkernel_sweepWithOptions(this.__wbg_ptr, profile, path_edge, ptr0, len0, ptr1, len1, segments);
|
|
3273
|
+
if (ret[2]) {
|
|
3274
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3275
|
+
}
|
|
3276
|
+
return ret[0] >>> 0;
|
|
3277
|
+
}
|
|
3278
|
+
/**
|
|
3279
|
+
* Tessellate an edge curve into polyline segments.
|
|
3280
|
+
*
|
|
3281
|
+
* For line edges, returns just start and end points.
|
|
3282
|
+
* For NURBS edges, samples at `num_points` along the curve.
|
|
3283
|
+
*
|
|
3284
|
+
* Returns flattened `[x, y, z, x, y, z, ...]` array.
|
|
3285
|
+
* @param {number} edge
|
|
3286
|
+
* @param {number} num_points
|
|
3287
|
+
* @returns {Float64Array}
|
|
3288
|
+
*/
|
|
3289
|
+
tessellateEdge(edge, num_points) {
|
|
3290
|
+
const ret = wasm.brepkernel_tessellateEdge(this.__wbg_ptr, edge, num_points);
|
|
3291
|
+
if (ret[3]) {
|
|
3292
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3293
|
+
}
|
|
3294
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3295
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3296
|
+
return v1;
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Tessellate a single face into a triangle mesh.
|
|
3300
|
+
*
|
|
3301
|
+
* # Errors
|
|
3302
|
+
*
|
|
3303
|
+
* Returns an error if the face handle is invalid or tessellation fails.
|
|
3304
|
+
* @param {number} face
|
|
3305
|
+
* @param {number} deflection
|
|
3306
|
+
* @returns {JsMesh}
|
|
3307
|
+
*/
|
|
3308
|
+
tessellateFace(face, deflection) {
|
|
3309
|
+
const ret = wasm.brepkernel_tessellateFace(this.__wbg_ptr, face, deflection);
|
|
3310
|
+
if (ret[2]) {
|
|
3311
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3312
|
+
}
|
|
3313
|
+
return JsMesh.__wrap(ret[0]);
|
|
3314
|
+
}
|
|
3315
|
+
/**
|
|
3316
|
+
* Tessellate all faces of a solid into a single merged triangle mesh.
|
|
3317
|
+
*
|
|
3318
|
+
* Includes both the outer shell and any inner shells (voids).
|
|
3319
|
+
*
|
|
3320
|
+
* # Errors
|
|
3321
|
+
*
|
|
3322
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
3323
|
+
* @param {number} solid
|
|
3324
|
+
* @param {number} deflection
|
|
3325
|
+
* @returns {JsMesh}
|
|
3326
|
+
*/
|
|
3327
|
+
tessellateSolid(solid, deflection) {
|
|
3328
|
+
const ret = wasm.brepkernel_tessellateSolid(this.__wbg_ptr, solid, deflection);
|
|
3329
|
+
if (ret[2]) {
|
|
3330
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3331
|
+
}
|
|
3332
|
+
return JsMesh.__wrap(ret[0]);
|
|
3333
|
+
}
|
|
3334
|
+
/**
|
|
3335
|
+
* Tessellate a solid with per-face triangle grouping.
|
|
3336
|
+
*
|
|
3337
|
+
* Returns a JSON string containing `{ positions, normals, indices, faceOffsets }`.
|
|
3338
|
+
* `faceOffsets` is an array where `faceOffsets[i]` is the start index into
|
|
3339
|
+
* `indices` for face `i`, and the last element is `indices.length`.
|
|
3340
|
+
* @param {number} solid
|
|
3341
|
+
* @param {number} deflection
|
|
3342
|
+
* @returns {any}
|
|
3343
|
+
*/
|
|
3344
|
+
tessellateSolidGrouped(solid, deflection) {
|
|
3345
|
+
const ret = wasm.brepkernel_tessellateSolidGrouped(this.__wbg_ptr, solid, deflection);
|
|
3346
|
+
if (ret[2]) {
|
|
3347
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3348
|
+
}
|
|
3349
|
+
return takeFromExternrefTable0(ret[0]);
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* Tessellate a solid and include per-vertex UV coordinates.
|
|
3353
|
+
*
|
|
3354
|
+
* Returns a JSON string containing `{ positions, normals, indices, uvs }`.
|
|
3355
|
+
* `uvs` is a flat array of `[u0, v0, u1, v1, ...]` values, two per vertex.
|
|
3356
|
+
* For analytic and NURBS surfaces, these are the parametric (u, v) values.
|
|
3357
|
+
* For planar faces, UVs are computed by projection onto the face plane.
|
|
3358
|
+
*
|
|
3359
|
+
* # Errors
|
|
3360
|
+
*
|
|
3361
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
3362
|
+
* @param {number} solid
|
|
3363
|
+
* @param {number} deflection
|
|
3364
|
+
* @returns {any}
|
|
3365
|
+
*/
|
|
3366
|
+
tessellateSolidUV(solid, deflection) {
|
|
3367
|
+
const ret = wasm.brepkernel_tessellateSolidUV(this.__wbg_ptr, solid, deflection);
|
|
3368
|
+
if (ret[2]) {
|
|
3369
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3370
|
+
}
|
|
3371
|
+
return takeFromExternrefTable0(ret[0]);
|
|
3372
|
+
}
|
|
3373
|
+
/**
|
|
3374
|
+
* Thicken a face into a solid by offsetting it by the given distance.
|
|
3375
|
+
*
|
|
3376
|
+
* Creates a solid from a face by extruding it along its normal by
|
|
3377
|
+
* `thickness`. Positive values offset outward, negative inward.
|
|
3378
|
+
*
|
|
3379
|
+
* # Errors
|
|
3380
|
+
*
|
|
3381
|
+
* Returns an error if the face handle is invalid or thickness is zero.
|
|
3382
|
+
* @param {number} face
|
|
3383
|
+
* @param {number} thickness
|
|
3384
|
+
* @returns {number}
|
|
3385
|
+
*/
|
|
3386
|
+
thicken(face, thickness) {
|
|
3387
|
+
const ret = wasm.brepkernel_thicken(this.__wbg_ptr, face, thickness);
|
|
3388
|
+
if (ret[2]) {
|
|
3389
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3390
|
+
}
|
|
3391
|
+
return ret[0] >>> 0;
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Serialize a solid's B-Rep topology to JSON.
|
|
3395
|
+
*
|
|
3396
|
+
* Returns a JSON string containing the solid's complete topology:
|
|
3397
|
+
* vertices, edges (with curve types), faces (with surface types), and
|
|
3398
|
+
* connectivity information.
|
|
3399
|
+
*
|
|
3400
|
+
* # Errors
|
|
3401
|
+
*
|
|
3402
|
+
* Returns an error if the solid handle is invalid.
|
|
3403
|
+
* @param {number} solid
|
|
3404
|
+
* @returns {any}
|
|
3405
|
+
*/
|
|
3406
|
+
toBREP(solid) {
|
|
3407
|
+
const ret = wasm.brepkernel_toBREP(this.__wbg_ptr, solid);
|
|
3408
|
+
if (ret[2]) {
|
|
3409
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3410
|
+
}
|
|
3411
|
+
return takeFromExternrefTable0(ret[0]);
|
|
3412
|
+
}
|
|
3413
|
+
/**
|
|
3414
|
+
* Apply a 4×4 affine transform to a solid (in place).
|
|
3415
|
+
*
|
|
3416
|
+
* The `matrix` must contain exactly 16 values in row-major order.
|
|
3417
|
+
*
|
|
3418
|
+
* # Errors
|
|
3419
|
+
*
|
|
3420
|
+
* Returns an error if the solid handle is invalid, the matrix doesn't
|
|
3421
|
+
* have 16 elements, or the matrix is singular.
|
|
3422
|
+
* @param {number} solid
|
|
3423
|
+
* @param {Float64Array} matrix
|
|
3424
|
+
*/
|
|
3425
|
+
transformSolid(solid, matrix) {
|
|
3426
|
+
const ptr0 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
3427
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3428
|
+
const ret = wasm.brepkernel_transformSolid(this.__wbg_ptr, solid, ptr0, len0);
|
|
3429
|
+
if (ret[1]) {
|
|
3430
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* Apply a 4×4 affine transform to a wire (in place).
|
|
3435
|
+
*
|
|
3436
|
+
* The `matrix` must contain exactly 16 values in row-major order.
|
|
3437
|
+
*
|
|
3438
|
+
* # Errors
|
|
3439
|
+
*
|
|
3440
|
+
* Returns an error if the wire handle is invalid, the matrix doesn't
|
|
3441
|
+
* have 16 elements, or the matrix is singular.
|
|
3442
|
+
* @param {number} wire
|
|
3443
|
+
* @param {Float64Array} matrix
|
|
3444
|
+
*/
|
|
3445
|
+
transformWire(wire, matrix) {
|
|
3446
|
+
const ptr0 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
3447
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3448
|
+
const ret = wasm.brepkernel_transformWire(this.__wbg_ptr, wire, ptr0, len0);
|
|
3449
|
+
if (ret[1]) {
|
|
3450
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* Untrim a NURBS face by fitting a new surface to the trimmed region.
|
|
3455
|
+
*
|
|
3456
|
+
* Returns a new face handle.
|
|
3457
|
+
* @param {number} face
|
|
3458
|
+
* @param {number} samples_per_curve
|
|
3459
|
+
* @param {number} interior_samples
|
|
3460
|
+
* @returns {number}
|
|
3461
|
+
*/
|
|
3462
|
+
untrimFace(face, samples_per_curve, interior_samples) {
|
|
3463
|
+
const ret = wasm.brepkernel_untrimFace(this.__wbg_ptr, face, samples_per_curve, interior_samples);
|
|
3464
|
+
if (ret[2]) {
|
|
3465
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3466
|
+
}
|
|
3467
|
+
return ret[0] >>> 0;
|
|
3468
|
+
}
|
|
3469
|
+
/**
|
|
3470
|
+
* Validate a solid, returning the number of errors found.
|
|
3471
|
+
*
|
|
3472
|
+
* Returns 0 if the solid is valid.
|
|
3473
|
+
*
|
|
3474
|
+
* # Errors
|
|
3475
|
+
*
|
|
3476
|
+
* Returns an error if the solid handle is invalid.
|
|
3477
|
+
* @param {number} solid
|
|
3478
|
+
* @returns {number}
|
|
3479
|
+
*/
|
|
3480
|
+
validateSolid(solid) {
|
|
3481
|
+
const ret = wasm.brepkernel_validateSolid(this.__wbg_ptr, solid);
|
|
3482
|
+
if (ret[2]) {
|
|
3483
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3484
|
+
}
|
|
3485
|
+
return ret[0] >>> 0;
|
|
3486
|
+
}
|
|
3487
|
+
/**
|
|
3488
|
+
* Compute the volume of a solid.
|
|
3489
|
+
*
|
|
3490
|
+
* # Errors
|
|
3491
|
+
*
|
|
3492
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
3493
|
+
* @param {number} solid
|
|
3494
|
+
* @param {number} deflection
|
|
3495
|
+
* @returns {number}
|
|
3496
|
+
*/
|
|
3497
|
+
volume(solid, deflection) {
|
|
3498
|
+
const ret = wasm.brepkernel_volume(this.__wbg_ptr, solid, deflection);
|
|
3499
|
+
if (ret[2]) {
|
|
3500
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3501
|
+
}
|
|
3502
|
+
return ret[0];
|
|
3503
|
+
}
|
|
3504
|
+
/**
|
|
3505
|
+
* Weld shells and faces into a single solid by sewing.
|
|
3506
|
+
*
|
|
3507
|
+
* Accepts an array of face handles from potentially different shells.
|
|
3508
|
+
* Sews all faces together into a single solid.
|
|
3509
|
+
* @param {Uint32Array} face_handles
|
|
3510
|
+
* @param {number} tolerance
|
|
3511
|
+
* @returns {number}
|
|
3512
|
+
*/
|
|
3513
|
+
weldShellsAndFaces(face_handles, tolerance) {
|
|
3514
|
+
const ptr0 = passArray32ToWasm0(face_handles, wasm.__wbindgen_malloc);
|
|
3515
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3516
|
+
const ret = wasm.brepkernel_weldShellsAndFaces(this.__wbg_ptr, ptr0, len0, tolerance);
|
|
3517
|
+
if (ret[2]) {
|
|
3518
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3519
|
+
}
|
|
3520
|
+
return ret[0] >>> 0;
|
|
3521
|
+
}
|
|
3522
|
+
/**
|
|
3523
|
+
* Compute the total arc-length of a wire.
|
|
3524
|
+
* @param {number} wire
|
|
3525
|
+
* @returns {number}
|
|
3526
|
+
*/
|
|
3527
|
+
wireLength(wire) {
|
|
3528
|
+
const ret = wasm.brepkernel_wireLength(this.__wbg_ptr, wire);
|
|
3529
|
+
if (ret[2]) {
|
|
3530
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3531
|
+
}
|
|
3532
|
+
return ret[0];
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
if (Symbol.dispose) BrepKernel.prototype[Symbol.dispose] = BrepKernel.prototype.free;
|
|
3536
|
+
exports.BrepKernel = BrepKernel;
|
|
3537
|
+
|
|
3538
|
+
/**
|
|
3539
|
+
* Edge polylines for wireframe rendering, exposed to JavaScript.
|
|
3540
|
+
*
|
|
3541
|
+
* Positions are flattened to `[x, y, z, x, y, z, ...]` format.
|
|
3542
|
+
* Offsets are float-array indices into `positions` (already multiplied by 3).
|
|
3543
|
+
*/
|
|
3544
|
+
class JsEdgeLines {
|
|
3545
|
+
static __wrap(ptr) {
|
|
3546
|
+
ptr = ptr >>> 0;
|
|
3547
|
+
const obj = Object.create(JsEdgeLines.prototype);
|
|
3548
|
+
obj.__wbg_ptr = ptr;
|
|
3549
|
+
JsEdgeLinesFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3550
|
+
return obj;
|
|
3551
|
+
}
|
|
3552
|
+
__destroy_into_raw() {
|
|
3553
|
+
const ptr = this.__wbg_ptr;
|
|
3554
|
+
this.__wbg_ptr = 0;
|
|
3555
|
+
JsEdgeLinesFinalization.unregister(this);
|
|
3556
|
+
return ptr;
|
|
3557
|
+
}
|
|
3558
|
+
free() {
|
|
3559
|
+
const ptr = this.__destroy_into_raw();
|
|
3560
|
+
wasm.__wbg_jsedgelines_free(ptr, 0);
|
|
3561
|
+
}
|
|
3562
|
+
/**
|
|
3563
|
+
* Number of edges.
|
|
3564
|
+
* @returns {number}
|
|
3565
|
+
*/
|
|
3566
|
+
get edgeCount() {
|
|
3567
|
+
const ret = wasm.jsedgelines_edgeCount(this.__wbg_ptr);
|
|
3568
|
+
return ret >>> 0;
|
|
3569
|
+
}
|
|
3570
|
+
/**
|
|
3571
|
+
* Start index into the flattened positions array for each edge polyline.
|
|
3572
|
+
*
|
|
3573
|
+
* The i-th edge's positions span from `positions[offsets[i]]` to
|
|
3574
|
+
* `positions[offsets[i+1]]` (or to the end for the last edge).
|
|
3575
|
+
* Each offset is already a float-array index (vertex index × 3).
|
|
3576
|
+
* @returns {Uint32Array}
|
|
3577
|
+
*/
|
|
3578
|
+
get offsets() {
|
|
3579
|
+
const ret = wasm.jsedgelines_offsets(this.__wbg_ptr);
|
|
3580
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3581
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3582
|
+
return v1;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Return all data in a single packed buffer for efficient FFI transfer.
|
|
3586
|
+
*
|
|
3587
|
+
* Layout: `[pos_bytes: u32 LE, off_bytes: u32 LE,
|
|
3588
|
+
* positions: f64 LE..., offsets: u32 LE...]`
|
|
3589
|
+
* @returns {Uint8Array}
|
|
3590
|
+
*/
|
|
3591
|
+
packedBuffer() {
|
|
3592
|
+
const ret = wasm.jsedgelines_packedBuffer(this.__wbg_ptr);
|
|
3593
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
3594
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
3595
|
+
return v1;
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* Flattened vertex positions as `[x, y, z, ...]`.
|
|
3599
|
+
* @returns {Float64Array}
|
|
3600
|
+
*/
|
|
3601
|
+
get positions() {
|
|
3602
|
+
const ret = wasm.jsedgelines_positions(this.__wbg_ptr);
|
|
3603
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3604
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3605
|
+
return v1;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
if (Symbol.dispose) JsEdgeLines.prototype[Symbol.dispose] = JsEdgeLines.prototype.free;
|
|
3609
|
+
exports.JsEdgeLines = JsEdgeLines;
|
|
3610
|
+
|
|
3611
|
+
/**
|
|
3612
|
+
* A triangle mesh exposed to JavaScript.
|
|
3613
|
+
*
|
|
3614
|
+
* Positions and normals are flattened to `[x, y, z, x, y, z, ...]` format
|
|
3615
|
+
* for efficient WASM transfer and direct use as GPU vertex buffers.
|
|
3616
|
+
*/
|
|
3617
|
+
class JsMesh {
|
|
3618
|
+
static __wrap(ptr) {
|
|
3619
|
+
ptr = ptr >>> 0;
|
|
3620
|
+
const obj = Object.create(JsMesh.prototype);
|
|
3621
|
+
obj.__wbg_ptr = ptr;
|
|
3622
|
+
JsMeshFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3623
|
+
return obj;
|
|
3624
|
+
}
|
|
3625
|
+
__destroy_into_raw() {
|
|
3626
|
+
const ptr = this.__wbg_ptr;
|
|
3627
|
+
this.__wbg_ptr = 0;
|
|
3628
|
+
JsMeshFinalization.unregister(this);
|
|
3629
|
+
return ptr;
|
|
3630
|
+
}
|
|
3631
|
+
free() {
|
|
3632
|
+
const ptr = this.__destroy_into_raw();
|
|
3633
|
+
wasm.__wbg_jsmesh_free(ptr, 0);
|
|
3634
|
+
}
|
|
3635
|
+
/**
|
|
3636
|
+
* Triangle indices (groups of 3).
|
|
3637
|
+
* @returns {Uint32Array}
|
|
3638
|
+
*/
|
|
3639
|
+
get indices() {
|
|
3640
|
+
const ret = wasm.jsmesh_indices(this.__wbg_ptr);
|
|
3641
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
3642
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
3643
|
+
return v1;
|
|
3644
|
+
}
|
|
3645
|
+
/**
|
|
3646
|
+
* Flattened per-vertex normals as `[nx, ny, nz, ...]`.
|
|
3647
|
+
* @returns {Float64Array}
|
|
3648
|
+
*/
|
|
3649
|
+
get normals() {
|
|
3650
|
+
const ret = wasm.jsmesh_normals(this.__wbg_ptr);
|
|
3651
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3652
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3653
|
+
return v1;
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* Return all mesh data in a single packed buffer for efficient FFI transfer.
|
|
3657
|
+
*
|
|
3658
|
+
* Layout: `[pos_bytes: u32 LE, norm_bytes: u32 LE, idx_bytes: u32 LE,
|
|
3659
|
+
* positions: f64 LE..., normals: f64 LE..., indices: u32 LE...]`
|
|
3660
|
+
*
|
|
3661
|
+
* This avoids three separate `.clone()` + FFI copies that the individual
|
|
3662
|
+
* getters (`positions`, `normals`, `indices`) would incur.
|
|
3663
|
+
* @returns {Uint8Array}
|
|
3664
|
+
*/
|
|
3665
|
+
packedBuffer() {
|
|
3666
|
+
const ret = wasm.jsmesh_packedBuffer(this.__wbg_ptr);
|
|
3667
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
3668
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
3669
|
+
return v1;
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Flattened vertex positions as `[x, y, z, ...]`.
|
|
3673
|
+
* @returns {Float64Array}
|
|
3674
|
+
*/
|
|
3675
|
+
get positions() {
|
|
3676
|
+
const ret = wasm.jsmesh_positions(this.__wbg_ptr);
|
|
3677
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3678
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3679
|
+
return v1;
|
|
3680
|
+
}
|
|
3681
|
+
/**
|
|
3682
|
+
* Number of triangles in the mesh.
|
|
3683
|
+
* @returns {number}
|
|
3684
|
+
*/
|
|
3685
|
+
get triangleCount() {
|
|
3686
|
+
const ret = wasm.jsmesh_triangleCount(this.__wbg_ptr);
|
|
3687
|
+
return ret >>> 0;
|
|
3688
|
+
}
|
|
3689
|
+
/**
|
|
3690
|
+
* Number of vertices in the mesh.
|
|
3691
|
+
* @returns {number}
|
|
3692
|
+
*/
|
|
3693
|
+
get vertexCount() {
|
|
3694
|
+
const ret = wasm.jsmesh_vertexCount(this.__wbg_ptr);
|
|
3695
|
+
return ret >>> 0;
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
if (Symbol.dispose) JsMesh.prototype[Symbol.dispose] = JsMesh.prototype.free;
|
|
3699
|
+
exports.JsMesh = JsMesh;
|
|
3700
|
+
|
|
3701
|
+
/**
|
|
3702
|
+
* A 3D point exposed to JavaScript.
|
|
3703
|
+
*/
|
|
3704
|
+
class JsPoint3 {
|
|
3705
|
+
__destroy_into_raw() {
|
|
3706
|
+
const ptr = this.__wbg_ptr;
|
|
3707
|
+
this.__wbg_ptr = 0;
|
|
3708
|
+
JsPoint3Finalization.unregister(this);
|
|
3709
|
+
return ptr;
|
|
3710
|
+
}
|
|
3711
|
+
free() {
|
|
3712
|
+
const ptr = this.__destroy_into_raw();
|
|
3713
|
+
wasm.__wbg_jspoint3_free(ptr, 0);
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* X coordinate.
|
|
3717
|
+
* @returns {number}
|
|
3718
|
+
*/
|
|
3719
|
+
get x() {
|
|
3720
|
+
const ret = wasm.__wbg_get_jspoint3_x(this.__wbg_ptr);
|
|
3721
|
+
return ret;
|
|
3722
|
+
}
|
|
3723
|
+
/**
|
|
3724
|
+
* Y coordinate.
|
|
3725
|
+
* @returns {number}
|
|
3726
|
+
*/
|
|
3727
|
+
get y() {
|
|
3728
|
+
const ret = wasm.__wbg_get_jspoint3_y(this.__wbg_ptr);
|
|
3729
|
+
return ret;
|
|
3730
|
+
}
|
|
3731
|
+
/**
|
|
3732
|
+
* Z coordinate.
|
|
3733
|
+
* @returns {number}
|
|
3734
|
+
*/
|
|
3735
|
+
get z() {
|
|
3736
|
+
const ret = wasm.__wbg_get_jspoint3_z(this.__wbg_ptr);
|
|
3737
|
+
return ret;
|
|
3738
|
+
}
|
|
3739
|
+
/**
|
|
3740
|
+
* Create a new 3D point.
|
|
3741
|
+
* @param {number} x
|
|
3742
|
+
* @param {number} y
|
|
3743
|
+
* @param {number} z
|
|
3744
|
+
*/
|
|
3745
|
+
constructor(x, y, z) {
|
|
3746
|
+
const ret = wasm.jspoint3_new(x, y, z);
|
|
3747
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3748
|
+
JsPoint3Finalization.register(this, this.__wbg_ptr, this);
|
|
3749
|
+
return this;
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
* X coordinate.
|
|
3753
|
+
* @param {number} arg0
|
|
3754
|
+
*/
|
|
3755
|
+
set x(arg0) {
|
|
3756
|
+
wasm.__wbg_set_jspoint3_x(this.__wbg_ptr, arg0);
|
|
3757
|
+
}
|
|
3758
|
+
/**
|
|
3759
|
+
* Y coordinate.
|
|
3760
|
+
* @param {number} arg0
|
|
3761
|
+
*/
|
|
3762
|
+
set y(arg0) {
|
|
3763
|
+
wasm.__wbg_set_jspoint3_y(this.__wbg_ptr, arg0);
|
|
3764
|
+
}
|
|
3765
|
+
/**
|
|
3766
|
+
* Z coordinate.
|
|
3767
|
+
* @param {number} arg0
|
|
3768
|
+
*/
|
|
3769
|
+
set z(arg0) {
|
|
3770
|
+
wasm.__wbg_set_jspoint3_z(this.__wbg_ptr, arg0);
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
if (Symbol.dispose) JsPoint3.prototype[Symbol.dispose] = JsPoint3.prototype.free;
|
|
3774
|
+
exports.JsPoint3 = JsPoint3;
|
|
3775
|
+
|
|
3776
|
+
/**
|
|
3777
|
+
* A 3D vector exposed to JavaScript.
|
|
3778
|
+
*/
|
|
3779
|
+
class JsVec3 {
|
|
3780
|
+
__destroy_into_raw() {
|
|
3781
|
+
const ptr = this.__wbg_ptr;
|
|
3782
|
+
this.__wbg_ptr = 0;
|
|
3783
|
+
JsVec3Finalization.unregister(this);
|
|
3784
|
+
return ptr;
|
|
3785
|
+
}
|
|
3786
|
+
free() {
|
|
3787
|
+
const ptr = this.__destroy_into_raw();
|
|
3788
|
+
wasm.__wbg_jsvec3_free(ptr, 0);
|
|
3789
|
+
}
|
|
3790
|
+
/**
|
|
3791
|
+
* X component.
|
|
3792
|
+
* @returns {number}
|
|
3793
|
+
*/
|
|
3794
|
+
get x() {
|
|
3795
|
+
const ret = wasm.__wbg_get_jsvec3_x(this.__wbg_ptr);
|
|
3796
|
+
return ret;
|
|
3797
|
+
}
|
|
3798
|
+
/**
|
|
3799
|
+
* Y component.
|
|
3800
|
+
* @returns {number}
|
|
3801
|
+
*/
|
|
3802
|
+
get y() {
|
|
3803
|
+
const ret = wasm.__wbg_get_jsvec3_y(this.__wbg_ptr);
|
|
3804
|
+
return ret;
|
|
3805
|
+
}
|
|
3806
|
+
/**
|
|
3807
|
+
* Z component.
|
|
3808
|
+
* @returns {number}
|
|
3809
|
+
*/
|
|
3810
|
+
get z() {
|
|
3811
|
+
const ret = wasm.__wbg_get_jsvec3_z(this.__wbg_ptr);
|
|
3812
|
+
return ret;
|
|
3813
|
+
}
|
|
3814
|
+
/**
|
|
3815
|
+
* Compute the length of this vector.
|
|
3816
|
+
* @returns {number}
|
|
3817
|
+
*/
|
|
3818
|
+
length() {
|
|
3819
|
+
const ret = wasm.jsvec3_length(this.__wbg_ptr);
|
|
3820
|
+
return ret;
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* Create a new 3D vector.
|
|
3824
|
+
* @param {number} x
|
|
3825
|
+
* @param {number} y
|
|
3826
|
+
* @param {number} z
|
|
3827
|
+
*/
|
|
3828
|
+
constructor(x, y, z) {
|
|
3829
|
+
const ret = wasm.jsvec3_new(x, y, z);
|
|
3830
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3831
|
+
JsVec3Finalization.register(this, this.__wbg_ptr, this);
|
|
3832
|
+
return this;
|
|
3833
|
+
}
|
|
3834
|
+
/**
|
|
3835
|
+
* X component.
|
|
3836
|
+
* @param {number} arg0
|
|
3837
|
+
*/
|
|
3838
|
+
set x(arg0) {
|
|
3839
|
+
wasm.__wbg_set_jsvec3_x(this.__wbg_ptr, arg0);
|
|
3840
|
+
}
|
|
3841
|
+
/**
|
|
3842
|
+
* Y component.
|
|
3843
|
+
* @param {number} arg0
|
|
3844
|
+
*/
|
|
3845
|
+
set y(arg0) {
|
|
3846
|
+
wasm.__wbg_set_jsvec3_y(this.__wbg_ptr, arg0);
|
|
3847
|
+
}
|
|
3848
|
+
/**
|
|
3849
|
+
* Z component.
|
|
3850
|
+
* @param {number} arg0
|
|
3851
|
+
*/
|
|
3852
|
+
set z(arg0) {
|
|
3853
|
+
wasm.__wbg_set_jsvec3_z(this.__wbg_ptr, arg0);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
if (Symbol.dispose) JsVec3.prototype[Symbol.dispose] = JsVec3.prototype.free;
|
|
3857
|
+
exports.JsVec3 = JsVec3;
|
|
3858
|
+
|
|
3859
|
+
function __wbg_get_imports() {
|
|
3860
|
+
const import0 = {
|
|
3861
|
+
__proto__: null,
|
|
3862
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
3863
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
3864
|
+
return ret;
|
|
3865
|
+
},
|
|
3866
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
3867
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
3868
|
+
},
|
|
3869
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
3870
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3871
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
3872
|
+
return ret;
|
|
3873
|
+
},
|
|
3874
|
+
__wbindgen_init_externref_table: function() {
|
|
3875
|
+
const table = wasm.__wbindgen_externrefs;
|
|
3876
|
+
const offset = table.grow(4);
|
|
3877
|
+
table.set(0, undefined);
|
|
3878
|
+
table.set(offset + 0, undefined);
|
|
3879
|
+
table.set(offset + 1, null);
|
|
3880
|
+
table.set(offset + 2, true);
|
|
3881
|
+
table.set(offset + 3, false);
|
|
3882
|
+
},
|
|
3883
|
+
};
|
|
3884
|
+
return {
|
|
3885
|
+
__proto__: null,
|
|
3886
|
+
"./brepkit_wasm_bg.js": import0,
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
const BrepKernelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3891
|
+
? { register: () => {}, unregister: () => {} }
|
|
3892
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_brepkernel_free(ptr >>> 0, 1));
|
|
3893
|
+
const JsEdgeLinesFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3894
|
+
? { register: () => {}, unregister: () => {} }
|
|
3895
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsedgelines_free(ptr >>> 0, 1));
|
|
3896
|
+
const JsMeshFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3897
|
+
? { register: () => {}, unregister: () => {} }
|
|
3898
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsmesh_free(ptr >>> 0, 1));
|
|
3899
|
+
const JsPoint3Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
3900
|
+
? { register: () => {}, unregister: () => {} }
|
|
3901
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jspoint3_free(ptr >>> 0, 1));
|
|
3902
|
+
const JsVec3Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
3903
|
+
? { register: () => {}, unregister: () => {} }
|
|
3904
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsvec3_free(ptr >>> 0, 1));
|
|
3905
|
+
|
|
3906
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
3907
|
+
ptr = ptr >>> 0;
|
|
3908
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3911
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
3912
|
+
ptr = ptr >>> 0;
|
|
3913
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
3917
|
+
ptr = ptr >>> 0;
|
|
3918
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
3922
|
+
function getFloat64ArrayMemory0() {
|
|
3923
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
3924
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
3925
|
+
}
|
|
3926
|
+
return cachedFloat64ArrayMemory0;
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
function getStringFromWasm0(ptr, len) {
|
|
3930
|
+
ptr = ptr >>> 0;
|
|
3931
|
+
return decodeText(ptr, len);
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
let cachedUint32ArrayMemory0 = null;
|
|
3935
|
+
function getUint32ArrayMemory0() {
|
|
3936
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
3937
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
3938
|
+
}
|
|
3939
|
+
return cachedUint32ArrayMemory0;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
let cachedUint8ArrayMemory0 = null;
|
|
3943
|
+
function getUint8ArrayMemory0() {
|
|
3944
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
3945
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
3946
|
+
}
|
|
3947
|
+
return cachedUint8ArrayMemory0;
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
3951
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
3952
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
3953
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3954
|
+
return ptr;
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
3958
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
3959
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
3960
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3961
|
+
return ptr;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
3965
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
3966
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
3967
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3968
|
+
return ptr;
|
|
3969
|
+
}
|
|
3970
|
+
|
|
3971
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
3972
|
+
if (realloc === undefined) {
|
|
3973
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
3974
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
3975
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
3976
|
+
WASM_VECTOR_LEN = buf.length;
|
|
3977
|
+
return ptr;
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
let len = arg.length;
|
|
3981
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
3982
|
+
|
|
3983
|
+
const mem = getUint8ArrayMemory0();
|
|
3984
|
+
|
|
3985
|
+
let offset = 0;
|
|
3986
|
+
|
|
3987
|
+
for (; offset < len; offset++) {
|
|
3988
|
+
const code = arg.charCodeAt(offset);
|
|
3989
|
+
if (code > 0x7F) break;
|
|
3990
|
+
mem[ptr + offset] = code;
|
|
3991
|
+
}
|
|
3992
|
+
if (offset !== len) {
|
|
3993
|
+
if (offset !== 0) {
|
|
3994
|
+
arg = arg.slice(offset);
|
|
3995
|
+
}
|
|
3996
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
3997
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
3998
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
3999
|
+
|
|
4000
|
+
offset += ret.written;
|
|
4001
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
WASM_VECTOR_LEN = offset;
|
|
4005
|
+
return ptr;
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
|
+
function takeFromExternrefTable0(idx) {
|
|
4009
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
4010
|
+
wasm.__externref_table_dealloc(idx);
|
|
4011
|
+
return value;
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
4015
|
+
cachedTextDecoder.decode();
|
|
4016
|
+
function decodeText(ptr, len) {
|
|
4017
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
const cachedTextEncoder = new TextEncoder();
|
|
4021
|
+
|
|
4022
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
4023
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
4024
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
4025
|
+
view.set(buf);
|
|
4026
|
+
return {
|
|
4027
|
+
read: arg.length,
|
|
4028
|
+
written: buf.length
|
|
4029
|
+
};
|
|
4030
|
+
};
|
|
4031
|
+
}
|
|
4032
|
+
|
|
4033
|
+
let WASM_VECTOR_LEN = 0;
|
|
4034
|
+
|
|
4035
|
+
const wasmPath = `${__dirname}/brepkit_wasm_bg.wasm`;
|
|
4036
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
4037
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
4038
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
4039
|
+
wasm.__wbindgen_start();
|