okgeometry-api 1.14.0 → 1.16.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 +83 -0
- package/dist/Brep.d.ts.map +1 -1
- package/dist/Brep.js +148 -0
- package/dist/Brep.js.map +1 -1
- package/dist/Mesh.d.ts +69 -0
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +145 -0
- package/dist/Mesh.js.map +1 -1
- package/dist/NurbsCurve.d.ts +78 -0
- package/dist/NurbsCurve.d.ts.map +1 -1
- package/dist/NurbsCurve.js +118 -0
- package/dist/NurbsCurve.js.map +1 -1
- package/dist/NurbsSurface.d.ts +23 -0
- package/dist/NurbsSurface.d.ts.map +1 -1
- package/dist/NurbsSurface.js +40 -0
- package/dist/NurbsSurface.js.map +1 -1
- package/dist/Polyline.d.ts +47 -0
- package/dist/Polyline.d.ts.map +1 -1
- package/dist/Polyline.js +45 -0
- package/dist/Polyline.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 +228 -0
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +336 -0
- package/dist/wasm-bindings.js.map +1 -1
- package/package.json +5 -3
- package/src/Brep.ts +164 -0
- package/src/Mesh.ts +173 -0
- package/src/NurbsCurve.ts +129 -0
- package/src/NurbsSurface.ts +41 -0
- package/src/Polyline.ts +145 -95
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings.d.ts +204 -0
- package/src/wasm-bindings.js +348 -0
package/src/wasm-bindings.js
CHANGED
|
@@ -64,6 +64,32 @@ export function brep_boolean_op(a_json, b_json, op, tolerance) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Boolean-intersection clip of an exact NURBS curve against a CLOSED solid
|
|
69
|
+
* BREP: the curve is split exactly (knot insertion) at every boundary
|
|
70
|
+
* crossing and each piece is classified by containment. Every returned
|
|
71
|
+
* piece lies exactly on the input curve; closed curves merge the run
|
|
72
|
+
* spanning the parameter seam (same convention as `mesh_clip_polyline`).
|
|
73
|
+
*
|
|
74
|
+
* Packing: `[insideCount, (bufLen, curveData…)·insideCount,
|
|
75
|
+
* outsideCount, (bufLen, curveData…)·outsideCount]` — two concatenated
|
|
76
|
+
* multi-curve packings, inside pieces first. Returns an empty buffer on
|
|
77
|
+
* failure (malformed input, or a BREP that is not a closed solid).
|
|
78
|
+
* @param {Float64Array} curve_data
|
|
79
|
+
* @param {string} brep_json
|
|
80
|
+
* @returns {Float64Array}
|
|
81
|
+
*/
|
|
82
|
+
export function brep_clip_curve_op(curve_data, brep_json) {
|
|
83
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
84
|
+
const len0 = WASM_VECTOR_LEN;
|
|
85
|
+
const ptr1 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
86
|
+
const len1 = WASM_VECTOR_LEN;
|
|
87
|
+
const ret = wasm.brep_clip_curve_op(ptr0, len0, ptr1, len1);
|
|
88
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
89
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
90
|
+
return v3;
|
|
91
|
+
}
|
|
92
|
+
|
|
67
93
|
/**
|
|
68
94
|
* Closest BREP face to a 3D point. Returns [faceIndex, u, v, distance,
|
|
69
95
|
* isNurbs] ((u, v) in the surface's KNOT domain) or empty on failure.
|
|
@@ -82,6 +108,34 @@ export function brep_closest_face(json, x, y, z) {
|
|
|
82
108
|
return v2;
|
|
83
109
|
}
|
|
84
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Find all points where a NURBS curve pierces a BREP's faces: per face, the
|
|
113
|
+
* curve is intersected with the EXACT surface and kept only when the hit
|
|
114
|
+
* lies INSIDE the face's trimmed region; crossings on shared edges are
|
|
115
|
+
* deduplicated (smallest face index kept).
|
|
116
|
+
*
|
|
117
|
+
* `curve_data` is the standard NURBS curve encoding. Hits are sorted by
|
|
118
|
+
* curve parameter (normalized [0, 1]); (u, v) are in the face's OWN
|
|
119
|
+
* parameter space (knot domain for NURBS faces, plane-frame coordinates for
|
|
120
|
+
* planar faces).
|
|
121
|
+
*
|
|
122
|
+
* Packing: `[count, (x, y, z, curveParam, faceIndex, u, v)·count]`.
|
|
123
|
+
* Returns an empty buffer on malformed input.
|
|
124
|
+
* @param {string} brep_json
|
|
125
|
+
* @param {Float64Array} curve_data
|
|
126
|
+
* @returns {Float64Array}
|
|
127
|
+
*/
|
|
128
|
+
export function brep_curve_intersection_op(brep_json, curve_data) {
|
|
129
|
+
const ptr0 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
const ptr1 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
132
|
+
const len1 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.brep_curve_intersection_op(ptr0, len0, ptr1, len1);
|
|
134
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
135
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
136
|
+
return v3;
|
|
137
|
+
}
|
|
138
|
+
|
|
85
139
|
/**
|
|
86
140
|
* All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
|
|
87
141
|
* @param {string} json
|
|
@@ -365,6 +419,66 @@ export function brep_info(json) {
|
|
|
365
419
|
return v2;
|
|
366
420
|
}
|
|
367
421
|
|
|
422
|
+
/**
|
|
423
|
+
* [`brep_intersection_curves_op`] with the per-face-pair pieces JOINED into
|
|
424
|
+
* maximal curves: greedy reversal-aware endpoint chaining, exact degree
|
|
425
|
+
* elevation to the chain maximum, exact `join_arcs` knot concatenation
|
|
426
|
+
* (junction multiplicity = degree, no re-parameterization), and a per-curve
|
|
427
|
+
* verification gate (dense samples within 5·tolerance of BOTH operands'
|
|
428
|
+
* surfaces — a chain failing the gate comes back unjoined, never corrupted).
|
|
429
|
+
* A closed intersection loop (e.g. plane through a cylinder) comes back as
|
|
430
|
+
* ONE closed curve.
|
|
431
|
+
*
|
|
432
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (standard NURBS
|
|
433
|
+
* curve encoding). Returns an EMPTY buffer on failure (invalid BREP JSON or
|
|
434
|
+
* a pipeline error) — distinguishable from `[0]`, which means the operands
|
|
435
|
+
* genuinely do not intersect.
|
|
436
|
+
* @param {string} a_json
|
|
437
|
+
* @param {string} b_json
|
|
438
|
+
* @param {number} tolerance
|
|
439
|
+
* @returns {Float64Array}
|
|
440
|
+
*/
|
|
441
|
+
export function brep_intersection_curves_joined_op(a_json, b_json, tolerance) {
|
|
442
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
443
|
+
const len0 = WASM_VECTOR_LEN;
|
|
444
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
445
|
+
const len1 = WASM_VECTOR_LEN;
|
|
446
|
+
const ret = wasm.brep_intersection_curves_joined_op(ptr0, len0, ptr1, len1, tolerance);
|
|
447
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
448
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
449
|
+
return v3;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* TRIM-EXACT intersection curves between two BREPs (solids OR sheets): the
|
|
454
|
+
* parametric boolean's SSI → clip → convergence stages run and the fitted 3D
|
|
455
|
+
* intersection edges come back WITHOUT classification/assembly.
|
|
456
|
+
*
|
|
457
|
+
* A closed intersection loop may come back as several contiguous pieces
|
|
458
|
+
* (split at surface seams and face-boundary crossings); the pieces chain
|
|
459
|
+
* end-to-end exactly. Coincident (overlapping) face pairs contribute no
|
|
460
|
+
* curves.
|
|
461
|
+
*
|
|
462
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (standard NURBS
|
|
463
|
+
* curve encoding). Returns an EMPTY buffer on failure (invalid BREP JSON or
|
|
464
|
+
* a pipeline error) — distinguishable from `[0]`, which means the operands
|
|
465
|
+
* genuinely do not intersect.
|
|
466
|
+
* @param {string} a_json
|
|
467
|
+
* @param {string} b_json
|
|
468
|
+
* @param {number} tolerance
|
|
469
|
+
* @returns {Float64Array}
|
|
470
|
+
*/
|
|
471
|
+
export function brep_intersection_curves_op(a_json, b_json, tolerance) {
|
|
472
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
474
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
475
|
+
const len1 = WASM_VECTOR_LEN;
|
|
476
|
+
const ret = wasm.brep_intersection_curves_op(ptr0, len0, ptr1, len1, tolerance);
|
|
477
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
478
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
479
|
+
return v3;
|
|
480
|
+
}
|
|
481
|
+
|
|
368
482
|
/**
|
|
369
483
|
* Loft through profile curves into a BREP.
|
|
370
484
|
* Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
|
|
@@ -386,6 +500,33 @@ export function brep_loft_curves(data) {
|
|
|
386
500
|
}
|
|
387
501
|
}
|
|
388
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Intersection curves between a BREP and a triangle mesh.
|
|
505
|
+
*
|
|
506
|
+
* TESSELLATION-BASED (documented approximation): the BREP is tessellated at
|
|
507
|
+
* `tolerance` (pass `<= 0` for the deterministic auto display tolerance)
|
|
508
|
+
* and intersected with the mesh via BVH-pruned tri-tri crossing + chaining.
|
|
509
|
+
*
|
|
510
|
+
* Mesh input is the standard `[vertexCount, positions..., indices...]`
|
|
511
|
+
* buffer. Returns the standard polyline group packing
|
|
512
|
+
* `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]`; empty on failure.
|
|
513
|
+
* @param {string} brep_json
|
|
514
|
+
* @param {number} vertex_count
|
|
515
|
+
* @param {Float64Array} mesh_buffer
|
|
516
|
+
* @param {number} tolerance
|
|
517
|
+
* @returns {Float64Array}
|
|
518
|
+
*/
|
|
519
|
+
export function brep_mesh_intersection_curves_op(brep_json, vertex_count, mesh_buffer, tolerance) {
|
|
520
|
+
const ptr0 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
521
|
+
const len0 = WASM_VECTOR_LEN;
|
|
522
|
+
const ptr1 = passArrayF64ToWasm0(mesh_buffer, wasm.__wbindgen_malloc);
|
|
523
|
+
const len1 = WASM_VECTOR_LEN;
|
|
524
|
+
const ret = wasm.brep_mesh_intersection_curves_op(ptr0, len0, vertex_count, ptr1, len1, tolerance);
|
|
525
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
526
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
527
|
+
return v3;
|
|
528
|
+
}
|
|
529
|
+
|
|
389
530
|
/**
|
|
390
531
|
* BREP primitives.
|
|
391
532
|
* kind: "box" [minx,miny,minz, maxx,maxy,maxz]
|
|
@@ -1807,6 +1948,36 @@ export function mesh_clip_polyline(vertex_count, buffer, points, closed) {
|
|
|
1807
1948
|
return v3;
|
|
1808
1949
|
}
|
|
1809
1950
|
|
|
1951
|
+
/**
|
|
1952
|
+
* Clip a polyline by an OPEN oriented sheet: split it at every sheet
|
|
1953
|
+
* crossing and classify each piece by the SIGNED SIDE of the sheet. This is
|
|
1954
|
+
* side classification, NOT containment (unlike `mesh_clip_polyline`, which
|
|
1955
|
+
* requires a closed volume): pieces far from the sheet still classify by
|
|
1956
|
+
* the nearest facet's normal. `inside` = the positive side, in FRONT of the
|
|
1957
|
+
* sheet normal; `outside` = behind it. The sheet may be any non-empty
|
|
1958
|
+
* triangle mesh, open or closed; its stored winding defines the normals.
|
|
1959
|
+
*
|
|
1960
|
+
* Returns two concatenated polyline buffers — inside pieces first, then
|
|
1961
|
+
* outside pieces — each encoded as `[num_polylines, n1, x,y,z,..., ...]`
|
|
1962
|
+
* (identical packing to `mesh_clip_polyline`). Returns an empty buffer on
|
|
1963
|
+
* failure (degenerate polyline/sheet).
|
|
1964
|
+
* @param {number} vertex_count
|
|
1965
|
+
* @param {Float64Array} buffer
|
|
1966
|
+
* @param {Float64Array} points
|
|
1967
|
+
* @param {boolean} closed
|
|
1968
|
+
* @returns {Float64Array}
|
|
1969
|
+
*/
|
|
1970
|
+
export function mesh_clip_polyline_by_sheet(vertex_count, buffer, points, closed) {
|
|
1971
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
1972
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1973
|
+
const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
1974
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1975
|
+
const ret = wasm.mesh_clip_polyline_by_sheet(vertex_count, ptr0, len0, ptr1, len1, closed);
|
|
1976
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1977
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1978
|
+
return v3;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1810
1981
|
/**
|
|
1811
1982
|
* Compute planar curve normal from ordered points.
|
|
1812
1983
|
* @param {Float64Array} coords
|
|
@@ -2472,6 +2643,36 @@ export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
|
|
|
2472
2643
|
return v2;
|
|
2473
2644
|
}
|
|
2474
2645
|
|
|
2646
|
+
/**
|
|
2647
|
+
* Compute all transversal crossing points of a polyline with a triangle
|
|
2648
|
+
* mesh. Works on OPEN meshes (sheets) — the mesh is NOT required to be a
|
|
2649
|
+
* closed volume, unlike `mesh_clip_polyline`.
|
|
2650
|
+
*
|
|
2651
|
+
* `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
|
|
2652
|
+
* (segment `i` runs `points[i] → points[(i+1) % n]`; open polylines have
|
|
2653
|
+
* n−1 segments, closed ones n).
|
|
2654
|
+
*
|
|
2655
|
+
* Packing: `[count, (x, y, z, segmentIndex, segmentT, triangleIndex)·count]`,
|
|
2656
|
+
* sorted by (segmentIndex, segmentT). Shared-edge/vertex crossings dedupe to
|
|
2657
|
+
* one hit (smallest triangle index kept); coplanar sliding overlaps yield no
|
|
2658
|
+
* hits. Returns an empty buffer on failure (degenerate polyline/mesh).
|
|
2659
|
+
* @param {number} vertex_count
|
|
2660
|
+
* @param {Float64Array} buffer
|
|
2661
|
+
* @param {Float64Array} points
|
|
2662
|
+
* @param {boolean} closed
|
|
2663
|
+
* @returns {Float64Array}
|
|
2664
|
+
*/
|
|
2665
|
+
export function mesh_polyline_intersection_points(vertex_count, buffer, points, closed) {
|
|
2666
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
2667
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2668
|
+
const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
2669
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2670
|
+
const ret = wasm.mesh_polyline_intersection_points(vertex_count, ptr0, len0, ptr1, len1, closed);
|
|
2671
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2672
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2673
|
+
return v3;
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2475
2676
|
/**
|
|
2476
2677
|
* Shift closed boolean cutter curve and adjust height.
|
|
2477
2678
|
* Returns [height, epsilon, pointCount, x,y,z,...]
|
|
@@ -2676,6 +2877,34 @@ export function mesh_split_by_surface_to_brep(vertex_count, buffer, surface_data
|
|
|
2676
2877
|
}
|
|
2677
2878
|
}
|
|
2678
2879
|
|
|
2880
|
+
/**
|
|
2881
|
+
* Intersect a polyline with a triangle mesh (open sheets allowed) and split
|
|
2882
|
+
* it into pieces at every crossing. Hit points become the shared endpoints
|
|
2883
|
+
* of adjacent pieces; a closed loop is opened at the first hit (N hits → N
|
|
2884
|
+
* pieces), an open polyline yields N + 1 pieces. With no crossings the
|
|
2885
|
+
* original polyline comes back as one piece.
|
|
2886
|
+
*
|
|
2887
|
+
* Packing: a single flat polyline-group buffer
|
|
2888
|
+
* `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]` (same group encoding as
|
|
2889
|
+
* `mesh_clip_polyline`, but ONE list — pieces are not classified). Returns
|
|
2890
|
+
* an empty buffer on failure.
|
|
2891
|
+
* @param {number} vertex_count
|
|
2892
|
+
* @param {Float64Array} buffer
|
|
2893
|
+
* @param {Float64Array} points
|
|
2894
|
+
* @param {boolean} closed
|
|
2895
|
+
* @returns {Float64Array}
|
|
2896
|
+
*/
|
|
2897
|
+
export function mesh_split_polyline(vertex_count, buffer, points, closed) {
|
|
2898
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
2899
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2900
|
+
const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
|
|
2901
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2902
|
+
const ret = wasm.mesh_split_polyline(vertex_count, ptr0, len0, ptr1, len1, closed);
|
|
2903
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2904
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2905
|
+
return v3;
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2679
2908
|
/**
|
|
2680
2909
|
* Trim an OPEN host surface by all closed cutter meshes in one WASM call.
|
|
2681
2910
|
*
|
|
@@ -2817,6 +3046,32 @@ export function nurbs_curve_curve_intersect(data_a, data_b) {
|
|
|
2817
3046
|
return v3;
|
|
2818
3047
|
}
|
|
2819
3048
|
|
|
3049
|
+
/**
|
|
3050
|
+
* Find all intersections between two NURBS curves, with exact parameters.
|
|
3051
|
+
*
|
|
3052
|
+
* Inputs are standard NURBS curve encodings
|
|
3053
|
+
* `[degree, num_cp, cp_xyz..., weights..., knots...]` (the same format
|
|
3054
|
+
* consumed by `sample_nurbs_curve` / produced by `build_nurbs_curve`).
|
|
3055
|
+
*
|
|
3056
|
+
* Packing: `[count, (x, y, z, paramA, paramB)·count]`. Parameters are
|
|
3057
|
+
* normalized to [0, 1]; results are sorted by `paramA`. Coincident
|
|
3058
|
+
* (overlapping) curve runs yield NO points (identical curves return
|
|
3059
|
+
* `[0]`). Returns an empty buffer on malformed input.
|
|
3060
|
+
* @param {Float64Array} curve_a_data
|
|
3061
|
+
* @param {Float64Array} curve_b_data
|
|
3062
|
+
* @returns {Float64Array}
|
|
3063
|
+
*/
|
|
3064
|
+
export function nurbs_curve_curve_intersect_params(curve_a_data, curve_b_data) {
|
|
3065
|
+
const ptr0 = passArrayF64ToWasm0(curve_a_data, wasm.__wbindgen_malloc);
|
|
3066
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3067
|
+
const ptr1 = passArrayF64ToWasm0(curve_b_data, wasm.__wbindgen_malloc);
|
|
3068
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3069
|
+
const ret = wasm.nurbs_curve_curve_intersect_params(ptr0, len0, ptr1, len1);
|
|
3070
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3071
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3072
|
+
return v3;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
2820
3075
|
/**
|
|
2821
3076
|
* Intersect a NURBS curve with a plane.
|
|
2822
3077
|
* Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
|
|
@@ -2837,6 +3092,68 @@ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
|
|
|
2837
3092
|
return v2;
|
|
2838
3093
|
}
|
|
2839
3094
|
|
|
3095
|
+
/**
|
|
3096
|
+
* Split a NURBS curve at multiple normalized parameters t ∈ [0, 1].
|
|
3097
|
+
*
|
|
3098
|
+
* Splitting is exact (knot insertion), so every returned piece lies exactly
|
|
3099
|
+
* on the input curve. Parameters are sorted/deduplicated/clamped internally;
|
|
3100
|
+
* closed curves are opened at the FIRST parameter (N interior parameters →
|
|
3101
|
+
* N pieces), open curves yield N + 1 pieces. With no valid parameters the
|
|
3102
|
+
* (clamped) curve comes back as the single piece.
|
|
3103
|
+
*
|
|
3104
|
+
* `closed_hint` is an explicit topology override: `> 0` forces closed
|
|
3105
|
+
* (seam-rejoin) semantics, `0` forces open semantics (an open curve whose
|
|
3106
|
+
* endpoints merely coincide keeps N + 1 pieces), `< 0` infers closedness
|
|
3107
|
+
* geometrically from the endpoint distance (the historical behavior).
|
|
3108
|
+
*
|
|
3109
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
|
|
3110
|
+
* is the standard NURBS curve encoding (same multi-curve packing as
|
|
3111
|
+
* `brep_face_iso_curves_trimmed`). Returns an empty buffer on malformed
|
|
3112
|
+
* input.
|
|
3113
|
+
* @param {Float64Array} curve_data
|
|
3114
|
+
* @param {Float64Array} params
|
|
3115
|
+
* @param {number} closed_hint
|
|
3116
|
+
* @returns {Float64Array}
|
|
3117
|
+
*/
|
|
3118
|
+
export function nurbs_curve_split_at_params(curve_data, params, closed_hint) {
|
|
3119
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
3120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3121
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
3122
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3123
|
+
const ret = wasm.nurbs_curve_split_at_params(ptr0, len0, ptr1, len1, closed_hint);
|
|
3124
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3125
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3126
|
+
return v3;
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
/**
|
|
3130
|
+
* Find all isolated intersections of a NURBS curve with a NURBS surface,
|
|
3131
|
+
* with exact parameters.
|
|
3132
|
+
*
|
|
3133
|
+
* `curve_data` is the standard NURBS curve encoding; `surface_data` is the
|
|
3134
|
+
* standard NURBS surface encoding `[degree_u, degree_v, num_u, num_v,
|
|
3135
|
+
* cp(flat)..., weights..., knots_u..., knots_v...]` (same as
|
|
3136
|
+
* `nurbs_surface_evaluate`).
|
|
3137
|
+
*
|
|
3138
|
+
* Packing: `[count, (x, y, z, t, u, v)·count]`. All parameters are
|
|
3139
|
+
* normalized to [0, 1]; results are sorted by `t`. Curve segments lying ON
|
|
3140
|
+
* the surface (coincident runs) yield no points. Returns an empty buffer on
|
|
3141
|
+
* malformed input.
|
|
3142
|
+
* @param {Float64Array} curve_data
|
|
3143
|
+
* @param {Float64Array} surface_data
|
|
3144
|
+
* @returns {Float64Array}
|
|
3145
|
+
*/
|
|
3146
|
+
export function nurbs_curve_surface_intersect_exact(curve_data, surface_data) {
|
|
3147
|
+
const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
|
|
3148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3149
|
+
const ptr1 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
|
|
3150
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3151
|
+
const ret = wasm.nurbs_curve_surface_intersect_exact(ptr0, len0, ptr1, len1);
|
|
3152
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3153
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3154
|
+
return v3;
|
|
3155
|
+
}
|
|
3156
|
+
|
|
2840
3157
|
/**
|
|
2841
3158
|
* Closest point on the surface to (x, y, z).
|
|
2842
3159
|
* Returns [u, v, px, py, pz] with u, v normalized to [0,1].
|
|
@@ -3125,6 +3442,37 @@ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
|
|
|
3125
3442
|
return v3;
|
|
3126
3443
|
}
|
|
3127
3444
|
|
|
3445
|
+
/**
|
|
3446
|
+
* EXACT intersection curves of two FULL (untrimmed) NURBS surfaces: the
|
|
3447
|
+
* parametric boolean's SSI pipeline (seeded tri-tri, chaining, tangent-plane
|
|
3448
|
+
* relaxation) fitted to tolerance-verified interpolating NURBS curves —
|
|
3449
|
+
* unlike `nurbs_surface_surface_intersect`, which returns tessellated
|
|
3450
|
+
* polylines.
|
|
3451
|
+
*
|
|
3452
|
+
* Inputs are standard NURBS surface encodings; `tolerance` is absolute
|
|
3453
|
+
* (floored relative to the combined model scale kernel-side). Closed loops
|
|
3454
|
+
* come back as ONE closed curve; coincident (overlapping) surfaces yield no
|
|
3455
|
+
* curves (their overlap is a 2D region).
|
|
3456
|
+
*
|
|
3457
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
|
|
3458
|
+
* is the standard NURBS curve encoding. Returns an empty buffer on
|
|
3459
|
+
* malformed input.
|
|
3460
|
+
* @param {Float64Array} surf_a_data
|
|
3461
|
+
* @param {Float64Array} surf_b_data
|
|
3462
|
+
* @param {number} tolerance
|
|
3463
|
+
* @returns {Float64Array}
|
|
3464
|
+
*/
|
|
3465
|
+
export function nurbs_surface_surface_intersect_curves(surf_a_data, surf_b_data, tolerance) {
|
|
3466
|
+
const ptr0 = passArrayF64ToWasm0(surf_a_data, wasm.__wbindgen_malloc);
|
|
3467
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3468
|
+
const ptr1 = passArrayF64ToWasm0(surf_b_data, wasm.__wbindgen_malloc);
|
|
3469
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3470
|
+
const ret = wasm.nurbs_surface_surface_intersect_curves(ptr0, len0, ptr1, len1, tolerance);
|
|
3471
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3472
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
3473
|
+
return v3;
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3128
3476
|
/**
|
|
3129
3477
|
* Curvature-adaptive tessellation against a chordal tolerance.
|
|
3130
3478
|
* Returns the standard mesh buffer [vertexCount, positions..., indices...].
|