Skip to content

ara3d/IFC-toolkit

Repository files navigation

Ara 3D IFC Toolkit

A set of open-source C# libraries (.NET 8.0) for loading and querying IFC files in STEP format and a C++ DLL built from source code copied from Web IFC engine for generating meshes.

Parsing IFC files without creating meshes is very fast. Mesh creation is currently a bottleneck.

Background

Speckle hired us (Ara 3D Inc) to improve the performance of their IFC import service. which was written in JavaScript and executed on the server using Node.JS and was using the Web IFC engine to parse files and generate geometry.

We originally started by wrapping the Web IFC engine in a C++/CLR wrapper. This project was successful, in that it allowed us to build a new IFC importer in C#, but it was not cross-platform. C++/CLR unforuntately only runs on Windows. It is now deprecated and replaced with this project.

Thanks to the funding from Speckle, at Ara 3D we decided to open-source our IFC/STEP file parser and combine it with a C++ DLL built on top of the Web IFC engine.

Next Steps

  1. [Short term] Speckle is going to start work on assuring that the code runs on Linux.
  2. [Medium term] Ara 3D future plans will replace the mesh code in C# using the Plato.Geometry library.

Solution Structure

This is the structure as it appears in the solution view in Visual Studio:

  • Ara3D.IfcLoader
    • A C# .NET 8 project with a dependency on a Windows DLL
    • Uses Ara3D.IfcParser to load the IFC graph and STEP document, uses the WebIfcDll to generate meshes.
    • Provides additional helper classes that wrap the WebIfcDll and provide a more C# friendly API.
  • Ara3D.IfcParser
    • A C# .NET 8 library
    • Creates an IFC graph containing nodes and relations, and IFC data structures. It uses the Ara3D.StepParser.
  • Ara3D.StepParser
    • A C# .NET 8 library
    • Loads and Parses an arbitrary IFC/STEP file. Parsing of individual entity values is done on demand.
  • WebIfcDll
  • speckle/
    • Ara3D.Speckle.Data
      • A C# .NET 8 library of utilities for working with Speckle data
    • Ara3D.Speckle.IfcLoader
      • A C# .NET 8 library for loading IFC files and generating Speckle objects
  • tests/
    • Ara3D.IfcParser.Test
      • An NUnit test project for working with IFC files and comparing different libraries
  • testfiles/
    • test IFC files copied from the Web IFC engine repository
  • schemas/
    • Formal definitions of IFC schemas in express (.exp) files

C++ DLL API

The public API of the C++ DLL, which is restricted to extracting gometry is as follows:

  • Api* InitializeApi();
  • void FinalizeApi(Api* api);
  • Model* LoadModel(Api* api, const char* fileName);
  • ::Geometry* GetGeometryFromId(Api* api, Model* model, uint32_t id);
  • ::Geometry* GetGeometryFromIndex(Api* api, Model* model, int index);
  • int GetNumGeometries(Api* api, Model* model);
  • int GetNumMeshes(Api* api, ::Geometry* geom);
  • Mesh* GetMesh(Api* api, ::Geometry* geom, int index);
  • double* GetTransform(Api* api, Mesh* mesh);
  • double* GetColor(Api* api, Mesh* mesh);
  • int GetNumVertices(Api* api, Mesh* mesh);
  • Vertex* GetVertices(Api* api, Mesh* mesh);
  • int GetNumIndices(Api* api, Mesh* mesh);
  • uint32_t* GetIndices(Api* api, Mesh* mesh);

See the file Ara3D.IfcLoader/WebIfcDll.cs for the C# PInvoke code.

Next Steps

  • Be able to compile project outside of Ara 3D main repo
  • Assure that all Ara 3D dependencies are taken from NuGet packages (not local)
  • Make a separate C++ project for the DLL for Linux
  • Test the C# and C++ code on Linux
  • Extract Global IDs from all product elements
  • Create a list of Express IDs that represent product elements
  • Testing: Convert loaded IFC file to OBJ files
  • Testing: Convert Speckle objects to OBJ files
  • Testing: Convert IFC to local Speckle objects
  • Testing: Automate pushing IFC files to Speckle project

C# to Plato.Geometry

  • Fill out IFC geometry structures using Plato.Geometry
  • Compute bounding boxes
  • Visualize bounding boxes, curves, points, alignments
  • Visualize polygon meshes
  • Implement CSG operations
  • Implement curve/profile to surface operations

WPF Viewer

There is a WPF 3D viewer that leverage the IFC library at https://github.com/ara3d/ara3d/tree/main/labs/Ara3D.Viewer.Wpf

image

Related Open-Source Work

C# Projects

Other Languages

Acknowledgements

This work was developed by Ara 3D and funded by Speckle Systems with additional guidance and test data provided by Impararia Solutions. Test files and geometry creation code provide by Tom van Diggelen and That Open Company.

Releases

No releases published

Packages

No packages published