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.
@@ -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,36 @@ export function brep_info(json) {
365
419
  return v2;
366
420
  }
367
421
 
422
+ /**
423
+ * TRIM-EXACT intersection curves between two BREPs (solids OR sheets): the
424
+ * parametric boolean's SSI → clip → convergence stages run and the fitted 3D
425
+ * intersection edges come back WITHOUT classification/assembly.
426
+ *
427
+ * A closed intersection loop may come back as several contiguous pieces
428
+ * (split at surface seams and face-boundary crossings); the pieces chain
429
+ * end-to-end exactly. Coincident (overlapping) face pairs contribute no
430
+ * curves.
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_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_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
+
368
452
  /**
369
453
  * Loft through profile curves into a BREP.
370
454
  * Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
@@ -386,6 +470,33 @@ export function brep_loft_curves(data) {
386
470
  }
387
471
  }
388
472
 
473
+ /**
474
+ * Intersection curves between a BREP and a triangle mesh.
475
+ *
476
+ * TESSELLATION-BASED (documented approximation): the BREP is tessellated at
477
+ * `tolerance` (pass `<= 0` for the deterministic auto display tolerance)
478
+ * and intersected with the mesh via BVH-pruned tri-tri crossing + chaining.
479
+ *
480
+ * Mesh input is the standard `[vertexCount, positions..., indices...]`
481
+ * buffer. Returns the standard polyline group packing
482
+ * `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]`; empty on failure.
483
+ * @param {string} brep_json
484
+ * @param {number} vertex_count
485
+ * @param {Float64Array} mesh_buffer
486
+ * @param {number} tolerance
487
+ * @returns {Float64Array}
488
+ */
489
+ export function brep_mesh_intersection_curves_op(brep_json, vertex_count, mesh_buffer, tolerance) {
490
+ const ptr0 = passStringToWasm0(brep_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
491
+ const len0 = WASM_VECTOR_LEN;
492
+ const ptr1 = passArrayF64ToWasm0(mesh_buffer, wasm.__wbindgen_malloc);
493
+ const len1 = WASM_VECTOR_LEN;
494
+ const ret = wasm.brep_mesh_intersection_curves_op(ptr0, len0, vertex_count, ptr1, len1, tolerance);
495
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
496
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
497
+ return v3;
498
+ }
499
+
389
500
  /**
390
501
  * BREP primitives.
391
502
  * kind: "box" [minx,miny,minz, maxx,maxy,maxz]
@@ -1807,6 +1918,36 @@ export function mesh_clip_polyline(vertex_count, buffer, points, closed) {
1807
1918
  return v3;
1808
1919
  }
1809
1920
 
1921
+ /**
1922
+ * Clip a polyline by an OPEN oriented sheet: split it at every sheet
1923
+ * crossing and classify each piece by the SIGNED SIDE of the sheet. This is
1924
+ * side classification, NOT containment (unlike `mesh_clip_polyline`, which
1925
+ * requires a closed volume): pieces far from the sheet still classify by
1926
+ * the nearest facet's normal. `inside` = the positive side, in FRONT of the
1927
+ * sheet normal; `outside` = behind it. The sheet may be any non-empty
1928
+ * triangle mesh, open or closed; its stored winding defines the normals.
1929
+ *
1930
+ * Returns two concatenated polyline buffers — inside pieces first, then
1931
+ * outside pieces — each encoded as `[num_polylines, n1, x,y,z,..., ...]`
1932
+ * (identical packing to `mesh_clip_polyline`). Returns an empty buffer on
1933
+ * failure (degenerate polyline/sheet).
1934
+ * @param {number} vertex_count
1935
+ * @param {Float64Array} buffer
1936
+ * @param {Float64Array} points
1937
+ * @param {boolean} closed
1938
+ * @returns {Float64Array}
1939
+ */
1940
+ export function mesh_clip_polyline_by_sheet(vertex_count, buffer, points, closed) {
1941
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1942
+ const len0 = WASM_VECTOR_LEN;
1943
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
1944
+ const len1 = WASM_VECTOR_LEN;
1945
+ const ret = wasm.mesh_clip_polyline_by_sheet(vertex_count, ptr0, len0, ptr1, len1, closed);
1946
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1947
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1948
+ return v3;
1949
+ }
1950
+
1810
1951
  /**
1811
1952
  * Compute planar curve normal from ordered points.
1812
1953
  * @param {Float64Array} coords
@@ -2472,6 +2613,36 @@ export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
2472
2613
  return v2;
2473
2614
  }
2474
2615
 
2616
+ /**
2617
+ * Compute all transversal crossing points of a polyline with a triangle
2618
+ * mesh. Works on OPEN meshes (sheets) — the mesh is NOT required to be a
2619
+ * closed volume, unlike `mesh_clip_polyline`.
2620
+ *
2621
+ * `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
2622
+ * (segment `i` runs `points[i] → points[(i+1) % n]`; open polylines have
2623
+ * n−1 segments, closed ones n).
2624
+ *
2625
+ * Packing: `[count, (x, y, z, segmentIndex, segmentT, triangleIndex)·count]`,
2626
+ * sorted by (segmentIndex, segmentT). Shared-edge/vertex crossings dedupe to
2627
+ * one hit (smallest triangle index kept); coplanar sliding overlaps yield no
2628
+ * hits. Returns an empty buffer on failure (degenerate polyline/mesh).
2629
+ * @param {number} vertex_count
2630
+ * @param {Float64Array} buffer
2631
+ * @param {Float64Array} points
2632
+ * @param {boolean} closed
2633
+ * @returns {Float64Array}
2634
+ */
2635
+ export function mesh_polyline_intersection_points(vertex_count, buffer, points, closed) {
2636
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2637
+ const len0 = WASM_VECTOR_LEN;
2638
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
2639
+ const len1 = WASM_VECTOR_LEN;
2640
+ const ret = wasm.mesh_polyline_intersection_points(vertex_count, ptr0, len0, ptr1, len1, closed);
2641
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2642
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2643
+ return v3;
2644
+ }
2645
+
2475
2646
  /**
2476
2647
  * Shift closed boolean cutter curve and adjust height.
2477
2648
  * Returns [height, epsilon, pointCount, x,y,z,...]
@@ -2676,6 +2847,34 @@ export function mesh_split_by_surface_to_brep(vertex_count, buffer, surface_data
2676
2847
  }
2677
2848
  }
2678
2849
 
2850
+ /**
2851
+ * Intersect a polyline with a triangle mesh (open sheets allowed) and split
2852
+ * it into pieces at every crossing. Hit points become the shared endpoints
2853
+ * of adjacent pieces; a closed loop is opened at the first hit (N hits → N
2854
+ * pieces), an open polyline yields N + 1 pieces. With no crossings the
2855
+ * original polyline comes back as one piece.
2856
+ *
2857
+ * Packing: a single flat polyline-group buffer
2858
+ * `[num_polylines, n1, x,y,z,..., n2, x,y,z,...]` (same group encoding as
2859
+ * `mesh_clip_polyline`, but ONE list — pieces are not classified). Returns
2860
+ * an empty buffer on failure.
2861
+ * @param {number} vertex_count
2862
+ * @param {Float64Array} buffer
2863
+ * @param {Float64Array} points
2864
+ * @param {boolean} closed
2865
+ * @returns {Float64Array}
2866
+ */
2867
+ export function mesh_split_polyline(vertex_count, buffer, points, closed) {
2868
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2869
+ const len0 = WASM_VECTOR_LEN;
2870
+ const ptr1 = passArrayF64ToWasm0(points, wasm.__wbindgen_malloc);
2871
+ const len1 = WASM_VECTOR_LEN;
2872
+ const ret = wasm.mesh_split_polyline(vertex_count, ptr0, len0, ptr1, len1, closed);
2873
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2874
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2875
+ return v3;
2876
+ }
2877
+
2679
2878
  /**
2680
2879
  * Trim an OPEN host surface by all closed cutter meshes in one WASM call.
2681
2880
  *
@@ -2817,6 +3016,32 @@ export function nurbs_curve_curve_intersect(data_a, data_b) {
2817
3016
  return v3;
2818
3017
  }
2819
3018
 
3019
+ /**
3020
+ * Find all intersections between two NURBS curves, with exact parameters.
3021
+ *
3022
+ * Inputs are standard NURBS curve encodings
3023
+ * `[degree, num_cp, cp_xyz..., weights..., knots...]` (the same format
3024
+ * consumed by `sample_nurbs_curve` / produced by `build_nurbs_curve`).
3025
+ *
3026
+ * Packing: `[count, (x, y, z, paramA, paramB)·count]`. Parameters are
3027
+ * normalized to [0, 1]; results are sorted by `paramA`. Coincident
3028
+ * (overlapping) curve runs yield NO points (identical curves return
3029
+ * `[0]`). Returns an empty buffer on malformed input.
3030
+ * @param {Float64Array} curve_a_data
3031
+ * @param {Float64Array} curve_b_data
3032
+ * @returns {Float64Array}
3033
+ */
3034
+ export function nurbs_curve_curve_intersect_params(curve_a_data, curve_b_data) {
3035
+ const ptr0 = passArrayF64ToWasm0(curve_a_data, wasm.__wbindgen_malloc);
3036
+ const len0 = WASM_VECTOR_LEN;
3037
+ const ptr1 = passArrayF64ToWasm0(curve_b_data, wasm.__wbindgen_malloc);
3038
+ const len1 = WASM_VECTOR_LEN;
3039
+ const ret = wasm.nurbs_curve_curve_intersect_params(ptr0, len0, ptr1, len1);
3040
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3041
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3042
+ return v3;
3043
+ }
3044
+
2820
3045
  /**
2821
3046
  * Intersect a NURBS curve with a plane.
2822
3047
  * Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
@@ -2837,6 +3062,68 @@ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
2837
3062
  return v2;
2838
3063
  }
2839
3064
 
3065
+ /**
3066
+ * Split a NURBS curve at multiple normalized parameters t ∈ [0, 1].
3067
+ *
3068
+ * Splitting is exact (knot insertion), so every returned piece lies exactly
3069
+ * on the input curve. Parameters are sorted/deduplicated/clamped internally;
3070
+ * closed curves are opened at the FIRST parameter (N interior parameters →
3071
+ * N pieces), open curves yield N + 1 pieces. With no valid parameters the
3072
+ * (clamped) curve comes back as the single piece.
3073
+ *
3074
+ * `closed_hint` is an explicit topology override: `> 0` forces closed
3075
+ * (seam-rejoin) semantics, `0` forces open semantics (an open curve whose
3076
+ * endpoints merely coincide keeps N + 1 pieces), `< 0` infers closedness
3077
+ * geometrically from the endpoint distance (the historical behavior).
3078
+ *
3079
+ * Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
3080
+ * is the standard NURBS curve encoding (same multi-curve packing as
3081
+ * `brep_face_iso_curves_trimmed`). Returns an empty buffer on malformed
3082
+ * input.
3083
+ * @param {Float64Array} curve_data
3084
+ * @param {Float64Array} params
3085
+ * @param {number} closed_hint
3086
+ * @returns {Float64Array}
3087
+ */
3088
+ export function nurbs_curve_split_at_params(curve_data, params, closed_hint) {
3089
+ const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
3090
+ const len0 = WASM_VECTOR_LEN;
3091
+ const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
3092
+ const len1 = WASM_VECTOR_LEN;
3093
+ const ret = wasm.nurbs_curve_split_at_params(ptr0, len0, ptr1, len1, closed_hint);
3094
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3095
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3096
+ return v3;
3097
+ }
3098
+
3099
+ /**
3100
+ * Find all isolated intersections of a NURBS curve with a NURBS surface,
3101
+ * with exact parameters.
3102
+ *
3103
+ * `curve_data` is the standard NURBS curve encoding; `surface_data` is the
3104
+ * standard NURBS surface encoding `[degree_u, degree_v, num_u, num_v,
3105
+ * cp(flat)..., weights..., knots_u..., knots_v...]` (same as
3106
+ * `nurbs_surface_evaluate`).
3107
+ *
3108
+ * Packing: `[count, (x, y, z, t, u, v)·count]`. All parameters are
3109
+ * normalized to [0, 1]; results are sorted by `t`. Curve segments lying ON
3110
+ * the surface (coincident runs) yield no points. Returns an empty buffer on
3111
+ * malformed input.
3112
+ * @param {Float64Array} curve_data
3113
+ * @param {Float64Array} surface_data
3114
+ * @returns {Float64Array}
3115
+ */
3116
+ export function nurbs_curve_surface_intersect_exact(curve_data, surface_data) {
3117
+ const ptr0 = passArrayF64ToWasm0(curve_data, wasm.__wbindgen_malloc);
3118
+ const len0 = WASM_VECTOR_LEN;
3119
+ const ptr1 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
3120
+ const len1 = WASM_VECTOR_LEN;
3121
+ const ret = wasm.nurbs_curve_surface_intersect_exact(ptr0, len0, ptr1, len1);
3122
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3123
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3124
+ return v3;
3125
+ }
3126
+
2840
3127
  /**
2841
3128
  * Closest point on the surface to (x, y, z).
2842
3129
  * Returns [u, v, px, py, pz] with u, v normalized to [0,1].
@@ -3125,6 +3412,37 @@ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
3125
3412
  return v3;
3126
3413
  }
3127
3414
 
3415
+ /**
3416
+ * EXACT intersection curves of two FULL (untrimmed) NURBS surfaces: the
3417
+ * parametric boolean's SSI pipeline (seeded tri-tri, chaining, tangent-plane
3418
+ * relaxation) fitted to tolerance-verified interpolating NURBS curves —
3419
+ * unlike `nurbs_surface_surface_intersect`, which returns tessellated
3420
+ * polylines.
3421
+ *
3422
+ * Inputs are standard NURBS surface encodings; `tolerance` is absolute
3423
+ * (floored relative to the combined model scale kernel-side). Closed loops
3424
+ * come back as ONE closed curve; coincident (overlapping) surfaces yield no
3425
+ * curves (their overlap is a 2D region).
3426
+ *
3427
+ * Packing: `[curveCount, (bufLen, curveData…)·curveCount]` where curveData
3428
+ * is the standard NURBS curve encoding. Returns an empty buffer on
3429
+ * malformed input.
3430
+ * @param {Float64Array} surf_a_data
3431
+ * @param {Float64Array} surf_b_data
3432
+ * @param {number} tolerance
3433
+ * @returns {Float64Array}
3434
+ */
3435
+ export function nurbs_surface_surface_intersect_curves(surf_a_data, surf_b_data, tolerance) {
3436
+ const ptr0 = passArrayF64ToWasm0(surf_a_data, wasm.__wbindgen_malloc);
3437
+ const len0 = WASM_VECTOR_LEN;
3438
+ const ptr1 = passArrayF64ToWasm0(surf_b_data, wasm.__wbindgen_malloc);
3439
+ const len1 = WASM_VECTOR_LEN;
3440
+ const ret = wasm.nurbs_surface_surface_intersect_curves(ptr0, len0, ptr1, len1, tolerance);
3441
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3442
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3443
+ return v3;
3444
+ }
3445
+
3128
3446
  /**
3129
3447
  * Curvature-adaptive tessellation against a chordal tolerance.
3130
3448
  * Returns the standard mesh buffer [vertexCount, positions..., indices...].