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sourcesContent":["import * as WEBIFC from \"web-ifc\";\r\nimport { IfcCategoryMap } from \"../ifc-category-map\";\r\nexport class IfcPropertiesUtils {\r\n static async getUnits(group) {\r\n const { IFCUNITASSIGNMENT } = WEBIFC;\r\n const allUnitsSets = await group.getAllPropertiesOfType(IFCUNITASSIGNMENT);\r\n if (!allUnitsSets) {\r\n return 1;\r\n }\r\n const unitIDs = Object.keys(allUnitsSets);\r\n const allUnits = allUnitsSets[parseInt(unitIDs[0], 10)];\r\n for (const unitRef of allUnits.Units) {\r\n if (unitRef.value === undefined || unitRef.value === null)\r\n continue;\r\n const unit = await group.getProperties(unitRef.value);\r\n if (!unit || !unit.UnitType || !unit.UnitType.value) {\r\n continue;\r\n }\r\n const value = unit.UnitType.value;\r\n if (value !== \"LENGTHUNIT\")\r\n continue;\r\n let factor = 1;\r\n let unitValue = 1;\r\n if (unit.Name.value === \"METRE\") {\r\n unitValue = 1;\r\n }\r\n if (unit.Name.value === \"FOOT\") {\r\n unitValue = 0.3048;\r\n }\r\n if (unit.Prefix?.value === \"MILLI\") {\r\n factor = 0.001;\r\n }\r\n return unitValue * factor;\r\n }\r\n return 1;\r\n }\r\n static async findItemByGuid(model, guid) {\r\n const ids = model.getAllPropertiesIDs();\r\n for (const id of ids) {\r\n const property = await model.getProperties(id);\r\n if (property && property.GlobalId?.value === guid) {\r\n return property;\r\n }\r\n }\r\n return null;\r\n }\r\n static async getRelationMap(model, relationType, onElementsFound) {\r\n const defaultCallback = () => { };\r\n const _onElementsFound = onElementsFound ?? defaultCallback;\r\n const result = {};\r\n const ids = model.getAllPropertiesIDs();\r\n for (const expressID of ids) {\r\n const prop = await model.getProperties(expressID);\r\n if (!prop) {\r\n continue;\r\n }\r\n const isRelation = prop.type === relationType;\r\n const relatingKey = Object.keys(prop).find((key) => key.startsWith(\"Relating\"));\r\n const relatedKey = Object.keys(prop).find((key) => key.startsWith(\"Related\"));\r\n if (!(isRelation && relatingKey && relatedKey))\r\n continue;\r\n const relating = await model.getProperties(prop[relatingKey]?.value);\r\n const related = prop[relatedKey];\r\n if (!relating || !related) {\r\n continue;\r\n }\r\n if (!(related && Array.isArray(related)))\r\n continue;\r\n const elements = related.map((el) => {\r\n return el.value;\r\n });\r\n _onElementsFound(relating.expressID, elements);\r\n result[relating.expressID] = elements;\r\n }\r\n return result;\r\n }\r\n static async getQsetQuantities(model, expressID, onQuantityFound) {\r\n const defaultCallback = () => { };\r\n const _onQuantityFound = onQuantityFound ?? defaultCallback;\r\n const pset = await model.getProperties(expressID);\r\n if (!pset || pset.type !== WEBIFC.IFCELEMENTQUANTITY) {\r\n return null;\r\n }\r\n const quantities = pset.Quantities ?? [{}];\r\n const qtos = quantities.map((prop) => {\r\n if (prop.value)\r\n _onQuantityFound(prop.value);\r\n return prop.value;\r\n });\r\n return qtos.filter((prop) => prop !== null);\r\n }\r\n static async getPsetProps(model, expressID, onPropFound) {\r\n const defaultCallback = () => { };\r\n const _onPropFound = onPropFound ?? defaultCallback;\r\n const pset = await model.getProperties(expressID);\r\n if (!pset || pset.type !== WEBIFC.IFCPROPERTYSET) {\r\n return null;\r\n }\r\n const hasProperties = pset.HasProperties ?? [{}];\r\n const props = hasProperties.map((prop) => {\r\n if (prop.value)\r\n _onPropFound(prop.value);\r\n return prop.value;\r\n });\r\n return props.filter((prop) => prop !== null);\r\n }\r\n static async getPsetRel(model, psetID) {\r\n const prop = await model.getProperties(psetID);\r\n if (!prop) {\r\n return null;\r\n }\r\n const allPropsRels = await model.getAllPropertiesOfType(WEBIFC.IFCRELDEFINESBYPROPERTIES);\r\n if (!allPropsRels) {\r\n return null;\r\n }\r\n const allRels = Object.values(allPropsRels);\r\n let found = null;\r\n for (const rel of allRels) {\r\n if (rel.RelatingPropertyDefinition?.value === psetID) {\r\n found = rel.expressID;\r\n }\r\n }\r\n return found;\r\n }\r\n static async getQsetRel(model, qsetID) {\r\n return IfcPropertiesUtils.getPsetRel(model, qsetID);\r\n }\r\n static async getEntityName(model, entityID) {\r\n const entity = await model.getProperties(entityID);\r\n if (!entity) {\r\n return { key: null, name: null };\r\n }\r\n const key = Object.keys(entity).find((key) => key.endsWith(\"Name\")) ?? null;\r\n const name = key ? entity[key]?.value : null;\r\n return { key, name };\r\n }\r\n static async getQuantityValue(model, quantityID) {\r\n const quantity = await model.getProperties(quantityID);\r\n if (!quantity) {\r\n return { key: null, value: null };\r\n }\r\n const key = Object.keys(quantity).find((key) => key.endsWith(\"Value\")) ?? null;\r\n let value;\r\n if (key === null) {\r\n value = null;\r\n }\r\n else if (quantity[key] === undefined || quantity[key] === null) {\r\n value = null;\r\n }\r\n else {\r\n value = quantity[key].value;\r\n }\r\n return { key, value };\r\n }\r\n static isRel(expressID) {\r\n const entityName = IfcCategoryMap[expressID];\r\n return entityName.startsWith(\"IFCREL\");\r\n }\r\n static async attributeExists(model, expressID, attribute) {\r\n const entity = await model.getProperties(expressID);\r\n if (!entity) {\r\n return false;\r\n }\r\n return Object.keys(entity).includes(attribute);\r\n }\r\n static async groupEntitiesByType(model, expressIDs) {\r\n const categoriesMap = new Map();\r\n for (const expressID of expressIDs) {\r\n const entity = await model.getProperties(expressID);\r\n if (!entity) {\r\n continue;\r\n }\r\n const key = entity.type;\r\n const set = categoriesMap.get(key);\r\n if (!set)\r\n categoriesMap.set(key, new Set());\r\n categoriesMap.get(key)?.add(expressID);\r\n }\r\n return categoriesMap;\r\n }\r\n}\r\n//# sourceMappingURL=index.js.map"],"names":["IfcPropertiesUtils","getUnits","group","IFCUNITASSIGNMENT","allUnitsSets","getAllPropertiesOfType","unitIDs","Object","keys","allUnits","parseInt","unitRef","Units","undefined","value","unit","getProperties","UnitType","factor","unitValue","Name","Prefix","findItemByGuid","model","guid","ids","getAllPropertiesIDs","id","property","GlobalId","getRelationMap","relationType","onElementsFound","_onElementsFound","result","expressID","prop","isRelation","type","relatingKey","find","key","startsWith","relatedKey","relating","related","Array","isArray","elements","map","el","getQsetQuantities","onQuantityFound","_onQuantityFound","pset","Quantities","filter","getPsetProps","onPropFound","_onPropFound","HasProperties","getPsetRel","psetID","allPropsRels","allRels","values","found","rel","RelatingPropertyDefinition","getQsetRel","qsetID","getEntityName","entityID","entity","name","endsWith","getQuantityValue","quantityID","quantity","isRel","attributeExists","attribute","includes","groupEntitiesByType","expressIDs","categoriesMap","Map","get","set","Set","add"],"sourceRoot":""}