brepjs-bim 0.10.0 → 0.11.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.
@@ -6378,10 +6378,12 @@ var BimModel = class {
6378
6378
  this.#associateClassification(id, spec);
6379
6379
  return (0, brepjs.ok)(id);
6380
6380
  }
6381
- addBeam(spec) {
6381
+ addBeam(spec, options) {
6382
+ const keyCheck = this.#checkStableKey(options);
6383
+ if (!keyCheck.ok) return keyCheck;
6382
6384
  const geomResult = beamToSolid(spec);
6383
6385
  if (!geomResult.ok) return (0, brepjs.err)(geomResult.error);
6384
- const id = this.#makeElement("BEAM", spec, geomResult.value);
6386
+ const id = this.#makeElement("BEAM", spec, geomResult.value, options?.stableKey);
6385
6387
  this.#associateMaterial(id, spec);
6386
6388
  this.#associateClassification(id, spec);
6387
6389
  return (0, brepjs.ok)(id);
@@ -16495,7 +16497,7 @@ function assignNum(target, key, value) {
16495
16497
  * while the IR path serves the viewport and dedup. GlobalIds derive from
16496
16498
  * families key paths (stable under reordering), not insertion order.
16497
16499
  *
16498
- * Scope: Storey containers, Wall/Slab/Column elements, and wall openings — a
16500
+ * Scope: Storey containers, Wall/Slab/Column/Beam elements, and wall openings — a
16499
16501
  * fill-role void (Door/Window family) maps onto addDoor/addWindow, which cut
16500
16502
  * the wall and wire IfcRelVoidsElement + IfcRelFillsElement; the opening and
16501
16503
  * filler GlobalIds derive from the synthesized key paths. Anonymous (non-fill)
@@ -16525,6 +16527,27 @@ var GEOMETRY_PROPS = /* @__PURE__ */ new Set([
16525
16527
  "transform",
16526
16528
  "psets"
16527
16529
  ]);
16530
+ var SPEC_ROUTES = {
16531
+ Wall: {
16532
+ parse: parseWallSpec,
16533
+ add: (m, spec, key) => m.addWall(spec, { stableKey: key })
16534
+ },
16535
+ Slab: {
16536
+ parse: parseSlabSpec,
16537
+ add: (m, spec, key) => m.addSlab(spec, { stableKey: key })
16538
+ },
16539
+ Column: {
16540
+ parse: parseColumnSpec,
16541
+ add: (m, spec, key) => m.addColumn(spec, { stableKey: key })
16542
+ },
16543
+ Beam: {
16544
+ parse: parseBeamSpec,
16545
+ add: (m, spec, key) => m.addBeam(spec, { stableKey: key })
16546
+ }
16547
+ };
16548
+ function specRoute(type) {
16549
+ return Object.hasOwn(SPEC_ROUTES, type) ? SPEC_ROUTES[type] : void 0;
16550
+ }
16528
16551
  /** Total of the resolved geometry's OUTER literal translate chain. The
16529
16552
  * transform vocabulary is translate-only, so frame differences are exact
16530
16553
  * subtractions. Parameter-driven translations stop the peel. */
@@ -16670,6 +16693,7 @@ function familiesToBim(root, options) {
16670
16693
  const idByKeyPath = /* @__PURE__ */ new Map();
16671
16694
  const walk = (el, storeyId) => {
16672
16695
  let containerId = storeyId;
16696
+ const route = specRoute(el.type);
16673
16697
  if (el.type === "Storey") {
16674
16698
  const keyed = requireKeyed(el);
16675
16699
  if (!keyed.ok) return keyed;
@@ -16680,12 +16704,12 @@ function familiesToBim(root, options) {
16680
16704
  model.aggregate(buildingId, id);
16681
16705
  idByKeyPath.set(el.keyPath, id);
16682
16706
  containerId = id;
16683
- } else if (el.type === "Wall" || el.type === "Slab" || el.type === "Column") {
16707
+ } else if (route !== void 0) {
16684
16708
  const keyed = requireKeyed(el);
16685
16709
  if (!keyed.ok) return keyed;
16686
- const parsed = el.type === "Wall" ? parseWallSpec(specInput(el)) : el.type === "Slab" ? parseSlabSpec(specInput(el)) : parseColumnSpec(specInput(el));
16710
+ const parsed = route.parse(specInput(el));
16687
16711
  if (!parsed.ok) return parsed;
16688
- const added = el.type === "Wall" ? model.addWall(parsed.value, { stableKey: el.keyPath }) : el.type === "Slab" ? model.addSlab(parsed.value, { stableKey: el.keyPath }) : model.addColumn(parsed.value, { stableKey: el.keyPath });
16712
+ const added = route.add(model, parsed.value, el.keyPath);
16689
16713
  if (!added.ok) return added;
16690
16714
  idByKeyPath.set(el.keyPath, added.value);
16691
16715
  if (containerId === null) return (0, brepjs.err)(specError("FAMILIES_NO_STOREY", `familiesToBim: '${el.keyPath}' has no Storey ancestor — IFC elements need spatial containment`));
@@ -6355,10 +6355,12 @@ var BimModel = class {
6355
6355
  this.#associateClassification(id, spec);
6356
6356
  return ok(id);
6357
6357
  }
6358
- addBeam(spec) {
6358
+ addBeam(spec, options) {
6359
+ const keyCheck = this.#checkStableKey(options);
6360
+ if (!keyCheck.ok) return keyCheck;
6359
6361
  const geomResult = beamToSolid(spec);
6360
6362
  if (!geomResult.ok) return err(geomResult.error);
6361
- const id = this.#makeElement("BEAM", spec, geomResult.value);
6363
+ const id = this.#makeElement("BEAM", spec, geomResult.value, options?.stableKey);
6362
6364
  this.#associateMaterial(id, spec);
6363
6365
  this.#associateClassification(id, spec);
6364
6366
  return ok(id);
@@ -16472,7 +16474,7 @@ function assignNum(target, key, value) {
16472
16474
  * while the IR path serves the viewport and dedup. GlobalIds derive from
16473
16475
  * families key paths (stable under reordering), not insertion order.
16474
16476
  *
16475
- * Scope: Storey containers, Wall/Slab/Column elements, and wall openings — a
16477
+ * Scope: Storey containers, Wall/Slab/Column/Beam elements, and wall openings — a
16476
16478
  * fill-role void (Door/Window family) maps onto addDoor/addWindow, which cut
16477
16479
  * the wall and wire IfcRelVoidsElement + IfcRelFillsElement; the opening and
16478
16480
  * filler GlobalIds derive from the synthesized key paths. Anonymous (non-fill)
@@ -16502,6 +16504,27 @@ var GEOMETRY_PROPS = /* @__PURE__ */ new Set([
16502
16504
  "transform",
16503
16505
  "psets"
16504
16506
  ]);
16507
+ var SPEC_ROUTES = {
16508
+ Wall: {
16509
+ parse: parseWallSpec,
16510
+ add: (m, spec, key) => m.addWall(spec, { stableKey: key })
16511
+ },
16512
+ Slab: {
16513
+ parse: parseSlabSpec,
16514
+ add: (m, spec, key) => m.addSlab(spec, { stableKey: key })
16515
+ },
16516
+ Column: {
16517
+ parse: parseColumnSpec,
16518
+ add: (m, spec, key) => m.addColumn(spec, { stableKey: key })
16519
+ },
16520
+ Beam: {
16521
+ parse: parseBeamSpec,
16522
+ add: (m, spec, key) => m.addBeam(spec, { stableKey: key })
16523
+ }
16524
+ };
16525
+ function specRoute(type) {
16526
+ return Object.hasOwn(SPEC_ROUTES, type) ? SPEC_ROUTES[type] : void 0;
16527
+ }
16505
16528
  /** Total of the resolved geometry's OUTER literal translate chain. The
16506
16529
  * transform vocabulary is translate-only, so frame differences are exact
16507
16530
  * subtractions. Parameter-driven translations stop the peel. */
@@ -16647,6 +16670,7 @@ function familiesToBim(root, options) {
16647
16670
  const idByKeyPath = /* @__PURE__ */ new Map();
16648
16671
  const walk = (el, storeyId) => {
16649
16672
  let containerId = storeyId;
16673
+ const route = specRoute(el.type);
16650
16674
  if (el.type === "Storey") {
16651
16675
  const keyed = requireKeyed(el);
16652
16676
  if (!keyed.ok) return keyed;
@@ -16657,12 +16681,12 @@ function familiesToBim(root, options) {
16657
16681
  model.aggregate(buildingId, id);
16658
16682
  idByKeyPath.set(el.keyPath, id);
16659
16683
  containerId = id;
16660
- } else if (el.type === "Wall" || el.type === "Slab" || el.type === "Column") {
16684
+ } else if (route !== void 0) {
16661
16685
  const keyed = requireKeyed(el);
16662
16686
  if (!keyed.ok) return keyed;
16663
- const parsed = el.type === "Wall" ? parseWallSpec(specInput(el)) : el.type === "Slab" ? parseSlabSpec(specInput(el)) : parseColumnSpec(specInput(el));
16687
+ const parsed = route.parse(specInput(el));
16664
16688
  if (!parsed.ok) return parsed;
16665
- const added = el.type === "Wall" ? model.addWall(parsed.value, { stableKey: el.keyPath }) : el.type === "Slab" ? model.addSlab(parsed.value, { stableKey: el.keyPath }) : model.addColumn(parsed.value, { stableKey: el.keyPath });
16689
+ const added = route.add(model, parsed.value, el.keyPath);
16666
16690
  if (!added.ok) return added;
16667
16691
  idByKeyPath.set(el.keyPath, added.value);
16668
16692
  if (containerId === null) return err(specError("FAMILIES_NO_STOREY", `familiesToBim: '${el.keyPath}' has no Storey ancestor — IFC elements need spatial containment`));
@@ -42,7 +42,7 @@ export declare class BimModel {
42
42
  addStorey(spec: StoreySpec, options?: ElementIdentityOptions): LocalId;
43
43
  addWall(spec: WallSpec, options?: ElementIdentityOptions): Result<LocalId, BimError>;
44
44
  addSlab(spec: SlabSpec, options?: ElementIdentityOptions): Result<LocalId, BimError>;
45
- addBeam(spec: BeamSpec): Result<LocalId, BimError>;
45
+ addBeam(spec: BeamSpec, options?: ElementIdentityOptions): Result<LocalId, BimError>;
46
46
  addColumn(spec: ColumnSpec, options?: ElementIdentityOptions): Result<LocalId, BimError>;
47
47
  addSpace(spec: SpaceSpec): Result<LocalId, BimError>;
48
48
  addRoof(spec: RoofSpec): Result<LocalId, BimError>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs-bim",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "BIM layer for brepjs — IFC4-aligned parametric building elements",
5
5
  "keywords": [
6
6
  "bim",