diff --git a/packages/core/package.json b/packages/core/package.json index fde0127ec..24d58e103 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@thatopen/components", "description": "Collection of core functionalities to author BIM apps.", - "version": "2.0.24", + "version": "2.0.25", "author": "That Open Company", "contributors": [ "Antonio Gonzalez Viegas (https://github.com/agviegas)", diff --git a/packages/core/src/core/Components/index.ts b/packages/core/src/core/Components/index.ts index 1bb693dbb..4507e9d0c 100644 --- a/packages/core/src/core/Components/index.ts +++ b/packages/core/src/core/Components/index.ts @@ -14,7 +14,7 @@ export class Components implements Disposable { /** * The version of the @thatopen/components library. */ - static readonly release = "2.0.24"; + static readonly release = "2.0.25"; /** {@link Disposable.onDisposed} */ readonly onDisposed = new Event(); diff --git a/packages/core/src/fragments/Classifier/index.ts b/packages/core/src/fragments/Classifier/index.ts index 023d47d70..e8e1c3ce3 100644 --- a/packages/core/src/fragments/Classifier/index.ts +++ b/packages/core/src/fragments/Classifier/index.ts @@ -348,27 +348,57 @@ export class Classifier extends Component implements Disposable { const modelRelations = indexer.relationMaps[model.uuid]; if (!modelRelations) { throw new Error( - `Classifier: model relations of ${model.name || model.uuid} have to exists to group by spatial structure.` + `Classifier: model relations of ${model.name || model.uuid} have to exists to group by spatial structure.`, ); } const systemName = "spatialStructures"; for (const [expressID] of modelRelations) { + const spatialRels = indexer.getEntityRelations( + model, + expressID, + "Decomposes", + ); + + // For spatial items like IFCSPACE + if (spatialRels) { + for (const id of spatialRels) { + const spatialRelAttrs = await model.getProperties(id); + if (!spatialRelAttrs) { + continue; + } + const relName = spatialRelAttrs.Name?.value; + + this.saveItem(model, systemName, relName, expressID); + } + } + const rels = indexer.getEntityRelations( model, expressID, "ContainsElements", ); + + if (!rels) { + continue; + } + const relAttrs = await model.getProperties(expressID); - if (!(rels && relAttrs)) continue; + if (!relAttrs) { + continue; + } const relName = relAttrs.Name?.value; + for (const id of rels) { this.saveItem(model, systemName, relName, id); + // For nested elements like curtain walls const decompositionRelations = indexer.getEntityRelations( model, Number(id), "IsDecomposedBy", ); - if (!decompositionRelations) continue; + if (!decompositionRelations) { + continue; + } for (const decomposedID of decompositionRelations) { this.saveItem(model, systemName, relName, decomposedID); } diff --git a/packages/core/src/ifc/IfcRelationsIndexer/index.ts b/packages/core/src/ifc/IfcRelationsIndexer/index.ts index 183d57122..01cec5948 100644 --- a/packages/core/src/ifc/IfcRelationsIndexer/index.ts +++ b/packages/core/src/ifc/IfcRelationsIndexer/index.ts @@ -243,12 +243,18 @@ export class IfcRelationsIndexer extends Component implements Disposable { relationName: InverseAttribute, ) { const indexMap = this.relationMaps[model.uuid]; - if (!indexMap) return null; + if (!indexMap) { + return null; + } const entityRelations = indexMap.get(expressID); const attributeIndex = this._inverseAttributes.indexOf(relationName); - if (!entityRelations || attributeIndex === -1) return null; + if (!entityRelations || attributeIndex === -1) { + return null; + } const relations = entityRelations.get(attributeIndex); - if (!relations) return null; + if (!relations) { + return null; + } return relations; }