Class IFCRuntime
Represents the runtime for handling IFC (Industry Foundation Classes) files in Evergine. This class provides methods to read, parse, and process IFC files, including their materials, nodes, and geometries.
Namespace: Evergine.Runtimes.IFC
Assembly: Evergine.Runtimes.IFC.dll
Syntax
public class IFCRuntime : ModelRuntime
Constructors
IFCRuntime(GraphicsContext, AssetsService, AssetsDirectory)
Initializes a new instance of the IFCRuntime class.
Declaration
public IFCRuntime(GraphicsContext graphicsContext, AssetsService assetsService, AssetsDirectory assetsDirectory)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsContext | graphicsContext | Graphics Context instance. |
| AssetsService | assetsService | Assets Service instance. |
| AssetsDirectory | assetsDirectory | Assets Directory instance. |
Fields
Instance
Gets a default instance of the class, resolving the required services using the default Evergine container.
Declaration
public static readonly IFCRuntime Instance
Field Value
| Type | Description |
|---|---|
| IFCRuntime |
Properties
ContextProgress
Gets or sets the progress reporter for the context loading operation.
Declaration
public IProgress<int> ContextProgress { get; set; }
Property Value
| Type | Description |
|---|---|
| IProgress<int> |
Extension
Gets the file extension associated with this runtime.
Declaration
public override string Extension { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
GeometryProgress
Gets or sets the progress reporter for the geometry loading operation.
Declaration
public IProgress<int> GeometryProgress { get; set; }
Property Value
| Type | Description |
|---|---|
| IProgress<int> |
OpenProgress
Gets or sets the progress reporter for the open operation.
Declaration
public IProgress<int> OpenProgress { get; set; }
Property Value
| Type | Description |
|---|---|
| IProgress<int> |
UseSmoothNormals
Gets or sets a value indicating whether to use smooth normals.
Declaration
public bool UseSmoothNormals { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Read(Stream, Func<MaterialData, Task<Material>>)
Reads an IFC model from a stream, saves it temporarily to disk, and processes it. This method creates a temporary file from the provided stream, processes the IFC data, and then deletes the temporary file after processing. It supports optional material assignment.
Declaration
public override Task<Model> Read(Stream stream, Func<MaterialData, Task<Material>> materialAssigner = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The input stream containing the IFC file data. |
| Func<MaterialData, Task<Material>> | materialAssigner | Optional function to assign materials to the model's geometry. If not provided, default materials will be used. |
Returns
| Type | Description |
|---|---|
| Task<Model> | A task representing the asynchronous operation, returning the processed Model instance. |
Overrides
Read(string, Func<MaterialData, Task<Material>>, bool)
Reads an IFC file from a file path and processes its content.
Declaration
public Task<Model> Read(string filePath, Func<MaterialData, Task<Material>> materialAssigner = null, bool useSmoothNormals = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The path to the IFC file. |
| Func<MaterialData, Task<Material>> | materialAssigner | Optional function to assign materials to the model's geometry. |
| bool | useSmoothNormals | Indicates whether to use smooth normals when generating mesh geometry. |
Returns
| Type | Description |
|---|---|
| Task<Model> | A task representing the asynchronous operation, returning the processed Model instance. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the file format is invalid or the file path does not exist. |
| Exception | Thrown if the IFC file cannot be read by XBim. |
ReadIFC(string, bool)
Reads an IFC file, extracts its project information, loads and batches its shapes, and constructs a node hierarchy.
Declaration
public Task<(NodeContent node, int index)> ReadIFC(string filepath, bool useSmoothNormals)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filepath | The path to the IFC file to read. |
| bool | useSmoothNormals | Indicates whether to use smooth normals when generating mesh geometry. |
Returns
| Type | Description |
|---|---|
| Task<(NodeContent node, int index)> | A task representing the asynchronous operation, returning a tuple containing the root NodeContent and its index in the node list. |