brepkit-wasm 0.1.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 +1210 -0
- package/brepkit_wasm.js +3129 -0
- package/brepkit_wasm_bg.wasm +0 -0
- package/package.json +17 -0
|
@@ -0,0 +1,1210 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The B-Rep modeling kernel.
|
|
6
|
+
*
|
|
7
|
+
* Owns all topological state. JavaScript holds this reference and
|
|
8
|
+
* invokes methods to create, transform, and query geometry.
|
|
9
|
+
*/
|
|
10
|
+
export class BrepKernel {
|
|
11
|
+
free(): void;
|
|
12
|
+
[Symbol.dispose](): void;
|
|
13
|
+
/**
|
|
14
|
+
* Add hole wires to an existing face, creating a new face with the same
|
|
15
|
+
* surface but additional inner wires.
|
|
16
|
+
*
|
|
17
|
+
* Returns a new face handle (`u32`).
|
|
18
|
+
*/
|
|
19
|
+
addHolesToFace(face: number, hole_wire_handles: Uint32Array): number;
|
|
20
|
+
/**
|
|
21
|
+
* Get faces adjacent to a given face within a solid.
|
|
22
|
+
*
|
|
23
|
+
* Returns an array of face handles.
|
|
24
|
+
*/
|
|
25
|
+
adjacentFaces(solid: number, face: number): Uint32Array;
|
|
26
|
+
/**
|
|
27
|
+
* Approximate a curve through points (least-squares).
|
|
28
|
+
*
|
|
29
|
+
* Returns an edge handle.
|
|
30
|
+
*/
|
|
31
|
+
approximateCurve(coords: Float64Array, degree: number, num_control_points: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Approximate a curve through points using LSPIA (progressive iteration).
|
|
34
|
+
*
|
|
35
|
+
* Returns an edge handle.
|
|
36
|
+
*/
|
|
37
|
+
approximateCurveLspia(coords: Float64Array, degree: number, num_control_points: number, tolerance: number, max_iterations: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Approximate a grid of points into a NURBS surface using LSPIA.
|
|
40
|
+
*
|
|
41
|
+
* Returns a face handle.
|
|
42
|
+
*/
|
|
43
|
+
approximateSurfaceLspia(coords: Float64Array, rows: number, cols: number, degree_u: number, degree_v: number, num_cps_u: number, num_cps_v: number, tolerance: number, max_iterations: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Add a child component to a parent in an assembly.
|
|
46
|
+
*
|
|
47
|
+
* Returns the component ID.
|
|
48
|
+
*/
|
|
49
|
+
assemblyAddChild(assembly: number, parent: number, name: string, solid: number, matrix: Float64Array): number;
|
|
50
|
+
/**
|
|
51
|
+
* Add a root component to an assembly.
|
|
52
|
+
*
|
|
53
|
+
* Returns the component ID.
|
|
54
|
+
*/
|
|
55
|
+
assemblyAddRoot(assembly: number, name: string, solid: number, matrix: Float64Array): number;
|
|
56
|
+
/**
|
|
57
|
+
* Get the bill of materials for an assembly.
|
|
58
|
+
*
|
|
59
|
+
* Returns a JSON string: `[{"name": "...", "solidIndex": n, "instanceCount": n}, ...]`.
|
|
60
|
+
*/
|
|
61
|
+
assemblyBom(assembly: number): string;
|
|
62
|
+
/**
|
|
63
|
+
* Flatten an assembly into `[(solid, matrix), ...]`.
|
|
64
|
+
*
|
|
65
|
+
* Returns a JSON string: `[{"solid": u32, "matrix": [16 floats]}, ...]`.
|
|
66
|
+
*/
|
|
67
|
+
assemblyFlatten(assembly: number): string;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new empty assembly. Returns an assembly index.
|
|
70
|
+
*/
|
|
71
|
+
assemblyNew(name: string): number;
|
|
72
|
+
/**
|
|
73
|
+
* Compute the axis-aligned bounding box of a solid.
|
|
74
|
+
*
|
|
75
|
+
* Returns `[min_x, min_y, min_z, max_x, max_y, max_z]`.
|
|
76
|
+
*
|
|
77
|
+
* # Errors
|
|
78
|
+
*
|
|
79
|
+
* Returns an error if the solid handle is invalid or has no vertices.
|
|
80
|
+
*/
|
|
81
|
+
boundingBox(solid: number): Float64Array;
|
|
82
|
+
/**
|
|
83
|
+
* Compute the center of mass of a solid (uniform density).
|
|
84
|
+
*
|
|
85
|
+
* Returns `[x, y, z]`.
|
|
86
|
+
*
|
|
87
|
+
* # Errors
|
|
88
|
+
*
|
|
89
|
+
* Returns an error if the solid has zero volume or tessellation fails.
|
|
90
|
+
*/
|
|
91
|
+
centerOfMass(solid: number, deflection: number): Float64Array;
|
|
92
|
+
/**
|
|
93
|
+
* Chamfer edges of a solid.
|
|
94
|
+
*
|
|
95
|
+
* `edge_handles` is an array of edge handles. Returns a solid handle.
|
|
96
|
+
*
|
|
97
|
+
* # Errors
|
|
98
|
+
*
|
|
99
|
+
* Returns an error if distance is non-positive or edges are invalid.
|
|
100
|
+
*/
|
|
101
|
+
chamfer(solid: number, edge_handles: Uint32Array, distance: number): number;
|
|
102
|
+
/**
|
|
103
|
+
* Create a circular pattern of a solid around an axis.
|
|
104
|
+
*
|
|
105
|
+
* Returns a compound handle.
|
|
106
|
+
*/
|
|
107
|
+
circularPattern(solid: number, ax: number, ay: number, az: number, count: number): number;
|
|
108
|
+
/**
|
|
109
|
+
* Classify a point relative to a solid: inside, outside, or on boundary.
|
|
110
|
+
*
|
|
111
|
+
* Returns `"inside"`, `"outside"`, or `"boundary"`.
|
|
112
|
+
*
|
|
113
|
+
* # Errors
|
|
114
|
+
*
|
|
115
|
+
* Returns an error if the solid handle is invalid.
|
|
116
|
+
*/
|
|
117
|
+
classifyPoint(solid: number, x: number, y: number, z: number, tolerance: number): string;
|
|
118
|
+
/**
|
|
119
|
+
* Classify a point using robust dual-method (winding + ray casting).
|
|
120
|
+
*
|
|
121
|
+
* Returns "inside", "outside", or "boundary".
|
|
122
|
+
*/
|
|
123
|
+
classifyPointRobust(solid: number, x: number, y: number, z: number, tolerance: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Classify a point relative to a solid using generalized winding numbers.
|
|
126
|
+
*
|
|
127
|
+
* Returns "inside", "outside", or "boundary".
|
|
128
|
+
*/
|
|
129
|
+
classifyPointWinding(solid: number, x: number, y: number, z: number, tolerance: number): string;
|
|
130
|
+
/**
|
|
131
|
+
* Build a convex hull solid from a point cloud.
|
|
132
|
+
*
|
|
133
|
+
* Uses a simple Quickhull-inspired algorithm for 3D point sets.
|
|
134
|
+
*
|
|
135
|
+
* Returns a solid handle (`u32`).
|
|
136
|
+
*
|
|
137
|
+
* # Errors
|
|
138
|
+
*
|
|
139
|
+
* Returns an error if fewer than 4 points are provided.
|
|
140
|
+
*/
|
|
141
|
+
convexHull(coords: Float64Array): number;
|
|
142
|
+
/**
|
|
143
|
+
* Copy a solid and apply a 4×4 row-major affine transform in one pass.
|
|
144
|
+
*
|
|
145
|
+
* Equivalent to `copySolid` + `transformSolid` but performs both in a
|
|
146
|
+
* single topology traversal, avoiding redundant NURBS clones.
|
|
147
|
+
*
|
|
148
|
+
* # Errors
|
|
149
|
+
*
|
|
150
|
+
* Returns an error if the solid handle is invalid, the matrix doesn't
|
|
151
|
+
* have 16 elements, or the matrix is singular.
|
|
152
|
+
*/
|
|
153
|
+
copyAndTransformSolid(solid: number, matrix: Float64Array): number;
|
|
154
|
+
/**
|
|
155
|
+
* Deep copy a solid, returning a new independent solid handle.
|
|
156
|
+
*
|
|
157
|
+
* # Errors
|
|
158
|
+
*
|
|
159
|
+
* Returns an error if the solid handle is invalid.
|
|
160
|
+
*/
|
|
161
|
+
copySolid(solid: number): number;
|
|
162
|
+
/**
|
|
163
|
+
* Elevate the degree of an edge's NURBS curve.
|
|
164
|
+
*
|
|
165
|
+
* Returns a new edge handle.
|
|
166
|
+
*/
|
|
167
|
+
curveDegreeElevate(edge: number, elevate_by: number): number;
|
|
168
|
+
/**
|
|
169
|
+
* Insert a knot into an edge's NURBS curve.
|
|
170
|
+
*
|
|
171
|
+
* Returns a new edge handle with the refined curve.
|
|
172
|
+
*/
|
|
173
|
+
curveKnotInsert(edge: number, knot: number, times: number): number;
|
|
174
|
+
/**
|
|
175
|
+
* Remove a knot from an edge's NURBS curve.
|
|
176
|
+
*
|
|
177
|
+
* Returns a new edge handle with the simplified curve.
|
|
178
|
+
*/
|
|
179
|
+
curveKnotRemove(edge: number, knot: number, tolerance: number): number;
|
|
180
|
+
/**
|
|
181
|
+
* Split an edge's NURBS curve at a parameter value.
|
|
182
|
+
*
|
|
183
|
+
* Returns two edge handles as `[u32; 2]`.
|
|
184
|
+
*/
|
|
185
|
+
curveSplit(edge: number, u: number): Uint32Array;
|
|
186
|
+
/**
|
|
187
|
+
* Cut (subtract) solid `b` from solid `a`.
|
|
188
|
+
*
|
|
189
|
+
* Returns a new solid handle (`u32`).
|
|
190
|
+
*
|
|
191
|
+
* # Errors
|
|
192
|
+
*
|
|
193
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
194
|
+
* produces an empty or non-manifold result.
|
|
195
|
+
*/
|
|
196
|
+
cut(a: number, b: number): number;
|
|
197
|
+
/**
|
|
198
|
+
* Remove specified faces from a solid (defeaturing).
|
|
199
|
+
*
|
|
200
|
+
* `face_handles` is an array of face handles to remove.
|
|
201
|
+
* Returns a new solid handle.
|
|
202
|
+
*/
|
|
203
|
+
defeature(solid: number, face_handles: Uint32Array): number;
|
|
204
|
+
/**
|
|
205
|
+
* Detect small features (faces below an area threshold).
|
|
206
|
+
*
|
|
207
|
+
* Returns an array of face handles.
|
|
208
|
+
*/
|
|
209
|
+
detectSmallFeatures(solid: number, area_threshold: number, deflection: number): Uint32Array;
|
|
210
|
+
/**
|
|
211
|
+
* Apply draft angle to faces of a solid.
|
|
212
|
+
*
|
|
213
|
+
* `face_handles` is an array of face handles to draft.
|
|
214
|
+
* Returns a solid handle.
|
|
215
|
+
*
|
|
216
|
+
* # Errors
|
|
217
|
+
*
|
|
218
|
+
* Returns an error if angle is zero or faces are invalid.
|
|
219
|
+
*/
|
|
220
|
+
draft(solid: number, face_handles: Uint32Array, pull_x: number, pull_y: number, pull_z: number, neutral_x: number, neutral_y: number, neutral_z: number, angle_degrees: number): number;
|
|
221
|
+
/**
|
|
222
|
+
* Compute the length of an edge.
|
|
223
|
+
*
|
|
224
|
+
* # Errors
|
|
225
|
+
*
|
|
226
|
+
* Returns an error if the edge handle is invalid.
|
|
227
|
+
*/
|
|
228
|
+
edgeLength(edge: number): number;
|
|
229
|
+
/**
|
|
230
|
+
* Get the edge-to-face adjacency map for a solid.
|
|
231
|
+
*
|
|
232
|
+
* Returns a JSON string: `{"edgeId": [faceId, ...], ...}`.
|
|
233
|
+
*/
|
|
234
|
+
edgeToFaceMap(solid: number): string;
|
|
235
|
+
/**
|
|
236
|
+
* Evaluate a point on an edge curve at parameter `t`.
|
|
237
|
+
*
|
|
238
|
+
* Returns `[x, y, z]`.
|
|
239
|
+
*/
|
|
240
|
+
evaluateEdgeCurve(edge: number, t: number): Float64Array;
|
|
241
|
+
/**
|
|
242
|
+
* Evaluate a point and tangent on an edge curve at parameter `t`.
|
|
243
|
+
*
|
|
244
|
+
* Returns `[px, py, pz, tx, ty, tz]`.
|
|
245
|
+
*/
|
|
246
|
+
evaluateEdgeCurveD1(edge: number, t: number): Float64Array;
|
|
247
|
+
/**
|
|
248
|
+
* Evaluate a point on a face surface at (u, v).
|
|
249
|
+
*
|
|
250
|
+
* Returns `[x, y, z]`.
|
|
251
|
+
*/
|
|
252
|
+
evaluateSurface(face: number, u: number, v: number): Float64Array;
|
|
253
|
+
/**
|
|
254
|
+
* Evaluate a surface normal at (u, v) on a face.
|
|
255
|
+
*
|
|
256
|
+
* Returns `[nx, ny, nz]`.
|
|
257
|
+
*/
|
|
258
|
+
evaluateSurfaceNormal(face: number, u: number, v: number): Float64Array;
|
|
259
|
+
/**
|
|
260
|
+
* Execute a batch of operations, crossing the JS/WASM boundary once.
|
|
261
|
+
*
|
|
262
|
+
* Accepts a JSON string containing an array of operation objects:
|
|
263
|
+
* ```json
|
|
264
|
+
* [
|
|
265
|
+
* {"op": "makeBox", "args": {"width": 2.0, "height": 2.0, "depth": 2.0}},
|
|
266
|
+
* {"op": "fuse", "args": {"solidA": 0, "solidB": 1}},
|
|
267
|
+
* {"op": "volume", "args": {"solid": 2, "deflection": 0.1}}
|
|
268
|
+
* ]
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* Returns a JSON string with an array of results:
|
|
272
|
+
* ```json
|
|
273
|
+
* [
|
|
274
|
+
* {"ok": 0},
|
|
275
|
+
* {"ok": 2},
|
|
276
|
+
* {"error": "invalid solid id"}
|
|
277
|
+
* ]
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* Operations are executed sequentially; an error in one does not
|
|
281
|
+
* prevent execution of subsequent operations.
|
|
282
|
+
*/
|
|
283
|
+
executeBatch(json: string): string;
|
|
284
|
+
/**
|
|
285
|
+
* Export a solid to 3MF format (ZIP archive as bytes).
|
|
286
|
+
*
|
|
287
|
+
* Returns a `Uint8Array` in JavaScript containing the `.3mf` file.
|
|
288
|
+
*
|
|
289
|
+
* # Errors
|
|
290
|
+
*
|
|
291
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
292
|
+
*/
|
|
293
|
+
export3mf(solid: number, deflection: number): Uint8Array;
|
|
294
|
+
/**
|
|
295
|
+
* Export a solid to glTF binary (.glb) format.
|
|
296
|
+
*
|
|
297
|
+
* # Errors
|
|
298
|
+
*
|
|
299
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
300
|
+
*/
|
|
301
|
+
exportGlb(solid: number, deflection: number): Uint8Array;
|
|
302
|
+
/**
|
|
303
|
+
* Export a solid to IGES format.
|
|
304
|
+
*
|
|
305
|
+
* Returns the IGES file as a UTF-8 encoded byte vector.
|
|
306
|
+
*
|
|
307
|
+
* # Errors
|
|
308
|
+
*
|
|
309
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
310
|
+
*/
|
|
311
|
+
exportIges(solid: number): Uint8Array;
|
|
312
|
+
/**
|
|
313
|
+
* Export a solid to OBJ format (UTF-8 string as bytes).
|
|
314
|
+
*
|
|
315
|
+
* # Errors
|
|
316
|
+
*
|
|
317
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
318
|
+
*/
|
|
319
|
+
exportObj(solid: number, deflection: number): Uint8Array;
|
|
320
|
+
/**
|
|
321
|
+
* Export a solid to PLY format (binary little-endian).
|
|
322
|
+
*
|
|
323
|
+
* # Errors
|
|
324
|
+
*
|
|
325
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
326
|
+
*/
|
|
327
|
+
exportPly(solid: number, deflection: number): Uint8Array;
|
|
328
|
+
/**
|
|
329
|
+
* Export a solid to STEP AP203 format.
|
|
330
|
+
*
|
|
331
|
+
* Returns the STEP file as a UTF-8 encoded byte vector.
|
|
332
|
+
*
|
|
333
|
+
* # Errors
|
|
334
|
+
*
|
|
335
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
336
|
+
*/
|
|
337
|
+
exportStep(solid: number): Uint8Array;
|
|
338
|
+
/**
|
|
339
|
+
* Export a solid to binary STL format.
|
|
340
|
+
*
|
|
341
|
+
* Returns a `Uint8Array` containing the `.stl` file.
|
|
342
|
+
*
|
|
343
|
+
* # Errors
|
|
344
|
+
*
|
|
345
|
+
* Returns an error if the solid handle is invalid or export fails.
|
|
346
|
+
*/
|
|
347
|
+
exportStl(solid: number, deflection: number): Uint8Array;
|
|
348
|
+
/**
|
|
349
|
+
* Extrude a planar face along a direction vector to create a solid.
|
|
350
|
+
*
|
|
351
|
+
* Returns a solid handle (`u32`).
|
|
352
|
+
*
|
|
353
|
+
* # Errors
|
|
354
|
+
*
|
|
355
|
+
* Returns an error if the face handle is invalid or the extrusion fails.
|
|
356
|
+
*/
|
|
357
|
+
extrude(face: number, dir_x: number, dir_y: number, dir_z: number, distance: number): number;
|
|
358
|
+
/**
|
|
359
|
+
* Compute the area of a single face.
|
|
360
|
+
*
|
|
361
|
+
* # Errors
|
|
362
|
+
*
|
|
363
|
+
* Returns an error if the face handle is invalid or tessellation fails.
|
|
364
|
+
*/
|
|
365
|
+
faceArea(face: number, deflection: number): number;
|
|
366
|
+
/**
|
|
367
|
+
* Compute the perimeter of a face.
|
|
368
|
+
*
|
|
369
|
+
* # Errors
|
|
370
|
+
*
|
|
371
|
+
* Returns an error if the face handle is invalid.
|
|
372
|
+
*/
|
|
373
|
+
facePerimeter(face: number): number;
|
|
374
|
+
/**
|
|
375
|
+
* Get the wires (outer + inner) of a face.
|
|
376
|
+
*
|
|
377
|
+
* Returns an array of wire handles.
|
|
378
|
+
*/
|
|
379
|
+
faceWires(face: number): Uint32Array;
|
|
380
|
+
/**
|
|
381
|
+
* Fill a 4-sided boundary with a Coons patch surface.
|
|
382
|
+
*
|
|
383
|
+
* `boundary_coords` is flat `[x,y,z, ...]` for all 4 curves concatenated.
|
|
384
|
+
* `curve_lengths` is `[n0, n1, n2, n3]` — number of points per curve.
|
|
385
|
+
* Returns a face handle.
|
|
386
|
+
*/
|
|
387
|
+
fillCoonsPatch(boundary_coords: Float64Array, curve_lengths: Uint32Array): number;
|
|
388
|
+
/**
|
|
389
|
+
* Fillet (round) edges of a solid.
|
|
390
|
+
*
|
|
391
|
+
* `edge_handles` is an array of edge handles. Returns a solid handle.
|
|
392
|
+
*
|
|
393
|
+
* # Errors
|
|
394
|
+
*
|
|
395
|
+
* Returns an error if radius is non-positive or edges are invalid.
|
|
396
|
+
*/
|
|
397
|
+
fillet(solid: number, edge_handles: Uint32Array, radius: number): number;
|
|
398
|
+
/**
|
|
399
|
+
* Apply variable-radius fillets to edges.
|
|
400
|
+
*
|
|
401
|
+
* `json` is a JSON string: `[{"edge": u32, "law": "constant"|"linear"|"scurve", "start": f64, "end": f64}]`
|
|
402
|
+
* Returns a new solid handle.
|
|
403
|
+
*/
|
|
404
|
+
filletVariable(solid: number, json: string): number;
|
|
405
|
+
/**
|
|
406
|
+
* Fix face orientations to ensure consistent outward normals.
|
|
407
|
+
*
|
|
408
|
+
* Returns the number of faces fixed.
|
|
409
|
+
*/
|
|
410
|
+
fixFaceOrientations(solid: number): number;
|
|
411
|
+
/**
|
|
412
|
+
* Fuse (union) two solids into one.
|
|
413
|
+
*
|
|
414
|
+
* Returns a new solid handle (`u32`).
|
|
415
|
+
*
|
|
416
|
+
* # Errors
|
|
417
|
+
*
|
|
418
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
419
|
+
* produces an empty or non-manifold result.
|
|
420
|
+
*/
|
|
421
|
+
fuse(a: number, b: number): number;
|
|
422
|
+
/**
|
|
423
|
+
* Get analytic surface parameters for a face.
|
|
424
|
+
*
|
|
425
|
+
* Returns a JSON string with type-dependent fields.
|
|
426
|
+
*/
|
|
427
|
+
getAnalyticSurfaceParams(face: number): string;
|
|
428
|
+
/**
|
|
429
|
+
* Get the parameter domain of an edge curve.
|
|
430
|
+
*
|
|
431
|
+
* Returns `[t_start, t_end]`.
|
|
432
|
+
* For line edges: `[0.0, length]`.
|
|
433
|
+
* For NURBS edges: knot domain.
|
|
434
|
+
*/
|
|
435
|
+
getEdgeCurveParameters(edge: number): Float64Array;
|
|
436
|
+
/**
|
|
437
|
+
* Get the curve type of an edge.
|
|
438
|
+
*
|
|
439
|
+
* Returns `"line"` or `"bspline"`.
|
|
440
|
+
*/
|
|
441
|
+
getEdgeCurveType(edge: number): string;
|
|
442
|
+
/**
|
|
443
|
+
* Build an edge's NURBS curve data for JS consumption.
|
|
444
|
+
*
|
|
445
|
+
* Returns `null` for line edges, or a JSON string with
|
|
446
|
+
* `{degree, knots, controlPoints, weights}` for NURBS edges.
|
|
447
|
+
*/
|
|
448
|
+
getEdgeNurbsData(edge: number): any;
|
|
449
|
+
/**
|
|
450
|
+
* Get the vertex positions of an edge.
|
|
451
|
+
*
|
|
452
|
+
* Returns `[start_x, start_y, start_z, end_x, end_y, end_z]`.
|
|
453
|
+
*
|
|
454
|
+
* # Errors
|
|
455
|
+
*
|
|
456
|
+
* Returns an error if the edge handle is invalid.
|
|
457
|
+
*/
|
|
458
|
+
getEdgeVertices(edge: number): Float64Array;
|
|
459
|
+
/**
|
|
460
|
+
* Get entity counts of a solid: `[faces, edges, vertices]`.
|
|
461
|
+
*
|
|
462
|
+
* # Errors
|
|
463
|
+
*
|
|
464
|
+
* Returns an error if the solid handle is invalid.
|
|
465
|
+
*/
|
|
466
|
+
getEntityCounts(solid: number): Uint32Array;
|
|
467
|
+
/**
|
|
468
|
+
* Get the edge handles of a face.
|
|
469
|
+
*
|
|
470
|
+
* Returns an array of edge handles (`u32[]`).
|
|
471
|
+
*/
|
|
472
|
+
getFaceEdges(face: number): Uint32Array;
|
|
473
|
+
/**
|
|
474
|
+
* Get the face normal of a planar face.
|
|
475
|
+
*
|
|
476
|
+
* Returns `[nx, ny, nz]`.
|
|
477
|
+
*
|
|
478
|
+
* # Errors
|
|
479
|
+
*
|
|
480
|
+
* Returns an error if the face is invalid or NURBS.
|
|
481
|
+
*/
|
|
482
|
+
getFaceNormal(face: number): Float64Array;
|
|
483
|
+
/**
|
|
484
|
+
* Get the outer wire handle of a face.
|
|
485
|
+
*
|
|
486
|
+
* Returns a wire handle (`u32`).
|
|
487
|
+
*/
|
|
488
|
+
getFaceOuterWire(face: number): number;
|
|
489
|
+
/**
|
|
490
|
+
* Get the vertex handles of a face.
|
|
491
|
+
*
|
|
492
|
+
* Returns an array of vertex handles (`u32[]`).
|
|
493
|
+
*/
|
|
494
|
+
getFaceVertices(face: number): Uint32Array;
|
|
495
|
+
/**
|
|
496
|
+
* Get all edge handles of a solid.
|
|
497
|
+
*
|
|
498
|
+
* Returns an array of unique edge handles (`u32[]`).
|
|
499
|
+
*
|
|
500
|
+
* # Errors
|
|
501
|
+
*
|
|
502
|
+
* Returns an error if the solid handle is invalid.
|
|
503
|
+
*/
|
|
504
|
+
getSolidEdges(solid: number): Uint32Array;
|
|
505
|
+
/**
|
|
506
|
+
* Get all face handles of a solid.
|
|
507
|
+
*
|
|
508
|
+
* Returns an array of face handles (`u32[]`).
|
|
509
|
+
*
|
|
510
|
+
* # Errors
|
|
511
|
+
*
|
|
512
|
+
* Returns an error if the solid handle is invalid.
|
|
513
|
+
*/
|
|
514
|
+
getSolidFaces(solid: number): Uint32Array;
|
|
515
|
+
/**
|
|
516
|
+
* Get all vertex handles of a solid.
|
|
517
|
+
*
|
|
518
|
+
* Returns an array of unique vertex handles (`u32[]`).
|
|
519
|
+
*
|
|
520
|
+
* # Errors
|
|
521
|
+
*
|
|
522
|
+
* Returns an error if the solid handle is invalid.
|
|
523
|
+
*/
|
|
524
|
+
getSolidVertices(solid: number): Uint32Array;
|
|
525
|
+
/**
|
|
526
|
+
* Get the UV parameter domain of a face's surface.
|
|
527
|
+
*
|
|
528
|
+
* Returns `[u_min, u_max, v_min, v_max]`.
|
|
529
|
+
*/
|
|
530
|
+
getSurfaceDomain(face: number): Float64Array;
|
|
531
|
+
/**
|
|
532
|
+
* Get the surface type of a face.
|
|
533
|
+
*
|
|
534
|
+
* Returns one of: `"plane"`, `"cylinder"`, `"cone"`, `"sphere"`,
|
|
535
|
+
* `"torus"`, `"bspline"`.
|
|
536
|
+
*/
|
|
537
|
+
getSurfaceType(face: number): string;
|
|
538
|
+
/**
|
|
539
|
+
* Get the position of a vertex.
|
|
540
|
+
*
|
|
541
|
+
* Returns `[x, y, z]`.
|
|
542
|
+
*
|
|
543
|
+
* # Errors
|
|
544
|
+
*
|
|
545
|
+
* Returns an error if the vertex handle is invalid.
|
|
546
|
+
*/
|
|
547
|
+
getVertexPosition(vertex: number): Float64Array;
|
|
548
|
+
/**
|
|
549
|
+
* Heal a solid topology.
|
|
550
|
+
*
|
|
551
|
+
* Returns the number of issues fixed.
|
|
552
|
+
*/
|
|
553
|
+
healSolid(solid: number): number;
|
|
554
|
+
/**
|
|
555
|
+
* Create a helical sweep of a profile face.
|
|
556
|
+
*
|
|
557
|
+
* Sweeps the profile along a helix defined by axis, radius, pitch,
|
|
558
|
+
* and number of turns. Used for generating thread geometry.
|
|
559
|
+
*
|
|
560
|
+
* # Errors
|
|
561
|
+
*
|
|
562
|
+
* Returns an error if parameters are invalid or the sweep fails.
|
|
563
|
+
*/
|
|
564
|
+
helicalSweep(profile: number, axis_origin_x: number, axis_origin_y: number, axis_origin_z: number, axis_dir_x: number, axis_dir_y: number, axis_dir_z: number, radius: number, pitch: number, turns: number): number;
|
|
565
|
+
/**
|
|
566
|
+
* Import a 3MF file and return solid handles.
|
|
567
|
+
*
|
|
568
|
+
* Returns handles for each object found in the 3MF archive.
|
|
569
|
+
*
|
|
570
|
+
* # Errors
|
|
571
|
+
*
|
|
572
|
+
* Returns an error if the 3MF data is malformed.
|
|
573
|
+
*/
|
|
574
|
+
import3mf(data: Uint8Array): Uint32Array;
|
|
575
|
+
/**
|
|
576
|
+
* Import a GLB (glTF binary) file and return a solid handle.
|
|
577
|
+
*
|
|
578
|
+
* # Errors
|
|
579
|
+
*
|
|
580
|
+
* Returns an error if the file is malformed or mesh import fails.
|
|
581
|
+
*/
|
|
582
|
+
importGlb(data: Uint8Array): number;
|
|
583
|
+
/**
|
|
584
|
+
* Import an IGES file and return solid handles.
|
|
585
|
+
*
|
|
586
|
+
* # Errors
|
|
587
|
+
*
|
|
588
|
+
* Returns an error if the IGES data is malformed.
|
|
589
|
+
*/
|
|
590
|
+
importIges(data: Uint8Array): Uint32Array;
|
|
591
|
+
/**
|
|
592
|
+
* Import an OBJ file and return a solid handle.
|
|
593
|
+
*
|
|
594
|
+
* # Errors
|
|
595
|
+
*
|
|
596
|
+
* Returns an error if the file is malformed or mesh import fails.
|
|
597
|
+
*/
|
|
598
|
+
importObj(data: Uint8Array): number;
|
|
599
|
+
/**
|
|
600
|
+
* Import a STEP file and return solid handles.
|
|
601
|
+
*
|
|
602
|
+
* Returns handles for each solid found in the STEP file.
|
|
603
|
+
*
|
|
604
|
+
* # Errors
|
|
605
|
+
*
|
|
606
|
+
* Returns an error if the STEP data is malformed.
|
|
607
|
+
*/
|
|
608
|
+
importStep(data: Uint8Array): Uint32Array;
|
|
609
|
+
/**
|
|
610
|
+
* Import an STL file (binary or ASCII) and return a solid handle.
|
|
611
|
+
*
|
|
612
|
+
* The mesh triangles are converted to planar B-Rep faces with
|
|
613
|
+
* vertex merging.
|
|
614
|
+
*
|
|
615
|
+
* # Errors
|
|
616
|
+
*
|
|
617
|
+
* Returns an error if the STL data is malformed or empty.
|
|
618
|
+
*/
|
|
619
|
+
importStl(data: Uint8Array): number;
|
|
620
|
+
/**
|
|
621
|
+
* Interpolate a NURBS curve through points and create an edge.
|
|
622
|
+
*
|
|
623
|
+
* Uses chord-length parameterization with the given degree.
|
|
624
|
+
* Returns an edge handle (`u32`).
|
|
625
|
+
*/
|
|
626
|
+
interpolatePoints(coords: Float64Array, degree: number): number;
|
|
627
|
+
/**
|
|
628
|
+
* Interpolate a grid of points into a NURBS surface.
|
|
629
|
+
*
|
|
630
|
+
* `coords` is a flat array `[x,y,z, ...]` of `rows * cols` points.
|
|
631
|
+
* Returns a face handle.
|
|
632
|
+
*/
|
|
633
|
+
interpolateSurface(coords: Float64Array, rows: number, cols: number, degree_u: number, degree_v: number): number;
|
|
634
|
+
/**
|
|
635
|
+
* Intersect two solids, keeping only their common volume.
|
|
636
|
+
*
|
|
637
|
+
* Returns a new solid handle (`u32`).
|
|
638
|
+
*
|
|
639
|
+
* # Errors
|
|
640
|
+
*
|
|
641
|
+
* Returns an error if either solid handle is invalid or the operation
|
|
642
|
+
* produces an empty result.
|
|
643
|
+
*/
|
|
644
|
+
intersect(a: number, b: number): number;
|
|
645
|
+
/**
|
|
646
|
+
* Check if an edge is forward-oriented in a given wire.
|
|
647
|
+
*
|
|
648
|
+
* Returns `true` if the edge is forward in the wire, `false` if reversed.
|
|
649
|
+
*/
|
|
650
|
+
isEdgeForwardInWire(edge: number, wire: number): boolean;
|
|
651
|
+
/**
|
|
652
|
+
* Create a linear pattern of a solid.
|
|
653
|
+
*
|
|
654
|
+
* Returns a compound handle containing all copies.
|
|
655
|
+
*
|
|
656
|
+
* # Errors
|
|
657
|
+
*
|
|
658
|
+
* Returns an error if inputs are invalid.
|
|
659
|
+
*/
|
|
660
|
+
linearPattern(solid: number, dx: number, dy: number, dz: number, spacing: number, count: number): number;
|
|
661
|
+
/**
|
|
662
|
+
* Loft two or more profile faces into a solid.
|
|
663
|
+
*
|
|
664
|
+
* Takes an array of face handles. Returns a solid handle (`u32`).
|
|
665
|
+
*
|
|
666
|
+
* # Errors
|
|
667
|
+
*
|
|
668
|
+
* Returns an error if fewer than 2 faces or profiles have
|
|
669
|
+
* different vertex counts.
|
|
670
|
+
*/
|
|
671
|
+
loft(faces: Uint32Array): number;
|
|
672
|
+
/**
|
|
673
|
+
* Create a box solid with the given dimensions, centered at the origin.
|
|
674
|
+
*
|
|
675
|
+
* Returns a solid handle (`u32`).
|
|
676
|
+
*
|
|
677
|
+
* # Errors
|
|
678
|
+
*
|
|
679
|
+
* Returns an error if any dimension is non-positive or non-finite.
|
|
680
|
+
*/
|
|
681
|
+
makeBox(dx: number, dy: number, dz: number): number;
|
|
682
|
+
/**
|
|
683
|
+
* Create a circular polygon approximation on the XY plane.
|
|
684
|
+
*
|
|
685
|
+
* The circle is centered at the origin with the given `radius`,
|
|
686
|
+
* approximated by `segments` straight edges.
|
|
687
|
+
* Returns a face handle (`u32`).
|
|
688
|
+
*
|
|
689
|
+
* # Errors
|
|
690
|
+
*
|
|
691
|
+
* Returns an error if fewer than 3 segments are specified.
|
|
692
|
+
*/
|
|
693
|
+
makeCircle(radius: number, segments: number): number;
|
|
694
|
+
/**
|
|
695
|
+
* Create a circular face on the XY plane (using NURBS arcs).
|
|
696
|
+
*
|
|
697
|
+
* Returns a face handle.
|
|
698
|
+
*/
|
|
699
|
+
makeCircleFace(radius: number, segments: number): number;
|
|
700
|
+
/**
|
|
701
|
+
* Create a compound from multiple solid handles.
|
|
702
|
+
*
|
|
703
|
+
* Returns a compound handle (stored as `u32`).
|
|
704
|
+
*/
|
|
705
|
+
makeCompound(solid_handles: Uint32Array): number;
|
|
706
|
+
/**
|
|
707
|
+
* Create a cone or frustum solid centered at the origin, axis along +Z.
|
|
708
|
+
*
|
|
709
|
+
* Returns a solid handle (`u32`).
|
|
710
|
+
*
|
|
711
|
+
* # Errors
|
|
712
|
+
*
|
|
713
|
+
* Returns an error if height is non-positive or both radii are zero.
|
|
714
|
+
*/
|
|
715
|
+
makeCone(bottom_radius: number, top_radius: number, height: number): number;
|
|
716
|
+
/**
|
|
717
|
+
* Create a cylinder solid centered at the origin, axis along +Z.
|
|
718
|
+
*
|
|
719
|
+
* Returns a solid handle (`u32`).
|
|
720
|
+
*
|
|
721
|
+
* # Errors
|
|
722
|
+
*
|
|
723
|
+
* Returns an error if radius or height is non-positive.
|
|
724
|
+
*/
|
|
725
|
+
makeCylinder(radius: number, height: number): number;
|
|
726
|
+
/**
|
|
727
|
+
* Create a planar face from a wire (computes normal from first 3 vertices).
|
|
728
|
+
*
|
|
729
|
+
* Returns a face handle (`u32`).
|
|
730
|
+
*/
|
|
731
|
+
makeFaceFromWire(wire: number): number;
|
|
732
|
+
/**
|
|
733
|
+
* Create a straight-line edge between two points.
|
|
734
|
+
*
|
|
735
|
+
* Returns an edge handle (`u32`).
|
|
736
|
+
*/
|
|
737
|
+
makeLineEdge(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): number;
|
|
738
|
+
/**
|
|
739
|
+
* Create a NURBS curve edge.
|
|
740
|
+
*
|
|
741
|
+
* Returns an edge handle (`u32`).
|
|
742
|
+
*/
|
|
743
|
+
makeNurbsEdge(start_x: number, start_y: number, start_z: number, end_x: number, end_y: number, end_z: number, degree: number, knots: Float64Array, control_points: Float64Array, weights: Float64Array): number;
|
|
744
|
+
/**
|
|
745
|
+
* Create a polygonal face from flat coordinate triples `[x,y,z, ...]`.
|
|
746
|
+
*
|
|
747
|
+
* Requires at least 3 points (9 `f64` values).
|
|
748
|
+
* Returns a face handle (`u32`).
|
|
749
|
+
*
|
|
750
|
+
* # Errors
|
|
751
|
+
*
|
|
752
|
+
* Returns an error if `coords` length is not a multiple of 3,
|
|
753
|
+
* fewer than 3 points are provided, or the face normal is degenerate.
|
|
754
|
+
*/
|
|
755
|
+
makePolygon(coords: Float64Array): number;
|
|
756
|
+
/**
|
|
757
|
+
* Create a closed polygon wire from flat coordinates.
|
|
758
|
+
*
|
|
759
|
+
* Returns a wire handle.
|
|
760
|
+
*/
|
|
761
|
+
makePolygonWire(coords: Float64Array): number;
|
|
762
|
+
/**
|
|
763
|
+
* Create a rectangular face on the XY plane centered at the origin.
|
|
764
|
+
*
|
|
765
|
+
* Returns a face handle (`u32`).
|
|
766
|
+
*
|
|
767
|
+
* # Errors
|
|
768
|
+
*
|
|
769
|
+
* Returns an error if `width` or `height` is non-positive, NaN,
|
|
770
|
+
* or infinite, or if the face geometry cannot be constructed.
|
|
771
|
+
*/
|
|
772
|
+
makeRectangle(width: number, height: number): number;
|
|
773
|
+
/**
|
|
774
|
+
* Create a regular polygon wire on the XY plane.
|
|
775
|
+
*
|
|
776
|
+
* Returns a wire handle.
|
|
777
|
+
*/
|
|
778
|
+
makeRegularPolygonWire(radius: number, n_sides: number): number;
|
|
779
|
+
/**
|
|
780
|
+
* Create a sphere solid centered at the origin.
|
|
781
|
+
*
|
|
782
|
+
* Returns a solid handle (`u32`).
|
|
783
|
+
*
|
|
784
|
+
* # Errors
|
|
785
|
+
*
|
|
786
|
+
* Returns an error if radius is non-positive or segments < 4.
|
|
787
|
+
*/
|
|
788
|
+
makeSphere(radius: number, segments: number): number;
|
|
789
|
+
/**
|
|
790
|
+
* Create a torus solid centered at the origin in the XY plane.
|
|
791
|
+
*
|
|
792
|
+
* Returns a solid handle (`u32`).
|
|
793
|
+
*
|
|
794
|
+
* # Errors
|
|
795
|
+
*
|
|
796
|
+
* Returns an error if radii are non-positive or minor >= major.
|
|
797
|
+
*/
|
|
798
|
+
makeTorus(major_radius: number, minor_radius: number, segments: number): number;
|
|
799
|
+
/**
|
|
800
|
+
* Create a vertex at the given position.
|
|
801
|
+
*
|
|
802
|
+
* Returns a vertex handle (`u32`).
|
|
803
|
+
*/
|
|
804
|
+
makeVertex(x: number, y: number, z: number): number;
|
|
805
|
+
/**
|
|
806
|
+
* Create a closed wire from an ordered array of edge handles.
|
|
807
|
+
*
|
|
808
|
+
* Returns a wire handle (`u32`).
|
|
809
|
+
*/
|
|
810
|
+
makeWire(edge_handles: Uint32Array, closed: boolean): number;
|
|
811
|
+
/**
|
|
812
|
+
* Merge coincident vertices in a solid.
|
|
813
|
+
*
|
|
814
|
+
* Returns the number of vertices merged.
|
|
815
|
+
*/
|
|
816
|
+
mergeCoincidentVertices(solid: number, tolerance: number): number;
|
|
817
|
+
/**
|
|
818
|
+
* Perform a mesh boolean on raw triangle data.
|
|
819
|
+
*
|
|
820
|
+
* Returns a `JsMesh` with the result.
|
|
821
|
+
*/
|
|
822
|
+
meshBoolean(positions_a: Float64Array, indices_a: Uint32Array, positions_b: Float64Array, indices_b: Uint32Array, op: string, tolerance: number): JsMesh;
|
|
823
|
+
/**
|
|
824
|
+
* Mirror a solid across a plane.
|
|
825
|
+
*
|
|
826
|
+
* Returns a new solid handle.
|
|
827
|
+
*
|
|
828
|
+
* # Errors
|
|
829
|
+
*
|
|
830
|
+
* Returns an error if the solid handle is invalid or the normal is zero.
|
|
831
|
+
*/
|
|
832
|
+
mirror(solid: number, px: number, py: number, pz: number, nx: number, ny: number, nz: number): number;
|
|
833
|
+
/**
|
|
834
|
+
* Create a new, empty kernel.
|
|
835
|
+
*/
|
|
836
|
+
constructor();
|
|
837
|
+
/**
|
|
838
|
+
* Offset a face by a distance along its surface normal.
|
|
839
|
+
*
|
|
840
|
+
* Returns the new offset face handle.
|
|
841
|
+
*
|
|
842
|
+
* # Errors
|
|
843
|
+
*
|
|
844
|
+
* Returns an error if the face handle is invalid or the operation fails.
|
|
845
|
+
*/
|
|
846
|
+
offsetFace(face: number, distance: number, samples: number): number;
|
|
847
|
+
/**
|
|
848
|
+
* Offset a 2D polygon by a signed distance.
|
|
849
|
+
*
|
|
850
|
+
* `coords` is a flat array `[x,y, x,y, ...]` of 2D points.
|
|
851
|
+
* Returns a flat array of offset polygon coordinates.
|
|
852
|
+
*/
|
|
853
|
+
offsetPolygon2d(coords: Float64Array, distance: number, tolerance: number): Float64Array;
|
|
854
|
+
/**
|
|
855
|
+
* Offset (shell) a solid by a distance.
|
|
856
|
+
*
|
|
857
|
+
* Returns a new solid handle.
|
|
858
|
+
*
|
|
859
|
+
* # Errors
|
|
860
|
+
*
|
|
861
|
+
* Returns an error if the distance is zero or the solid is invalid.
|
|
862
|
+
*/
|
|
863
|
+
offsetSolid(solid: number, distance: number): number;
|
|
864
|
+
/**
|
|
865
|
+
* Offset a wire on a planar face.
|
|
866
|
+
*
|
|
867
|
+
* Returns a new wire handle.
|
|
868
|
+
*/
|
|
869
|
+
offsetWire(face: number, distance: number): number;
|
|
870
|
+
/**
|
|
871
|
+
* Pipe sweep: sweep a profile along a NURBS path (no guide).
|
|
872
|
+
*
|
|
873
|
+
* Returns a solid handle.
|
|
874
|
+
*
|
|
875
|
+
* # Errors
|
|
876
|
+
*
|
|
877
|
+
* Returns an error if the face or path is invalid.
|
|
878
|
+
*/
|
|
879
|
+
pipe(face: number, path_degree: number, path_knots: Float64Array, path_control_points: Float64Array, path_weights: Float64Array): number;
|
|
880
|
+
/**
|
|
881
|
+
* Compute minimum distance from a point to a solid.
|
|
882
|
+
*
|
|
883
|
+
* Returns `[distance, closest_x, closest_y, closest_z]`.
|
|
884
|
+
*
|
|
885
|
+
* # Errors
|
|
886
|
+
*
|
|
887
|
+
* Returns an error if the solid handle is invalid.
|
|
888
|
+
*/
|
|
889
|
+
pointToSolidDistance(px: number, py: number, pz: number, solid: number): Float64Array;
|
|
890
|
+
/**
|
|
891
|
+
* Project a 3D point onto a face surface using Newton iteration.
|
|
892
|
+
*
|
|
893
|
+
* Returns `[u, v, px, py, pz, distance]`.
|
|
894
|
+
*/
|
|
895
|
+
projectPointOnSurface(face: number, px: number, py: number, pz: number): Float64Array;
|
|
896
|
+
/**
|
|
897
|
+
* Recognize geometric features in a solid.
|
|
898
|
+
*
|
|
899
|
+
* Returns a JSON string describing the recognized features.
|
|
900
|
+
*/
|
|
901
|
+
recognizeFeatures(solid: number, deflection: number): string;
|
|
902
|
+
/**
|
|
903
|
+
* Remove degenerate (zero-length) edges from a solid.
|
|
904
|
+
*
|
|
905
|
+
* Returns the number of edges removed.
|
|
906
|
+
*/
|
|
907
|
+
removeDegenerateEdges(solid: number, tolerance: number): number;
|
|
908
|
+
/**
|
|
909
|
+
* Revolve a planar face around an axis to create a solid of revolution.
|
|
910
|
+
*
|
|
911
|
+
* The axis is defined by an origin point `(ox, oy, oz)` and a direction
|
|
912
|
+
* `(dx, dy, dz)`. The angle is in degrees and must be in (0, 360].
|
|
913
|
+
*
|
|
914
|
+
* Returns a solid handle (`u32`).
|
|
915
|
+
*
|
|
916
|
+
* # Errors
|
|
917
|
+
*
|
|
918
|
+
* Returns an error if any input is non-finite, the face handle is
|
|
919
|
+
* invalid, or the revolve operation fails.
|
|
920
|
+
*/
|
|
921
|
+
revolve(face: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, angle_degrees: number): number;
|
|
922
|
+
/**
|
|
923
|
+
* Section a solid with a plane, returning cross-section face handles.
|
|
924
|
+
*
|
|
925
|
+
* Returns an array of face handles (`u32[]`).
|
|
926
|
+
*
|
|
927
|
+
* # Errors
|
|
928
|
+
*
|
|
929
|
+
* Returns an error if the solid handle is invalid or the plane doesn't
|
|
930
|
+
* intersect the solid.
|
|
931
|
+
*/
|
|
932
|
+
section(solid: number, px: number, py: number, pz: number, nx: number, ny: number, nz: number): Uint32Array;
|
|
933
|
+
/**
|
|
934
|
+
* Sew loose faces into a connected solid.
|
|
935
|
+
*
|
|
936
|
+
* `face_handles` is an array of face handles. Returns a solid handle.
|
|
937
|
+
*
|
|
938
|
+
* # Errors
|
|
939
|
+
*
|
|
940
|
+
* Returns an error if fewer than 2 faces or sewing fails.
|
|
941
|
+
*/
|
|
942
|
+
sewFaces(face_handles: Uint32Array, tolerance: number): number;
|
|
943
|
+
/**
|
|
944
|
+
* Get edges shared between two faces.
|
|
945
|
+
*
|
|
946
|
+
* Returns an array of edge handles.
|
|
947
|
+
*/
|
|
948
|
+
sharedEdges(face_a: number, face_b: number): Uint32Array;
|
|
949
|
+
/**
|
|
950
|
+
* Hollow a solid with uniform wall thickness.
|
|
951
|
+
*
|
|
952
|
+
* `open_faces` is an array of face handles to remove (creating openings).
|
|
953
|
+
* Returns a solid handle (`u32`).
|
|
954
|
+
*
|
|
955
|
+
* # Errors
|
|
956
|
+
*
|
|
957
|
+
* Returns an error if thickness is non-positive or the solid is invalid.
|
|
958
|
+
*/
|
|
959
|
+
shell(solid: number, thickness: number, open_faces: Uint32Array): number;
|
|
960
|
+
/**
|
|
961
|
+
* Add a constraint to a sketch from a JSON string.
|
|
962
|
+
*
|
|
963
|
+
* Formats: `{"type":"coincident","p1":0,"p2":1}`,
|
|
964
|
+
* `{"type":"distance","p1":0,"p2":1,"value":5.0}`,
|
|
965
|
+
* `{"type":"fixX","point":0,"value":1.0}`, etc.
|
|
966
|
+
*/
|
|
967
|
+
sketchAddConstraint(sketch: number, json: string): void;
|
|
968
|
+
/**
|
|
969
|
+
* Add a point to a sketch. Returns the point index.
|
|
970
|
+
*/
|
|
971
|
+
sketchAddPoint(sketch: number, x: number, y: number, fixed: boolean): number;
|
|
972
|
+
/**
|
|
973
|
+
* Create a new empty sketch. Returns a sketch index.
|
|
974
|
+
*/
|
|
975
|
+
sketchNew(): number;
|
|
976
|
+
/**
|
|
977
|
+
* Solve the sketch constraints.
|
|
978
|
+
*
|
|
979
|
+
* Returns a JSON string: `{"converged": bool, "iterations": n, "maxResidual": f, "points": [[x,y], ...]}`.
|
|
980
|
+
*/
|
|
981
|
+
sketchSolve(sketch: number, max_iterations: number, tolerance: number): string;
|
|
982
|
+
/**
|
|
983
|
+
* Create a solid from a shell.
|
|
984
|
+
*
|
|
985
|
+
* Returns a solid handle (`u32`).
|
|
986
|
+
*/
|
|
987
|
+
solidFromShell(shell: number): number;
|
|
988
|
+
/**
|
|
989
|
+
* Compute minimum distance between two solids.
|
|
990
|
+
*
|
|
991
|
+
* Returns `[distance]`.
|
|
992
|
+
*
|
|
993
|
+
* # Errors
|
|
994
|
+
*
|
|
995
|
+
* Returns an error if either solid handle is invalid.
|
|
996
|
+
*/
|
|
997
|
+
solidToSolidDistance(a: number, b: number): number;
|
|
998
|
+
/**
|
|
999
|
+
* Split a solid into two halves along a plane.
|
|
1000
|
+
*
|
|
1001
|
+
* Returns `[positive_solid_handle, negative_solid_handle]`.
|
|
1002
|
+
*
|
|
1003
|
+
* # Errors
|
|
1004
|
+
*
|
|
1005
|
+
* Returns an error if the plane doesn't intersect the solid.
|
|
1006
|
+
*/
|
|
1007
|
+
split(solid: number, px: number, py: number, pz: number, nx: number, ny: number, nz: number): Uint32Array;
|
|
1008
|
+
/**
|
|
1009
|
+
* Compute the total surface area of a solid.
|
|
1010
|
+
*
|
|
1011
|
+
* # Errors
|
|
1012
|
+
*
|
|
1013
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
1014
|
+
*/
|
|
1015
|
+
surfaceArea(solid: number, deflection: number): number;
|
|
1016
|
+
/**
|
|
1017
|
+
* Sweep a planar face along a NURBS curve path to create a solid.
|
|
1018
|
+
*
|
|
1019
|
+
* The path is specified as flat arrays for JS interop:
|
|
1020
|
+
* - `path_degree` — polynomial degree of the path curve
|
|
1021
|
+
* - `path_knots` — knot vector
|
|
1022
|
+
* - `path_control_points` — flat `[x,y,z, ...]` control point coordinates
|
|
1023
|
+
* - `path_weights` — per-control-point weights
|
|
1024
|
+
*
|
|
1025
|
+
* Returns a solid handle (`u32`).
|
|
1026
|
+
*
|
|
1027
|
+
* # Errors
|
|
1028
|
+
*
|
|
1029
|
+
* Returns an error if the face handle is invalid, the NURBS arrays have
|
|
1030
|
+
* inconsistent lengths, or the sweep operation fails.
|
|
1031
|
+
*/
|
|
1032
|
+
sweep(face: number, path_degree: number, path_knots: Float64Array, path_control_points: Float64Array, path_weights: Float64Array): number;
|
|
1033
|
+
/**
|
|
1034
|
+
* Sweep a face along a path defined by a chain of edges.
|
|
1035
|
+
*
|
|
1036
|
+
* Collects points from the edges, fits an interpolating NURBS curve,
|
|
1037
|
+
* then sweeps the profile along that curve.
|
|
1038
|
+
*
|
|
1039
|
+
* Returns a solid handle (`u32`).
|
|
1040
|
+
*
|
|
1041
|
+
* # Errors
|
|
1042
|
+
*
|
|
1043
|
+
* Returns an error if fewer than 2 edges or the fit fails.
|
|
1044
|
+
*/
|
|
1045
|
+
sweepAlongEdges(face: number, edge_handles: Uint32Array): number;
|
|
1046
|
+
/**
|
|
1047
|
+
* Sweep a face along a NURBS path with advanced options.
|
|
1048
|
+
*
|
|
1049
|
+
* `contact_mode`: "rmf" (default), "fixed", or "constantNormal:x,y,z"
|
|
1050
|
+
* `scale_values`: flat `[t0,s0,t1,s1,...]` pairs for piecewise-linear scale law.
|
|
1051
|
+
* Returns a solid handle.
|
|
1052
|
+
*/
|
|
1053
|
+
sweepWithOptions(profile: number, path_edge: number, contact_mode: string, scale_values: Float64Array, segments: number): number;
|
|
1054
|
+
/**
|
|
1055
|
+
* Tessellate an edge curve into polyline segments.
|
|
1056
|
+
*
|
|
1057
|
+
* For line edges, returns just start and end points.
|
|
1058
|
+
* For NURBS edges, samples at `num_points` along the curve.
|
|
1059
|
+
*
|
|
1060
|
+
* Returns flattened `[x, y, z, x, y, z, ...]` array.
|
|
1061
|
+
*/
|
|
1062
|
+
tessellateEdge(edge: number, num_points: number): Float64Array;
|
|
1063
|
+
/**
|
|
1064
|
+
* Tessellate a single face into a triangle mesh.
|
|
1065
|
+
*
|
|
1066
|
+
* # Errors
|
|
1067
|
+
*
|
|
1068
|
+
* Returns an error if the face handle is invalid or tessellation fails.
|
|
1069
|
+
*/
|
|
1070
|
+
tessellateFace(face: number, deflection: number): JsMesh;
|
|
1071
|
+
/**
|
|
1072
|
+
* Tessellate all faces of a solid into a single merged triangle mesh.
|
|
1073
|
+
*
|
|
1074
|
+
* Includes both the outer shell and any inner shells (voids).
|
|
1075
|
+
*
|
|
1076
|
+
* # Errors
|
|
1077
|
+
*
|
|
1078
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
1079
|
+
*/
|
|
1080
|
+
tessellateSolid(solid: number, deflection: number): JsMesh;
|
|
1081
|
+
/**
|
|
1082
|
+
* Apply a 4×4 affine transform to a solid (in place).
|
|
1083
|
+
*
|
|
1084
|
+
* The `matrix` must contain exactly 16 values in row-major order.
|
|
1085
|
+
*
|
|
1086
|
+
* # Errors
|
|
1087
|
+
*
|
|
1088
|
+
* Returns an error if the solid handle is invalid, the matrix doesn't
|
|
1089
|
+
* have 16 elements, or the matrix is singular.
|
|
1090
|
+
*/
|
|
1091
|
+
transformSolid(solid: number, matrix: Float64Array): void;
|
|
1092
|
+
/**
|
|
1093
|
+
* Untrim a NURBS face by fitting a new surface to the trimmed region.
|
|
1094
|
+
*
|
|
1095
|
+
* Returns a new face handle.
|
|
1096
|
+
*/
|
|
1097
|
+
untrimFace(face: number, samples_per_curve: number, interior_samples: number): number;
|
|
1098
|
+
/**
|
|
1099
|
+
* Validate a solid, returning the number of errors found.
|
|
1100
|
+
*
|
|
1101
|
+
* Returns 0 if the solid is valid.
|
|
1102
|
+
*
|
|
1103
|
+
* # Errors
|
|
1104
|
+
*
|
|
1105
|
+
* Returns an error if the solid handle is invalid.
|
|
1106
|
+
*/
|
|
1107
|
+
validateSolid(solid: number): number;
|
|
1108
|
+
/**
|
|
1109
|
+
* Compute the volume of a solid.
|
|
1110
|
+
*
|
|
1111
|
+
* # Errors
|
|
1112
|
+
*
|
|
1113
|
+
* Returns an error if the solid handle is invalid or tessellation fails.
|
|
1114
|
+
*/
|
|
1115
|
+
volume(solid: number, deflection: number): number;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* A triangle mesh exposed to JavaScript.
|
|
1120
|
+
*
|
|
1121
|
+
* Positions and normals are flattened to `[x, y, z, x, y, z, ...]` format
|
|
1122
|
+
* for efficient WASM transfer and direct use as GPU vertex buffers.
|
|
1123
|
+
*/
|
|
1124
|
+
export class JsMesh {
|
|
1125
|
+
private constructor();
|
|
1126
|
+
free(): void;
|
|
1127
|
+
[Symbol.dispose](): void;
|
|
1128
|
+
/**
|
|
1129
|
+
* Return all mesh data in a single packed buffer for efficient FFI transfer.
|
|
1130
|
+
*
|
|
1131
|
+
* Layout: `[pos_bytes: u32 LE, norm_bytes: u32 LE, idx_bytes: u32 LE,
|
|
1132
|
+
* positions: f64 LE..., normals: f64 LE..., indices: u32 LE...]`
|
|
1133
|
+
*
|
|
1134
|
+
* This avoids three separate `.clone()` + FFI copies that the individual
|
|
1135
|
+
* getters (`positions`, `normals`, `indices`) would incur.
|
|
1136
|
+
*/
|
|
1137
|
+
packedBuffer(): Uint8Array;
|
|
1138
|
+
/**
|
|
1139
|
+
* Triangle indices (groups of 3).
|
|
1140
|
+
*/
|
|
1141
|
+
readonly indices: Uint32Array;
|
|
1142
|
+
/**
|
|
1143
|
+
* Flattened per-vertex normals as `[nx, ny, nz, ...]`.
|
|
1144
|
+
*/
|
|
1145
|
+
readonly normals: Float64Array;
|
|
1146
|
+
/**
|
|
1147
|
+
* Flattened vertex positions as `[x, y, z, ...]`.
|
|
1148
|
+
*/
|
|
1149
|
+
readonly positions: Float64Array;
|
|
1150
|
+
/**
|
|
1151
|
+
* Number of triangles in the mesh.
|
|
1152
|
+
*/
|
|
1153
|
+
readonly triangleCount: number;
|
|
1154
|
+
/**
|
|
1155
|
+
* Number of vertices in the mesh.
|
|
1156
|
+
*/
|
|
1157
|
+
readonly vertexCount: number;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* A 3D point exposed to JavaScript.
|
|
1162
|
+
*/
|
|
1163
|
+
export class JsPoint3 {
|
|
1164
|
+
free(): void;
|
|
1165
|
+
[Symbol.dispose](): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* Create a new 3D point.
|
|
1168
|
+
*/
|
|
1169
|
+
constructor(x: number, y: number, z: number);
|
|
1170
|
+
/**
|
|
1171
|
+
* X coordinate.
|
|
1172
|
+
*/
|
|
1173
|
+
x: number;
|
|
1174
|
+
/**
|
|
1175
|
+
* Y coordinate.
|
|
1176
|
+
*/
|
|
1177
|
+
y: number;
|
|
1178
|
+
/**
|
|
1179
|
+
* Z coordinate.
|
|
1180
|
+
*/
|
|
1181
|
+
z: number;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* A 3D vector exposed to JavaScript.
|
|
1186
|
+
*/
|
|
1187
|
+
export class JsVec3 {
|
|
1188
|
+
free(): void;
|
|
1189
|
+
[Symbol.dispose](): void;
|
|
1190
|
+
/**
|
|
1191
|
+
* Compute the length of this vector.
|
|
1192
|
+
*/
|
|
1193
|
+
length(): number;
|
|
1194
|
+
/**
|
|
1195
|
+
* Create a new 3D vector.
|
|
1196
|
+
*/
|
|
1197
|
+
constructor(x: number, y: number, z: number);
|
|
1198
|
+
/**
|
|
1199
|
+
* X component.
|
|
1200
|
+
*/
|
|
1201
|
+
x: number;
|
|
1202
|
+
/**
|
|
1203
|
+
* Y component.
|
|
1204
|
+
*/
|
|
1205
|
+
y: number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Z component.
|
|
1208
|
+
*/
|
|
1209
|
+
z: number;
|
|
1210
|
+
}
|