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/dist/wasm-bindings.js
CHANGED
|
@@ -31,6 +31,307 @@ export function arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_an
|
|
|
31
31
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
32
32
|
return v1;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Parametric BREP boolean: exact surface–surface intersection curves with
|
|
36
|
+
* trimmed-surface output. Both operands must be closed solids.
|
|
37
|
+
* op: "union" | "intersect" | "subtract".
|
|
38
|
+
* Returns the result BREP as JSON, or {"error": "..."} on failure.
|
|
39
|
+
* @param {string} a_json
|
|
40
|
+
* @param {string} b_json
|
|
41
|
+
* @param {string} op
|
|
42
|
+
* @param {number} tolerance
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
export function brep_boolean_op(a_json, b_json, op, tolerance) {
|
|
46
|
+
let deferred4_0;
|
|
47
|
+
let deferred4_1;
|
|
48
|
+
try {
|
|
49
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
50
|
+
const len0 = WASM_VECTOR_LEN;
|
|
51
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
52
|
+
const len1 = WASM_VECTOR_LEN;
|
|
53
|
+
const ptr2 = passStringToWasm0(op, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
|
+
const len2 = WASM_VECTOR_LEN;
|
|
55
|
+
const ret = wasm.brep_boolean_op(ptr0, len0, ptr1, len1, ptr2, len2, tolerance);
|
|
56
|
+
deferred4_0 = ret[0];
|
|
57
|
+
deferred4_1 = ret[1];
|
|
58
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
|
|
66
|
+
* @param {string} json
|
|
67
|
+
* @param {number} tolerance
|
|
68
|
+
* @returns {Float64Array}
|
|
69
|
+
*/
|
|
70
|
+
export function brep_edges(json, tolerance) {
|
|
71
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
72
|
+
const len0 = WASM_VECTOR_LEN;
|
|
73
|
+
const ret = wasm.brep_edges(ptr0, len0, tolerance);
|
|
74
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
75
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
76
|
+
return v2;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Extrude a profile curve into a BREP (closed profile → capped solid,
|
|
80
|
+
* open profile → sheet). Returns JSON.
|
|
81
|
+
* @param {Float64Array} curve_data
|
|
82
|
+
* @param {number} dx
|
|
83
|
+
* @param {number} dy
|
|
84
|
+
* @param {number} dz
|
|
85
|
+
* @param {number} height
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
88
|
+
export function brep_extrude_curve(curve_data, dx, dy, dz, height) {
|
|
89
|
+
let deferred2_0;
|
|
90
|
+
let deferred2_1;
|
|
91
|
+
try {
|
|
92
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
93
|
+
const len0 = WASM_VECTOR_LEN;
|
|
94
|
+
const ret = wasm.brep_extrude_curve(ptr0, len0, dx, dy, dz, height);
|
|
95
|
+
deferred2_0 = ret[0];
|
|
96
|
+
deferred2_1 = ret[1];
|
|
97
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Iso-parametric curve of a NURBS face's backing surface (untrimmed).
|
|
105
|
+
* Returns curve data, or empty for planar faces.
|
|
106
|
+
* @param {string} json
|
|
107
|
+
* @param {number} face_index
|
|
108
|
+
* @param {number} t
|
|
109
|
+
* @param {boolean} u_dir
|
|
110
|
+
* @returns {Float64Array}
|
|
111
|
+
*/
|
|
112
|
+
export function brep_face_iso_curve(json, face_index, t, u_dir) {
|
|
113
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
115
|
+
const ret = wasm.brep_face_iso_curve(ptr0, len0, face_index, t, u_dir);
|
|
116
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
117
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
118
|
+
return v2;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Geometric backing of a face.
|
|
122
|
+
* Returns [0, ox,oy,oz, ux,uy,uz, vx,vy,vz] for planes,
|
|
123
|
+
* or [1, surface_data...] for NURBS faces.
|
|
124
|
+
* @param {string} json
|
|
125
|
+
* @param {number} face_index
|
|
126
|
+
* @returns {Float64Array}
|
|
127
|
+
*/
|
|
128
|
+
export function brep_face_surface(json, face_index) {
|
|
129
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
const ret = wasm.brep_face_surface(ptr0, len0, face_index);
|
|
132
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
133
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
134
|
+
return v2;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Tessellate a single BREP face. Returns the standard mesh buffer.
|
|
138
|
+
* @param {string} json
|
|
139
|
+
* @param {number} face_index
|
|
140
|
+
* @param {number} tolerance
|
|
141
|
+
* @returns {Float64Array}
|
|
142
|
+
*/
|
|
143
|
+
export function brep_face_tessellate(json, face_index, tolerance) {
|
|
144
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
146
|
+
const ret = wasm.brep_face_tessellate(ptr0, len0, face_index, tolerance);
|
|
147
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
148
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
149
|
+
return v2;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* BREP structure summary: [face_count, edge_count, vertex_count, is_closed].
|
|
153
|
+
* @param {string} json
|
|
154
|
+
* @returns {Float64Array}
|
|
155
|
+
*/
|
|
156
|
+
export function brep_info(json) {
|
|
157
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
158
|
+
const len0 = WASM_VECTOR_LEN;
|
|
159
|
+
const ret = wasm.brep_info(ptr0, len0);
|
|
160
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
161
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
162
|
+
return v2;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Loft through profile curves into a BREP.
|
|
166
|
+
* Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
|
|
167
|
+
* @param {Float64Array} data
|
|
168
|
+
* @returns {string}
|
|
169
|
+
*/
|
|
170
|
+
export function brep_loft_curves(data) {
|
|
171
|
+
let deferred2_0;
|
|
172
|
+
let deferred2_1;
|
|
173
|
+
try {
|
|
174
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
175
|
+
const len0 = WASM_VECTOR_LEN;
|
|
176
|
+
const ret = wasm.brep_loft_curves(ptr0, len0);
|
|
177
|
+
deferred2_0 = ret[0];
|
|
178
|
+
deferred2_1 = ret[1];
|
|
179
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* BREP primitives.
|
|
187
|
+
* kind: "box" [minx,miny,minz, maxx,maxy,maxz]
|
|
188
|
+
* "cylinder" [bx,by,bz, ax,ay,az, radius, height]
|
|
189
|
+
* "sphere" [cx,cy,cz, radius]
|
|
190
|
+
* "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
|
|
191
|
+
* "torus" [cx,cy,cz, major, minor]
|
|
192
|
+
* Returns the BREP as JSON ("" on failure).
|
|
193
|
+
* @param {string} kind
|
|
194
|
+
* @param {Float64Array} params
|
|
195
|
+
* @returns {string}
|
|
196
|
+
*/
|
|
197
|
+
export function brep_primitive(kind, params) {
|
|
198
|
+
let deferred3_0;
|
|
199
|
+
let deferred3_1;
|
|
200
|
+
try {
|
|
201
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
202
|
+
const len0 = WASM_VECTOR_LEN;
|
|
203
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
204
|
+
const len1 = WASM_VECTOR_LEN;
|
|
205
|
+
const ret = wasm.brep_primitive(ptr0, len0, ptr1, len1);
|
|
206
|
+
deferred3_0 = ret[0];
|
|
207
|
+
deferred3_1 = ret[1];
|
|
208
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Revolve a profile curve into a BREP. Returns JSON.
|
|
216
|
+
* @param {Float64Array} curve_data
|
|
217
|
+
* @param {number} ox
|
|
218
|
+
* @param {number} oy
|
|
219
|
+
* @param {number} oz
|
|
220
|
+
* @param {number} ax
|
|
221
|
+
* @param {number} ay
|
|
222
|
+
* @param {number} az
|
|
223
|
+
* @param {number} angle
|
|
224
|
+
* @returns {string}
|
|
225
|
+
*/
|
|
226
|
+
export function brep_revolve_curve(curve_data, ox, oy, oz, ax, ay, az, angle) {
|
|
227
|
+
let deferred2_0;
|
|
228
|
+
let deferred2_1;
|
|
229
|
+
try {
|
|
230
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
232
|
+
const ret = wasm.brep_revolve_curve(ptr0, len0, ox, oy, oz, ax, ay, az, angle);
|
|
233
|
+
deferred2_0 = ret[0];
|
|
234
|
+
deferred2_1 = ret[1];
|
|
235
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Untrimmed sheet BREP from a NURBS surface. Returns JSON.
|
|
243
|
+
* @param {Float64Array} surface_data
|
|
244
|
+
* @returns {string}
|
|
245
|
+
*/
|
|
246
|
+
export function brep_sheet_from_surface(surface_data) {
|
|
247
|
+
let deferred2_0;
|
|
248
|
+
let deferred2_1;
|
|
249
|
+
try {
|
|
250
|
+
const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
|
|
251
|
+
const len0 = WASM_VECTOR_LEN;
|
|
252
|
+
const ret = wasm.brep_sheet_from_surface(ptr0, len0);
|
|
253
|
+
deferred2_0 = ret[0];
|
|
254
|
+
deferred2_1 = ret[1];
|
|
255
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Tessellate a BREP into the standard mesh buffer
|
|
263
|
+
* [vertexCount, positions..., indices...]. Crack-free across shared edges.
|
|
264
|
+
* @param {string} json
|
|
265
|
+
* @param {number} tolerance
|
|
266
|
+
* @returns {Float64Array}
|
|
267
|
+
*/
|
|
268
|
+
export function brep_tessellate(json, tolerance) {
|
|
269
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ret = wasm.brep_tessellate(ptr0, len0, tolerance);
|
|
272
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
273
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
274
|
+
return v2;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Apply a row-major 4x4 matrix to a BREP. Returns transformed JSON.
|
|
278
|
+
* @param {string} json
|
|
279
|
+
* @param {Float64Array} matrix
|
|
280
|
+
* @returns {string}
|
|
281
|
+
*/
|
|
282
|
+
export function brep_transform(json, matrix) {
|
|
283
|
+
let deferred3_0;
|
|
284
|
+
let deferred3_1;
|
|
285
|
+
try {
|
|
286
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
|
|
289
|
+
const len1 = WASM_VECTOR_LEN;
|
|
290
|
+
const ret = wasm.brep_transform(ptr0, len0, ptr1, len1);
|
|
291
|
+
deferred3_0 = ret[0];
|
|
292
|
+
deferred3_1 = ret[1];
|
|
293
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Validate a BREP. Returns a JSON report:
|
|
301
|
+
* {"isClosed":bool,"boundaryEdgeCount":n,"maxCoherenceError":e,"issues":[...]}
|
|
302
|
+
* @param {string} json
|
|
303
|
+
* @param {number} tolerance
|
|
304
|
+
* @returns {string}
|
|
305
|
+
*/
|
|
306
|
+
export function brep_validate(json, tolerance) {
|
|
307
|
+
let deferred2_0;
|
|
308
|
+
let deferred2_1;
|
|
309
|
+
try {
|
|
310
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
312
|
+
const ret = wasm.brep_validate(ptr0, len0, tolerance);
|
|
313
|
+
deferred2_0 = ret[0];
|
|
314
|
+
deferred2_1 = ret[1];
|
|
315
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Volume and surface area from tessellation: [volume, area].
|
|
323
|
+
* @param {string} json
|
|
324
|
+
* @param {number} tolerance
|
|
325
|
+
* @returns {Float64Array}
|
|
326
|
+
*/
|
|
327
|
+
export function brep_volume_area(json, tolerance) {
|
|
328
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
329
|
+
const len0 = WASM_VECTOR_LEN;
|
|
330
|
+
const ret = wasm.brep_volume_area(ptr0, len0, tolerance);
|
|
331
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
332
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
333
|
+
return v2;
|
|
334
|
+
}
|
|
34
335
|
/**
|
|
35
336
|
* Build a NURBS curve from raw control points with kernel-managed knots and weights.
|
|
36
337
|
*
|
|
@@ -1192,6 +1493,30 @@ export function mesh_chamfer_all_edges(mesh_type, params, offset) {
|
|
|
1192
1493
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1193
1494
|
return v3;
|
|
1194
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Clip a polyline against a closed mesh volume (boolean intersection for curves).
|
|
1498
|
+
*
|
|
1499
|
+
* `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
|
|
1500
|
+
* (no duplicated seam point required, one is tolerated).
|
|
1501
|
+
* Returns two concatenated polyline buffers — inside pieces first, then
|
|
1502
|
+
* outside pieces — each encoded as [num_polylines, n1, x,y,z,..., ...].
|
|
1503
|
+
* Returns an empty buffer on failure (open cutter, degenerate polyline).
|
|
1504
|
+
* @param {number} vertex_count
|
|
1505
|
+
* @param {Float64Array} buffer
|
|
1506
|
+
* @param {Float64Array} points
|
|
1507
|
+
* @param {boolean} closed
|
|
1508
|
+
* @returns {Float64Array}
|
|
1509
|
+
*/
|
|
1510
|
+
export function mesh_clip_polyline(vertex_count, buffer, points, closed) {
|
|
1511
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
1512
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1513
|
+
const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
1514
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1515
|
+
const ret = wasm.mesh_clip_polyline(vertex_count, ptr0, len0, ptr1, len1, closed);
|
|
1516
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1517
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1518
|
+
return v3;
|
|
1519
|
+
}
|
|
1195
1520
|
/**
|
|
1196
1521
|
* Compute planar curve normal from ordered points.
|
|
1197
1522
|
* @param {Float64Array} coords
|
|
@@ -1885,6 +2210,32 @@ export function mesh_solid_split_plane(vertex_count, buffer, nx, ny, nz, d, oper
|
|
|
1885
2210
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1886
2211
|
return v3;
|
|
1887
2212
|
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Trim an OPEN host surface by all closed cutter meshes in one WASM call.
|
|
2215
|
+
*
|
|
2216
|
+
* `packed` layout matches `mesh_boolean_difference_all`: the FIRST mesh is
|
|
2217
|
+
* the open host and every following mesh is a closed cutter volume.
|
|
2218
|
+
* `flags`: `""` or `"trustedInput"`.
|
|
2219
|
+
*
|
|
2220
|
+
* Unlike folding pairwise surface-split subtracts over the cutter list,
|
|
2221
|
+
* every host triangle is cut by ALL relevant cutters at once (one CDT per
|
|
2222
|
+
* triangle) and classified inside-any-cutter — one pass over the host
|
|
2223
|
+
* instead of N passes over an ever-growing, ever-degrading host.
|
|
2224
|
+
* Returns the outside (kept) mesh buffer, or an empty vector on failure.
|
|
2225
|
+
* @param {Float64Array} packed
|
|
2226
|
+
* @param {string} flags
|
|
2227
|
+
* @returns {Float64Array}
|
|
2228
|
+
*/
|
|
2229
|
+
export function mesh_surface_difference_all(packed, flags) {
|
|
2230
|
+
const ptr0 = passArrayF64ToWasm0(packed, wasm.__wbindgen_malloc);
|
|
2231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2232
|
+
const ptr1 = passStringToWasm0(flags, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2233
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2234
|
+
const ret = wasm.mesh_surface_difference_all(ptr0, len0, ptr1, len1);
|
|
2235
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2236
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2237
|
+
return v3;
|
|
2238
|
+
}
|
|
1888
2239
|
/**
|
|
1889
2240
|
* @param {number} vertex_count_a
|
|
1890
2241
|
* @param {Float64Array} buffer_a
|
|
@@ -2012,6 +2363,70 @@ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
|
|
|
2012
2363
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2013
2364
|
return v2;
|
|
2014
2365
|
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Closest point on the surface to (x, y, z).
|
|
2368
|
+
* Returns [u, v, px, py, pz] with u, v normalized to [0,1].
|
|
2369
|
+
* @param {Float64Array} data
|
|
2370
|
+
* @param {number} x
|
|
2371
|
+
* @param {number} y
|
|
2372
|
+
* @param {number} z
|
|
2373
|
+
* @returns {Float64Array}
|
|
2374
|
+
*/
|
|
2375
|
+
export function nurbs_surface_closest_point(data, x, y, z) {
|
|
2376
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2377
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2378
|
+
const ret = wasm.nurbs_surface_closest_point(ptr0, len0, x, y, z);
|
|
2379
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2380
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2381
|
+
return v2;
|
|
2382
|
+
}
|
|
2383
|
+
/**
|
|
2384
|
+
* Surface curvature at normalized (u, v): [k1, k2, gaussian, mean, nx, ny, nz].
|
|
2385
|
+
* @param {Float64Array} data
|
|
2386
|
+
* @param {number} u
|
|
2387
|
+
* @param {number} v
|
|
2388
|
+
* @returns {Float64Array}
|
|
2389
|
+
*/
|
|
2390
|
+
export function nurbs_surface_curvature(data, u, v) {
|
|
2391
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2392
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2393
|
+
const ret = wasm.nurbs_surface_curvature(ptr0, len0, u, v);
|
|
2394
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2395
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2396
|
+
return v2;
|
|
2397
|
+
}
|
|
2398
|
+
/**
|
|
2399
|
+
* Analytic surface derivatives at normalized (u, v) in [0,1]².
|
|
2400
|
+
* Returns 18 floats: [S, Su, Sv, Suu, Suv, Svv] (xyz each), derivatives taken
|
|
2401
|
+
* with respect to the NORMALIZED parameters (chain rule applied).
|
|
2402
|
+
* @param {Float64Array} data
|
|
2403
|
+
* @param {number} u
|
|
2404
|
+
* @param {number} v
|
|
2405
|
+
* @returns {Float64Array}
|
|
2406
|
+
*/
|
|
2407
|
+
export function nurbs_surface_derivatives(data, u, v) {
|
|
2408
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2409
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2410
|
+
const ret = wasm.nurbs_surface_derivatives(ptr0, len0, u, v);
|
|
2411
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2412
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2413
|
+
return v2;
|
|
2414
|
+
}
|
|
2415
|
+
/**
|
|
2416
|
+
* Exact degree elevation by `t` in one direction.
|
|
2417
|
+
* @param {Float64Array} data
|
|
2418
|
+
* @param {boolean} u_dir
|
|
2419
|
+
* @param {number} t
|
|
2420
|
+
* @returns {Float64Array}
|
|
2421
|
+
*/
|
|
2422
|
+
export function nurbs_surface_elevate_degree(data, u_dir, t) {
|
|
2423
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2424
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2425
|
+
const ret = wasm.nurbs_surface_elevate_degree(ptr0, len0, u_dir, t);
|
|
2426
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2427
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2428
|
+
return v2;
|
|
2429
|
+
}
|
|
2015
2430
|
/**
|
|
2016
2431
|
* Evaluate a NURBS surface at normalized parameters (u, v) in [0,1].
|
|
2017
2432
|
* Returns [x, y, z]
|
|
@@ -2028,6 +2443,73 @@ export function nurbs_surface_evaluate(data, u, v) {
|
|
|
2028
2443
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2029
2444
|
return v2;
|
|
2030
2445
|
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Exact sub-patch extraction over normalized ranges.
|
|
2448
|
+
* @param {Float64Array} data
|
|
2449
|
+
* @param {number} u0
|
|
2450
|
+
* @param {number} u1
|
|
2451
|
+
* @param {number} v0
|
|
2452
|
+
* @param {number} v1
|
|
2453
|
+
* @returns {Float64Array}
|
|
2454
|
+
*/
|
|
2455
|
+
export function nurbs_surface_extract_region(data, u0, u1, v0, v1) {
|
|
2456
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2457
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2458
|
+
const ret = wasm.nurbs_surface_extract_region(ptr0, len0, u0, u1, v0, v1);
|
|
2459
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2460
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2461
|
+
return v2;
|
|
2462
|
+
}
|
|
2463
|
+
/**
|
|
2464
|
+
* Exact extruded (translational) surface from a profile curve.
|
|
2465
|
+
* @param {Float64Array} curve_data
|
|
2466
|
+
* @param {number} dx
|
|
2467
|
+
* @param {number} dy
|
|
2468
|
+
* @param {number} dz
|
|
2469
|
+
* @returns {Float64Array}
|
|
2470
|
+
*/
|
|
2471
|
+
export function nurbs_surface_extrude(curve_data, dx, dy, dz) {
|
|
2472
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
2473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2474
|
+
const ret = wasm.nurbs_surface_extrude(ptr0, len0, dx, dy, dz);
|
|
2475
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2476
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2477
|
+
return v2;
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Exact knot insertion at normalized parameter t (repeated `times`).
|
|
2481
|
+
* Returns the refined surface in standard surface format.
|
|
2482
|
+
* @param {Float64Array} data
|
|
2483
|
+
* @param {boolean} u_dir
|
|
2484
|
+
* @param {number} t
|
|
2485
|
+
* @param {number} times
|
|
2486
|
+
* @returns {Float64Array}
|
|
2487
|
+
*/
|
|
2488
|
+
export function nurbs_surface_insert_knot(data, u_dir, t, times) {
|
|
2489
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2491
|
+
const ret = wasm.nurbs_surface_insert_knot(ptr0, len0, u_dir, t, times);
|
|
2492
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2493
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2494
|
+
return v2;
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Exact rational iso-parametric curve. `u_dir = true` extracts the curve
|
|
2498
|
+
* running along u at constant v = t; false extracts along v at constant u = t.
|
|
2499
|
+
* t is normalized [0,1]. Returns curve data [degree, n, pts..., w..., knots...].
|
|
2500
|
+
* @param {Float64Array} data
|
|
2501
|
+
* @param {number} t
|
|
2502
|
+
* @param {boolean} u_dir
|
|
2503
|
+
* @returns {Float64Array}
|
|
2504
|
+
*/
|
|
2505
|
+
export function nurbs_surface_iso_curve(data, t, u_dir) {
|
|
2506
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2507
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2508
|
+
const ret = wasm.nurbs_surface_iso_curve(ptr0, len0, t, u_dir);
|
|
2509
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2510
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2511
|
+
return v2;
|
|
2512
|
+
}
|
|
2031
2513
|
/**
|
|
2032
2514
|
* Evaluate a NURBS surface unit normal at normalized parameters (u, v) in [0,1].
|
|
2033
2515
|
* Returns [x, y, z]
|
|
@@ -2064,6 +2546,77 @@ export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess)
|
|
|
2064
2546
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2065
2547
|
return v2;
|
|
2066
2548
|
}
|
|
2549
|
+
/**
|
|
2550
|
+
* Exact rational primitive surfaces.
|
|
2551
|
+
* kind: "cylinder" [bx,by,bz, ax,ay,az, radius, height]
|
|
2552
|
+
* "sphere" [cx,cy,cz, radius]
|
|
2553
|
+
* "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
|
|
2554
|
+
* "torus" [cx,cy,cz, major, minor]
|
|
2555
|
+
* @param {string} kind
|
|
2556
|
+
* @param {Float64Array} params
|
|
2557
|
+
* @returns {Float64Array}
|
|
2558
|
+
*/
|
|
2559
|
+
export function nurbs_surface_primitive(kind, params) {
|
|
2560
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2561
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2562
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
2563
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2564
|
+
const ret = wasm.nurbs_surface_primitive(ptr0, len0, ptr1, len1);
|
|
2565
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2566
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2567
|
+
return v3;
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Exact surface of revolution from a profile curve (A8.1).
|
|
2571
|
+
* @param {Float64Array} curve_data
|
|
2572
|
+
* @param {number} ox
|
|
2573
|
+
* @param {number} oy
|
|
2574
|
+
* @param {number} oz
|
|
2575
|
+
* @param {number} ax
|
|
2576
|
+
* @param {number} ay
|
|
2577
|
+
* @param {number} az
|
|
2578
|
+
* @param {number} angle
|
|
2579
|
+
* @returns {Float64Array}
|
|
2580
|
+
*/
|
|
2581
|
+
export function nurbs_surface_revolve(curve_data, ox, oy, oz, ax, ay, az, angle) {
|
|
2582
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
2583
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2584
|
+
const ret = wasm.nurbs_surface_revolve(ptr0, len0, ox, oy, oz, ax, ay, az, angle);
|
|
2585
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2586
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2587
|
+
return v2;
|
|
2588
|
+
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Exact ruled surface between two curves (auto degree/knot compatibility).
|
|
2591
|
+
* @param {Float64Array} curve_a
|
|
2592
|
+
* @param {Float64Array} curve_b
|
|
2593
|
+
* @returns {Float64Array}
|
|
2594
|
+
*/
|
|
2595
|
+
export function nurbs_surface_ruled(curve_a, curve_b) {
|
|
2596
|
+
const ptr0 = passArrayF64ToWasm0(curve_a, wasm.__wbindgen_malloc);
|
|
2597
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2598
|
+
const ptr1 = passArrayF64ToWasm0(curve_b, wasm.__wbindgen_malloc);
|
|
2599
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2600
|
+
const ret = wasm.nurbs_surface_ruled(ptr0, len0, ptr1, len1);
|
|
2601
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2602
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2603
|
+
return v3;
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Exact split at normalized parameter t. Returns [lenA, surfaceA..., lenB, surfaceB...].
|
|
2607
|
+
* @param {Float64Array} data
|
|
2608
|
+
* @param {boolean} u_dir
|
|
2609
|
+
* @param {number} t
|
|
2610
|
+
* @returns {Float64Array}
|
|
2611
|
+
*/
|
|
2612
|
+
export function nurbs_surface_split(data, u_dir, t) {
|
|
2613
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2614
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2615
|
+
const ret = wasm.nurbs_surface_split(ptr0, len0, u_dir, t);
|
|
2616
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2617
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2618
|
+
return v2;
|
|
2619
|
+
}
|
|
2067
2620
|
/**
|
|
2068
2621
|
* Intersect two NURBS surfaces.
|
|
2069
2622
|
* Returns polyline buffer.
|
|
@@ -2082,6 +2635,42 @@ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
|
|
|
2082
2635
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2083
2636
|
return v3;
|
|
2084
2637
|
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Curvature-adaptive tessellation against a chordal tolerance.
|
|
2640
|
+
* Returns the standard mesh buffer [vertexCount, positions..., indices...].
|
|
2641
|
+
* @param {Float64Array} data
|
|
2642
|
+
* @param {number} tolerance
|
|
2643
|
+
* @param {number} max_segments_per_span
|
|
2644
|
+
* @returns {Float64Array}
|
|
2645
|
+
*/
|
|
2646
|
+
export function nurbs_surface_tessellate_adaptive(data, tolerance, max_segments_per_span) {
|
|
2647
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2648
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2649
|
+
const ret = wasm.nurbs_surface_tessellate_adaptive(ptr0, len0, tolerance, max_segments_per_span);
|
|
2650
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2651
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2652
|
+
return v2;
|
|
2653
|
+
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Display-ready render tessellation: twist-aware adaptive grid with ANALYTIC
|
|
2656
|
+
* surface normals, plus feature edges only where the surface really has them
|
|
2657
|
+
* (boundaries, kinked C0 knot lines, kinked closed seams).
|
|
2658
|
+
* Output (f32, same packing as `mesh_build_render_buffers`):
|
|
2659
|
+
* [vertexCount, positions..., normals..., edgeSegmentCount, edgeSegments...]
|
|
2660
|
+
* @param {Float64Array} data
|
|
2661
|
+
* @param {number} tolerance
|
|
2662
|
+
* @param {number} max_segments_per_span
|
|
2663
|
+
* @param {number} crease_angle_deg
|
|
2664
|
+
* @returns {Float32Array}
|
|
2665
|
+
*/
|
|
2666
|
+
export function nurbs_surface_tessellate_render(data, tolerance, max_segments_per_span, crease_angle_deg) {
|
|
2667
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
2668
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2669
|
+
const ret = wasm.nurbs_surface_tessellate_render(ptr0, len0, tolerance, max_segments_per_span, crease_angle_deg);
|
|
2670
|
+
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
2671
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
2672
|
+
return v2;
|
|
2673
|
+
}
|
|
2085
2674
|
/**
|
|
2086
2675
|
* Offset a polycurve made of line and arc segments.
|
|
2087
2676
|
* Input format: [segment_count, type, ...data, ...]
|