okgeometry-api 1.5.0 → 1.9.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/dist/Brep.d.ts +177 -0
- package/dist/Brep.d.ts.map +1 -0
- package/dist/Brep.js +368 -0
- package/dist/Brep.js.map +1 -0
- package/dist/Mesh.d.ts +21 -1
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +63 -1
- package/dist/Mesh.js.map +1 -1
- package/dist/NurbsSurface.d.ts +121 -0
- package/dist/NurbsSurface.d.ts.map +1 -1
- package/dist/NurbsSurface.js +261 -7
- package/dist/NurbsSurface.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/wasm-base64.d.ts +1 -1
- package/dist/wasm-base64.d.ts.map +1 -1
- package/dist/wasm-base64.js +1 -1
- package/dist/wasm-base64.js.map +1 -1
- package/dist/wasm-bindings.d.ts +300 -0
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +589 -0
- package/dist/wasm-bindings.js.map +1 -1
- package/package.json +50 -48
- package/src/Brep.ts +437 -0
- package/src/Mesh.ts +73 -2
- package/src/NurbsSurface.ts +367 -62
- package/src/index.ts +77 -68
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings.d.ts +233 -0
- package/src/wasm-bindings.js +612 -0
package/src/wasm-bindings.js
CHANGED
|
@@ -34,6 +34,314 @@ export function arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_an
|
|
|
34
34
|
return v1;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Parametric BREP boolean: exact surface–surface intersection curves with
|
|
39
|
+
* trimmed-surface output. Both operands must be closed solids.
|
|
40
|
+
* op: "union" | "intersect" | "subtract".
|
|
41
|
+
* Returns the result BREP as JSON, or {"error": "..."} on failure.
|
|
42
|
+
* @param {string} a_json
|
|
43
|
+
* @param {string} b_json
|
|
44
|
+
* @param {string} op
|
|
45
|
+
* @param {number} tolerance
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
export function brep_boolean_op(a_json, b_json, op, tolerance) {
|
|
49
|
+
let deferred4_0;
|
|
50
|
+
let deferred4_1;
|
|
51
|
+
try {
|
|
52
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
55
|
+
const len1 = WASM_VECTOR_LEN;
|
|
56
|
+
const ptr2 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
57
|
+
const len2 = WASM_VECTOR_LEN;
|
|
58
|
+
const ret = wasm.brep_boolean_op(ptr0, len0, ptr1, len1, ptr2, len2, tolerance);
|
|
59
|
+
deferred4_0 = ret[0];
|
|
60
|
+
deferred4_1 = ret[1];
|
|
61
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
62
|
+
} finally {
|
|
63
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
|
|
69
|
+
* @param {string} json
|
|
70
|
+
* @param {number} tolerance
|
|
71
|
+
* @returns {Float64Array}
|
|
72
|
+
*/
|
|
73
|
+
export function brep_edges(json, tolerance) {
|
|
74
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
const len0 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.brep_edges(ptr0, len0, tolerance);
|
|
77
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
78
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
79
|
+
return v2;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Extrude a profile curve into a BREP (closed profile → capped solid,
|
|
84
|
+
* open profile → sheet). Returns JSON.
|
|
85
|
+
* @param {Float64Array} curve_data
|
|
86
|
+
* @param {number} dx
|
|
87
|
+
* @param {number} dy
|
|
88
|
+
* @param {number} dz
|
|
89
|
+
* @param {number} height
|
|
90
|
+
* @returns {string}
|
|
91
|
+
*/
|
|
92
|
+
export function brep_extrude_curve(curve_data, dx, dy, dz, height) {
|
|
93
|
+
let deferred2_0;
|
|
94
|
+
let deferred2_1;
|
|
95
|
+
try {
|
|
96
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
97
|
+
const len0 = WASM_VECTOR_LEN;
|
|
98
|
+
const ret = wasm.brep_extrude_curve(ptr0, len0, dx, dy, dz, height);
|
|
99
|
+
deferred2_0 = ret[0];
|
|
100
|
+
deferred2_1 = ret[1];
|
|
101
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
102
|
+
} finally {
|
|
103
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Iso-parametric curve of a NURBS face's backing surface (untrimmed).
|
|
109
|
+
* Returns curve data, or empty for planar faces.
|
|
110
|
+
* @param {string} json
|
|
111
|
+
* @param {number} face_index
|
|
112
|
+
* @param {number} t
|
|
113
|
+
* @param {boolean} u_dir
|
|
114
|
+
* @returns {Float64Array}
|
|
115
|
+
*/
|
|
116
|
+
export function brep_face_iso_curve(json, face_index, t, u_dir) {
|
|
117
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.brep_face_iso_curve(ptr0, len0, face_index, t, u_dir);
|
|
120
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
121
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
122
|
+
return v2;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Geometric backing of a face.
|
|
127
|
+
* Returns [0, ox,oy,oz, ux,uy,uz, vx,vy,vz] for planes,
|
|
128
|
+
* or [1, surface_data...] for NURBS faces.
|
|
129
|
+
* @param {string} json
|
|
130
|
+
* @param {number} face_index
|
|
131
|
+
* @returns {Float64Array}
|
|
132
|
+
*/
|
|
133
|
+
export function brep_face_surface(json, face_index) {
|
|
134
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
135
|
+
const len0 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.brep_face_surface(ptr0, len0, face_index);
|
|
137
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
138
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
139
|
+
return v2;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Tessellate a single BREP face. Returns the standard mesh buffer.
|
|
144
|
+
* @param {string} json
|
|
145
|
+
* @param {number} face_index
|
|
146
|
+
* @param {number} tolerance
|
|
147
|
+
* @returns {Float64Array}
|
|
148
|
+
*/
|
|
149
|
+
export function brep_face_tessellate(json, face_index, tolerance) {
|
|
150
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
+
const len0 = WASM_VECTOR_LEN;
|
|
152
|
+
const ret = wasm.brep_face_tessellate(ptr0, len0, face_index, tolerance);
|
|
153
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
154
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
155
|
+
return v2;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* BREP structure summary: [face_count, edge_count, vertex_count, is_closed].
|
|
160
|
+
* @param {string} json
|
|
161
|
+
* @returns {Float64Array}
|
|
162
|
+
*/
|
|
163
|
+
export function brep_info(json) {
|
|
164
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
165
|
+
const len0 = WASM_VECTOR_LEN;
|
|
166
|
+
const ret = wasm.brep_info(ptr0, len0);
|
|
167
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
168
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
169
|
+
return v2;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Loft through profile curves into a BREP.
|
|
174
|
+
* Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
|
|
175
|
+
* @param {Float64Array} data
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
export function brep_loft_curves(data) {
|
|
179
|
+
let deferred2_0;
|
|
180
|
+
let deferred2_1;
|
|
181
|
+
try {
|
|
182
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
183
|
+
const len0 = WASM_VECTOR_LEN;
|
|
184
|
+
const ret = wasm.brep_loft_curves(ptr0, len0);
|
|
185
|
+
deferred2_0 = ret[0];
|
|
186
|
+
deferred2_1 = ret[1];
|
|
187
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
188
|
+
} finally {
|
|
189
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* BREP primitives.
|
|
195
|
+
* kind: "box" [minx,miny,minz, maxx,maxy,maxz]
|
|
196
|
+
* "cylinder" [bx,by,bz, ax,ay,az, radius, height]
|
|
197
|
+
* "sphere" [cx,cy,cz, radius]
|
|
198
|
+
* "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
|
|
199
|
+
* "torus" [cx,cy,cz, major, minor]
|
|
200
|
+
* Returns the BREP as JSON ("" on failure).
|
|
201
|
+
* @param {string} kind
|
|
202
|
+
* @param {Float64Array} params
|
|
203
|
+
* @returns {string}
|
|
204
|
+
*/
|
|
205
|
+
export function brep_primitive(kind, params) {
|
|
206
|
+
let deferred3_0;
|
|
207
|
+
let deferred3_1;
|
|
208
|
+
try {
|
|
209
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
+
const len0 = WASM_VECTOR_LEN;
|
|
211
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
212
|
+
const len1 = WASM_VECTOR_LEN;
|
|
213
|
+
const ret = wasm.brep_primitive(ptr0, len0, ptr1, len1);
|
|
214
|
+
deferred3_0 = ret[0];
|
|
215
|
+
deferred3_1 = ret[1];
|
|
216
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
217
|
+
} finally {
|
|
218
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Revolve a profile curve into a BREP. Returns JSON.
|
|
224
|
+
* @param {Float64Array} curve_data
|
|
225
|
+
* @param {number} ox
|
|
226
|
+
* @param {number} oy
|
|
227
|
+
* @param {number} oz
|
|
228
|
+
* @param {number} ax
|
|
229
|
+
* @param {number} ay
|
|
230
|
+
* @param {number} az
|
|
231
|
+
* @param {number} angle
|
|
232
|
+
* @returns {string}
|
|
233
|
+
*/
|
|
234
|
+
export function brep_revolve_curve(curve_data, ox, oy, oz, ax, ay, az, angle) {
|
|
235
|
+
let deferred2_0;
|
|
236
|
+
let deferred2_1;
|
|
237
|
+
try {
|
|
238
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
const ret = wasm.brep_revolve_curve(ptr0, len0, ox, oy, oz, ax, ay, az, angle);
|
|
241
|
+
deferred2_0 = ret[0];
|
|
242
|
+
deferred2_1 = ret[1];
|
|
243
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
244
|
+
} finally {
|
|
245
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Untrimmed sheet BREP from a NURBS surface. Returns JSON.
|
|
251
|
+
* @param {Float64Array} surface_data
|
|
252
|
+
* @returns {string}
|
|
253
|
+
*/
|
|
254
|
+
export function brep_sheet_from_surface(surface_data) {
|
|
255
|
+
let deferred2_0;
|
|
256
|
+
let deferred2_1;
|
|
257
|
+
try {
|
|
258
|
+
const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.brep_sheet_from_surface(ptr0, len0);
|
|
261
|
+
deferred2_0 = ret[0];
|
|
262
|
+
deferred2_1 = ret[1];
|
|
263
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
264
|
+
} finally {
|
|
265
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Tessellate a BREP into the standard mesh buffer
|
|
271
|
+
* [vertexCount, positions..., indices...]. Crack-free across shared edges.
|
|
272
|
+
* @param {string} json
|
|
273
|
+
* @param {number} tolerance
|
|
274
|
+
* @returns {Float64Array}
|
|
275
|
+
*/
|
|
276
|
+
export function brep_tessellate(json, tolerance) {
|
|
277
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
const len0 = WASM_VECTOR_LEN;
|
|
279
|
+
const ret = wasm.brep_tessellate(ptr0, len0, tolerance);
|
|
280
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
281
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
282
|
+
return v2;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Apply a row-major 4x4 matrix to a BREP. Returns transformed JSON.
|
|
287
|
+
* @param {string} json
|
|
288
|
+
* @param {Float64Array} matrix
|
|
289
|
+
* @returns {string}
|
|
290
|
+
*/
|
|
291
|
+
export function brep_transform(json, matrix) {
|
|
292
|
+
let deferred3_0;
|
|
293
|
+
let deferred3_1;
|
|
294
|
+
try {
|
|
295
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
296
|
+
const len0 = WASM_VECTOR_LEN;
|
|
297
|
+
const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
298
|
+
const len1 = WASM_VECTOR_LEN;
|
|
299
|
+
const ret = wasm.brep_transform(ptr0, len0, ptr1, len1);
|
|
300
|
+
deferred3_0 = ret[0];
|
|
301
|
+
deferred3_1 = ret[1];
|
|
302
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
303
|
+
} finally {
|
|
304
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Validate a BREP. Returns a JSON report:
|
|
310
|
+
* {"isClosed":bool,"boundaryEdgeCount":n,"maxCoherenceError":e,"issues":[...]}
|
|
311
|
+
* @param {string} json
|
|
312
|
+
* @param {number} tolerance
|
|
313
|
+
* @returns {string}
|
|
314
|
+
*/
|
|
315
|
+
export function brep_validate(json, tolerance) {
|
|
316
|
+
let deferred2_0;
|
|
317
|
+
let deferred2_1;
|
|
318
|
+
try {
|
|
319
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
const len0 = WASM_VECTOR_LEN;
|
|
321
|
+
const ret = wasm.brep_validate(ptr0, len0, tolerance);
|
|
322
|
+
deferred2_0 = ret[0];
|
|
323
|
+
deferred2_1 = ret[1];
|
|
324
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
325
|
+
} finally {
|
|
326
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Volume and surface area from tessellation: [volume, area].
|
|
332
|
+
* @param {string} json
|
|
333
|
+
* @param {number} tolerance
|
|
334
|
+
* @returns {Float64Array}
|
|
335
|
+
*/
|
|
336
|
+
export function brep_volume_area(json, tolerance) {
|
|
337
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
339
|
+
const ret = wasm.brep_volume_area(ptr0, len0, tolerance);
|
|
340
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
341
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
342
|
+
return v2;
|
|
343
|
+
}
|
|
344
|
+
|
|
37
345
|
/**
|
|
38
346
|
* Build a NURBS curve from raw control points with kernel-managed knots and weights.
|
|
39
347
|
*
|
|
@@ -1231,6 +1539,31 @@ export function mesh_chamfer_all_edges(mesh_type, params, offset) {
|
|
|
1231
1539
|
return v3;
|
|
1232
1540
|
}
|
|
1233
1541
|
|
|
1542
|
+
/**
|
|
1543
|
+
* Clip a polyline against a closed mesh volume (boolean intersection for curves).
|
|
1544
|
+
*
|
|
1545
|
+
* `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
|
|
1546
|
+
* (no duplicated seam point required, one is tolerated).
|
|
1547
|
+
* Returns two concatenated polyline buffers — inside pieces first, then
|
|
1548
|
+
* outside pieces — each encoded as [num_polylines, n1, x,y,z,..., ...].
|
|
1549
|
+
* Returns an empty buffer on failure (open cutter, degenerate polyline).
|
|
1550
|
+
* @param {number} vertex_count
|
|
1551
|
+
* @param {Float64Array} buffer
|
|
1552
|
+
* @param {Float64Array} points
|
|
1553
|
+
* @param {boolean} closed
|
|
1554
|
+
* @returns {Float64Array}
|
|
1555
|
+
*/
|
|
1556
|
+
export function mesh_clip_polyline(vertex_count, buffer, points, closed) {
|
|
1557
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
1558
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1559
|
+
const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
1560
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1561
|
+
const ret = wasm.mesh_clip_polyline(vertex_count, ptr0, len0, ptr1, len1, closed);
|
|
1562
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1563
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1564
|
+
return v3;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1234
1567
|
/**
|
|
1235
1568
|
* Compute planar curve normal from ordered points.
|
|
1236
1569
|
* @param {Float64Array} coords
|
|
@@ -1960,6 +2293,33 @@ export function mesh_solid_split_plane(vertex_count, buffer, nx, ny, nz, d, oper
|
|
|
1960
2293
|
return v3;
|
|
1961
2294
|
}
|
|
1962
2295
|
|
|
2296
|
+
/**
|
|
2297
|
+
* Trim an OPEN host surface by all closed cutter meshes in one WASM call.
|
|
2298
|
+
*
|
|
2299
|
+
* `packed` layout matches `mesh_boolean_difference_all`: the FIRST mesh is
|
|
2300
|
+
* the open host and every following mesh is a closed cutter volume.
|
|
2301
|
+
* `flags`: `""` or `"trustedInput"`.
|
|
2302
|
+
*
|
|
2303
|
+
* Unlike folding pairwise surface-split subtracts over the cutter list,
|
|
2304
|
+
* every host triangle is cut by ALL relevant cutters at once (one CDT per
|
|
2305
|
+
* triangle) and classified inside-any-cutter — one pass over the host
|
|
2306
|
+
* instead of N passes over an ever-growing, ever-degrading host.
|
|
2307
|
+
* Returns the outside (kept) mesh buffer, or an empty vector on failure.
|
|
2308
|
+
* @param {Float64Array} packed
|
|
2309
|
+
* @param {string} flags
|
|
2310
|
+
* @returns {Float64Array}
|
|
2311
|
+
*/
|
|
2312
|
+
export function mesh_surface_difference_all(packed, flags) {
|
|
2313
|
+
const ptr0 = passArrayF64ToWasm0(packed, wasm.__wbindgen_malloc);
|
|
2314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2315
|
+
const ptr1 = passStringToWasm0(flags, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2317
|
+
const ret = wasm.mesh_surface_difference_all(ptr0, len0, ptr1, len1);
|
|
2318
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2319
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2320
|
+
return v3;
|
|
2321
|
+
}
|
|
2322
|
+
|
|
1963
2323
|
/**
|
|
1964
2324
|
* @param {number} vertex_count_a
|
|
1965
2325
|
* @param {Float64Array} buffer_a
|
|
@@ -2094,6 +2454,74 @@ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
|
|
|
2094
2454
|
return v2;
|
|
2095
2455
|
}
|
|
2096
2456
|
|
|
2457
|
+
/**
|
|
2458
|
+
* Closest point on the surface to (x, y, z).
|
|
2459
|
+
* Returns [u, v, px, py, pz] with u, v normalized to [0,1].
|
|
2460
|
+
* @param {Float64Array} data
|
|
2461
|
+
* @param {number} x
|
|
2462
|
+
* @param {number} y
|
|
2463
|
+
* @param {number} z
|
|
2464
|
+
* @returns {Float64Array}
|
|
2465
|
+
*/
|
|
2466
|
+
export function nurbs_surface_closest_point(data, x, y, z) {
|
|
2467
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2468
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2469
|
+
const ret = wasm.nurbs_surface_closest_point(ptr0, len0, x, y, z);
|
|
2470
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2471
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2472
|
+
return v2;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* Surface curvature at normalized (u, v): [k1, k2, gaussian, mean, nx, ny, nz].
|
|
2477
|
+
* @param {Float64Array} data
|
|
2478
|
+
* @param {number} u
|
|
2479
|
+
* @param {number} v
|
|
2480
|
+
* @returns {Float64Array}
|
|
2481
|
+
*/
|
|
2482
|
+
export function nurbs_surface_curvature(data, u, v) {
|
|
2483
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2484
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2485
|
+
const ret = wasm.nurbs_surface_curvature(ptr0, len0, u, v);
|
|
2486
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2487
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2488
|
+
return v2;
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
/**
|
|
2492
|
+
* Analytic surface derivatives at normalized (u, v) in [0,1]².
|
|
2493
|
+
* Returns 18 floats: [S, Su, Sv, Suu, Suv, Svv] (xyz each), derivatives taken
|
|
2494
|
+
* with respect to the NORMALIZED parameters (chain rule applied).
|
|
2495
|
+
* @param {Float64Array} data
|
|
2496
|
+
* @param {number} u
|
|
2497
|
+
* @param {number} v
|
|
2498
|
+
* @returns {Float64Array}
|
|
2499
|
+
*/
|
|
2500
|
+
export function nurbs_surface_derivatives(data, u, v) {
|
|
2501
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2502
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2503
|
+
const ret = wasm.nurbs_surface_derivatives(ptr0, len0, u, v);
|
|
2504
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2505
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2506
|
+
return v2;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/**
|
|
2510
|
+
* Exact degree elevation by `t` in one direction.
|
|
2511
|
+
* @param {Float64Array} data
|
|
2512
|
+
* @param {boolean} u_dir
|
|
2513
|
+
* @param {number} t
|
|
2514
|
+
* @returns {Float64Array}
|
|
2515
|
+
*/
|
|
2516
|
+
export function nurbs_surface_elevate_degree(data, u_dir, t) {
|
|
2517
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2518
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2519
|
+
const ret = wasm.nurbs_surface_elevate_degree(ptr0, len0, u_dir, t);
|
|
2520
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2521
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2522
|
+
return v2;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2097
2525
|
/**
|
|
2098
2526
|
* Evaluate a NURBS surface at normalized parameters (u, v) in [0,1].
|
|
2099
2527
|
* Returns [x, y, z]
|
|
@@ -2111,6 +2539,77 @@ export function nurbs_surface_evaluate(data, u, v) {
|
|
|
2111
2539
|
return v2;
|
|
2112
2540
|
}
|
|
2113
2541
|
|
|
2542
|
+
/**
|
|
2543
|
+
* Exact sub-patch extraction over normalized ranges.
|
|
2544
|
+
* @param {Float64Array} data
|
|
2545
|
+
* @param {number} u0
|
|
2546
|
+
* @param {number} u1
|
|
2547
|
+
* @param {number} v0
|
|
2548
|
+
* @param {number} v1
|
|
2549
|
+
* @returns {Float64Array}
|
|
2550
|
+
*/
|
|
2551
|
+
export function nurbs_surface_extract_region(data, u0, u1, v0, v1) {
|
|
2552
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2553
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2554
|
+
const ret = wasm.nurbs_surface_extract_region(ptr0, len0, u0, u1, v0, v1);
|
|
2555
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2556
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2557
|
+
return v2;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
/**
|
|
2561
|
+
* Exact extruded (translational) surface from a profile curve.
|
|
2562
|
+
* @param {Float64Array} curve_data
|
|
2563
|
+
* @param {number} dx
|
|
2564
|
+
* @param {number} dy
|
|
2565
|
+
* @param {number} dz
|
|
2566
|
+
* @returns {Float64Array}
|
|
2567
|
+
*/
|
|
2568
|
+
export function nurbs_surface_extrude(curve_data, dx, dy, dz) {
|
|
2569
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
2570
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2571
|
+
const ret = wasm.nurbs_surface_extrude(ptr0, len0, dx, dy, dz);
|
|
2572
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2573
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2574
|
+
return v2;
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
/**
|
|
2578
|
+
* Exact knot insertion at normalized parameter t (repeated `times`).
|
|
2579
|
+
* Returns the refined surface in standard surface format.
|
|
2580
|
+
* @param {Float64Array} data
|
|
2581
|
+
* @param {boolean} u_dir
|
|
2582
|
+
* @param {number} t
|
|
2583
|
+
* @param {number} times
|
|
2584
|
+
* @returns {Float64Array}
|
|
2585
|
+
*/
|
|
2586
|
+
export function nurbs_surface_insert_knot(data, u_dir, t, times) {
|
|
2587
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2588
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2589
|
+
const ret = wasm.nurbs_surface_insert_knot(ptr0, len0, u_dir, t, times);
|
|
2590
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2591
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2592
|
+
return v2;
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
/**
|
|
2596
|
+
* Exact rational iso-parametric curve. `u_dir = true` extracts the curve
|
|
2597
|
+
* running along u at constant v = t; false extracts along v at constant u = t.
|
|
2598
|
+
* t is normalized [0,1]. Returns curve data [degree, n, pts..., w..., knots...].
|
|
2599
|
+
* @param {Float64Array} data
|
|
2600
|
+
* @param {number} t
|
|
2601
|
+
* @param {boolean} u_dir
|
|
2602
|
+
* @returns {Float64Array}
|
|
2603
|
+
*/
|
|
2604
|
+
export function nurbs_surface_iso_curve(data, t, u_dir) {
|
|
2605
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2606
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2607
|
+
const ret = wasm.nurbs_surface_iso_curve(ptr0, len0, t, u_dir);
|
|
2608
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2609
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2610
|
+
return v2;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2114
2613
|
/**
|
|
2115
2614
|
* Evaluate a NURBS surface unit normal at normalized parameters (u, v) in [0,1].
|
|
2116
2615
|
* Returns [x, y, z]
|
|
@@ -2149,6 +2648,81 @@ export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess)
|
|
|
2149
2648
|
return v2;
|
|
2150
2649
|
}
|
|
2151
2650
|
|
|
2651
|
+
/**
|
|
2652
|
+
* Exact rational primitive surfaces.
|
|
2653
|
+
* kind: "cylinder" [bx,by,bz, ax,ay,az, radius, height]
|
|
2654
|
+
* "sphere" [cx,cy,cz, radius]
|
|
2655
|
+
* "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
|
|
2656
|
+
* "torus" [cx,cy,cz, major, minor]
|
|
2657
|
+
* @param {string} kind
|
|
2658
|
+
* @param {Float64Array} params
|
|
2659
|
+
* @returns {Float64Array}
|
|
2660
|
+
*/
|
|
2661
|
+
export function nurbs_surface_primitive(kind, params) {
|
|
2662
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2663
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2664
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
2665
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2666
|
+
const ret = wasm.nurbs_surface_primitive(ptr0, len0, ptr1, len1);
|
|
2667
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2668
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2669
|
+
return v3;
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
/**
|
|
2673
|
+
* Exact surface of revolution from a profile curve (A8.1).
|
|
2674
|
+
* @param {Float64Array} curve_data
|
|
2675
|
+
* @param {number} ox
|
|
2676
|
+
* @param {number} oy
|
|
2677
|
+
* @param {number} oz
|
|
2678
|
+
* @param {number} ax
|
|
2679
|
+
* @param {number} ay
|
|
2680
|
+
* @param {number} az
|
|
2681
|
+
* @param {number} angle
|
|
2682
|
+
* @returns {Float64Array}
|
|
2683
|
+
*/
|
|
2684
|
+
export function nurbs_surface_revolve(curve_data, ox, oy, oz, ax, ay, az, angle) {
|
|
2685
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
2686
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2687
|
+
const ret = wasm.nurbs_surface_revolve(ptr0, len0, ox, oy, oz, ax, ay, az, angle);
|
|
2688
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2689
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2690
|
+
return v2;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
/**
|
|
2694
|
+
* Exact ruled surface between two curves (auto degree/knot compatibility).
|
|
2695
|
+
* @param {Float64Array} curve_a
|
|
2696
|
+
* @param {Float64Array} curve_b
|
|
2697
|
+
* @returns {Float64Array}
|
|
2698
|
+
*/
|
|
2699
|
+
export function nurbs_surface_ruled(curve_a, curve_b) {
|
|
2700
|
+
const ptr0 = passArrayF64ToWasm0(curve_a, wasm.__wbindgen_malloc);
|
|
2701
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2702
|
+
const ptr1 = passArrayF64ToWasm0(curve_b, wasm.__wbindgen_malloc);
|
|
2703
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2704
|
+
const ret = wasm.nurbs_surface_ruled(ptr0, len0, ptr1, len1);
|
|
2705
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2706
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2707
|
+
return v3;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
/**
|
|
2711
|
+
* Exact split at normalized parameter t. Returns [lenA, surfaceA..., lenB, surfaceB...].
|
|
2712
|
+
* @param {Float64Array} data
|
|
2713
|
+
* @param {boolean} u_dir
|
|
2714
|
+
* @param {number} t
|
|
2715
|
+
* @returns {Float64Array}
|
|
2716
|
+
*/
|
|
2717
|
+
export function nurbs_surface_split(data, u_dir, t) {
|
|
2718
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2719
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2720
|
+
const ret = wasm.nurbs_surface_split(ptr0, len0, u_dir, t);
|
|
2721
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2722
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2723
|
+
return v2;
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2152
2726
|
/**
|
|
2153
2727
|
* Intersect two NURBS surfaces.
|
|
2154
2728
|
* Returns polyline buffer.
|
|
@@ -2168,6 +2742,44 @@ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
|
|
|
2168
2742
|
return v3;
|
|
2169
2743
|
}
|
|
2170
2744
|
|
|
2745
|
+
/**
|
|
2746
|
+
* Curvature-adaptive tessellation against a chordal tolerance.
|
|
2747
|
+
* Returns the standard mesh buffer [vertexCount, positions..., indices...].
|
|
2748
|
+
* @param {Float64Array} data
|
|
2749
|
+
* @param {number} tolerance
|
|
2750
|
+
* @param {number} max_segments_per_span
|
|
2751
|
+
* @returns {Float64Array}
|
|
2752
|
+
*/
|
|
2753
|
+
export function nurbs_surface_tessellate_adaptive(data, tolerance, max_segments_per_span) {
|
|
2754
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2755
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2756
|
+
const ret = wasm.nurbs_surface_tessellate_adaptive(ptr0, len0, tolerance, max_segments_per_span);
|
|
2757
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2758
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2759
|
+
return v2;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
/**
|
|
2763
|
+
* Display-ready render tessellation: twist-aware adaptive grid with ANALYTIC
|
|
2764
|
+
* surface normals, plus feature edges only where the surface really has them
|
|
2765
|
+
* (boundaries, kinked C0 knot lines, kinked closed seams).
|
|
2766
|
+
* Output (f32, same packing as `mesh_build_render_buffers`):
|
|
2767
|
+
* [vertexCount, positions..., normals..., edgeSegmentCount, edgeSegments...]
|
|
2768
|
+
* @param {Float64Array} data
|
|
2769
|
+
* @param {number} tolerance
|
|
2770
|
+
* @param {number} max_segments_per_span
|
|
2771
|
+
* @param {number} crease_angle_deg
|
|
2772
|
+
* @returns {Float32Array}
|
|
2773
|
+
*/
|
|
2774
|
+
export function nurbs_surface_tessellate_render(data, tolerance, max_segments_per_span, crease_angle_deg) {
|
|
2775
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2776
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2777
|
+
const ret = wasm.nurbs_surface_tessellate_render(ptr0, len0, tolerance, max_segments_per_span, crease_angle_deg);
|
|
2778
|
+
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
2779
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2780
|
+
return v2;
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2171
2783
|
/**
|
|
2172
2784
|
* Offset a polycurve made of line and arc segments.
|
|
2173
2785
|
* Input format: [segment_count, type, ...data, ...]
|