@ifc-lite/wasm 4.4.0 → 4.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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "IFC-Lite Contributors"
6
6
  ],
7
7
  "description": "WebAssembly bindings for IFC-Lite",
8
- "version": "4.4.0",
8
+ "version": "4.5.0",
9
9
  "license": "MPL-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/pkg/ifc-lite.d.ts CHANGED
@@ -1535,6 +1535,69 @@ export class SymbolicText {
1535
1535
  readonly y: number;
1536
1536
  }
1537
1537
 
1538
+ /**
1539
+ * One closed solid of a split element.
1540
+ */
1541
+ export class ZonePieceJs {
1542
+ private constructor();
1543
+ free(): void;
1544
+ [Symbol.dispose](): void;
1545
+ /**
1546
+ * Flat triangle indices into `positions`.
1547
+ */
1548
+ readonly indices: Uint32Array;
1549
+ /**
1550
+ * Flat `[x, y, z, ...]` in the caller's frame.
1551
+ */
1552
+ readonly positions: Float64Array;
1553
+ /**
1554
+ * Enclosed volume of this piece, cubic units of the caller's frame.
1555
+ */
1556
+ readonly volume: number;
1557
+ /**
1558
+ * Index into the zone array that was passed in, or `-1` for the part of
1559
+ * the element inside no zone.
1560
+ */
1561
+ readonly zoneIndex: number;
1562
+ }
1563
+
1564
+ /**
1565
+ * The result of splitting one element.
1566
+ */
1567
+ export class ZoneSplitJs {
1568
+ private constructor();
1569
+ free(): void;
1570
+ [Symbol.dispose](): void;
1571
+ /**
1572
+ * Piece `index`, or `undefined` when out of range. Each call COPIES the
1573
+ * piece out, matching the rest of this API surface.
1574
+ */
1575
+ piece(index: number): ZonePieceJs | undefined;
1576
+ readonly pieceCount: number;
1577
+ /**
1578
+ * The part of the element inside NO zone could not be built.
1579
+ *
1580
+ * Separate from `sumErrorRel` because the two have opposite fixes: a
1581
+ * raised sum means the zones overlap and want redrawing, while this means
1582
+ * real volume is MISSING from the result. A caller must refuse the split
1583
+ * outright rather than publish the zone pieces alone.
1584
+ */
1585
+ readonly remainderFailed: boolean;
1586
+ /**
1587
+ * How far the pieces are from summing to the whole, relative.
1588
+ *
1589
+ * The invariant #2508 puts above everything else here. Exposed rather than
1590
+ * enforced: the caller decides what to do with a split that does not add
1591
+ * up (the expected cause is zones that overlap each other), and a number
1592
+ * it can show beats a silent refusal.
1593
+ */
1594
+ readonly sumErrorRel: number;
1595
+ /**
1596
+ * Enclosed volume of the input element.
1597
+ */
1598
+ readonly wholeVolume: number;
1599
+ }
1600
+
1538
1601
  /**
1539
1602
  * `a - b`, keeping EVERY disjoint remnant.
1540
1603
  *
@@ -1591,6 +1654,50 @@ export function meshOutline2d(positions: Float32Array, indices: Uint32Array, axi
1591
1654
  */
1592
1655
  export function resolve2d(a: Contours2D): Contours2D;
1593
1656
 
1657
+ /**
1658
+ * Split a mesh into one closed solid per zone, plus the remainder.
1659
+ *
1660
+ * `positions` is flat XYZ (f64, caller's frame), `indices` flat triangle
1661
+ * indices. `zones` is flat, SEVEN numbers per zone:
1662
+ * `[cx, cy, cz, sx, sy, sz, rotationY]`, where the sizes are FULL extents
1663
+ * (matching the viewer's `Zone.size`) and the rotation is radians about the
1664
+ * vertical axis. A trailing partial zone is ignored rather than guessed at.
1665
+ *
1666
+ * A zone becomes a PRISM (#2508 item 4) when `footprint_counts[i]` is at
1667
+ * least 3: it then takes that many `[x, z]` pairs from `footprints`, in order,
1668
+ * and uses the 7-tuple only for its vertical extent (`cy +/- sy/2`). The
1669
+ * footprint must be CONVEX; the viewer gates that on import, because a concave
1670
+ * polygon fans into overlapping triangles and would cut wrong rather than
1671
+ * fail. A count of 1 or 2 is not a polygon: it still consumes its pairs, so
1672
+ * later zones stay aligned, and leaves that zone a box. Passing empty arrays
1673
+ * keeps every zone a box.
1674
+ *
1675
+ * The caller must have established that the mesh is a closed orientable solid
1676
+ * first, exactly as it must before quoting a volume at all (#1891/#1993): a
1677
+ * clip of an open shell produces pieces whose volumes are arbitrary rather
1678
+ * than approximate.
1679
+ *
1680
+ * A triangle with an out-of-range index or a non-finite coordinate is DROPPED
1681
+ * rather than reported, matching `kernel::mesh_bridge::mesh_to_tris`, which is
1682
+ * panic-free for the same reason: the alternative is a crash deep in the
1683
+ * predicates. It does mean a malformed caller can open the surface and get
1684
+ * meaningless volumes with a plausible `sumErrorRel`, so the closure proof
1685
+ * above is the caller's responsibility and not a formality.
1686
+ *
1687
+ * ```javascript
1688
+ * const split = splitMeshByZones(positions, indices, new Float64Array([
1689
+ * 0, 0, 0, 10, 10, 10, 0,
1690
+ * ]));
1691
+ * for (let i = 0; i < split.pieceCount; i++) {
1692
+ * const piece = split.piece(i);
1693
+ * // piece.zoneIndex, piece.positions, piece.indices, piece.volume
1694
+ * piece.free();
1695
+ * }
1696
+ * split.free();
1697
+ * ```
1698
+ */
1699
+ export function splitMeshByZones(positions: Float64Array, indices: Uint32Array, zones: Float64Array, footprints?: Float64Array | null, footprint_counts?: Uint32Array | null): ZoneSplitJs;
1700
+
1594
1701
  /**
1595
1702
  * `a ∪ b`.
1596
1703
  */
@@ -1634,6 +1741,8 @@ export interface InitOutput {
1634
1741
  readonly __wbg_symbolicpolyline_free: (a: number, b: number) => void;
1635
1742
  readonly __wbg_symbolicrepresentationcollection_free: (a: number, b: number) => void;
1636
1743
  readonly __wbg_symbolictext_free: (a: number, b: number) => void;
1744
+ readonly __wbg_zonepiecejs_free: (a: number, b: number) => void;
1745
+ readonly __wbg_zonesplitjs_free: (a: number, b: number) => void;
1637
1746
  readonly clashrunresult_a: (a: number, b: number) => void;
1638
1747
  readonly clashrunresult_b: (a: number, b: number) => void;
1639
1748
  readonly clashrunresult_bounds: (a: number, b: number) => void;
@@ -1810,6 +1919,7 @@ export interface InitOutput {
1810
1919
  readonly spaceplatehandle_snapshot: (a: number, b: number) => void;
1811
1920
  readonly spaceplatehandle_splitEdge: (a: number, b: number, c: number, d: number, e: number) => void;
1812
1921
  readonly spaceplatehandle_splitFace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1922
+ readonly splitMeshByZones: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
1813
1923
  readonly symboliccircle_centerX: (a: number) => number;
1814
1924
  readonly symboliccircle_centerY: (a: number) => number;
1815
1925
  readonly symboliccircle_endAngle: (a: number) => number;
@@ -1860,6 +1970,14 @@ export interface InitOutput {
1860
1970
  readonly symbolictext_targetPx: (a: number) => number;
1861
1971
  readonly union2d: (a: number, b: number) => number;
1862
1972
  readonly version: (a: number) => void;
1973
+ readonly zonepiecejs_indices: (a: number) => number;
1974
+ readonly zonepiecejs_positions: (a: number) => number;
1975
+ readonly zonepiecejs_volume: (a: number) => number;
1976
+ readonly zonepiecejs_zoneIndex: (a: number) => number;
1977
+ readonly zonesplitjs_piece: (a: number, b: number) => number;
1978
+ readonly zonesplitjs_pieceCount: (a: number) => number;
1979
+ readonly zonesplitjs_remainderFailed: (a: number) => number;
1980
+ readonly zonesplitjs_sumErrorRel: (a: number) => number;
1863
1981
  readonly init: () => void;
1864
1982
  readonly meshoutlinejs_contourCount: (a: number) => number;
1865
1983
  readonly symbolicpolyline_pointCount: (a: number) => number;
@@ -1876,6 +1994,7 @@ export interface InitOutput {
1876
1994
  readonly symbolictext_worldY: (a: number) => number;
1877
1995
  readonly symbolictext_x: (a: number) => number;
1878
1996
  readonly symbolictext_y: (a: number) => number;
1997
+ readonly zonesplitjs_wholeVolume: (a: number) => number;
1879
1998
  readonly __wbindgen_export: (a: number, b: number) => number;
1880
1999
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1881
2000
  readonly __wbindgen_export3: (a: number) => void;
package/pkg/ifc-lite.js CHANGED
@@ -4268,6 +4268,136 @@ export class SymbolicText {
4268
4268
  }
4269
4269
  if (Symbol.dispose) SymbolicText.prototype[Symbol.dispose] = SymbolicText.prototype.free;
4270
4270
 
4271
+ /**
4272
+ * One closed solid of a split element.
4273
+ */
4274
+ export class ZonePieceJs {
4275
+ static __wrap(ptr) {
4276
+ const obj = Object.create(ZonePieceJs.prototype);
4277
+ obj.__wbg_ptr = ptr;
4278
+ ZonePieceJsFinalization.register(obj, obj.__wbg_ptr, obj);
4279
+ return obj;
4280
+ }
4281
+ __destroy_into_raw() {
4282
+ const ptr = this.__wbg_ptr;
4283
+ this.__wbg_ptr = 0;
4284
+ ZonePieceJsFinalization.unregister(this);
4285
+ return ptr;
4286
+ }
4287
+ free() {
4288
+ const ptr = this.__destroy_into_raw();
4289
+ wasm.__wbg_zonepiecejs_free(ptr, 0);
4290
+ }
4291
+ /**
4292
+ * Flat triangle indices into `positions`.
4293
+ * @returns {Uint32Array}
4294
+ */
4295
+ get indices() {
4296
+ const ret = wasm.zonepiecejs_indices(this.__wbg_ptr);
4297
+ return takeObject(ret);
4298
+ }
4299
+ /**
4300
+ * Flat `[x, y, z, ...]` in the caller's frame.
4301
+ * @returns {Float64Array}
4302
+ */
4303
+ get positions() {
4304
+ const ret = wasm.zonepiecejs_positions(this.__wbg_ptr);
4305
+ return takeObject(ret);
4306
+ }
4307
+ /**
4308
+ * Enclosed volume of this piece, cubic units of the caller's frame.
4309
+ * @returns {number}
4310
+ */
4311
+ get volume() {
4312
+ const ret = wasm.zonepiecejs_volume(this.__wbg_ptr);
4313
+ return ret;
4314
+ }
4315
+ /**
4316
+ * Index into the zone array that was passed in, or `-1` for the part of
4317
+ * the element inside no zone.
4318
+ * @returns {number}
4319
+ */
4320
+ get zoneIndex() {
4321
+ const ret = wasm.zonepiecejs_zoneIndex(this.__wbg_ptr);
4322
+ return ret;
4323
+ }
4324
+ }
4325
+ if (Symbol.dispose) ZonePieceJs.prototype[Symbol.dispose] = ZonePieceJs.prototype.free;
4326
+
4327
+ /**
4328
+ * The result of splitting one element.
4329
+ */
4330
+ export class ZoneSplitJs {
4331
+ static __wrap(ptr) {
4332
+ const obj = Object.create(ZoneSplitJs.prototype);
4333
+ obj.__wbg_ptr = ptr;
4334
+ ZoneSplitJsFinalization.register(obj, obj.__wbg_ptr, obj);
4335
+ return obj;
4336
+ }
4337
+ __destroy_into_raw() {
4338
+ const ptr = this.__wbg_ptr;
4339
+ this.__wbg_ptr = 0;
4340
+ ZoneSplitJsFinalization.unregister(this);
4341
+ return ptr;
4342
+ }
4343
+ free() {
4344
+ const ptr = this.__destroy_into_raw();
4345
+ wasm.__wbg_zonesplitjs_free(ptr, 0);
4346
+ }
4347
+ /**
4348
+ * Piece `index`, or `undefined` when out of range. Each call COPIES the
4349
+ * piece out, matching the rest of this API surface.
4350
+ * @param {number} index
4351
+ * @returns {ZonePieceJs | undefined}
4352
+ */
4353
+ piece(index) {
4354
+ const ret = wasm.zonesplitjs_piece(this.__wbg_ptr, index);
4355
+ return ret === 0 ? undefined : ZonePieceJs.__wrap(ret);
4356
+ }
4357
+ /**
4358
+ * @returns {number}
4359
+ */
4360
+ get pieceCount() {
4361
+ const ret = wasm.zonesplitjs_pieceCount(this.__wbg_ptr);
4362
+ return ret >>> 0;
4363
+ }
4364
+ /**
4365
+ * The part of the element inside NO zone could not be built.
4366
+ *
4367
+ * Separate from `sumErrorRel` because the two have opposite fixes: a
4368
+ * raised sum means the zones overlap and want redrawing, while this means
4369
+ * real volume is MISSING from the result. A caller must refuse the split
4370
+ * outright rather than publish the zone pieces alone.
4371
+ * @returns {boolean}
4372
+ */
4373
+ get remainderFailed() {
4374
+ const ret = wasm.zonesplitjs_remainderFailed(this.__wbg_ptr);
4375
+ return ret !== 0;
4376
+ }
4377
+ /**
4378
+ * How far the pieces are from summing to the whole, relative.
4379
+ *
4380
+ * The invariant #2508 puts above everything else here. Exposed rather than
4381
+ * enforced: the caller decides what to do with a split that does not add
4382
+ * up (the expected cause is zones that overlap each other), and a number
4383
+ * it can show beats a silent refusal.
4384
+ * @returns {number}
4385
+ */
4386
+ get sumErrorRel() {
4387
+ const ret = wasm.zonesplitjs_sumErrorRel(this.__wbg_ptr);
4388
+ return ret;
4389
+ }
4390
+ /**
4391
+ * Enclosed volume of the input element.
4392
+ * @returns {number}
4393
+ */
4394
+ get wholeVolume() {
4395
+ const ret = wasm.zonesplitjs_wholeVolume(this.__wbg_ptr);
4396
+ return ret;
4397
+ }
4398
+ }
4399
+ if (Symbol.dispose) ZoneSplitJs.prototype[Symbol.dispose] = ZoneSplitJs.prototype.free;
4400
+
4271
4401
  /**
4272
4402
  * `a - b`, keeping EVERY disjoint remnant.
4273
4403
  *
@@ -4364,6 +4494,69 @@ export function resolve2d(a) {
4364
4494
  return Contours2D.__wrap(ret);
4365
4495
  }
4366
4496
 
4497
+ /**
4498
+ * Split a mesh into one closed solid per zone, plus the remainder.
4499
+ *
4500
+ * `positions` is flat XYZ (f64, caller's frame), `indices` flat triangle
4501
+ * indices. `zones` is flat, SEVEN numbers per zone:
4502
+ * `[cx, cy, cz, sx, sy, sz, rotationY]`, where the sizes are FULL extents
4503
+ * (matching the viewer's `Zone.size`) and the rotation is radians about the
4504
+ * vertical axis. A trailing partial zone is ignored rather than guessed at.
4505
+ *
4506
+ * A zone becomes a PRISM (#2508 item 4) when `footprint_counts[i]` is at
4507
+ * least 3: it then takes that many `[x, z]` pairs from `footprints`, in order,
4508
+ * and uses the 7-tuple only for its vertical extent (`cy +/- sy/2`). The
4509
+ * footprint must be CONVEX; the viewer gates that on import, because a concave
4510
+ * polygon fans into overlapping triangles and would cut wrong rather than
4511
+ * fail. A count of 1 or 2 is not a polygon: it still consumes its pairs, so
4512
+ * later zones stay aligned, and leaves that zone a box. Passing empty arrays
4513
+ * keeps every zone a box.
4514
+ *
4515
+ * The caller must have established that the mesh is a closed orientable solid
4516
+ * first, exactly as it must before quoting a volume at all (#1891/#1993): a
4517
+ * clip of an open shell produces pieces whose volumes are arbitrary rather
4518
+ * than approximate.
4519
+ *
4520
+ * A triangle with an out-of-range index or a non-finite coordinate is DROPPED
4521
+ * rather than reported, matching `kernel::mesh_bridge::mesh_to_tris`, which is
4522
+ * panic-free for the same reason: the alternative is a crash deep in the
4523
+ * predicates. It does mean a malformed caller can open the surface and get
4524
+ * meaningless volumes with a plausible `sumErrorRel`, so the closure proof
4525
+ * above is the caller's responsibility and not a formality.
4526
+ *
4527
+ * ```javascript
4528
+ * const split = splitMeshByZones(positions, indices, new Float64Array([
4529
+ * 0, 0, 0, 10, 10, 10, 0,
4530
+ * ]));
4531
+ * for (let i = 0; i < split.pieceCount; i++) {
4532
+ * const piece = split.piece(i);
4533
+ * // piece.zoneIndex, piece.positions, piece.indices, piece.volume
4534
+ * piece.free();
4535
+ * }
4536
+ * split.free();
4537
+ * ```
4538
+ * @param {Float64Array} positions
4539
+ * @param {Uint32Array} indices
4540
+ * @param {Float64Array} zones
4541
+ * @param {Float64Array | null} [footprints]
4542
+ * @param {Uint32Array | null} [footprint_counts]
4543
+ * @returns {ZoneSplitJs}
4544
+ */
4545
+ export function splitMeshByZones(positions, indices, zones, footprints, footprint_counts) {
4546
+ const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_export);
4547
+ const len0 = WASM_VECTOR_LEN;
4548
+ const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_export);
4549
+ const len1 = WASM_VECTOR_LEN;
4550
+ const ptr2 = passArrayF64ToWasm0(zones, wasm.__wbindgen_export);
4551
+ const len2 = WASM_VECTOR_LEN;
4552
+ var ptr3 = isLikeNone(footprints) ? 0 : passArrayF64ToWasm0(footprints, wasm.__wbindgen_export);
4553
+ var len3 = WASM_VECTOR_LEN;
4554
+ var ptr4 = isLikeNone(footprint_counts) ? 0 : passArray32ToWasm0(footprint_counts, wasm.__wbindgen_export);
4555
+ var len4 = WASM_VECTOR_LEN;
4556
+ const ret = wasm.splitMeshByZones(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
4557
+ return ZoneSplitJs.__wrap(ret);
4558
+ }
4559
+
4367
4560
  /**
4368
4561
  * `a ∪ b`.
4369
4562
  * @param {Contours2D} a
@@ -4624,6 +4817,12 @@ const SymbolicRepresentationCollectionFinalization = (typeof FinalizationRegistr
4624
4817
  const SymbolicTextFinalization = (typeof FinalizationRegistry === 'undefined')
4625
4818
  ? { register: () => {}, unregister: () => {} }
4626
4819
  : new FinalizationRegistry(ptr => wasm.__wbg_symbolictext_free(ptr, 1));
4820
+ const ZonePieceJsFinalization = (typeof FinalizationRegistry === 'undefined')
4821
+ ? { register: () => {}, unregister: () => {} }
4822
+ : new FinalizationRegistry(ptr => wasm.__wbg_zonepiecejs_free(ptr, 1));
4823
+ const ZoneSplitJsFinalization = (typeof FinalizationRegistry === 'undefined')
4824
+ ? { register: () => {}, unregister: () => {} }
4825
+ : new FinalizationRegistry(ptr => wasm.__wbg_zonesplitjs_free(ptr, 1));
4627
4826
 
4628
4827
  function addHeapObject(obj) {
4629
4828
  if (heap_next === heap.length) heap.push(heap.length + 1);
Binary file