okgeometry-api 1.11.0 → 1.14.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.
@@ -20,23 +20,65 @@ export function arc_point_at(cx: number, cy: number, cz: number, nx: number, ny:
20
20
  */
21
21
  export function brep_boolean_op(a_json: string, b_json: string, op: string, tolerance: number): string;
22
22
 
23
+ /**
24
+ * Closest BREP face to a 3D point. Returns [faceIndex, u, v, distance,
25
+ * isNurbs] ((u, v) in the surface's KNOT domain) or empty on failure.
26
+ */
27
+ export function brep_closest_face(json: string, x: number, y: number, z: number): Float64Array;
28
+
23
29
  /**
24
30
  * All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
25
31
  */
26
32
  export function brep_edges(json: string, tolerance: number): Float64Array;
27
33
 
34
+ /**
35
+ * Extract one face as a standalone single-face TRIMMED sheet BREP (trim
36
+ * loops, pcurves, edges and vertices preserved). Returns JSON, empty on
37
+ * failure.
38
+ */
39
+ export function brep_extract_face(json: string, face_index: number): string;
40
+
41
+ /**
42
+ * ALL faces as standalone single-face trimmed sheet BREPs, in one crossing
43
+ * (the source JSON is parsed once). Returns a JSON ARRAY aligned with face
44
+ * indices; faces that fail to extract are `null`.
45
+ */
46
+ export function brep_extract_faces(json: string): string;
47
+
28
48
  /**
29
49
  * Extrude a profile curve into a BREP (closed profile → capped solid,
30
50
  * open profile → sheet). Returns JSON.
31
51
  */
32
52
  export function brep_extrude_curve(curve_data: Float64Array, dx: number, dy: number, dz: number, height: number): string;
33
53
 
54
+ /**
55
+ * Exact (u, v) of a point on a specific BREP face (closest-point Newton for
56
+ * NURBS, frame projection for planes). Returns [u, v, distance, isNurbs].
57
+ */
58
+ export function brep_face_closest_uv(json: string, face_index: number, x: number, y: number, z: number): Float64Array;
59
+
34
60
  /**
35
61
  * Iso-parametric curve of a NURBS face's backing surface (untrimmed).
36
62
  * Returns curve data, or empty for planar faces.
37
63
  */
38
64
  export function brep_face_iso_curve(json: string, face_index: number, t: number, u_dir: boolean): Float64Array;
39
65
 
66
+ /**
67
+ * Exact isocurve(s) of a BREP face at KNOT-domain parameter `t`, CLIPPED to
68
+ * the face's trimmed region. `u_dir = true` runs along u at fixed v = t.
69
+ * Line pieces (planar faces) are encoded as degree-1 NURBS.
70
+ * Packing: [curveCount, (bufLen, curveData…)·curveCount] where curveData is
71
+ * the standard NURBS curve encoding.
72
+ */
73
+ export function brep_face_iso_curves_trimmed(json: string, face_index: number, t: number, u_dir: boolean): Float64Array;
74
+
75
+ /**
76
+ * Like `brep_face_iso_curves_trimmed`, but `t` is NORMALIZED [0, 1] across
77
+ * the face's trim extent in the fixed direction — callers don't need the
78
+ * surface knot domain. Same packing.
79
+ */
80
+ export function brep_face_iso_curves_trimmed_normalized(json: string, face_index: number, t: number, u_dir: boolean): Float64Array;
81
+
40
82
  /**
41
83
  * Geometric backing of a face.
42
84
  * Returns [0, ox,oy,oz, ux,uy,uz, vx,vy,vz] for planes,
@@ -44,11 +86,38 @@ export function brep_face_iso_curve(json: string, face_index: number, t: number,
44
86
  */
45
87
  export function brep_face_surface(json: string, face_index: number): Float64Array;
46
88
 
89
+ /**
90
+ * Underlying surface of a face CROPPED to its trim extent, ALWAYS as a NURBS
91
+ * surface (planar faces become exact degree-1 patches). Returns surface
92
+ * data, empty on failure.
93
+ */
94
+ export function brep_face_surface_cropped(json: string, face_index: number): Float64Array;
95
+
96
+ /**
97
+ * Batch variant of `brep_face_surface_cropped` for all faces in one
98
+ * crossing. Packing: [faceCount, (bufLen, surfaceData…)·faceCount], aligned
99
+ * with face indices — a face that fails to crop gets bufLen 0.
100
+ */
101
+ export function brep_face_surfaces_cropped(json: string): Float64Array;
102
+
47
103
  /**
48
104
  * Tessellate a single BREP face. Returns the standard mesh buffer.
49
105
  */
50
106
  export function brep_face_tessellate(json: string, face_index: number, tolerance: number): Float64Array;
51
107
 
108
+ /**
109
+ * UV bounding box of a face's trim loops in surface parameter space:
110
+ * [u_min, u_max, v_min, v_max]. Empty on failure.
111
+ */
112
+ export function brep_face_trim_bounds(json: string, face_index: number): Float64Array;
113
+
114
+ /**
115
+ * Convert a closed manifold triangle mesh into a planar-face BREP.
116
+ * `normal_angle_tol_deg` ≤ 0 selects the default (≈0.057°); `max_faces` 0 =
117
+ * default guard (4096). Returns BREP JSON or {"error": ...}.
118
+ */
119
+ export function brep_from_mesh_buffer(vertex_count: number, buffer: Float64Array, normal_angle_tol_deg: number, max_faces: number): string;
120
+
52
121
  /**
53
122
  * BREP structure summary: [face_count, edge_count, vertex_count, is_closed].
54
123
  */
@@ -81,12 +150,30 @@ export function brep_revolve_curve(curve_data: Float64Array, ox: number, oy: num
81
150
  */
82
151
  export function brep_sheet_from_surface(surface_data: Float64Array): string;
83
152
 
153
+ /**
154
+ * Split a closed solid BREP by a sheet BREP into BOTH capped halves.
155
+ * Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
156
+ * Sides follow the sheet normal (negative = behind it), matching
157
+ * `mesh_solid_split_by_surface`.
158
+ */
159
+ export function brep_split_solid_by_sheet_op(solid_json: string, sheet_json: string, tolerance: number): string;
160
+
84
161
  /**
85
162
  * Tessellate a BREP into the standard mesh buffer
86
163
  * [vertexCount, positions..., indices...]. Crack-free across shared edges.
87
164
  */
88
165
  export function brep_tessellate(json: string, tolerance: number): Float64Array;
89
166
 
167
+ /**
168
+ * Tessellate a BREP with per-face triangle ranges for face-level picking.
169
+ * `tolerance <= 0` selects the deterministic auto display tolerance (from the
170
+ * BREP's own extent), so triangle indices from a previously produced
171
+ * auto-tolerance display mesh stay valid across calls.
172
+ * Packing: [vertexCount, indexCount, rangeCount,
173
+ * positions(3·vc), indices(ic), (face, firstTri, triCount)·rc].
174
+ */
175
+ export function brep_tessellate_with_face_ranges(json: string, tolerance: number): Float64Array;
176
+
90
177
  /**
91
178
  * Apply a row-major 4x4 matrix to a BREP. Returns transformed JSON.
92
179
  */
@@ -544,6 +631,19 @@ export function mesh_get_edge_vertex_pairs(vertex_count: number, buffer: Float64
544
631
  */
545
632
  export function mesh_get_face_area(vertex_count: number, buffer: Float64Array, face_index: number): number;
546
633
 
634
+ /**
635
+ * Boundary loops of the coplanar connected face group containing `face_index`.
636
+ *
637
+ * Boundary edges are the directed triangle edges whose reversed twin is not
638
+ * present within the group; chaining them preserves the group's winding.
639
+ * Consecutive collinear points (T-junction subdivisions) are collapsed so
640
+ * consumers receive clean polygon corners.
641
+ *
642
+ * Output format: [loopCount, (pointCount, x, y, z, ...) per loop].
643
+ * Loops are implicitly closed (last point connects back to the first).
644
+ */
645
+ export function mesh_get_face_boundary_loops(vertex_count: number, buffer: Float64Array, face_index: number): Float64Array;
646
+
547
647
  /**
548
648
  * Face centroid as [x, y, z].
549
649
  */
@@ -681,6 +781,14 @@ export function mesh_solid_split_by_surface(vertex_count_a: number, buffer_a: Fl
681
781
 
682
782
  export function mesh_solid_split_plane(vertex_count: number, buffer: Float64Array, nx: number, ny: number, nz: number, d: number, operation: string): Float64Array;
683
783
 
784
+ /**
785
+ * One-shot production path: closed manifold triangle mesh ÷ NURBS surface →
786
+ * both halves as exact capped BREPs, in a single WASM crossing (mesh→BREP
787
+ * conversion, sheet construction and the parametric split all run kernel-side).
788
+ * Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
789
+ */
790
+ export function mesh_split_by_surface_to_brep(vertex_count: number, buffer: Float64Array, surface_data: Float64Array, tolerance: number, normal_angle_tol_deg: number, max_faces: number): string;
791
+
684
792
  /**
685
793
  * Trim an OPEN host surface by all closed cutter meshes in one WASM call.
686
794
  *
@@ -970,17 +1078,29 @@ export interface InitOutput {
970
1078
  readonly arc_length: (a: number, b: number, c: number) => number;
971
1079
  readonly arc_point_at: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
972
1080
  readonly brep_boolean_op: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1081
+ readonly brep_closest_face: (a: number, b: number, c: number, d: number, e: number) => [number, number];
973
1082
  readonly brep_edges: (a: number, b: number, c: number) => [number, number];
1083
+ readonly brep_extract_face: (a: number, b: number, c: number) => [number, number];
1084
+ readonly brep_extract_faces: (a: number, b: number) => [number, number];
974
1085
  readonly brep_extrude_curve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1086
+ readonly brep_face_closest_uv: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
975
1087
  readonly brep_face_iso_curve: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1088
+ readonly brep_face_iso_curves_trimmed: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1089
+ readonly brep_face_iso_curves_trimmed_normalized: (a: number, b: number, c: number, d: number, e: number) => [number, number];
976
1090
  readonly brep_face_surface: (a: number, b: number, c: number) => [number, number];
1091
+ readonly brep_face_surface_cropped: (a: number, b: number, c: number) => [number, number];
1092
+ readonly brep_face_surfaces_cropped: (a: number, b: number) => [number, number];
977
1093
  readonly brep_face_tessellate: (a: number, b: number, c: number, d: number) => [number, number];
1094
+ readonly brep_face_trim_bounds: (a: number, b: number, c: number) => [number, number];
1095
+ readonly brep_from_mesh_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
978
1096
  readonly brep_info: (a: number, b: number) => [number, number];
979
1097
  readonly brep_loft_curves: (a: number, b: number) => [number, number];
980
1098
  readonly brep_primitive: (a: number, b: number, c: number, d: number) => [number, number];
981
1099
  readonly brep_revolve_curve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
982
1100
  readonly brep_sheet_from_surface: (a: number, b: number) => [number, number];
1101
+ readonly brep_split_solid_by_sheet_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
983
1102
  readonly brep_tessellate: (a: number, b: number, c: number) => [number, number];
1103
+ readonly brep_tessellate_with_face_ranges: (a: number, b: number, c: number) => [number, number];
984
1104
  readonly brep_transform: (a: number, b: number, c: number, d: number) => [number, number];
985
1105
  readonly brep_validate: (a: number, b: number, c: number) => [number, number];
986
1106
  readonly brep_volume_area: (a: number, b: number, c: number) => [number, number];
@@ -1060,6 +1180,7 @@ export interface InitOutput {
1060
1180
  readonly mesh_get_coplanar_face_region: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => [number, number];
1061
1181
  readonly mesh_get_edge_vertex_pairs: (a: number, b: number, c: number) => [number, number];
1062
1182
  readonly mesh_get_face_area: (a: number, b: number, c: number, d: number) => number;
1183
+ readonly mesh_get_face_boundary_loops: (a: number, b: number, c: number, d: number) => [number, number];
1063
1184
  readonly mesh_get_face_centroid: (a: number, b: number, c: number, d: number) => [number, number];
1064
1185
  readonly mesh_get_face_normal: (a: number, b: number, c: number, d: number) => [number, number];
1065
1186
  readonly mesh_get_smooth_face_group: (a: number, b: number, c: number, d: number, e: number) => [number, number];
@@ -1083,6 +1204,7 @@ export interface InitOutput {
1083
1204
  readonly mesh_scale: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1084
1205
  readonly mesh_solid_split_by_surface: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1085
1206
  readonly mesh_solid_split_plane: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
1207
+ readonly mesh_split_by_surface_to_brep: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1086
1208
  readonly mesh_surface_difference_all: (a: number, b: number, c: number, d: number) => [number, number];
1087
1209
  readonly mesh_surface_split: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1088
1210
  readonly mesh_surface_split_plane: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
@@ -64,6 +64,24 @@ export function brep_boolean_op(a_json, b_json, op, tolerance) {
64
64
  }
65
65
  }
66
66
 
67
+ /**
68
+ * Closest BREP face to a 3D point. Returns [faceIndex, u, v, distance,
69
+ * isNurbs] ((u, v) in the surface's KNOT domain) or empty on failure.
70
+ * @param {string} json
71
+ * @param {number} x
72
+ * @param {number} y
73
+ * @param {number} z
74
+ * @returns {Float64Array}
75
+ */
76
+ export function brep_closest_face(json, x, y, z) {
77
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ const len0 = WASM_VECTOR_LEN;
79
+ const ret = wasm.brep_closest_face(ptr0, len0, x, y, z);
80
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
81
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
82
+ return v2;
83
+ }
84
+
67
85
  /**
68
86
  * All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
69
87
  * @param {string} json
@@ -79,6 +97,51 @@ export function brep_edges(json, tolerance) {
79
97
  return v2;
80
98
  }
81
99
 
100
+ /**
101
+ * Extract one face as a standalone single-face TRIMMED sheet BREP (trim
102
+ * loops, pcurves, edges and vertices preserved). Returns JSON, empty on
103
+ * failure.
104
+ * @param {string} json
105
+ * @param {number} face_index
106
+ * @returns {string}
107
+ */
108
+ export function brep_extract_face(json, face_index) {
109
+ let deferred2_0;
110
+ let deferred2_1;
111
+ try {
112
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len0 = WASM_VECTOR_LEN;
114
+ const ret = wasm.brep_extract_face(ptr0, len0, face_index);
115
+ deferred2_0 = ret[0];
116
+ deferred2_1 = ret[1];
117
+ return getStringFromWasm0(ret[0], ret[1]);
118
+ } finally {
119
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
120
+ }
121
+ }
122
+
123
+ /**
124
+ * ALL faces as standalone single-face trimmed sheet BREPs, in one crossing
125
+ * (the source JSON is parsed once). Returns a JSON ARRAY aligned with face
126
+ * indices; faces that fail to extract are `null`.
127
+ * @param {string} json
128
+ * @returns {string}
129
+ */
130
+ export function brep_extract_faces(json) {
131
+ let deferred2_0;
132
+ let deferred2_1;
133
+ try {
134
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ret = wasm.brep_extract_faces(ptr0, len0);
137
+ deferred2_0 = ret[0];
138
+ deferred2_1 = ret[1];
139
+ return getStringFromWasm0(ret[0], ret[1]);
140
+ } finally {
141
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
142
+ }
143
+ }
144
+
82
145
  /**
83
146
  * Extrude a profile curve into a BREP (closed profile → capped solid,
84
147
  * open profile → sheet). Returns JSON.
@@ -104,6 +167,25 @@ export function brep_extrude_curve(curve_data, dx, dy, dz, height) {
104
167
  }
105
168
  }
106
169
 
170
+ /**
171
+ * Exact (u, v) of a point on a specific BREP face (closest-point Newton for
172
+ * NURBS, frame projection for planes). Returns [u, v, distance, isNurbs].
173
+ * @param {string} json
174
+ * @param {number} face_index
175
+ * @param {number} x
176
+ * @param {number} y
177
+ * @param {number} z
178
+ * @returns {Float64Array}
179
+ */
180
+ export function brep_face_closest_uv(json, face_index, x, y, z) {
181
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ const ret = wasm.brep_face_closest_uv(ptr0, len0, face_index, x, y, z);
184
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
185
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
186
+ return v2;
187
+ }
188
+
107
189
  /**
108
190
  * Iso-parametric curve of a NURBS face's backing surface (untrimmed).
109
191
  * Returns curve data, or empty for planar faces.
@@ -122,6 +204,46 @@ export function brep_face_iso_curve(json, face_index, t, u_dir) {
122
204
  return v2;
123
205
  }
124
206
 
207
+ /**
208
+ * Exact isocurve(s) of a BREP face at KNOT-domain parameter `t`, CLIPPED to
209
+ * the face's trimmed region. `u_dir = true` runs along u at fixed v = t.
210
+ * Line pieces (planar faces) are encoded as degree-1 NURBS.
211
+ * Packing: [curveCount, (bufLen, curveData…)·curveCount] where curveData is
212
+ * the standard NURBS curve encoding.
213
+ * @param {string} json
214
+ * @param {number} face_index
215
+ * @param {number} t
216
+ * @param {boolean} u_dir
217
+ * @returns {Float64Array}
218
+ */
219
+ export function brep_face_iso_curves_trimmed(json, face_index, t, u_dir) {
220
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ const ret = wasm.brep_face_iso_curves_trimmed(ptr0, len0, face_index, t, u_dir);
223
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
224
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
225
+ return v2;
226
+ }
227
+
228
+ /**
229
+ * Like `brep_face_iso_curves_trimmed`, but `t` is NORMALIZED [0, 1] across
230
+ * the face's trim extent in the fixed direction — callers don't need the
231
+ * surface knot domain. Same packing.
232
+ * @param {string} json
233
+ * @param {number} face_index
234
+ * @param {number} t
235
+ * @param {boolean} u_dir
236
+ * @returns {Float64Array}
237
+ */
238
+ export function brep_face_iso_curves_trimmed_normalized(json, face_index, t, u_dir) {
239
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len0 = WASM_VECTOR_LEN;
241
+ const ret = wasm.brep_face_iso_curves_trimmed_normalized(ptr0, len0, face_index, t, u_dir);
242
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
243
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
244
+ return v2;
245
+ }
246
+
125
247
  /**
126
248
  * Geometric backing of a face.
127
249
  * Returns [0, ox,oy,oz, ux,uy,uz, vx,vy,vz] for planes,
@@ -139,6 +261,39 @@ export function brep_face_surface(json, face_index) {
139
261
  return v2;
140
262
  }
141
263
 
264
+ /**
265
+ * Underlying surface of a face CROPPED to its trim extent, ALWAYS as a NURBS
266
+ * surface (planar faces become exact degree-1 patches). Returns surface
267
+ * data, empty on failure.
268
+ * @param {string} json
269
+ * @param {number} face_index
270
+ * @returns {Float64Array}
271
+ */
272
+ export function brep_face_surface_cropped(json, face_index) {
273
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len0 = WASM_VECTOR_LEN;
275
+ const ret = wasm.brep_face_surface_cropped(ptr0, len0, face_index);
276
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
277
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
278
+ return v2;
279
+ }
280
+
281
+ /**
282
+ * Batch variant of `brep_face_surface_cropped` for all faces in one
283
+ * crossing. Packing: [faceCount, (bufLen, surfaceData…)·faceCount], aligned
284
+ * with face indices — a face that fails to crop gets bufLen 0.
285
+ * @param {string} json
286
+ * @returns {Float64Array}
287
+ */
288
+ export function brep_face_surfaces_cropped(json) {
289
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
290
+ const len0 = WASM_VECTOR_LEN;
291
+ const ret = wasm.brep_face_surfaces_cropped(ptr0, len0);
292
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
293
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
294
+ return v2;
295
+ }
296
+
142
297
  /**
143
298
  * Tessellate a single BREP face. Returns the standard mesh buffer.
144
299
  * @param {string} json
@@ -155,6 +310,47 @@ export function brep_face_tessellate(json, face_index, tolerance) {
155
310
  return v2;
156
311
  }
157
312
 
313
+ /**
314
+ * UV bounding box of a face's trim loops in surface parameter space:
315
+ * [u_min, u_max, v_min, v_max]. Empty on failure.
316
+ * @param {string} json
317
+ * @param {number} face_index
318
+ * @returns {Float64Array}
319
+ */
320
+ export function brep_face_trim_bounds(json, face_index) {
321
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
322
+ const len0 = WASM_VECTOR_LEN;
323
+ const ret = wasm.brep_face_trim_bounds(ptr0, len0, face_index);
324
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
325
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
326
+ return v2;
327
+ }
328
+
329
+ /**
330
+ * Convert a closed manifold triangle mesh into a planar-face BREP.
331
+ * `normal_angle_tol_deg` ≤ 0 selects the default (≈0.057°); `max_faces` 0 =
332
+ * default guard (4096). Returns BREP JSON or {"error": ...}.
333
+ * @param {number} vertex_count
334
+ * @param {Float64Array} buffer
335
+ * @param {number} normal_angle_tol_deg
336
+ * @param {number} max_faces
337
+ * @returns {string}
338
+ */
339
+ export function brep_from_mesh_buffer(vertex_count, buffer, normal_angle_tol_deg, max_faces) {
340
+ let deferred2_0;
341
+ let deferred2_1;
342
+ try {
343
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
344
+ const len0 = WASM_VECTOR_LEN;
345
+ const ret = wasm.brep_from_mesh_buffer(vertex_count, ptr0, len0, normal_angle_tol_deg, max_faces);
346
+ deferred2_0 = ret[0];
347
+ deferred2_1 = ret[1];
348
+ return getStringFromWasm0(ret[0], ret[1]);
349
+ } finally {
350
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
351
+ }
352
+ }
353
+
158
354
  /**
159
355
  * BREP structure summary: [face_count, edge_count, vertex_count, is_closed].
160
356
  * @param {string} json
@@ -266,6 +462,33 @@ export function brep_sheet_from_surface(surface_data) {
266
462
  }
267
463
  }
268
464
 
465
+ /**
466
+ * Split a closed solid BREP by a sheet BREP into BOTH capped halves.
467
+ * Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
468
+ * Sides follow the sheet normal (negative = behind it), matching
469
+ * `mesh_solid_split_by_surface`.
470
+ * @param {string} solid_json
471
+ * @param {string} sheet_json
472
+ * @param {number} tolerance
473
+ * @returns {string}
474
+ */
475
+ export function brep_split_solid_by_sheet_op(solid_json, sheet_json, tolerance) {
476
+ let deferred3_0;
477
+ let deferred3_1;
478
+ try {
479
+ const ptr0 = passStringToWasm0(solid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ const ptr1 = passStringToWasm0(sheet_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
+ const len1 = WASM_VECTOR_LEN;
483
+ const ret = wasm.brep_split_solid_by_sheet_op(ptr0, len0, ptr1, len1, tolerance);
484
+ deferred3_0 = ret[0];
485
+ deferred3_1 = ret[1];
486
+ return getStringFromWasm0(ret[0], ret[1]);
487
+ } finally {
488
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
489
+ }
490
+ }
491
+
269
492
  /**
270
493
  * Tessellate a BREP into the standard mesh buffer
271
494
  * [vertexCount, positions..., indices...]. Crack-free across shared edges.
@@ -282,6 +505,26 @@ export function brep_tessellate(json, tolerance) {
282
505
  return v2;
283
506
  }
284
507
 
508
+ /**
509
+ * Tessellate a BREP with per-face triangle ranges for face-level picking.
510
+ * `tolerance <= 0` selects the deterministic auto display tolerance (from the
511
+ * BREP's own extent), so triangle indices from a previously produced
512
+ * auto-tolerance display mesh stay valid across calls.
513
+ * Packing: [vertexCount, indexCount, rangeCount,
514
+ * positions(3·vc), indices(ic), (face, firstTri, triCount)·rc].
515
+ * @param {string} json
516
+ * @param {number} tolerance
517
+ * @returns {Float64Array}
518
+ */
519
+ export function brep_tessellate_with_face_ranges(json, tolerance) {
520
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
521
+ const len0 = WASM_VECTOR_LEN;
522
+ const ret = wasm.brep_tessellate_with_face_ranges(ptr0, len0, tolerance);
523
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
524
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
525
+ return v2;
526
+ }
527
+
285
528
  /**
286
529
  * Apply a row-major 4x4 matrix to a BREP. Returns transformed JSON.
287
530
  * @param {string} json
@@ -1930,6 +2173,30 @@ export function mesh_get_face_area(vertex_count, buffer, face_index) {
1930
2173
  return ret;
1931
2174
  }
1932
2175
 
2176
+ /**
2177
+ * Boundary loops of the coplanar connected face group containing `face_index`.
2178
+ *
2179
+ * Boundary edges are the directed triangle edges whose reversed twin is not
2180
+ * present within the group; chaining them preserves the group's winding.
2181
+ * Consecutive collinear points (T-junction subdivisions) are collapsed so
2182
+ * consumers receive clean polygon corners.
2183
+ *
2184
+ * Output format: [loopCount, (pointCount, x, y, z, ...) per loop].
2185
+ * Loops are implicitly closed (last point connects back to the first).
2186
+ * @param {number} vertex_count
2187
+ * @param {Float64Array} buffer
2188
+ * @param {number} face_index
2189
+ * @returns {Float64Array}
2190
+ */
2191
+ export function mesh_get_face_boundary_loops(vertex_count, buffer, face_index) {
2192
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2193
+ const len0 = WASM_VECTOR_LEN;
2194
+ const ret = wasm.mesh_get_face_boundary_loops(vertex_count, ptr0, len0, face_index);
2195
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2196
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2197
+ return v2;
2198
+ }
2199
+
1933
2200
  /**
1934
2201
  * Face centroid as [x, y, z].
1935
2202
  * @param {number} vertex_count
@@ -2379,6 +2646,36 @@ export function mesh_solid_split_plane(vertex_count, buffer, nx, ny, nz, d, oper
2379
2646
  return v3;
2380
2647
  }
2381
2648
 
2649
+ /**
2650
+ * One-shot production path: closed manifold triangle mesh ÷ NURBS surface →
2651
+ * both halves as exact capped BREPs, in a single WASM crossing (mesh→BREP
2652
+ * conversion, sheet construction and the parametric split all run kernel-side).
2653
+ * Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
2654
+ * @param {number} vertex_count
2655
+ * @param {Float64Array} buffer
2656
+ * @param {Float64Array} surface_data
2657
+ * @param {number} tolerance
2658
+ * @param {number} normal_angle_tol_deg
2659
+ * @param {number} max_faces
2660
+ * @returns {string}
2661
+ */
2662
+ export function mesh_split_by_surface_to_brep(vertex_count, buffer, surface_data, tolerance, normal_angle_tol_deg, max_faces) {
2663
+ let deferred3_0;
2664
+ let deferred3_1;
2665
+ try {
2666
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
2667
+ const len0 = WASM_VECTOR_LEN;
2668
+ const ptr1 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
2669
+ const len1 = WASM_VECTOR_LEN;
2670
+ const ret = wasm.mesh_split_by_surface_to_brep(vertex_count, ptr0, len0, ptr1, len1, tolerance, normal_angle_tol_deg, max_faces);
2671
+ deferred3_0 = ret[0];
2672
+ deferred3_1 = ret[1];
2673
+ return getStringFromWasm0(ret[0], ret[1]);
2674
+ } finally {
2675
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2676
+ }
2677
+ }
2678
+
2382
2679
  /**
2383
2680
  * Trim an OPEN host surface by all closed cutter meshes in one WASM call.
2384
2681
  *