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E5C,EAEJL,EAAgBmB,KAAO,uCACvB,qBAA+BnB,EAAgBmB,K","sources":["webpack://client-app/./node_modules/openbim-components/src/fragments/FragmentIfcLoader/src/ifc-fragment-settings.js","webpack://client-app/./node_modules/openbim-components/src/fragments/FragmentIfcLoader/src/units.js","webpack://client-app/./node_modules/openbim-components/src/fragments/FragmentIfcLoader/src/spatial-structure.js","webpack://client-app/./node_modules/openbim-components/src/fragments/FragmentManager/index.js"],"sourcesContent":["import * as WEBIFC from \"web-ifc\";\r\n/** Configuration of the IFC-fragment conversion. */\r\nexport class IfcFragmentSettings {\r\n constructor() {\r\n /** Whether to extract the IFC properties into a JSON. */\r\n this.includeProperties = true;\r\n /**\r\n * Generate the geometry for categories that are not included by default,\r\n * like IFCSPACE.\r\n */\r\n this.optionalCategories = [WEBIFC.IFCSPACE];\r\n /** Whether to use the coordination data coming from the IFC files. */\r\n this.coordinate = true;\r\n /** Path of the WASM for [web-ifc](https://github.com/ifcjs/web-ifc). */\r\n this.wasm = {\r\n path: \"\",\r\n absolute: false,\r\n };\r\n /** List of categories that won't be converted to fragments. */\r\n this.excludedCategories = new Set();\r\n /** Whether to save the absolute location of all IFC items. */\r\n this.saveLocations = false;\r\n /** Loader settings for [web-ifc](https://github.com/ifcjs/web-ifc). */\r\n this.webIfc = {\r\n COORDINATE_TO_ORIGIN: true,\r\n USE_FAST_BOOLS: true,\r\n OPTIMIZE_PROFILES: true,\r\n };\r\n }\r\n}\r\n//# sourceMappingURL=ifc-fragment-settings.js.map","import * as WEBIFC from \"web-ifc\";\r\nimport * as THREE from \"three\";\r\nexport class Units {\r\n constructor() {\r\n this.factor = 1;\r\n this.complement = 1;\r\n }\r\n apply(matrix) {\r\n const scale = this.getScaleMatrix();\r\n const result = scale.multiply(matrix);\r\n matrix.copy(result);\r\n }\r\n setUp(webIfc) {\r\n var _a;\r\n this.factor = 1;\r\n const length = this.getLengthUnits(webIfc);\r\n if (!length) {\r\n return;\r\n }\r\n const isLengthNull = length === undefined || length === null;\r\n const isValueNull = length.Name === undefined || length.Name === null;\r\n if (isLengthNull || isValueNull) {\r\n return;\r\n }\r\n if (length.Name.value === \"FOOT\") {\r\n this.factor = 0.3048;\r\n }\r\n else if (((_a = length.Prefix) === null || _a === void 0 ? void 0 : _a.value) === \"MILLI\") {\r\n this.complement = 0.001;\r\n }\r\n }\r\n getLengthUnits(webIfc) {\r\n try {\r\n const allUnitsAssigns = webIfc.GetLineIDsWithType(0, WEBIFC.IFCUNITASSIGNMENT);\r\n const unitsAssign = allUnitsAssigns.get(0);\r\n const unitsAssignProps = webIfc.GetLine(0, unitsAssign);\r\n for (const units of unitsAssignProps.Units) {\r\n if (!units || units.value === null || units.value === undefined) {\r\n continue;\r\n }\r\n const unitsProps = webIfc.GetLine(0, units.value);\r\n if (unitsProps.UnitType && unitsProps.UnitType.value === \"LENGTHUNIT\") {\r\n return unitsProps;\r\n }\r\n }\r\n return null;\r\n }\r\n catch (e) {\r\n console.log(\"Could not get units\");\r\n return null;\r\n }\r\n }\r\n getScaleMatrix() {\r\n const f = this.factor;\r\n // prettier-ignore\r\n return new THREE.Matrix4().fromArray([\r\n f, 0, 0, 0,\r\n 0, f, 0, 0,\r\n 0, 0, f, 0,\r\n 0, 0, 0, 1,\r\n ]);\r\n }\r\n}\r\n//# sourceMappingURL=units.js.map","import * as WEBIFC from \"web-ifc\";\r\nimport { Units } from \"./units\";\r\nexport class SpatialStructure {\r\n constructor() {\r\n this.itemsByFloor = {};\r\n this._units = new Units();\r\n }\r\n // TODO: Maybe make this more flexible so that it also support more exotic spatial structures?\r\n async setUp(webIfc) {\r\n this._units.setUp(webIfc);\r\n this.cleanUp();\r\n try {\r\n const spatialRels = webIfc.GetLineIDsWithType(0, WEBIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE);\r\n const allRooms = new Set();\r\n const rooms = webIfc.GetLineIDsWithType(0, WEBIFC.IFCSPACE);\r\n for (let i = 0; i < rooms.size(); i++) {\r\n allRooms.add(rooms.get(i));\r\n }\r\n // First add rooms (if any) to floors\r\n const aggregates = webIfc.GetLineIDsWithType(0, WEBIFC.IFCRELAGGREGATES);\r\n const aggregatesSize = aggregates.size();\r\n for (let i = 0; i < aggregatesSize; i++) {\r\n const id = aggregates.get(i);\r\n const properties = webIfc.GetLine(0, id);\r\n if (!properties ||\r\n !properties.RelatingObject ||\r\n !properties.RelatedObjects) {\r\n continue;\r\n }\r\n const parentID = properties.RelatingObject.value;\r\n const childsIDs = properties.RelatedObjects;\r\n for (const child of childsIDs) {\r\n const childID = child.value;\r\n if (allRooms.has(childID)) {\r\n this.itemsByFloor[childID] = parentID;\r\n }\r\n }\r\n }\r\n // Now add items contained in floors and rooms\r\n // If items contained in room, look for the floor where that room is and assign it to it\r\n const itemsContainedInRooms = {};\r\n const spatialRelsSize = spatialRels.size();\r\n for (let i = 0; i < spatialRelsSize; i++) {\r\n const id = spatialRels.get(i);\r\n const properties = webIfc.GetLine(0, id);\r\n if (!properties ||\r\n !properties.RelatingStructure ||\r\n !properties.RelatedElements) {\r\n continue;\r\n }\r\n const structureID = properties.RelatingStructure.value;\r\n const relatedItems = properties.RelatedElements;\r\n if (allRooms.has(structureID)) {\r\n for (const related of relatedItems) {\r\n if (!itemsContainedInRooms[structureID]) {\r\n itemsContainedInRooms[structureID] = [];\r\n }\r\n const id = related.value;\r\n itemsContainedInRooms[structureID].push(id);\r\n }\r\n }\r\n else {\r\n for (const related of relatedItems) {\r\n const id = related.value;\r\n this.itemsByFloor[id] = structureID;\r\n }\r\n }\r\n }\r\n for (const roomID in itemsContainedInRooms) {\r\n const roomFloor = this.itemsByFloor[roomID];\r\n if (roomFloor !== undefined) {\r\n const items = itemsContainedInRooms[roomID];\r\n for (const item of items) {\r\n this.itemsByFloor[item] = roomFloor;\r\n }\r\n }\r\n }\r\n // Finally, add nested items (e.g. elements of curtain walls)\r\n for (let i = 0; i < aggregatesSize; i++) {\r\n const id = aggregates.get(i);\r\n const properties = webIfc.GetLine(0, id);\r\n if (!properties ||\r\n !properties.RelatingObject ||\r\n !properties.RelatedObjects) {\r\n continue;\r\n }\r\n const parentID = properties.RelatingObject.value;\r\n const childsIDs = properties.RelatedObjects;\r\n for (const child of childsIDs) {\r\n const childID = child.value;\r\n const parentStructure = this.itemsByFloor[parentID];\r\n if (parentStructure !== undefined) {\r\n this.itemsByFloor[childID] = parentStructure;\r\n }\r\n }\r\n }\r\n }\r\n catch (e) {\r\n console.log(\"Could not get floors.\");\r\n }\r\n }\r\n cleanUp() {\r\n this.itemsByFloor = {};\r\n }\r\n}\r\n//# sourceMappingURL=spatial-structure.js.map","import { Serializer } from \"bim-fragment\";\r\nimport { Component } from \"../../base-types/component\";\r\nimport { UIElement } from \"../../base-types/ui-element\";\r\nimport { Event } from \"../../base-types\";\r\nimport { ToolComponent } from \"../../core/ToolsComponent\";\r\nimport { Button, FloatingWindow, SimpleUICard, SimpleUIComponent, } from \"../../ui\";\r\n/**\r\n * Object that can efficiently load binary files that contain\r\n * [fragment geometry](https://github.com/ifcjs/fragment).\r\n */\r\nexport class FragmentManager extends Component {\r\n /** The list of meshes of the created fragments. */\r\n get meshes() {\r\n const allMeshes = [];\r\n for (const fragID in this.list) {\r\n allMeshes.push(this.list[fragID].mesh);\r\n }\r\n return allMeshes;\r\n }\r\n constructor(components) {\r\n super(components);\r\n /** {@link Disposable.onDisposed} */\r\n this.onDisposed = new Event();\r\n /** {@link Component.enabled} */\r\n this.enabled = true;\r\n /** All the created [fragments](https://github.com/ifcjs/fragment). */\r\n this.list = {};\r\n this.groups = [];\r\n this.baseCoordinationModel = \"\";\r\n this.onFragmentsLoaded = new Event();\r\n this.onFragmentsDisposed = new Event();\r\n this.uiElement = new UIElement();\r\n this.commands = [];\r\n this._loader = new Serializer();\r\n this._cards = [];\r\n this.components.tools.add(FragmentManager.uuid, this);\r\n if (components.uiEnabled) {\r\n this.setupUI(components);\r\n }\r\n }\r\n /** {@link Component.get} */\r\n get() {\r\n return Object.values(this.list);\r\n }\r\n /** {@link Component.get} */\r\n async dispose(disposeUI = false) {\r\n if (disposeUI) {\r\n this.uiElement.dispose();\r\n }\r\n for (const group of this.groups) {\r\n group.dispose(true);\r\n }\r\n for (const command of this.commands) {\r\n await command.dispose();\r\n }\r\n for (const card of this._cards) {\r\n await card.dispose();\r\n }\r\n this.groups = [];\r\n this.list = {};\r\n this.onFragmentsLoaded.reset();\r\n this.onFragmentsDisposed.reset();\r\n await this.onDisposed.trigger(FragmentManager.uuid);\r\n this.onDisposed.reset();\r\n }\r\n async disposeGroup(group) {\r\n const { uuid: groupID } = group;\r\n const fragmentIDs = group.items.map((fragment) => fragment.id);\r\n for (const fragment of group.items) {\r\n this.removeFragmentMesh(fragment);\r\n delete this.list[fragment.id];\r\n }\r\n group.dispose(true);\r\n const index = this.groups.indexOf(group);\r\n this.groups.splice(index, 1);\r\n await this.onFragmentsDisposed.trigger({\r\n groupID,\r\n fragmentIDs,\r\n });\r\n await this.updateWindow();\r\n }\r\n /** Disposes all existing fragments */\r\n reset() {\r\n for (const id in this.list) {\r\n const fragment = this.list[id];\r\n fragment.dispose();\r\n }\r\n this.list = {};\r\n }\r\n /**\r\n * Loads one or many fragments into the scene.\r\n * @param data - the bytes containing the data for the fragments to load.\r\n * @returns the list of IDs of the loaded fragments.\r\n */\r\n async load(data, coordinate = true) {\r\n const model = this._loader.import(data);\r\n const scene = this.components.scene.get();\r\n const ids = [];\r\n scene.add(model);\r\n for (const fragment of model.items) {\r\n fragment.group = model;\r\n this.list[fragment.id] = fragment;\r\n ids.push(fragment.id);\r\n this.components.meshes.push(fragment.mesh);\r\n }\r\n if (coordinate) {\r\n const isFirstModel = this.groups.length === 0;\r\n if (isFirstModel) {\r\n this.baseCoordinationModel = model.uuid;\r\n }\r\n else {\r\n this.coordinate([model]);\r\n }\r\n }\r\n this.groups.push(model);\r\n await this.onFragmentsLoaded.trigger(model);\r\n return model;\r\n }\r\n /**\r\n * Export the specified fragments.\r\n * @param group - the fragments group to be exported.\r\n * @returns the exported data as binary buffer.\r\n */\r\n export(group) {\r\n return this._loader.export(group);\r\n }\r\n async updateWindow() {\r\n if (!this.components.uiEnabled) {\r\n return;\r\n }\r\n for (const card of this._cards) {\r\n await card.dispose();\r\n }\r\n for (const group of this.groups) {\r\n const card = new SimpleUICard(this.components);\r\n // TODO: Make all cards like this?\r\n card.domElement.classList.remove(\"bg-ifcjs-120\");\r\n card.domElement.classList.remove(\"border-transparent\");\r\n card.domElement.className += ` min-w-[300px] my-2 border-1 border-solid border-[#3A444E] `;\r\n const buttonContainer = new SimpleUIComponent(this.components);\r\n card.addChild(buttonContainer);\r\n card.title = group.name;\r\n this.uiElement.get(\"window\").addChild(card);\r\n this._cards.push(card);\r\n // TODO: Use command list just like in fragment plans\r\n const commandsButton = new Button(this.components);\r\n commandsButton.materialIcon = \"delete\";\r\n buttonContainer.addChild(commandsButton);\r\n commandsButton.onClick.add(() => this.disposeGroup(group));\r\n }\r\n }\r\n coordinate(models = this.groups) {\r\n const baseModel = this.groups.find((group) => group.uuid === this.baseCoordinationModel);\r\n if (!baseModel) {\r\n console.log(\"No base model found for coordination!\");\r\n return;\r\n }\r\n for (const model of models) {\r\n if (model === baseModel) {\r\n continue;\r\n }\r\n model.position.set(0, 0, 0);\r\n model.rotation.set(0, 0, 0);\r\n model.scale.set(1, 1, 1);\r\n model.updateMatrix();\r\n model.applyMatrix4(model.coordinationMatrix.clone().invert());\r\n model.applyMatrix4(baseModel.coordinationMatrix);\r\n }\r\n }\r\n setupUI(components) {\r\n const window = new FloatingWindow(components);\r\n window.title = \"Models\";\r\n window.domElement.style.left = \"70px\";\r\n window.domElement.style.top = \"100px\";\r\n window.domElement.style.width = \"340px\";\r\n window.domElement.style.height = \"400px\";\r\n const windowContent = window.slots.content.domElement;\r\n windowContent.classList.remove(\"overflow-auto\");\r\n windowContent.classList.add(\"overflow-x-hidden\");\r\n components.ui.add(window);\r\n window.visible = false;\r\n const main = new Button(components);\r\n main.tooltip = \"Models\";\r\n main.materialIcon = \"inbox\";\r\n main.onClick.add(() => {\r\n window.visible = !window.visible;\r\n });\r\n this.uiElement.set({ main, window });\r\n this.onFragmentsLoaded.add(() => this.updateWindow());\r\n }\r\n removeFragmentMesh(fragment) {\r\n const meshes = this.components.meshes;\r\n const mesh = fragment.mesh;\r\n if (meshes.includes(mesh)) {\r\n meshes.splice(meshes.indexOf(mesh), 1);\r\n }\r\n }\r\n}\r\nFragmentManager.uuid = \"fef46874-46a3-461b-8c44-2922ab77c806\";\r\nToolComponent.libraryUUIDs.add(FragmentManager.uuid);\r\n//# sourceMappingURL=index.js.map"],"names":["IfcFragmentSettings","constructor","this","includeProperties","optionalCategories","coordinate","wasm","path","absolute","excludedCategories","Set","saveLocations","webIfc","COORDINATE_TO_ORIGIN","USE_FAST_BOOLS","OPTIMIZE_PROFILES","Units","factor","complement","apply","matrix","result","getScaleMatrix","multiply","copy","setUp","_a","length","getLengthUnits","isLengthNull","isValueNull","undefined","Name","value","Prefix","unitsAssign","GetLineIDsWithType","get","unitsAssignProps","GetLine","units","unitsProps","UnitType","e","console","log","f","fromArray","SpatialStructure","itemsByFloor","_units","async","cleanUp","spatialRels","allRooms","rooms","i","size","add","aggregates","aggregatesSize","id","properties","RelatingObject","RelatedObjects","parentID","childsIDs","child","childID","has","itemsContainedInRooms","spatialRelsSize","RelatingStructure","RelatedElements","structureID","relatedItems","related","push","roomID","roomFloor","items","item","parentStructure","FragmentManager","meshes","allMeshes","fragID","list","mesh","components","super","onDisposed","enabled","groups","baseCoordinationModel","onFragmentsLoaded","onFragmentsDisposed","uiElement","commands","_loader","_cards","tools","uuid","uiEnabled","setupUI","Object","values","disposeUI","dispose","group","command","card","reset","trigger","groupID","fragmentIDs","map","fragment","removeFragmentMesh","index","indexOf","splice","updateWindow","data","model","import","ids","scene","export","domElement","classList","remove","className","buttonContainer","addChild","title","name","commandsButton","materialIcon","onClick","disposeGroup","models","baseModel","find","position","set","rotation","scale","updateMatrix","applyMatrix4","coordinationMatrix","clone","invert","window","style","left","top","width","height","windowContent","slots","content","ui","visible","main","tooltip","includes"],"sourceRoot":""}