brepkit-wasm 2.4.1 → 2.5.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/brepkit_wasm.d.ts CHANGED
@@ -235,13 +235,13 @@ export class BrepKernel {
235
235
  /**
236
236
  * Build a convex hull solid from a point cloud.
237
237
  *
238
- * Uses a simple Quickhull-inspired algorithm for 3D point sets.
238
+ * Uses the Quickhull algorithm for 3D point sets.
239
239
  *
240
240
  * Returns a solid handle (`u32`).
241
241
  *
242
242
  * # Errors
243
243
  *
244
- * Returns an error if fewer than 4 points are provided.
244
+ * Returns an error if fewer than 4 non-coplanar points are provided.
245
245
  */
246
246
  convexHull(coords: Float64Array): number;
247
247
  /**
@@ -549,6 +549,10 @@ export class BrepKernel {
549
549
  * Apply variable-radius fillets to edges.
550
550
  *
551
551
  * `json` is a JSON string: `[{"edge": u32, "law": "constant"|"linear"|"scurve", "start": f64, "end": f64}]`
552
+ *
553
+ * Also accepts brepjs-style fields: `startRadius`/`endRadius` as aliases for `start`/`end`.
554
+ * When `law` is omitted and `startRadius` != `endRadius`, the law auto-detects as `"linear"`.
555
+ *
552
556
  * Returns a new solid handle.
553
557
  */
554
558
  filletVariable(solid: number, json: string): number;
@@ -561,10 +565,11 @@ export class BrepKernel {
561
565
  /**
562
566
  * Reconstruct a solid from a `toBREP` JSON string.
563
567
  *
564
- * Currently supports planar faces with line edges. Non-line edges are
565
- * approximated as lines (straight segments between start/end vertices).
566
- * Non-planar surfaces are approximated as planes computed from the wire
567
- * vertex positions.
568
+ * Supports all edge curve types (line, circle, ellipse, NURBS) and
569
+ * all surface types (plane, cylinder, cone, sphere, torus, NURBS)
570
+ * via `curveParams` and `surfaceParams` in the JSON. Unrecognized
571
+ * edge types fall back to lines; unrecognized surface types fall back
572
+ * to planes computed from wire vertices.
568
573
  *
569
574
  * Returns a solid handle.
570
575
  *
@@ -1252,6 +1257,18 @@ export class BrepKernel {
1252
1257
  * Returns a new wire handle.
1253
1258
  */
1254
1259
  offsetWire(face: number, distance: number): number;
1260
+ /**
1261
+ * Offset a wire on a planar face with a specific join type.
1262
+ *
1263
+ * `join_type` must be one of `"intersection"`, `"arc"`, or `"chamfer"`.
1264
+ * Returns a new wire handle.
1265
+ *
1266
+ * # Errors
1267
+ *
1268
+ * Returns an error if the face handle is invalid, the join type string
1269
+ * is unrecognized, or the offset operation fails.
1270
+ */
1271
+ offsetWireWithJoinType(face: number, distance: number, join_type: string): number;
1255
1272
  /**
1256
1273
  * Pipe sweep: sweep a profile along a NURBS path (no guide).
1257
1274
  *
@@ -1453,13 +1470,13 @@ export class BrepKernel {
1453
1470
  /**
1454
1471
  * Compute minimum distance between two solids.
1455
1472
  *
1456
- * Returns `[distance]`.
1473
+ * Returns `[distance, point_a_x, point_a_y, point_a_z, point_b_x, point_b_y, point_b_z]`.
1457
1474
  *
1458
1475
  * # Errors
1459
1476
  *
1460
1477
  * Returns an error if either solid handle is invalid.
1461
1478
  */
1462
- solidToSolidDistance(a: number, b: number): number;
1479
+ solidToSolidDistance(a: number, b: number): Float64Array;
1463
1480
  /**
1464
1481
  * Split a solid into two halves along a plane.
1465
1482
  *
@@ -1527,9 +1544,10 @@ export class BrepKernel {
1527
1544
  *
1528
1545
  * `contact_mode`: "rmf" (default), "fixed", or "constantNormal:x,y,z"
1529
1546
  * `scale_values`: flat `[t0,s0,t1,s1,...]` pairs for piecewise-linear scale law.
1547
+ * `corner_mode`: "smooth" (default), "miter", or "round"
1530
1548
  * Returns a solid handle.
1531
1549
  */
1532
- sweepWithOptions(profile: number, path_edge: number, contact_mode: string, scale_values: Float64Array, segments: number): number;
1550
+ sweepWithOptions(profile: number, path_edge: number, contact_mode: string, scale_values: Float64Array, segments: number, corner_mode: string): number;
1533
1551
  /**
1534
1552
  * Tessellate an edge curve into polyline segments.
1535
1553
  *
@@ -1663,6 +1681,20 @@ export class BrepKernel {
1663
1681
  * Returns an error if the solid handle is invalid.
1664
1682
  */
1665
1683
  validateSolidRelaxed(solid: number): number;
1684
+ /**
1685
+ * Validate a solid with configurable tolerance scaling.
1686
+ *
1687
+ * `tolerance_scale` multiplies geometric tolerances used for the
1688
+ * face-normal and face-area checks. Use `10.0` to reduce false
1689
+ * positives on NURBS faces from fillet/shell operations.
1690
+ *
1691
+ * Returns 0 if the solid is valid.
1692
+ *
1693
+ * # Errors
1694
+ *
1695
+ * Returns an error if the solid handle is invalid.
1696
+ */
1697
+ validateSolidWithOptions(solid: number, tolerance_scale: number): number;
1666
1698
  /**
1667
1699
  * Compute the volume of a solid.
1668
1700
  *
@@ -508,13 +508,13 @@ export class BrepKernel {
508
508
  /**
509
509
  * Build a convex hull solid from a point cloud.
510
510
  *
511
- * Uses a simple Quickhull-inspired algorithm for 3D point sets.
511
+ * Uses the Quickhull algorithm for 3D point sets.
512
512
  *
513
513
  * Returns a solid handle (`u32`).
514
514
  *
515
515
  * # Errors
516
516
  *
517
- * Returns an error if fewer than 4 points are provided.
517
+ * Returns an error if fewer than 4 non-coplanar points are provided.
518
518
  * @param {Float64Array} coords
519
519
  * @returns {number}
520
520
  */
@@ -1215,6 +1215,10 @@ export class BrepKernel {
1215
1215
  * Apply variable-radius fillets to edges.
1216
1216
  *
1217
1217
  * `json` is a JSON string: `[{"edge": u32, "law": "constant"|"linear"|"scurve", "start": f64, "end": f64}]`
1218
+ *
1219
+ * Also accepts brepjs-style fields: `startRadius`/`endRadius` as aliases for `start`/`end`.
1220
+ * When `law` is omitted and `startRadius` != `endRadius`, the law auto-detects as `"linear"`.
1221
+ *
1218
1222
  * Returns a new solid handle.
1219
1223
  * @param {number} solid
1220
1224
  * @param {string} json
@@ -1246,10 +1250,11 @@ export class BrepKernel {
1246
1250
  /**
1247
1251
  * Reconstruct a solid from a `toBREP` JSON string.
1248
1252
  *
1249
- * Currently supports planar faces with line edges. Non-line edges are
1250
- * approximated as lines (straight segments between start/end vertices).
1251
- * Non-planar surfaces are approximated as planes computed from the wire
1252
- * vertex positions.
1253
+ * Supports all edge curve types (line, circle, ellipse, NURBS) and
1254
+ * all surface types (plane, cylinder, cone, sphere, torus, NURBS)
1255
+ * via `curveParams` and `surfaceParams` in the JSON. Unrecognized
1256
+ * edge types fall back to lines; unrecognized surface types fall back
1257
+ * to planes computed from wire vertices.
1253
1258
  *
1254
1259
  * Returns a solid handle.
1255
1260
  *
@@ -2844,6 +2849,30 @@ export class BrepKernel {
2844
2849
  }
2845
2850
  return ret[0] >>> 0;
2846
2851
  }
2852
+ /**
2853
+ * Offset a wire on a planar face with a specific join type.
2854
+ *
2855
+ * `join_type` must be one of `"intersection"`, `"arc"`, or `"chamfer"`.
2856
+ * Returns a new wire handle.
2857
+ *
2858
+ * # Errors
2859
+ *
2860
+ * Returns an error if the face handle is invalid, the join type string
2861
+ * is unrecognized, or the offset operation fails.
2862
+ * @param {number} face
2863
+ * @param {number} distance
2864
+ * @param {string} join_type
2865
+ * @returns {number}
2866
+ */
2867
+ offsetWireWithJoinType(face, distance, join_type) {
2868
+ const ptr0 = passStringToWasm0(join_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2869
+ const len0 = WASM_VECTOR_LEN;
2870
+ const ret = wasm.brepkernel_offsetWireWithJoinType(this.__wbg_ptr, face, distance, ptr0, len0);
2871
+ if (ret[2]) {
2872
+ throw takeFromExternrefTable0(ret[1]);
2873
+ }
2874
+ return ret[0] >>> 0;
2875
+ }
2847
2876
  /**
2848
2877
  * Pipe sweep: sweep a profile along a NURBS path (no guide).
2849
2878
  *
@@ -3336,21 +3365,23 @@ export class BrepKernel {
3336
3365
  /**
3337
3366
  * Compute minimum distance between two solids.
3338
3367
  *
3339
- * Returns `[distance]`.
3368
+ * Returns `[distance, point_a_x, point_a_y, point_a_z, point_b_x, point_b_y, point_b_z]`.
3340
3369
  *
3341
3370
  * # Errors
3342
3371
  *
3343
3372
  * Returns an error if either solid handle is invalid.
3344
3373
  * @param {number} a
3345
3374
  * @param {number} b
3346
- * @returns {number}
3375
+ * @returns {Float64Array}
3347
3376
  */
3348
3377
  solidToSolidDistance(a, b) {
3349
3378
  const ret = wasm.brepkernel_solidToSolidDistance(this.__wbg_ptr, a, b);
3350
- if (ret[2]) {
3351
- throw takeFromExternrefTable0(ret[1]);
3379
+ if (ret[3]) {
3380
+ throw takeFromExternrefTable0(ret[2]);
3352
3381
  }
3353
- return ret[0];
3382
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3383
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3384
+ return v1;
3354
3385
  }
3355
3386
  /**
3356
3387
  * Split a solid into two halves along a plane.
@@ -3491,20 +3522,24 @@ export class BrepKernel {
3491
3522
  *
3492
3523
  * `contact_mode`: "rmf" (default), "fixed", or "constantNormal:x,y,z"
3493
3524
  * `scale_values`: flat `[t0,s0,t1,s1,...]` pairs for piecewise-linear scale law.
3525
+ * `corner_mode`: "smooth" (default), "miter", or "round"
3494
3526
  * Returns a solid handle.
3495
3527
  * @param {number} profile
3496
3528
  * @param {number} path_edge
3497
3529
  * @param {string} contact_mode
3498
3530
  * @param {Float64Array} scale_values
3499
3531
  * @param {number} segments
3532
+ * @param {string} corner_mode
3500
3533
  * @returns {number}
3501
3534
  */
3502
- sweepWithOptions(profile, path_edge, contact_mode, scale_values, segments) {
3535
+ sweepWithOptions(profile, path_edge, contact_mode, scale_values, segments, corner_mode) {
3503
3536
  const ptr0 = passStringToWasm0(contact_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3504
3537
  const len0 = WASM_VECTOR_LEN;
3505
3538
  const ptr1 = passArrayF64ToWasm0(scale_values, wasm.__wbindgen_malloc);
3506
3539
  const len1 = WASM_VECTOR_LEN;
3507
- const ret = wasm.brepkernel_sweepWithOptions(this.__wbg_ptr, profile, path_edge, ptr0, len0, ptr1, len1, segments);
3540
+ const ptr2 = passStringToWasm0(corner_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3541
+ const len2 = WASM_VECTOR_LEN;
3542
+ const ret = wasm.brepkernel_sweepWithOptions(this.__wbg_ptr, profile, path_edge, ptr0, len0, ptr1, len1, segments, ptr2, len2);
3508
3543
  if (ret[2]) {
3509
3544
  throw takeFromExternrefTable0(ret[1]);
3510
3545
  }
@@ -3759,6 +3794,29 @@ export class BrepKernel {
3759
3794
  }
3760
3795
  return ret[0] >>> 0;
3761
3796
  }
3797
+ /**
3798
+ * Validate a solid with configurable tolerance scaling.
3799
+ *
3800
+ * `tolerance_scale` multiplies geometric tolerances used for the
3801
+ * face-normal and face-area checks. Use `10.0` to reduce false
3802
+ * positives on NURBS faces from fillet/shell operations.
3803
+ *
3804
+ * Returns 0 if the solid is valid.
3805
+ *
3806
+ * # Errors
3807
+ *
3808
+ * Returns an error if the solid handle is invalid.
3809
+ * @param {number} solid
3810
+ * @param {number} tolerance_scale
3811
+ * @returns {number}
3812
+ */
3813
+ validateSolidWithOptions(solid, tolerance_scale) {
3814
+ const ret = wasm.brepkernel_validateSolidWithOptions(this.__wbg_ptr, solid, tolerance_scale);
3815
+ if (ret[2]) {
3816
+ throw takeFromExternrefTable0(ret[1]);
3817
+ }
3818
+ return ret[0] >>> 0;
3819
+ }
3762
3820
  /**
3763
3821
  * Compute the volume of a solid.
3764
3822
  *
Binary file
@@ -510,13 +510,13 @@ class BrepKernel {
510
510
  /**
511
511
  * Build a convex hull solid from a point cloud.
512
512
  *
513
- * Uses a simple Quickhull-inspired algorithm for 3D point sets.
513
+ * Uses the Quickhull algorithm for 3D point sets.
514
514
  *
515
515
  * Returns a solid handle (`u32`).
516
516
  *
517
517
  * # Errors
518
518
  *
519
- * Returns an error if fewer than 4 points are provided.
519
+ * Returns an error if fewer than 4 non-coplanar points are provided.
520
520
  * @param {Float64Array} coords
521
521
  * @returns {number}
522
522
  */
@@ -1217,6 +1217,10 @@ class BrepKernel {
1217
1217
  * Apply variable-radius fillets to edges.
1218
1218
  *
1219
1219
  * `json` is a JSON string: `[{"edge": u32, "law": "constant"|"linear"|"scurve", "start": f64, "end": f64}]`
1220
+ *
1221
+ * Also accepts brepjs-style fields: `startRadius`/`endRadius` as aliases for `start`/`end`.
1222
+ * When `law` is omitted and `startRadius` != `endRadius`, the law auto-detects as `"linear"`.
1223
+ *
1220
1224
  * Returns a new solid handle.
1221
1225
  * @param {number} solid
1222
1226
  * @param {string} json
@@ -1248,10 +1252,11 @@ class BrepKernel {
1248
1252
  /**
1249
1253
  * Reconstruct a solid from a `toBREP` JSON string.
1250
1254
  *
1251
- * Currently supports planar faces with line edges. Non-line edges are
1252
- * approximated as lines (straight segments between start/end vertices).
1253
- * Non-planar surfaces are approximated as planes computed from the wire
1254
- * vertex positions.
1255
+ * Supports all edge curve types (line, circle, ellipse, NURBS) and
1256
+ * all surface types (plane, cylinder, cone, sphere, torus, NURBS)
1257
+ * via `curveParams` and `surfaceParams` in the JSON. Unrecognized
1258
+ * edge types fall back to lines; unrecognized surface types fall back
1259
+ * to planes computed from wire vertices.
1255
1260
  *
1256
1261
  * Returns a solid handle.
1257
1262
  *
@@ -2846,6 +2851,30 @@ class BrepKernel {
2846
2851
  }
2847
2852
  return ret[0] >>> 0;
2848
2853
  }
2854
+ /**
2855
+ * Offset a wire on a planar face with a specific join type.
2856
+ *
2857
+ * `join_type` must be one of `"intersection"`, `"arc"`, or `"chamfer"`.
2858
+ * Returns a new wire handle.
2859
+ *
2860
+ * # Errors
2861
+ *
2862
+ * Returns an error if the face handle is invalid, the join type string
2863
+ * is unrecognized, or the offset operation fails.
2864
+ * @param {number} face
2865
+ * @param {number} distance
2866
+ * @param {string} join_type
2867
+ * @returns {number}
2868
+ */
2869
+ offsetWireWithJoinType(face, distance, join_type) {
2870
+ const ptr0 = passStringToWasm0(join_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2871
+ const len0 = WASM_VECTOR_LEN;
2872
+ const ret = wasm.brepkernel_offsetWireWithJoinType(this.__wbg_ptr, face, distance, ptr0, len0);
2873
+ if (ret[2]) {
2874
+ throw takeFromExternrefTable0(ret[1]);
2875
+ }
2876
+ return ret[0] >>> 0;
2877
+ }
2849
2878
  /**
2850
2879
  * Pipe sweep: sweep a profile along a NURBS path (no guide).
2851
2880
  *
@@ -3338,21 +3367,23 @@ class BrepKernel {
3338
3367
  /**
3339
3368
  * Compute minimum distance between two solids.
3340
3369
  *
3341
- * Returns `[distance]`.
3370
+ * Returns `[distance, point_a_x, point_a_y, point_a_z, point_b_x, point_b_y, point_b_z]`.
3342
3371
  *
3343
3372
  * # Errors
3344
3373
  *
3345
3374
  * Returns an error if either solid handle is invalid.
3346
3375
  * @param {number} a
3347
3376
  * @param {number} b
3348
- * @returns {number}
3377
+ * @returns {Float64Array}
3349
3378
  */
3350
3379
  solidToSolidDistance(a, b) {
3351
3380
  const ret = wasm.brepkernel_solidToSolidDistance(this.__wbg_ptr, a, b);
3352
- if (ret[2]) {
3353
- throw takeFromExternrefTable0(ret[1]);
3381
+ if (ret[3]) {
3382
+ throw takeFromExternrefTable0(ret[2]);
3354
3383
  }
3355
- return ret[0];
3384
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3385
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3386
+ return v1;
3356
3387
  }
3357
3388
  /**
3358
3389
  * Split a solid into two halves along a plane.
@@ -3493,20 +3524,24 @@ class BrepKernel {
3493
3524
  *
3494
3525
  * `contact_mode`: "rmf" (default), "fixed", or "constantNormal:x,y,z"
3495
3526
  * `scale_values`: flat `[t0,s0,t1,s1,...]` pairs for piecewise-linear scale law.
3527
+ * `corner_mode`: "smooth" (default), "miter", or "round"
3496
3528
  * Returns a solid handle.
3497
3529
  * @param {number} profile
3498
3530
  * @param {number} path_edge
3499
3531
  * @param {string} contact_mode
3500
3532
  * @param {Float64Array} scale_values
3501
3533
  * @param {number} segments
3534
+ * @param {string} corner_mode
3502
3535
  * @returns {number}
3503
3536
  */
3504
- sweepWithOptions(profile, path_edge, contact_mode, scale_values, segments) {
3537
+ sweepWithOptions(profile, path_edge, contact_mode, scale_values, segments, corner_mode) {
3505
3538
  const ptr0 = passStringToWasm0(contact_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3506
3539
  const len0 = WASM_VECTOR_LEN;
3507
3540
  const ptr1 = passArrayF64ToWasm0(scale_values, wasm.__wbindgen_malloc);
3508
3541
  const len1 = WASM_VECTOR_LEN;
3509
- const ret = wasm.brepkernel_sweepWithOptions(this.__wbg_ptr, profile, path_edge, ptr0, len0, ptr1, len1, segments);
3542
+ const ptr2 = passStringToWasm0(corner_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3543
+ const len2 = WASM_VECTOR_LEN;
3544
+ const ret = wasm.brepkernel_sweepWithOptions(this.__wbg_ptr, profile, path_edge, ptr0, len0, ptr1, len1, segments, ptr2, len2);
3510
3545
  if (ret[2]) {
3511
3546
  throw takeFromExternrefTable0(ret[1]);
3512
3547
  }
@@ -3761,6 +3796,29 @@ class BrepKernel {
3761
3796
  }
3762
3797
  return ret[0] >>> 0;
3763
3798
  }
3799
+ /**
3800
+ * Validate a solid with configurable tolerance scaling.
3801
+ *
3802
+ * `tolerance_scale` multiplies geometric tolerances used for the
3803
+ * face-normal and face-area checks. Use `10.0` to reduce false
3804
+ * positives on NURBS faces from fillet/shell operations.
3805
+ *
3806
+ * Returns 0 if the solid is valid.
3807
+ *
3808
+ * # Errors
3809
+ *
3810
+ * Returns an error if the solid handle is invalid.
3811
+ * @param {number} solid
3812
+ * @param {number} tolerance_scale
3813
+ * @returns {number}
3814
+ */
3815
+ validateSolidWithOptions(solid, tolerance_scale) {
3816
+ const ret = wasm.brepkernel_validateSolidWithOptions(this.__wbg_ptr, solid, tolerance_scale);
3817
+ if (ret[2]) {
3818
+ throw takeFromExternrefTable0(ret[1]);
3819
+ }
3820
+ return ret[0] >>> 0;
3821
+ }
3764
3822
  /**
3765
3823
  * Compute the volume of a solid.
3766
3824
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "brepkit-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for brepkit — browser-native B-Rep solid modeling",
5
- "version": "2.4.1",
5
+ "version": "2.5.0",
6
6
  "license": "AGPL-3.0-only",
7
7
  "repository": {
8
8
  "type": "git",