Skip to content

Commit

Permalink
fix: make classifier take ifc spaces into account for spatial structure
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Jul 8, 2024
1 parent 68b40c1 commit e54e13b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>();
Expand Down
36 changes: 33 additions & 3 deletions packages/core/src/fragments/Classifier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/core/src/ifc/IfcRelationsIndexer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e54e13b

Please sign in to comment.