bimatter-viewer-react 0.11.11 → 0.11.12

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.
@@ -191338,139 +191338,148 @@ var x_ = class {
191338
191338
  this.clearPropertyCaches(), this.spatialLinesCache.clear(), this.spatialTreeChunksCache.clear();
191339
191339
  }
191340
191340
  async getPropertiesAsBlobs(e, t, n, r) {
191341
- let i = await this.getAllRelDefinesByProps(e), a = i.size, o = t.size, s = {}, c = this.parser.GetLineIDsWithType(e, Cd).get(0);
191342
- if (c === void 0) return s;
191343
- let l = await this.getItemPropertiesBatch(e, i), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
191344
- for (let e of l.values()) {
191341
+ let i = await this.getAllRelDefinesByProps(e), a = i.size, o = t.size, s = await this.getMaterialsByElement(e), c = {}, l = this.parser.GetLineIDsWithType(e, Cd).get(0);
191342
+ if (l === void 0) return c;
191343
+ let u = await this.getItemPropertiesBatch(e, i), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
191344
+ for (let e of u.values()) {
191345
191345
  if (!e) continue;
191346
191346
  let t = y_(e.RelatingPropertyDefinition);
191347
- t !== null && u.add(t);
191348
- for (let t of b_(e.RelatedObjects)) d.add(t);
191349
- }
191350
- let f = await this.getItemPropertiesBatch(e, u), p = /* @__PURE__ */ new Set();
191351
- for (let e of f.values()) if (e) {
191352
- for (let t of b_(e.HasProperties)) p.add(t);
191353
- for (let t of b_(e.Quantities)) p.add(t);
191354
- }
191355
- await this.getItemPropertiesBatch(e, p);
191356
- let m = new Set(t);
191357
- for (let e of d) m.add(e);
191358
- m.add(c), await this.getItemPropertiesBatch(e, m);
191359
- let ee = await this.getItemProperty(e, c) ?? {
191360
- id: c,
191347
+ t !== null && d.add(t);
191348
+ for (let t of b_(e.RelatedObjects)) f.add(t);
191349
+ }
191350
+ let p = await this.getTypePropertySetIDsByElement(e);
191351
+ for (let [e, t] of p) f.add(e), t.forEach((e) => d.add(e));
191352
+ let m = await this.getItemPropertiesBatch(e, d), ee = /* @__PURE__ */ new Set();
191353
+ for (let e of m.values()) if (e) {
191354
+ for (let t of b_(e.HasProperties)) ee.add(t);
191355
+ for (let t of b_(e.Quantities)) ee.add(t);
191356
+ }
191357
+ await this.getItemPropertiesBatch(e, ee);
191358
+ let te = /* @__PURE__ */ new Map(), ne = (t) => {
191359
+ let n = te.get(t);
191360
+ return n || (n = this.createPropertySet(e, t), te.set(t, n)), n;
191361
+ }, re = /* @__PURE__ */ new Map();
191362
+ for (let [e, t] of p) {
191363
+ let n = [];
191364
+ for (let e of t) n = this.mergePropertySet(n, await ne(e));
191365
+ re.set(e, n);
191366
+ }
191367
+ let h = new Set(t);
191368
+ for (let e of f) h.add(e);
191369
+ h.add(l), await this.getItemPropertiesBatch(e, h);
191370
+ let ie = await this.getItemProperty(e, l) ?? {
191371
+ id: l,
191361
191372
  props: {},
191362
191373
  sets: []
191363
191374
  };
191364
- ee.sets = [], s[c] = ee;
191365
- let te = 0;
191375
+ ie.sets = [], c[l] = ie;
191376
+ let ae = 0;
191366
191377
  for (let t of i) {
191367
191378
  let r = await this.getItemProperty(e, t);
191368
191379
  if (r) {
191369
191380
  let t = y_(r.RelatingPropertyDefinition);
191370
191381
  if (t === null) continue;
191371
- let n = await this.getPropertySetData(e, t), i = {
191372
- id: t,
191373
- guid: "null",
191374
- name: "null",
191375
- props: [],
191376
- isQuantities: !1
191377
- };
191378
- n && (n.HasProperties || n.Quantities) && (i = {
191379
- id: t,
191380
- guid: this.getStringValue(n.GlobalId) ?? "null",
191381
- name: this.getStringValue(n.Name) ?? "null",
191382
- props: n.HasProperties ? n.HasProperties : n.Quantities ? n.Quantities : [],
191383
- isQuantities: !!n.Quantities
191384
- });
191385
- let a = b_(r.RelatedObjects);
191386
- for (let t of a) if (s[t]) s[t].sets ??= [], s[t].sets.push(i);
191382
+ let n = await ne(t), i = b_(r.RelatedObjects);
191383
+ for (let t of i) if (c[t]) c[t].sets ??= [], c[t].sets = this.mergePropertySet(c[t].sets, n);
191387
191384
  else {
191388
- let n = await this.getItemProperty(e, t);
191389
- if (n) {
191390
- let e = this.getStringValue(n.GlobalId), r = n.Name, a = n.ObjectType, o = n.LongName, c = this.getStringValue(n.type), l = {
191391
- name: r,
191385
+ let r = await this.getItemProperty(e, t);
191386
+ if (r) {
191387
+ let e = this.getStringValue(r.GlobalId), i = r.Name, a = r.ObjectType, o = r.LongName, l = this.getStringValue(r.type), u = {
191388
+ Material: s.get(t),
191389
+ PredefinedType: r.PredefinedType,
191390
+ name: i,
191392
191391
  typeName: a,
191393
191392
  longName: o,
191394
- type: c,
191393
+ type: l,
191395
191394
  elevation: void 0
191396
191395
  };
191397
- s[t] = {
191396
+ c[t] = {
191398
191397
  id: t,
191399
191398
  guid: e,
191400
- props: l,
191401
- sets: [i]
191402
- }, c === "IfcBuildingStorey" && (l.elevation = n.Elevation);
191403
- } else s[t] = {
191399
+ props: u,
191400
+ sets: this.mergePropertySet(re.get(t) ?? [], n)
191401
+ }, l === "IfcBuildingStorey" && (u.elevation = r.Elevation);
191402
+ } else c[t] = {
191404
191403
  id: t,
191405
191404
  guid: "null",
191406
191405
  props: {
191406
+ Material: s.get(t),
191407
+ PredefinedType: "null",
191407
191408
  name: "null",
191408
191409
  typeName: "null",
191409
191410
  longName: "null",
191410
191411
  type: "null",
191411
191412
  elevation: void 0
191412
191413
  },
191413
- sets: [i]
191414
+ sets: this.mergePropertySet(re.get(t) ?? [], n)
191414
191415
  };
191415
191416
  }
191416
191417
  }
191417
- te += 1, this.shouldEmitProgress(te, a) && n?.({
191418
- loaded: te,
191418
+ ae += 1, this.shouldEmitProgress(ae, a) && n?.({
191419
+ loaded: ae,
191419
191420
  phase: "propertySets",
191420
191421
  total: a
191421
191422
  });
191422
191423
  }
191423
- let ne = 0, re = /* @__PURE__ */ new Set(), h = (e) => {
191424
- if (re.has(e)) return;
191425
- let t = s[e];
191426
- t && (re.add(e), r?.({
191424
+ let oe = 0, se = /* @__PURE__ */ new Set(), ce = (e) => {
191425
+ if (se.has(e)) return;
191426
+ let t = c[e];
191427
+ t && (se.add(e), r?.({
191427
191428
  elementID: e,
191428
191429
  props: t
191429
191430
  }));
191430
191431
  };
191431
- Object.keys(s).forEach((e) => {
191432
+ Object.keys(c).forEach((e) => {
191432
191433
  let t = Number(e);
191433
- Number.isFinite(t) && h(t);
191434
+ Number.isFinite(t) && ce(t);
191434
191435
  });
191435
191436
  for (let r of t) {
191436
- if (s[r]) {
191437
- h(r), ne += 1, this.shouldEmitProgress(ne, o) && n?.({
191438
- loaded: ne,
191437
+ if (c[r]) {
191438
+ ce(r), oe += 1, this.shouldEmitProgress(oe, o) && n?.({
191439
+ loaded: oe,
191439
191440
  phase: "elements",
191440
191441
  total: o
191441
191442
  });
191442
191443
  continue;
191443
191444
  }
191444
191445
  let t = await this.getItemProperty(e, r);
191445
- t ? s[r] = {
191446
- id: r,
191447
- guid: this.getStringValue(t.GlobalId),
191448
- props: {
191449
- name: t.Name,
191450
- typeName: t.ObjectType,
191451
- longName: t.LongName,
191452
- type: this.getStringValue(t.type),
191453
- elevation: void 0
191454
- },
191455
- sets: []
191456
- } : s[r] = {
191446
+ if (t) {
191447
+ let e = this.getStringValue(t.GlobalId), n = t.Name, i = t.ObjectType, a = t.LongName, o = this.getStringValue(t.type);
191448
+ c[r] = {
191449
+ id: r,
191450
+ guid: e,
191451
+ props: {
191452
+ Material: s.get(r),
191453
+ PredefinedType: t.PredefinedType,
191454
+ name: n,
191455
+ typeName: i,
191456
+ longName: a,
191457
+ type: o,
191458
+ elevation: void 0
191459
+ },
191460
+ sets: [...re.get(r) ?? []]
191461
+ };
191462
+ } else c[r] = {
191457
191463
  id: r,
191458
191464
  guid: "null",
191459
191465
  props: {
191466
+ Material: s.get(r),
191467
+ PredefinedType: "null",
191460
191468
  name: "null",
191461
191469
  typeName: "null",
191462
191470
  longName: "null",
191463
191471
  type: "null",
191464
191472
  elevation: void 0
191465
191473
  },
191466
- sets: []
191467
- }, h(r), ne += 1, this.shouldEmitProgress(ne, o) && n?.({
191468
- loaded: ne,
191474
+ sets: [...re.get(r) ?? []]
191475
+ };
191476
+ ce(r), oe += 1, this.shouldEmitProgress(oe, o) && n?.({
191477
+ loaded: oe,
191469
191478
  phase: "elements",
191470
191479
  total: o
191471
191480
  });
191472
191481
  }
191473
- return s;
191482
+ return c;
191474
191483
  }
191475
191484
  async getItemProperty(e, t, n = !1) {
191476
191485
  let r = this.getItemPropertyCacheKey(e, t, n), i = this.itemPropertyCache.get(r);
@@ -191618,6 +191627,145 @@ var x_ = class {
191618
191627
  for (let e = 0; e < r; e++) n.add(t.get(e));
191619
191628
  return n;
191620
191629
  }
191630
+ async getTypePropertySetIDsByElement(e) {
191631
+ let t = this.parser.GetLineIDsWithType(e, M), n = [];
191632
+ for (let e = 0; e < t.size(); e += 1) n.push(t.get(e));
191633
+ let r = await this.getItemPropertiesBatch(e, n), i = /* @__PURE__ */ new Set();
191634
+ for (let e of r.values()) {
191635
+ if (!e) continue;
191636
+ let t = y_(e.RelatingType);
191637
+ t !== null && i.add(t);
191638
+ }
191639
+ let a = await this.getItemPropertiesBatch(e, i), o = /* @__PURE__ */ new Map();
191640
+ for (let e of r.values()) {
191641
+ if (!e) continue;
191642
+ let t = y_(e.RelatingType);
191643
+ if (t === null) continue;
191644
+ let n = a.get(t);
191645
+ if (!n) continue;
191646
+ let r = b_(n.HasPropertySets);
191647
+ if (r.length !== 0) for (let t of b_(e.RelatedObjects)) o.set(t, r);
191648
+ }
191649
+ return o;
191650
+ }
191651
+ async createPropertySet(e, t) {
191652
+ let n = await this.getPropertySetData(e, t);
191653
+ return !n || !n.HasProperties && !n.Quantities ? {
191654
+ id: t,
191655
+ guid: "null",
191656
+ name: "null",
191657
+ props: [],
191658
+ isQuantities: !1
191659
+ } : {
191660
+ id: t,
191661
+ guid: this.getStringValue(n.GlobalId) ?? "null",
191662
+ name: this.getStringValue(n.Name) ?? "null",
191663
+ props: n.HasProperties ?? n.Quantities ?? [],
191664
+ isQuantities: !!n.Quantities
191665
+ };
191666
+ }
191667
+ mergePropertySet(e, t) {
191668
+ let n = this.getPropertySetMergeName(t);
191669
+ if (!n) return [...e, t];
191670
+ let r = e.findIndex((e) => this.getPropertySetMergeName(e) === n);
191671
+ if (r === -1) return [...e, t];
191672
+ let i = e[r], a = [...e];
191673
+ return a[r] = {
191674
+ ...i,
191675
+ ...t,
191676
+ props: this.mergePropertySetProps(i.props, t.props)
191677
+ }, a;
191678
+ }
191679
+ getPropertySetMergeName(e) {
191680
+ let t = this.getStringValue(e.name)?.trim();
191681
+ return t && t !== "null" ? t : void 0;
191682
+ }
191683
+ mergePropertySetProps(e, t) {
191684
+ if (Array.isArray(e) && Array.isArray(t)) {
191685
+ let n = [...e], r = /* @__PURE__ */ new Map();
191686
+ return n.forEach((e, t) => {
191687
+ let n = this.getPropertyMergeName(e);
191688
+ n && r.set(n, t);
191689
+ }), t.forEach((e) => {
191690
+ let t = this.getPropertyMergeName(e), i = t ? r.get(t) : void 0;
191691
+ i === void 0 ? (t && r.set(t, n.length), n.push(e)) : n[i] = e;
191692
+ }), n;
191693
+ }
191694
+ return e && t && typeof e == "object" && typeof t == "object" && !Array.isArray(e) && !Array.isArray(t) ? {
191695
+ ...e,
191696
+ ...t
191697
+ } : t ?? e;
191698
+ }
191699
+ getPropertyMergeName(e) {
191700
+ if (!e || typeof e != "object" || Array.isArray(e)) return;
191701
+ let t = e;
191702
+ return this.getStringValue(t.Name ?? t.name)?.trim() || void 0;
191703
+ }
191704
+ async getMaterialsByElement(e) {
191705
+ let t = this.parser.GetLineIDsWithType(e, id), n = [];
191706
+ for (let e = 0; e < t.size(); e += 1) n.push(t.get(e));
191707
+ let r = await this.getItemPropertiesBatch(e, n), i = /* @__PURE__ */ new Set();
191708
+ for (let e of r.values()) {
191709
+ if (!e) continue;
191710
+ let t = y_(e.RelatingMaterial);
191711
+ t !== null && i.add(t);
191712
+ }
191713
+ let a = await this.getItemPropertiesBatch(e, i, !0), o = /* @__PURE__ */ new Map();
191714
+ for (let e of r.values()) {
191715
+ if (!e) continue;
191716
+ let t = y_(e.RelatingMaterial);
191717
+ if (t === null) continue;
191718
+ let n = a.get(t);
191719
+ if (!n) continue;
191720
+ let r = this.getMaterialNames(n);
191721
+ if (r.length !== 0) for (let t of b_(e.RelatedObjects)) {
191722
+ let e = o.get(t) ?? /* @__PURE__ */ new Set();
191723
+ r.forEach((t) => e.add(t)), o.set(t, e);
191724
+ }
191725
+ }
191726
+ let s = this.parser.GetLineIDsWithType(e, M), c = [];
191727
+ for (let e = 0; e < s.size(); e += 1) c.push(s.get(e));
191728
+ let l = await this.getItemPropertiesBatch(e, c);
191729
+ for (let e of l.values()) {
191730
+ if (!e) continue;
191731
+ let t = y_(e.RelatingType);
191732
+ if (t === null) continue;
191733
+ let n = o.get(t);
191734
+ if (n) for (let t of b_(e.RelatedObjects)) {
191735
+ let e = o.get(t) ?? /* @__PURE__ */ new Set();
191736
+ n.forEach((t) => e.add(t)), o.set(t, e);
191737
+ }
191738
+ }
191739
+ let u = /* @__PURE__ */ new Map();
191740
+ return o.forEach((e, t) => {
191741
+ let n = [...e];
191742
+ u.set(t, n.length === 1 ? n[0] : n);
191743
+ }), u;
191744
+ }
191745
+ getMaterialNames(e) {
191746
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
191747
+ if (!e || typeof e != "object" || n.has(e)) return;
191748
+ if (n.add(e), Array.isArray(e)) {
191749
+ e.forEach(r);
191750
+ return;
191751
+ }
191752
+ if (v_(e)) {
191753
+ r(e.value);
191754
+ return;
191755
+ }
191756
+ let i = e, a = v_(i.type) ? i.type.value : i.type;
191757
+ if (a === 1838606355 || typeof a == "string" && a.replace(/[^a-z0-9]/gi, "").toUpperCase() === "IFCMATERIAL") {
191758
+ let e = this.getStringValue(i.Name);
191759
+ e && t.add(e);
191760
+ }
191761
+ Object.values(i).forEach(r);
191762
+ };
191763
+ if (r(e), t.size === 0) {
191764
+ let n = this.getStringValue(e.Name) ?? this.getStringValue(e.LayerSetName);
191765
+ n && t.add(n);
191766
+ }
191767
+ return [...t];
191768
+ }
191621
191769
  async getSpatialStructure(e, t = !1) {
191622
191770
  let n = await this.getSpatialTreeChunks(e), r = await this.getSpatialLineMap(e, n), i = this.getProjectID(e);
191623
191771
  if (i === void 0) return {
@@ -10,14 +10,17 @@ type IfcLineData = Record<string, IfcRawValue> & {
10
10
  expressID?: number;
11
11
  Elevation?: BmtPropertyValue;
12
12
  GlobalId?: BmtPropertyValue;
13
+ HasPropertySets?: IfcRawValue[];
13
14
  HasProperties?: BmtPropertyRecord[];
14
15
  HasQuantities?: IfcRawValue[];
15
16
  LongName?: BmtPropertyValue;
16
17
  Name?: BmtPropertyValue;
17
18
  ObjectType?: BmtPropertyValue;
19
+ PredefinedType?: BmtPropertyValue;
18
20
  Quantities?: BmtPropertyRecord[];
19
21
  RelatedObjects?: number[];
20
22
  RelatingPropertyDefinition?: number;
23
+ RelatingType?: number;
21
24
  type?: number | string;
22
25
  };
23
26
  type PropertyRelationConfig = {
@@ -68,6 +71,14 @@ export declare class PropertySerializer {
68
71
  getElementsAssembly(modelID: number): Promise<IfcElementsAssembly>;
69
72
  private formatItemProperties;
70
73
  private getAllRelDefinesByProps;
74
+ private getTypePropertySetIDsByElement;
75
+ private createPropertySet;
76
+ private mergePropertySet;
77
+ private getPropertySetMergeName;
78
+ private mergePropertySetProps;
79
+ private getPropertyMergeName;
80
+ private getMaterialsByElement;
81
+ private getMaterialNames;
71
82
  getSpatialStructure(modelID: number, includeProperties?: boolean): Promise<BmtModelStructureNode>;
72
83
  getRelatedProperties(modelID: number, elementID: number, propsName: PropertyRelationConfig, recursive?: boolean): Promise<IfcLineData[]>;
73
84
  getChunks(modelID: number, chunks: SpatialTreeChunks, propNames: PropertyRelationConfig): Promise<void>;