okgeometry-api 1.15.0 → 1.17.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 +95 -6
- package/dist/Brep.d.ts.map +1 -1
- package/dist/Brep.js +114 -5
- package/dist/Brep.js.map +1 -1
- package/dist/GeometryBoolean.d.ts +136 -0
- package/dist/GeometryBoolean.d.ts.map +1 -0
- package/dist/GeometryBoolean.js +632 -0
- package/dist/GeometryBoolean.js.map +1 -0
- package/dist/Mesh.d.ts +21 -1
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +66 -4
- package/dist/Mesh.js.map +1 -1
- package/dist/NurbsCurve.d.ts +66 -0
- package/dist/NurbsCurve.d.ts.map +1 -1
- package/dist/NurbsCurve.js +101 -0
- package/dist/NurbsCurve.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 +123 -1
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +193 -1
- package/dist/wasm-bindings.js.map +1 -1
- package/package.json +58 -54
- package/src/Brep.ts +147 -10
- package/src/GeometryBoolean.ts +863 -0
- package/src/Mesh.ts +3804 -3730
- package/src/NurbsCurve.ts +110 -0
- package/src/index.ts +88 -79
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings.d.ts +110 -1
- package/src/wasm-bindings.js +197 -1
package/src/wasm-bindings.d.ts
CHANGED
|
@@ -14,7 +14,20 @@ export function arc_point_at(cx: number, cy: number, cz: number, nx: number, ny:
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Parametric BREP boolean: exact surface–surface intersection curves with
|
|
17
|
-
* trimmed-surface output.
|
|
17
|
+
* trimmed-surface output. Operands may be closed solids OR open sheets —
|
|
18
|
+
* the kernel dispatches on closedness (oriented-sheet convention: a sheet's
|
|
19
|
+
* "inside" is the FRONT of its normal):
|
|
20
|
+
* - closed × closed: full volumetric boolean.
|
|
21
|
+
* - sheet × solid: subtract keeps the sheet outside the solid, intersect
|
|
22
|
+
* keeps the inside.
|
|
23
|
+
* - solid × sheet: subtract keeps the capped half BEHIND the sheet normal,
|
|
24
|
+
* intersect the front half.
|
|
25
|
+
* - sheet × sheet: a sheet's material is its FRONT half-space, so union
|
|
26
|
+
* stitches A-BACK + B-BACK at the intersection edges (front pieces are
|
|
27
|
+
* interior to the union material; uncut pieces are kept, coincident
|
|
28
|
+
* overlaps keep A's copy); subtract keeps A's back pieces; intersect
|
|
29
|
+
* A's front pieces.
|
|
30
|
+
* - union of a solid and a sheet is not defined and returns an error.
|
|
18
31
|
* op: "union" | "intersect" | "subtract".
|
|
19
32
|
* Returns the result BREP as JSON, or {"error": "..."} on failure.
|
|
20
33
|
*/
|
|
@@ -153,6 +166,23 @@ export function brep_from_mesh_buffer(vertex_count: number, buffer: Float64Array
|
|
|
153
166
|
*/
|
|
154
167
|
export function brep_info(json: string): Float64Array;
|
|
155
168
|
|
|
169
|
+
/**
|
|
170
|
+
* [`brep_intersection_curves_op`] with the per-face-pair pieces JOINED into
|
|
171
|
+
* maximal curves: greedy reversal-aware endpoint chaining, exact degree
|
|
172
|
+
* elevation to the chain maximum, exact `join_arcs` knot concatenation
|
|
173
|
+
* (junction multiplicity = degree, no re-parameterization), and a per-curve
|
|
174
|
+
* verification gate (dense samples within 5·tolerance of BOTH operands'
|
|
175
|
+
* surfaces — a chain failing the gate comes back unjoined, never corrupted).
|
|
176
|
+
* A closed intersection loop (e.g. plane through a cylinder) comes back as
|
|
177
|
+
* ONE closed curve.
|
|
178
|
+
*
|
|
179
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (standard NURBS
|
|
180
|
+
* curve encoding). Returns an EMPTY buffer on failure (invalid BREP JSON or
|
|
181
|
+
* a pipeline error) — distinguishable from `[0]`, which means the operands
|
|
182
|
+
* genuinely do not intersect.
|
|
183
|
+
*/
|
|
184
|
+
export function brep_intersection_curves_joined_op(a_json: string, b_json: string, tolerance: number): Float64Array;
|
|
185
|
+
|
|
156
186
|
/**
|
|
157
187
|
* TRIM-EXACT intersection curves between two BREPs (solids OR sheets): the
|
|
158
188
|
* parametric boolean's SSI → clip → convergence stages run and the fitted 3D
|
|
@@ -210,6 +240,24 @@ export function brep_revolve_curve(curve_data: Float64Array, ox: number, oy: num
|
|
|
210
240
|
*/
|
|
211
241
|
export function brep_sheet_from_surface(surface_data: Float64Array): string;
|
|
212
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Split an OPEN sheet BREP `a` by another OPEN sheet BREP `b`.
|
|
245
|
+
* Returns {"inside": <brep|null>, "outside": <brep|null>} or {"error":...}:
|
|
246
|
+
* `inside` = a's pieces in FRONT of b's oriented normal, `outside` = the
|
|
247
|
+
* pieces behind it (matching the oriented-sheet convention of
|
|
248
|
+
* `mesh_clip_polyline` and the sheet boolean dispatch).
|
|
249
|
+
*/
|
|
250
|
+
export function brep_split_sheet_by_sheet_op(a_json: string, b_json: string, tolerance: number): string;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Split an OPEN sheet BREP by a CLOSED solid BREP into containment sides.
|
|
254
|
+
* Returns {"inside": <brep|null>, "outside": <brep|null>} or {"error":...}:
|
|
255
|
+
* `inside` = the sheet pieces contained in the solid (ON-boundary pieces
|
|
256
|
+
* count as inside), `outside` = the rest. Both preserve the sheet's exact
|
|
257
|
+
* trimmed faces, pcurves and edges.
|
|
258
|
+
*/
|
|
259
|
+
export function brep_split_sheet_by_solid_op(sheet_json: string, solid_json: string, tolerance: number): string;
|
|
260
|
+
|
|
213
261
|
/**
|
|
214
262
|
* Split a closed solid BREP by a sheet BREP into BOTH capped halves.
|
|
215
263
|
* Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
|
|
@@ -304,6 +352,49 @@ export function create_line(x1: number, y1: number, z1: number, x2: number, y2:
|
|
|
304
352
|
*/
|
|
305
353
|
export function create_polyline(coords: Float64Array, samples_per_segment: number): Float64Array;
|
|
306
354
|
|
|
355
|
+
/**
|
|
356
|
+
* 2D REGION boolean between two CLOSED, COPLANAR curves (Rhino CurveBoolean).
|
|
357
|
+
*
|
|
358
|
+
* Both inputs are standard NURBS curve encodings (the TS layer coerces
|
|
359
|
+
* circles/arcs/polylines/polycurves to exact NURBS first). The curves are
|
|
360
|
+
* projected onto a common plane (fitted from A, coplanarity verified),
|
|
361
|
+
* tessellated to polygons, arranged in 2D, classified by inside-A/inside-B
|
|
362
|
+
* (nonzero winding), and the result loops emitted per op. CLOSURE is
|
|
363
|
+
* verified kernel-side: each curve's endpoints must coincide within a
|
|
364
|
+
* scale-relative tolerance, open curves error out (never silently
|
|
365
|
+
* chord-closed).
|
|
366
|
+
*
|
|
367
|
+
* `op`: 0 = union, 1 = subtract (A − B), 2 = intersect.
|
|
368
|
+
*
|
|
369
|
+
* Result loops are POLYLINE (degree-1 NURBS) closed curves — Rhino-parity
|
|
370
|
+
* fidelity. Tessellation samples include every distinct interior knot value,
|
|
371
|
+
* so degree-1 polygon corners and C0 kinks are preserved EXACTLY, and
|
|
372
|
+
* consecutive collinear points are collapsed so straight runs come back as
|
|
373
|
+
* single segments. Outer boundaries are CCW (positive plane-signed area),
|
|
374
|
+
* holes CW. CCW is measured about a DETERMINISTIC plane normal: the normal
|
|
375
|
+
* fitted from curve A, flipped so its dominant world-axis component is
|
|
376
|
+
* positive (for XY-plane curves the reference is +Z). The orientation is
|
|
377
|
+
* therefore independent of the inputs' drawing direction. Callers
|
|
378
|
+
* reconstruct nesting from the winding sign.
|
|
379
|
+
*
|
|
380
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (same multi-curve
|
|
381
|
+
* packing as `nurbs_curve_split_at_params`). An EMPTY buffer signals an error
|
|
382
|
+
* (non-coplanar / open input / malformed input); a valid but EMPTY result
|
|
383
|
+
* (e.g. disjoint intersect) is the non-empty `[0]` packing.
|
|
384
|
+
*/
|
|
385
|
+
export function curve_region_boolean(a_data: Float64Array, b_data: Float64Array, op: number): Float64Array;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* SPLIT two CLOSED, COPLANAR curves into ALL region boundaries (Rhino
|
|
389
|
+
* "region split"): the arrangement of A and B partitions the plane into the
|
|
390
|
+
* pieces inside-A-only, inside-B-only and inside-both; each bounded region's
|
|
391
|
+
* outer and hole loops are returned as their own closed curves.
|
|
392
|
+
*
|
|
393
|
+
* Inputs, plane/coplanarity handling, fidelity and orientation follow
|
|
394
|
+
* `curve_region_boolean`. Same multi-curve packing; empty buffer on error.
|
|
395
|
+
*/
|
|
396
|
+
export function curve_region_split(a_data: Float64Array, b_data: Float64Array): Float64Array;
|
|
397
|
+
|
|
307
398
|
/**
|
|
308
399
|
* Serialize a curve to a list of points for Three.js rendering
|
|
309
400
|
* Returns a flat array of coordinates: [x1, y1, z1, x2, y2, z2, ...]
|
|
@@ -862,6 +953,18 @@ export function mesh_rotate(vertex_count: number, buffer: Float64Array, ax: numb
|
|
|
862
953
|
*/
|
|
863
954
|
export function mesh_scale(vertex_count: number, buffer: Float64Array, sx: number, sy: number, sz: number): Float64Array;
|
|
864
955
|
|
|
956
|
+
/**
|
|
957
|
+
* Union of two OPEN oriented sheets (mesh A ∪ mesh B): mutual trim + join.
|
|
958
|
+
* A sheet's material is its FRONT half-space, so the union boundary keeps
|
|
959
|
+
* A's pieces BEHIND B and B's pieces BEHIND A (pieces in front of the other
|
|
960
|
+
* sheet are interior to the union material and are dropped), stitched at
|
|
961
|
+
* the shared intersection seam; regions the other operand never cuts are
|
|
962
|
+
* kept wholesale (coincident-overlap regions keep A's copy only). Rejects
|
|
963
|
+
* closed operands — those belong to the solid boolean. Returns one mesh
|
|
964
|
+
* buffer in the standard `[vertexCount, positions…, indices…]` layout.
|
|
965
|
+
*/
|
|
966
|
+
export function mesh_sheet_union(vertex_count_a: number, buffer_a: Float64Array, vertex_count_b: number, buffer_b: Float64Array, flags: string): Float64Array;
|
|
967
|
+
|
|
865
968
|
/**
|
|
866
969
|
* Split a closed solid (mesh A) by a surface (mesh B) into BOTH capped solids.
|
|
867
970
|
* `outside` = the solid on the negative side of the surface, `inside` = the
|
|
@@ -1271,12 +1374,15 @@ export interface InitOutput {
|
|
|
1271
1374
|
readonly brep_face_trim_bounds: (a: number, b: number, c: number) => [number, number];
|
|
1272
1375
|
readonly brep_from_mesh_buffer: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1273
1376
|
readonly brep_info: (a: number, b: number) => [number, number];
|
|
1377
|
+
readonly brep_intersection_curves_joined_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1274
1378
|
readonly brep_intersection_curves_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1275
1379
|
readonly brep_loft_curves: (a: number, b: number) => [number, number];
|
|
1276
1380
|
readonly brep_mesh_intersection_curves_op: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
1277
1381
|
readonly brep_primitive: (a: number, b: number, c: number, d: number) => [number, number];
|
|
1278
1382
|
readonly brep_revolve_curve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
1279
1383
|
readonly brep_sheet_from_surface: (a: number, b: number) => [number, number];
|
|
1384
|
+
readonly brep_split_sheet_by_sheet_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1385
|
+
readonly brep_split_sheet_by_solid_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1280
1386
|
readonly brep_split_solid_by_sheet_op: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1281
1387
|
readonly brep_tessellate: (a: number, b: number, c: number) => [number, number];
|
|
1282
1388
|
readonly brep_tessellate_with_face_ranges: (a: number, b: number, c: number) => [number, number];
|
|
@@ -1291,6 +1397,8 @@ export interface InitOutput {
|
|
|
1291
1397
|
readonly create_circle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
1292
1398
|
readonly create_line: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
1293
1399
|
readonly create_polyline: (a: number, b: number, c: number) => [number, number];
|
|
1400
|
+
readonly curve_region_boolean: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1401
|
+
readonly curve_region_split: (a: number, b: number, c: number, d: number) => [number, number];
|
|
1294
1402
|
readonly curve_to_points: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1295
1403
|
readonly evaluate_nurbs_curve_at: (a: number, b: number, c: number) => [number, number];
|
|
1296
1404
|
readonly extrude_circle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
|
|
@@ -1383,6 +1491,7 @@ export interface InitOutput {
|
|
|
1383
1491
|
readonly mesh_raycast_many: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
1384
1492
|
readonly mesh_rotate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
1385
1493
|
readonly mesh_scale: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
1494
|
+
readonly mesh_sheet_union: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
1386
1495
|
readonly mesh_solid_split_by_surface: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
1387
1496
|
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];
|
|
1388
1497
|
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];
|
package/src/wasm-bindings.js
CHANGED
|
@@ -36,7 +36,20 @@ export function arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_an
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Parametric BREP boolean: exact surface–surface intersection curves with
|
|
39
|
-
* trimmed-surface output.
|
|
39
|
+
* trimmed-surface output. Operands may be closed solids OR open sheets —
|
|
40
|
+
* the kernel dispatches on closedness (oriented-sheet convention: a sheet's
|
|
41
|
+
* "inside" is the FRONT of its normal):
|
|
42
|
+
* - closed × closed: full volumetric boolean.
|
|
43
|
+
* - sheet × solid: subtract keeps the sheet outside the solid, intersect
|
|
44
|
+
* keeps the inside.
|
|
45
|
+
* - solid × sheet: subtract keeps the capped half BEHIND the sheet normal,
|
|
46
|
+
* intersect the front half.
|
|
47
|
+
* - sheet × sheet: a sheet's material is its FRONT half-space, so union
|
|
48
|
+
* stitches A-BACK + B-BACK at the intersection edges (front pieces are
|
|
49
|
+
* interior to the union material; uncut pieces are kept, coincident
|
|
50
|
+
* overlaps keep A's copy); subtract keeps A's back pieces; intersect
|
|
51
|
+
* A's front pieces.
|
|
52
|
+
* - union of a solid and a sheet is not defined and returns an error.
|
|
40
53
|
* op: "union" | "intersect" | "subtract".
|
|
41
54
|
* Returns the result BREP as JSON, or {"error": "..."} on failure.
|
|
42
55
|
* @param {string} a_json
|
|
@@ -419,6 +432,36 @@ export function brep_info(json) {
|
|
|
419
432
|
return v2;
|
|
420
433
|
}
|
|
421
434
|
|
|
435
|
+
/**
|
|
436
|
+
* [`brep_intersection_curves_op`] with the per-face-pair pieces JOINED into
|
|
437
|
+
* maximal curves: greedy reversal-aware endpoint chaining, exact degree
|
|
438
|
+
* elevation to the chain maximum, exact `join_arcs` knot concatenation
|
|
439
|
+
* (junction multiplicity = degree, no re-parameterization), and a per-curve
|
|
440
|
+
* verification gate (dense samples within 5·tolerance of BOTH operands'
|
|
441
|
+
* surfaces — a chain failing the gate comes back unjoined, never corrupted).
|
|
442
|
+
* A closed intersection loop (e.g. plane through a cylinder) comes back as
|
|
443
|
+
* ONE closed curve.
|
|
444
|
+
*
|
|
445
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (standard NURBS
|
|
446
|
+
* curve encoding). Returns an EMPTY buffer on failure (invalid BREP JSON or
|
|
447
|
+
* a pipeline error) — distinguishable from `[0]`, which means the operands
|
|
448
|
+
* genuinely do not intersect.
|
|
449
|
+
* @param {string} a_json
|
|
450
|
+
* @param {string} b_json
|
|
451
|
+
* @param {number} tolerance
|
|
452
|
+
* @returns {Float64Array}
|
|
453
|
+
*/
|
|
454
|
+
export function brep_intersection_curves_joined_op(a_json, b_json, tolerance) {
|
|
455
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
456
|
+
const len0 = WASM_VECTOR_LEN;
|
|
457
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
458
|
+
const len1 = WASM_VECTOR_LEN;
|
|
459
|
+
const ret = wasm.brep_intersection_curves_joined_op(ptr0, len0, ptr1, len1, tolerance);
|
|
460
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
461
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
462
|
+
return v3;
|
|
463
|
+
}
|
|
464
|
+
|
|
422
465
|
/**
|
|
423
466
|
* TRIM-EXACT intersection curves between two BREPs (solids OR sheets): the
|
|
424
467
|
* parametric boolean's SSI → clip → convergence stages run and the fitted 3D
|
|
@@ -573,6 +616,62 @@ export function brep_sheet_from_surface(surface_data) {
|
|
|
573
616
|
}
|
|
574
617
|
}
|
|
575
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Split an OPEN sheet BREP `a` by another OPEN sheet BREP `b`.
|
|
621
|
+
* Returns {"inside": <brep|null>, "outside": <brep|null>} or {"error":...}:
|
|
622
|
+
* `inside` = a's pieces in FRONT of b's oriented normal, `outside` = the
|
|
623
|
+
* pieces behind it (matching the oriented-sheet convention of
|
|
624
|
+
* `mesh_clip_polyline` and the sheet boolean dispatch).
|
|
625
|
+
* @param {string} a_json
|
|
626
|
+
* @param {string} b_json
|
|
627
|
+
* @param {number} tolerance
|
|
628
|
+
* @returns {string}
|
|
629
|
+
*/
|
|
630
|
+
export function brep_split_sheet_by_sheet_op(a_json, b_json, tolerance) {
|
|
631
|
+
let deferred3_0;
|
|
632
|
+
let deferred3_1;
|
|
633
|
+
try {
|
|
634
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
635
|
+
const len0 = WASM_VECTOR_LEN;
|
|
636
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
637
|
+
const len1 = WASM_VECTOR_LEN;
|
|
638
|
+
const ret = wasm.brep_split_sheet_by_sheet_op(ptr0, len0, ptr1, len1, tolerance);
|
|
639
|
+
deferred3_0 = ret[0];
|
|
640
|
+
deferred3_1 = ret[1];
|
|
641
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
642
|
+
} finally {
|
|
643
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Split an OPEN sheet BREP by a CLOSED solid BREP into containment sides.
|
|
649
|
+
* Returns {"inside": <brep|null>, "outside": <brep|null>} or {"error":...}:
|
|
650
|
+
* `inside` = the sheet pieces contained in the solid (ON-boundary pieces
|
|
651
|
+
* count as inside), `outside` = the rest. Both preserve the sheet's exact
|
|
652
|
+
* trimmed faces, pcurves and edges.
|
|
653
|
+
* @param {string} sheet_json
|
|
654
|
+
* @param {string} solid_json
|
|
655
|
+
* @param {number} tolerance
|
|
656
|
+
* @returns {string}
|
|
657
|
+
*/
|
|
658
|
+
export function brep_split_sheet_by_solid_op(sheet_json, solid_json, tolerance) {
|
|
659
|
+
let deferred3_0;
|
|
660
|
+
let deferred3_1;
|
|
661
|
+
try {
|
|
662
|
+
const ptr0 = passStringToWasm0(sheet_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
663
|
+
const len0 = WASM_VECTOR_LEN;
|
|
664
|
+
const ptr1 = passStringToWasm0(solid_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
665
|
+
const len1 = WASM_VECTOR_LEN;
|
|
666
|
+
const ret = wasm.brep_split_sheet_by_solid_op(ptr0, len0, ptr1, len1, tolerance);
|
|
667
|
+
deferred3_0 = ret[0];
|
|
668
|
+
deferred3_1 = ret[1];
|
|
669
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
670
|
+
} finally {
|
|
671
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
576
675
|
/**
|
|
577
676
|
* Split a closed solid BREP by a sheet BREP into BOTH capped halves.
|
|
578
677
|
* Returns {"negative": <brep|null>, "positive": <brep|null>} or {"error":...}.
|
|
@@ -843,6 +942,74 @@ export function create_polyline(coords, samples_per_segment) {
|
|
|
843
942
|
return v2;
|
|
844
943
|
}
|
|
845
944
|
|
|
945
|
+
/**
|
|
946
|
+
* 2D REGION boolean between two CLOSED, COPLANAR curves (Rhino CurveBoolean).
|
|
947
|
+
*
|
|
948
|
+
* Both inputs are standard NURBS curve encodings (the TS layer coerces
|
|
949
|
+
* circles/arcs/polylines/polycurves to exact NURBS first). The curves are
|
|
950
|
+
* projected onto a common plane (fitted from A, coplanarity verified),
|
|
951
|
+
* tessellated to polygons, arranged in 2D, classified by inside-A/inside-B
|
|
952
|
+
* (nonzero winding), and the result loops emitted per op. CLOSURE is
|
|
953
|
+
* verified kernel-side: each curve's endpoints must coincide within a
|
|
954
|
+
* scale-relative tolerance, open curves error out (never silently
|
|
955
|
+
* chord-closed).
|
|
956
|
+
*
|
|
957
|
+
* `op`: 0 = union, 1 = subtract (A − B), 2 = intersect.
|
|
958
|
+
*
|
|
959
|
+
* Result loops are POLYLINE (degree-1 NURBS) closed curves — Rhino-parity
|
|
960
|
+
* fidelity. Tessellation samples include every distinct interior knot value,
|
|
961
|
+
* so degree-1 polygon corners and C0 kinks are preserved EXACTLY, and
|
|
962
|
+
* consecutive collinear points are collapsed so straight runs come back as
|
|
963
|
+
* single segments. Outer boundaries are CCW (positive plane-signed area),
|
|
964
|
+
* holes CW. CCW is measured about a DETERMINISTIC plane normal: the normal
|
|
965
|
+
* fitted from curve A, flipped so its dominant world-axis component is
|
|
966
|
+
* positive (for XY-plane curves the reference is +Z). The orientation is
|
|
967
|
+
* therefore independent of the inputs' drawing direction. Callers
|
|
968
|
+
* reconstruct nesting from the winding sign.
|
|
969
|
+
*
|
|
970
|
+
* Packing: `[curveCount, (bufLen, curveData…)·curveCount]` (same multi-curve
|
|
971
|
+
* packing as `nurbs_curve_split_at_params`). An EMPTY buffer signals an error
|
|
972
|
+
* (non-coplanar / open input / malformed input); a valid but EMPTY result
|
|
973
|
+
* (e.g. disjoint intersect) is the non-empty `[0]` packing.
|
|
974
|
+
* @param {Float64Array} a_data
|
|
975
|
+
* @param {Float64Array} b_data
|
|
976
|
+
* @param {number} op
|
|
977
|
+
* @returns {Float64Array}
|
|
978
|
+
*/
|
|
979
|
+
export function curve_region_boolean(a_data, b_data, op) {
|
|
980
|
+
const ptr0 = passArrayF64ToWasm0(a_data, wasm.__wbindgen_malloc);
|
|
981
|
+
const len0 = WASM_VECTOR_LEN;
|
|
982
|
+
const ptr1 = passArrayF64ToWasm0(b_data, wasm.__wbindgen_malloc);
|
|
983
|
+
const len1 = WASM_VECTOR_LEN;
|
|
984
|
+
const ret = wasm.curve_region_boolean(ptr0, len0, ptr1, len1, op);
|
|
985
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
986
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
987
|
+
return v3;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* SPLIT two CLOSED, COPLANAR curves into ALL region boundaries (Rhino
|
|
992
|
+
* "region split"): the arrangement of A and B partitions the plane into the
|
|
993
|
+
* pieces inside-A-only, inside-B-only and inside-both; each bounded region's
|
|
994
|
+
* outer and hole loops are returned as their own closed curves.
|
|
995
|
+
*
|
|
996
|
+
* Inputs, plane/coplanarity handling, fidelity and orientation follow
|
|
997
|
+
* `curve_region_boolean`. Same multi-curve packing; empty buffer on error.
|
|
998
|
+
* @param {Float64Array} a_data
|
|
999
|
+
* @param {Float64Array} b_data
|
|
1000
|
+
* @returns {Float64Array}
|
|
1001
|
+
*/
|
|
1002
|
+
export function curve_region_split(a_data, b_data) {
|
|
1003
|
+
const ptr0 = passArrayF64ToWasm0(a_data, wasm.__wbindgen_malloc);
|
|
1004
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1005
|
+
const ptr1 = passArrayF64ToWasm0(b_data, wasm.__wbindgen_malloc);
|
|
1006
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1007
|
+
const ret = wasm.curve_region_split(ptr0, len0, ptr1, len1);
|
|
1008
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1009
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
1010
|
+
return v3;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
846
1013
|
/**
|
|
847
1014
|
* Serialize a curve to a list of points for Three.js rendering
|
|
848
1015
|
* Returns a flat array of coordinates: [x1, y1, z1, x2, y2, z2, ...]
|
|
@@ -2770,6 +2937,35 @@ export function mesh_scale(vertex_count, buffer, sx, sy, sz) {
|
|
|
2770
2937
|
return v2;
|
|
2771
2938
|
}
|
|
2772
2939
|
|
|
2940
|
+
/**
|
|
2941
|
+
* Union of two OPEN oriented sheets (mesh A ∪ mesh B): mutual trim + join.
|
|
2942
|
+
* A sheet's material is its FRONT half-space, so the union boundary keeps
|
|
2943
|
+
* A's pieces BEHIND B and B's pieces BEHIND A (pieces in front of the other
|
|
2944
|
+
* sheet are interior to the union material and are dropped), stitched at
|
|
2945
|
+
* the shared intersection seam; regions the other operand never cuts are
|
|
2946
|
+
* kept wholesale (coincident-overlap regions keep A's copy only). Rejects
|
|
2947
|
+
* closed operands — those belong to the solid boolean. Returns one mesh
|
|
2948
|
+
* buffer in the standard `[vertexCount, positions…, indices…]` layout.
|
|
2949
|
+
* @param {number} vertex_count_a
|
|
2950
|
+
* @param {Float64Array} buffer_a
|
|
2951
|
+
* @param {number} vertex_count_b
|
|
2952
|
+
* @param {Float64Array} buffer_b
|
|
2953
|
+
* @param {string} flags
|
|
2954
|
+
* @returns {Float64Array}
|
|
2955
|
+
*/
|
|
2956
|
+
export function mesh_sheet_union(vertex_count_a, buffer_a, vertex_count_b, buffer_b, flags) {
|
|
2957
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
2958
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2959
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
2960
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2961
|
+
const ptr2 = passStringToWasm0(flags, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2962
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2963
|
+
const ret = wasm.mesh_sheet_union(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1, ptr2, len2);
|
|
2964
|
+
var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2965
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
2966
|
+
return v4;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2773
2969
|
/**
|
|
2774
2970
|
* Split a closed solid (mesh A) by a surface (mesh B) into BOTH capped solids.
|
|
2775
2971
|
* `outside` = the solid on the negative side of the surface, `inside` = the
|