# Class BimIfcLoader

Represents a BIM IFC Loader. Responsible for managing a collection of IFC files and loading data from them.

#### Implements

- BimIfcLoaderElementParent

##### Index

### Constructors

constructor

### Properties

vertexDataRepository

### Accessors

classes
disciplines
floors
ifcHttpResources
ifcProductsWithGeometryCount
loaderElements
projects
regionBoundingInfo
spaces

### Methods

aabb
add
addOrGetIfcProductCache
applyAndResetTrackedVisualChanges
applyColor
clear
deleteIfcProductCache
foreach
geometryBuilder
getRegionBoundingInfo
loadPropertySets
products

## Constructors

### constructor

- new BimIfcLoader(
  _bimApi: BimCoreApiClient,
  _propertySetRepository: BimPropertySetRepository,
  _geometricFeaturesRepository: BimGeometricFeaturesRepository,
  vertexDataRepository: BimVertexDataRepository,
  _materials: Materials,
  _twinInputResolver?: TwinInputResolver,
  _renderControl?: GeometryBuilderRenderControl,
  ): BimIfcLoader

  Creates a instance of BimIfcLoader class. Responsible for managing a collection of IFC files and loading data from them.

  #### Parameters

  - _bimApi: BimCoreApiClient
  - _propertySetRepository: BimPropertySetRepository
  - _geometricFeaturesRepository: BimGeometricFeaturesRepository
  - vertexDataRepository: BimVertexDataRepository
  - _materials: Materials
  - `Optional`_twinInputResolver: TwinInputResolver
  - `Optional`_renderControl: GeometryBuilderRenderControl

  #### Returns BimIfcLoader

## Properties

### `Readonly` vertexDataRepository

vertexDataRepository: BimVertexDataRepository

## Accessors

### classes

- get classes(): ModelProductClass[]

  Gets all the IFC classes used by IFC products in the currently loaded IFC files.

  #### Returns ModelProductClass[]

  An array of BimIfcClass objects representing the available classes.

  Implementation of BimIfcLoaderElementParent.classes

### disciplines

- get disciplines(): Discipline[]

  Gets the available disciplines.

  #### Returns Discipline[]

  An array of Discipline objects.

  Implementation of BimIfcLoaderElementParent.disciplines

### floors

- get floors(): BimIfcBuildingStorey[]

  Gets the floors (IfcBuildingStorey) available in the currently loaded IFC files.

  #### Returns BimIfcBuildingStorey[]

  An array of BimIfcBuildingStorey objects representing the available floors (storey levels).

  Implementation of BimIfcLoaderElementParent.floors

### ifcHttpResources

- get ifcHttpResources(): BimChangeIfc[]

  Gets the array of BimChangeIfc objects representing the IFC files that are loaded.

  #### Returns BimChangeIfc[]

  An array of BimChangeIfc objects.

### ifcProductsWithGeometryCount

- get ifcProductsWithGeometryCount(): number

  Gets the count of IFC products with geometry.

  #### Returns number

  The number of IFC products with geometry.

### loaderElements

- get loaderElements(): IBimIfcLoaderElement[]

  Gets the IBimIfcLoaderElement for the loaded IFC files.

  #### Returns IBimIfcLoaderElement[]

  An array of IBimIfcLoaderElement objects.

  Implementation of BimIfcLoaderElementParent.loaderElements

### projects

- get projects(): BimIfcObject[]

  Gets the IfcProject root nodes from each loaded IFC file.

  #### Returns BimIfcObject[]

  An array of BimIfcObject representing the projects.

  #### Remarks

  These can then be used to traverse the IFC file structure by calling BimIfcObject.foreach, or BimIfcObject.entries on each project.

  Implementation of BimIfcLoaderElementParent.projects

### regionBoundingInfo

- get regionBoundingInfo(): BoundingInfo

  Get the bounding info for loaded IFC files based on the most populated regions of each IFC file, excluding outliers and anomalous regions. The bounding info is derived from the regions with the highest IFC product count in each IFC file. Regions distant from the majority are excluded. The `regionBoundingInfo` is critical for camera positioning to ensure the entire `regionBoundingInfo` is within the camera's frustum. Overly large `regionBoundingInfo` can result in the camera being too distant, causing visibility issues. This can occur if anomalies are undetectable, e.g., when 50% of regions are proximate while the remaining 50% are outliers but also proximate to each other. This is common when IFC files are modeled in different coordinate systems, leading to disparate global positions for files intended to be co-located. There have been cases where IFC files, that should been co-located, are actually located in widely different places on the globe. Whenever add is called (before clear) this property is updated.

  #### Returns BoundingInfo

### spaces

- get spaces(): BimIfcSpace[]

  Gets the spaces (IfcSpace) available in the currently loaded IFC files..

  #### Returns BimIfcSpace[]

  An array of BimIfcSpace objects.

  Implementation of BimIfcLoaderElementParent.spaces

## Methods

### aabb

- aabb(
  min: Vector3,
  max: Vector3,
  ifcProducts: BimIfcObject[],
  predicate?: (
  o: BimIfcObject,
  recursionOptions: BimIfcObjectRecursionOptions,
  ) => unknown,
  ): void

  Calculates the `min` and `max` coordinate of the axis-aligned bounding box (AABB) encompassing a collection of BimIfcObject's. The AABB is defined by the minimum and maximum coordinates in each axis. The result is written to the provided `min` and `max` vectors.

  #### Parameters

  - min: Vector3

    The minimum coordinates of the AABB will be stored in this vector.

  - max: Vector3

    The maximum coordinates of the AABB will be stored in this vector.

  - ifcProducts: BimIfcObject[]

    The collection of BimIfcObject to calculate the AABB for.

  - predicate: (o: BimIfcObject, recursionOptions: BimIfcObjectRecursionOptions) => unknown = DefaultBimIfcObjectForEachPredicate

    The predicate function to filter the BimIfcObject. Defaults to DefaultBimIfcObjectForEachPredicate.

  #### Returns void

### add

- add(
  inputs: IfcAddInput | IfcAddInput[],
  ): Promise<
  (
  | IBimIfcLoaderElement
  | T8BimIfcLoaderElementCreateFailure
  | BimIfcLoaderElementCreateFailure
  )[],
  >

  Adds the specified IFC files or twins to the loader.

  #### Parameters

  - inputs: IfcAddInput | IfcAddInput[]

    An array of IfcAddInput (either IfcWithOptions or TwinInput).

  #### Returns Promise<
  (
  | IBimIfcLoaderElement
  | T8BimIfcLoaderElementCreateFailure
  | BimIfcLoaderElementCreateFailure
  )[],
  >

  A promise that resolves to an array of IBimIfcLoaderElement or failure instances. Use isFailure to check if a returned instance is a failure or not. Its not required to check for failures but it can be useful to know why a file failed to load.

  #### Remarks

  When files are added, the loader will load the IFC files and create IBimIfcLoaderElement instances for each file. See loaderElements for the created instances. To read the IFC products, present the loaded files, use foreach or products.

  Twin inputs (TwinInput) are resolved into IfcWithOptions via the configured TwinInputResolver.

### addOrGetIfcProductCache

- addOrGetIfcProductCache<T extends BimIfcObject = BimIfcObject>(
  key: string,
  predicate: BimIfcObjectForEachPredicate,
  ): DeepImmutable<Set<T>>

  Adds or retrieves the cached set of BimIfcObject instances based on the provided key and predicate. Cache is cleared when clear is called.

  #### Type Parameters

  - T extends BimIfcObject = BimIfcObject

    The type of BimIfcObject to be stored in the cache.

  #### Parameters

  - key: string

    The key used to identify the cache entry.

  - predicate: BimIfcObjectForEachPredicate

    The predicate function used to filter BimIfcObject instances. If it returns `truthy` then object is added to cache. Otherwise not

  #### Returns DeepImmutable<Set<T>>

  The cached set of BimIfcObject instances.

  Implementation of BimIfcLoaderElementParent.addOrGetIfcProductCache

### applyAndResetTrackedVisualChanges

- applyAndResetTrackedVisualChanges(): undefined | ReadonlySet<BimIfcObject>

  #### Returns undefined | ReadonlySet<BimIfcObject>

  #### Deprecated

  - No longer does anything.

### applyColor

- applyColor(): void

  #### Returns void

  #### Deprecated

  No longer does anything

### clear

- clear(): void

  Clears the state of the BimIfcLoader instance. If geometryBuilder has been called, and if it has been used to create Geometry3d instances that have been added to TwinfinityViewer then those instances are NOT removed from the viewer. Call BimCoreApi.clear to remove all geometry from the viewer as well.

  #### Returns void

  Implementation of BimIfcLoaderElementParent.clear

### deleteIfcProductCache

- deleteIfcProductCache(key: string): boolean

  Deletes a cache created by addOrGetIfcProductCache-

  #### Parameters

  - key: string

    Cache to delete

  #### Returns boolean

  `true` if a cache was deleted, otherwise `false`.

  Implementation of BimIfcLoaderElementParent.deleteIfcProductCache

### foreach

- foreach(action: BimIfcObjectForEachAction): void

  Iterate all IFC objects with a callback. Its also possible to call products to get an iterator.

  #### Parameters

  - action: BimIfcObjectForEachAction

    Visitor callback. Called for every IFC object.

  #### Returns void

### geometryBuilder

- geometryBuilder(
  options?:
  | GeometryBuilderOptions
  | ((ifcProduct: BimIfcObject) => unknown),
  ): Promise<IfcGeometryBuilder>

  Creates an IfcGeometryBuilder containing the BimIfcObject instances matched by the provided predicate. If no predicate is provided, all objects will be included.

  #### Parameters

  - `Optional` options: GeometryBuilderOptions | ((ifcProduct: BimIfcObject) => unknown)

    Optional predicate function to filter the objects.

  #### Returns Promise<IfcGeometryBuilder>

  A promise that resolves to an instance of IfcGeometryBuilder.

  #### Remarks

  The IfcGeometryBuilder can be used to create Geometry3d instances for the matched objects. In order to visualize them use TwinfinityViewer.addOrReplaceMesh.

  Implementation of BimIfcLoaderElementParent.geometryBuilder

### getRegionBoundingInfo

- getRegionBoundingInfo(
  onlyMostPopulatedRegions: boolean,
  useWorldSpace?: boolean,
  ): BoundingInfo

  Calculate the bounding info for the currently loaded IFC files based on the most populated regions of each IFC file, excluding outliers and anomalous regions.

  #### Parameters

  - onlyMostPopulatedRegions: boolean

    Indicates whether to include only the most populated regions.

  - useWorldSpace: boolean = true

    Indicates whether to use world space coordinates. Default is `true`

  #### Returns BoundingInfo

  The bounding information for the regions.

  #### Remarks

  The bounding info is derived from the regions with the highest IFC product count in each IFC file. Regions distant from the majority are excluded. The `regionBoundingInfo` is critical for camera positioning to ensure the entire `regionBoundingInfo` is within the camera's frustum. Overly large `regionBoundingInfo` can result in the camera being too distant, causing visibility issues. This can occur if anomalies are undetectable, e.g., when 50% of regions are proximate while the remaining 50% are outliers but also proximate to each other. This is common when IFC files are modeled in different coordinate systems, leading to disparate global positions for files intended to be co-located. There have been cases where IFC files, that should been co-located, are actually located in widely different places on the globe.

### loadPropertySets

- loadPropertySets(): Promise<void>

  Loads the property sets for currently loaded IFC files add. If property sets are already loaded then this method does nothing.

  #### Returns Promise<void>

  A promise that resolves when all property sets have been loaded.

### products

- products(): IterableIterator<BimIfcObject>

  Gets a iterator for all Ifc products currently loaded.

  #### Returns IterableIterator<BimIfcObject>