Skip to content

Commit

Permalink
feat: add methods to traverse properties
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Feb 18, 2024
1 parent 787ede6 commit 40f0891
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bim-fragment",
"version": "1.3.20",
"version": "1.3.22",
"description": "3D BIM Geometry API",
"main": "src/index.js",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions resources/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7516,6 +7516,28 @@ class FragmentsGroup extends THREE.Group {
this.items = [];
this.ifcCivil = undefined;
}
setProperties(properties) {
this._properties = properties;
}
getAllIDs() {
if (this._properties) {
return Object.keys(this._properties).map((id) => parseInt(id, 10));
}
return Array.from(this.streamSettings.ids.keys());
}
getAllTypes() {
if (this._properties) {
const types = new Set();
for (const id in this._properties) {
const property = this._properties[id];
if (property.type !== undefined) {
types.add(property.type);
}
}
return Array.from(types);
}
return Array.from(this.streamSettings.types.keys());
}
getProperties(id) {
if (!this._properties) {
throw new Error("Properties not initialized!");
Expand Down
25 changes: 25 additions & 0 deletions src/fragments-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ export class FragmentsGroup extends THREE.Group {
this.ifcCivil = undefined;
}

setProperties(properties: IfcProperties) {
this._properties = properties;
}

getAllIDs() {
if (this._properties) {
return Object.keys(this._properties).map((id) => parseInt(id, 10));
}
return Array.from(this.streamSettings.ids.keys());
}

getAllTypes() {
if (this._properties) {
const types = new Set<number>();
for (const id in this._properties) {
const property = this._properties[id];
if (property.type !== undefined) {
types.add(property.type);
}
}
return Array.from(types);
}
return Array.from(this.streamSettings.types.keys());
}

getProperties(id: number): IfcProperties | null {
if (!this._properties) {
throw new Error("Properties not initialized!");
Expand Down

0 comments on commit 40f0891

Please sign in to comment.