Files
huanld 1686f08040
Release pipeline / Get version (push) Has been cancelled
Release pipeline / Get Chart Name (push) Has been cancelled
Release pipeline / tests (push) Has been cancelled
Release pipeline / builds (push) Has been cancelled
Release pipeline / builds-ghcr (push) Has been cancelled
Release pipeline / test-deployments (push) Has been cancelled
Release pipeline / deploy (push) Has been cancelled
Release pipeline / Helm chart oci (push) Has been cancelled
Release pipeline / npm (push) Has been cancelled
Release pipeline / snyk (push) Has been cancelled
feat: commit IFC-toolkit and engine_web-ifc source code
2026-04-16 07:47:58 +07:00

58 lines
1.7 KiB
C#

using Ara3D.IfcParser;
using Ara3D.Logging;
using Ara3D.StepParser;
using Ara3D.Utils;
namespace Ara3D.IfcLoader
{
public class IfcFile
{
public IfcGraph Graph;
public StepDocument Document => Graph.Document;
public IfcModel Model;
public IntPtr ApiPtr;
public FilePath FilePath;
public IfcFile(FilePath fp, bool includeGeometry, ILogger? logger = null)
{
if (!File.Exists(fp))
throw new FileNotFoundException($"File not found: {fp}");
FilePath = fp;
logger?.Log($"Starting load of {fp.GetFileName()}");
if (includeGeometry)
{
Parallel.Invoke(
() => { LoadGeometryData(logger); },
() => { LoadNonGeometryData(logger); });
}
else
{
LoadNonGeometryData(logger);
}
logger?.Log($"Completed loading {fp.GetFileName()}");
}
private void LoadGeometryData(ILogger? logger)
{
logger?.Log($"Loading IFC geometry");
ApiPtr = WebIfcDll.InitializeApi();
Model = new IfcModel(this, ApiPtr, WebIfcDll.LoadModel(ApiPtr, FilePath));
logger?.Log($"Completed loading IFC geometry");
}
private void LoadNonGeometryData(ILogger? logger)
{
logger?.Log($"Loading IFC data");
Graph = IfcGraph.Load(FilePath, logger);
logger?.Log($"Completed loading IFC data");
}
public static IfcFile Load(FilePath fp, bool includeGeometry, ILogger logger = null)
=> new IfcFile(fp, includeGeometry, logger);
public bool GeometryDataLoaded
=> Model != null;
}
}