okgeometry-api 1.14.0 → 1.15.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.
@@ -61,6 +61,31 @@ export function brep_boolean_op(a_json, b_json, op, tolerance) {
61
61
  wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
62
62
  }
63
63
  }
64
+ /**
65
+ * Boolean-intersection clip of an exact NURBS curve against a CLOSED solid
66
+ * BREP: the curve is split exactly (knot insertion) at every boundary
67
+ * crossing and each piece is classified by containment. Every returned
68
+ * piece lies exactly on the input curve; closed curves merge the run
69
+ * spanning the parameter seam (same convention as `mesh_clip_polyline`).
70
+ *
71
+ * Packing: `[insideCount, (bufLen, curveData…)·insideCount,
72
+ * outsideCount, (bufLen, curveData…)·outsideCount]` — two concatenated
73
+ * multi-curve packings, inside pieces first. Returns an empty buffer on
74
+ * failure (malformed input, or a BREP that is not a closed solid).
75
+ * @param {Float64Array} curve_data
76
+ * @param {string} brep_json
77
+ * @returns {Float64Array}
78
+ */
79
+ export function brep_clip_curve_op(curve_data, brep_json) {
80
+ const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
81
+ const len0 = WASM_VECTOR_LEN;
82
+ const ptr1 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len1 = WASM_VECTOR_LEN;
84
+ const ret = wasm.brep_clip_curve_op(ptr0, len0, ptr1, len1);
85
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
86
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
87
+ return v3;
88
+ }
64
89
  /**
65
90
  * Closest BREP face to a 3D point. Returns [faceIndex, u, v, distance,
66
91
  * isNurbs] ((u, v) in the surface's KNOT domain) or empty on failure.
@@ -78,6 +103,33 @@ export function brep_closest_face(json, x, y, z) {
78
103
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
79
104
  return v2;
80
105
  }
106
+ /**
107
+ * Find all points where a NURBS curve pierces a BREP's faces: per face, the
108
+ * curve is intersected with the EXACT surface and kept only when the hit
109
+ * lies INSIDE the face's trimmed region; crossings on shared edges are
110
+ * deduplicated (smallest face index kept).
111
+ *
112
+ * `curve_data` is the standard NURBS curve encoding. Hits are sorted by
113
+ * curve parameter (normalized [0, 1]); (u, v) are in the face's OWN
114
+ * parameter space (knot domain for NURBS faces, plane-frame coordinates for
115
+ * planar faces).
116
+ *
117
+ * Packing: `[count, (x, y, z, curveParam, faceIndex, u, v)·count]`.
118
+ * Returns an empty buffer on malformed input.
119
+ * @param {string} brep_json
120
+ * @param {Float64Array} curve_data
121
+ * @returns {Float64Array}
122
+ */
123
+ export function brep_curve_intersection_op(brep_json, curve_data) {
124
+ const ptr0 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ptr1 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
127
+ const len1 = WASM_VECTOR_LEN;
128
+ const ret = wasm.brep_curve_intersection_op(ptr0, len0, ptr1, len1);
129
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
130
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
131
+ return v3;
132
+ }
81
133
  /**
82
134
  * All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
83
135
  * @param {string} json
@@ -350,6 +402,35 @@ export function brep_info(json) {
350
402
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
351
403
  return v2;
352
404
  }
405
+ /**
406
+ * TRIM-EXACT intersection curves between two BREPs (solids OR sheets): the
407
+ * parametric boolean's SSI → clip → convergence stages run and the fitted 3D
408
+ * intersection edges come back WITHOUT classification/assembly.
409
+ *
410
+ * A closed intersection loop may come back as several contiguous pieces
411
+ * (split at surface seams and face-boundary crossings); the pieces chain
412
+ * end-to-end exactly. Coincident (overlapping) face pairs contribute no
413
+ * curves.
414
+ *
415
+ * Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (standard NURBS
416
+ * curve encoding). Returns an EMPTY buffer on failure (invalid BREP JSON or
417
+ * a pipeline error) — distinguishable from `[0]`, which means the operands
418
+ * genuinely do not intersect.
419
+ * @param {string} a_json
420
+ * @param {string} b_json
421
+ * @param {number} tolerance
422
+ * @returns {Float64Array}
423
+ */
424
+ export function brep_intersection_curves_op(a_json, b_json, tolerance) {
425
+ const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
426
+ const len0 = WASM_VECTOR_LEN;
427
+ const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
428
+ const len1 = WASM_VECTOR_LEN;
429
+ const ret = wasm.brep_intersection_curves_op(ptr0, len0, ptr1, len1, tolerance);
430
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
431
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
432
+ return v3;
433
+ }
353
434
  /**
354
435
  * Loft through profile curves into a BREP.
355
436
  * Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
@@ -371,6 +452,32 @@ export function brep_loft_curves(data) {
371
452
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
372
453
  }
373
454
  }
455
+ /**
456
+ * Intersection curves between a BREP and a triangle mesh.
457
+ *
458
+ * TESSELLATION-BASED (documented approximation): the BREP is tessellated at
459
+ * `tolerance` (pass `<= 0` for the deterministic auto display tolerance)
460
+ * and intersected with the mesh via BVH-pruned tri-tri crossing + chaining.
461
+ *
462
+ * Mesh input is the standard `[vertexCount, positions..., indices...]`
463
+ * buffer. Returns the standard polyline group packing
464
+ * `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]`; empty on failure.
465
+ * @param {string} brep_json
466
+ * @param {number} vertex_count
467
+ * @param {Float64Array} mesh_buffer
468
+ * @param {number} tolerance
469
+ * @returns {Float64Array}
470
+ */
471
+ export function brep_mesh_intersection_curves_op(brep_json, vertex_count, mesh_buffer, tolerance) {
472
+ const ptr0 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
473
+ const len0 = WASM_VECTOR_LEN;
474
+ const ptr1 = passArrayF64ToWasm0(mesh_buffer, wasm.__wbindgen_malloc);
475
+ const len1 = WASM_VECTOR_LEN;
476
+ const ret = wasm.brep_mesh_intersection_curves_op(ptr0, len0, vertex_count, 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
+ }
374
481
  /**
375
482
  * BREP primitives.
376
483
  * kind: "box" [minx,miny,minz, maxx,maxy,maxz]
@@ -1752,6 +1859,35 @@ export function mesh_clip_polyline(vertex_count, buffer, points, closed) {
1752
1859
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1753
1860
  return v3;
1754
1861
  }
1862
+ /**
1863
+ * Clip a polyline by an OPEN oriented sheet: split it at every sheet
1864
+ * crossing and classify each piece by the SIGNED SIDE of the sheet. This is
1865
+ * side classification, NOT containment (unlike `mesh_clip_polyline`, which
1866
+ * requires a closed volume): pieces far from the sheet still classify by
1867
+ * the nearest facet's normal. `inside` = the positive side, in FRONT of the
1868
+ * sheet normal; `outside` = behind it. The sheet may be any non-empty
1869
+ * triangle mesh, open or closed; its stored winding defines the normals.
1870
+ *
1871
+ * Returns two concatenated polyline buffers — inside pieces first, then
1872
+ * outside pieces — each encoded as `[num_polylines, n1, x,y,z,..., ...]`
1873
+ * (identical packing to `mesh_clip_polyline`). Returns an empty buffer on
1874
+ * failure (degenerate polyline/sheet).
1875
+ * @param {number} vertex_count
1876
+ * @param {Float64Array} buffer
1877
+ * @param {Float64Array} points
1878
+ * @param {boolean} closed
1879
+ * @returns {Float64Array}
1880
+ */
1881
+ export function mesh_clip_polyline_by_sheet(vertex_count, buffer, points, closed) {
1882
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1883
+ const len0 = WASM_VECTOR_LEN;
1884
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
1885
+ const len1 = WASM_VECTOR_LEN;
1886
+ const ret = wasm.mesh_clip_polyline_by_sheet(vertex_count, ptr0, len0, ptr1, len1, closed);
1887
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1888
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1889
+ return v3;
1890
+ }
1755
1891
  /**
1756
1892
  * Compute planar curve normal from ordered points.
1757
1893
  * @param {Float64Array} coords
@@ -2385,6 +2521,35 @@ export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
2385
2521
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2386
2522
  return v2;
2387
2523
  }
2524
+ /**
2525
+ * Compute all transversal crossing points of a polyline with a triangle
2526
+ * mesh. Works on OPEN meshes (sheets) — the mesh is NOT required to be a
2527
+ * closed volume, unlike `mesh_clip_polyline`.
2528
+ *
2529
+ * `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
2530
+ * (segment `i` runs `points[i] → points[(i+1) % n]`; open polylines have
2531
+ * n−1 segments, closed ones n).
2532
+ *
2533
+ * Packing: `[count, (x, y, z, segmentIndex, segmentT, triangleIndex)·count]`,
2534
+ * sorted by (segmentIndex, segmentT). Shared-edge/vertex crossings dedupe to
2535
+ * one hit (smallest triangle index kept); coplanar sliding overlaps yield no
2536
+ * hits. Returns an empty buffer on failure (degenerate polyline/mesh).
2537
+ * @param {number} vertex_count
2538
+ * @param {Float64Array} buffer
2539
+ * @param {Float64Array} points
2540
+ * @param {boolean} closed
2541
+ * @returns {Float64Array}
2542
+ */
2543
+ export function mesh_polyline_intersection_points(vertex_count, buffer, points, closed) {
2544
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2545
+ const len0 = WASM_VECTOR_LEN;
2546
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
2547
+ const len1 = WASM_VECTOR_LEN;
2548
+ const ret = wasm.mesh_polyline_intersection_points(vertex_count, ptr0, len0, ptr1, len1, closed);
2549
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2550
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2551
+ return v3;
2552
+ }
2388
2553
  /**
2389
2554
  * Shift closed boolean cutter curve and adjust height.
2390
2555
  * Returns [height, epsilon, pointCount, x,y,z,...]
@@ -2581,6 +2746,33 @@ export function mesh_split_by_surface_to_brep(vertex_count, buffer, surface_data
2581
2746
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2582
2747
  }
2583
2748
  }
2749
+ /**
2750
+ * Intersect a polyline with a triangle mesh (open sheets allowed) and split
2751
+ * it into pieces at every crossing. Hit points become the shared endpoints
2752
+ * of adjacent pieces; a closed loop is opened at the first hit (N hits → N
2753
+ * pieces), an open polyline yields N + 1 pieces. With no crossings the
2754
+ * original polyline comes back as one piece.
2755
+ *
2756
+ * Packing: a single flat polyline-group buffer
2757
+ * `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]` (same group encoding as
2758
+ * `mesh_clip_polyline`, but ONE list — pieces are not classified). Returns
2759
+ * an empty buffer on failure.
2760
+ * @param {number} vertex_count
2761
+ * @param {Float64Array} buffer
2762
+ * @param {Float64Array} points
2763
+ * @param {boolean} closed
2764
+ * @returns {Float64Array}
2765
+ */
2766
+ export function mesh_split_polyline(vertex_count, buffer, points, closed) {
2767
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2768
+ const len0 = WASM_VECTOR_LEN;
2769
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
2770
+ const len1 = WASM_VECTOR_LEN;
2771
+ const ret = wasm.mesh_split_polyline(vertex_count, ptr0, len0, ptr1, len1, closed);
2772
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2773
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2774
+ return v3;
2775
+ }
2584
2776
  /**
2585
2777
  * Trim an OPEN host surface by all closed cutter meshes in one WASM call.
2586
2778
  *
@@ -2715,6 +2907,31 @@ export function nurbs_curve_curve_intersect(data_a, data_b) {
2715
2907
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2716
2908
  return v3;
2717
2909
  }
2910
+ /**
2911
+ * Find all intersections between two NURBS curves, with exact parameters.
2912
+ *
2913
+ * Inputs are standard NURBS curve encodings
2914
+ * `[degree, num_cp, cp_xyz..., weights..., knots...]` (the same format
2915
+ * consumed by `sample_nurbs_curve` / produced by `build_nurbs_curve`).
2916
+ *
2917
+ * Packing: `[count, (x, y, z, paramA, paramB)·count]`. Parameters are
2918
+ * normalized to [0, 1]; results are sorted by `paramA`. Coincident
2919
+ * (overlapping) curve runs yield NO points (identical curves return
2920
+ * `[0]`). Returns an empty buffer on malformed input.
2921
+ * @param {Float64Array} curve_a_data
2922
+ * @param {Float64Array} curve_b_data
2923
+ * @returns {Float64Array}
2924
+ */
2925
+ export function nurbs_curve_curve_intersect_params(curve_a_data, curve_b_data) {
2926
+ const ptr0 = passArrayF64ToWasm0(curve_a_data, wasm.__wbindgen_malloc);
2927
+ const len0 = WASM_VECTOR_LEN;
2928
+ const ptr1 = passArrayF64ToWasm0(curve_b_data, wasm.__wbindgen_malloc);
2929
+ const len1 = WASM_VECTOR_LEN;
2930
+ const ret = wasm.nurbs_curve_curve_intersect_params(ptr0, len0, ptr1, len1);
2931
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2932
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2933
+ return v3;
2934
+ }
2718
2935
  /**
2719
2936
  * Intersect a NURBS curve with a plane.
2720
2937
  * Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
@@ -2734,6 +2951,66 @@ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
2734
2951
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2735
2952
  return v2;
2736
2953
  }
2954
+ /**
2955
+ * Split a NURBS curve at multiple normalized parameters t ∈ [0, 1].
2956
+ *
2957
+ * Splitting is exact (knot insertion), so every returned piece lies exactly
2958
+ * on the input curve. Parameters are sorted/deduplicated/clamped internally;
2959
+ * closed curves are opened at the FIRST parameter (N interior parameters →
2960
+ * N pieces), open curves yield N + 1 pieces. With no valid parameters the
2961
+ * (clamped) curve comes back as the single piece.
2962
+ *
2963
+ * `closed_hint` is an explicit topology override: `> 0` forces closed
2964
+ * (seam-rejoin) semantics, `0` forces open semantics (an open curve whose
2965
+ * endpoints merely coincide keeps N + 1 pieces), `< 0` infers closedness
2966
+ * geometrically from the endpoint distance (the historical behavior).
2967
+ *
2968
+ * Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
2969
+ * is the standard NURBS curve encoding (same multi-curve packing as
2970
+ * `brep_face_iso_curves_trimmed`). Returns an empty buffer on malformed
2971
+ * input.
2972
+ * @param {Float64Array} curve_data
2973
+ * @param {Float64Array} params
2974
+ * @param {number} closed_hint
2975
+ * @returns {Float64Array}
2976
+ */
2977
+ export function nurbs_curve_split_at_params(curve_data, params, closed_hint) {
2978
+ const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
2979
+ const len0 = WASM_VECTOR_LEN;
2980
+ const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
2981
+ const len1 = WASM_VECTOR_LEN;
2982
+ const ret = wasm.nurbs_curve_split_at_params(ptr0, len0, ptr1, len1, closed_hint);
2983
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2984
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2985
+ return v3;
2986
+ }
2987
+ /**
2988
+ * Find all isolated intersections of a NURBS curve with a NURBS surface,
2989
+ * with exact parameters.
2990
+ *
2991
+ * `curve_data` is the standard NURBS curve encoding; `surface_data` is the
2992
+ * standard NURBS surface encoding `[degree_u, degree_v, num_u, num_v,
2993
+ * cp(flat)..., weights..., knots_u..., knots_v...]` (same as
2994
+ * `nurbs_surface_evaluate`).
2995
+ *
2996
+ * Packing: `[count, (x, y, z, t, u, v)·count]`. All parameters are
2997
+ * normalized to [0, 1]; results are sorted by `t`. Curve segments lying ON
2998
+ * the surface (coincident runs) yield no points. Returns an empty buffer on
2999
+ * malformed input.
3000
+ * @param {Float64Array} curve_data
3001
+ * @param {Float64Array} surface_data
3002
+ * @returns {Float64Array}
3003
+ */
3004
+ export function nurbs_curve_surface_intersect_exact(curve_data, surface_data) {
3005
+ const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
3006
+ const len0 = WASM_VECTOR_LEN;
3007
+ const ptr1 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
3008
+ const len1 = WASM_VECTOR_LEN;
3009
+ const ret = wasm.nurbs_curve_surface_intersect_exact(ptr0, len0, ptr1, len1);
3010
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3011
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3012
+ return v3;
3013
+ }
2737
3014
  /**
2738
3015
  * Closest point on the surface to (x, y, z).
2739
3016
  * Returns [u, v, px, py, pz] with u, v normalized to [0,1].
@@ -3006,6 +3283,36 @@ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
3006
3283
  wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3007
3284
  return v3;
3008
3285
  }
3286
+ /**
3287
+ * EXACT intersection curves of two FULL (untrimmed) NURBS surfaces: the
3288
+ * parametric boolean's SSI pipeline (seeded tri-tri, chaining, tangent-plane
3289
+ * relaxation) fitted to tolerance-verified interpolating NURBS curves —
3290
+ * unlike `nurbs_surface_surface_intersect`, which returns tessellated
3291
+ * polylines.
3292
+ *
3293
+ * Inputs are standard NURBS surface encodings; `tolerance` is absolute
3294
+ * (floored relative to the combined model scale kernel-side). Closed loops
3295
+ * come back as ONE closed curve; coincident (overlapping) surfaces yield no
3296
+ * curves (their overlap is a 2D region).
3297
+ *
3298
+ * Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
3299
+ * is the standard NURBS curve encoding. Returns an empty buffer on
3300
+ * malformed input.
3301
+ * @param {Float64Array} surf_a_data
3302
+ * @param {Float64Array} surf_b_data
3303
+ * @param {number} tolerance
3304
+ * @returns {Float64Array}
3305
+ */
3306
+ export function nurbs_surface_surface_intersect_curves(surf_a_data, surf_b_data, tolerance) {
3307
+ const ptr0 = passArrayF64ToWasm0(surf_a_data, wasm.__wbindgen_malloc);
3308
+ const len0 = WASM_VECTOR_LEN;
3309
+ const ptr1 = passArrayF64ToWasm0(surf_b_data, wasm.__wbindgen_malloc);
3310
+ const len1 = WASM_VECTOR_LEN;
3311
+ const ret = wasm.nurbs_surface_surface_intersect_curves(ptr0, len0, ptr1, len1, tolerance);
3312
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3313
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3314
+ return v3;
3315
+ }
3009
3316
  /**
3010
3317
  * Curvature-adaptive tessellation against a chordal tolerance.
3011
3318
  * Returns the standard mesh buffer [vertexCount, positions..., indices...].