3difcbimxbim

Can xBim toolkit help me calculate the volume of some objects in an IFC model?


I am new to .NET xBim Toolkit and I wonder if it can help with calculating the volume of some objects in an IFC model. In particular, there is module called XbimGeometry but I am unsure if and how it could be used for this purpose. Or if it is just meant for graphics.


Solution

  • Yes it can. In Xbim.Geometry v5.1 (the latest in develop/master) you can calculate the volume of some IFC geometry primitives.

    Typically the Geometry Engine is used to create a Scene which is tessellated / meshed, but it can also be used to calculate more fundamental geometry data.

    E.g. in this unit test you can see how to get the volume of a single IfcSweptDiskSolid object https://github.com/xBimTeam/XbimGeometry/blob/c1c22812601d0bd506c5f9230b731d0ab0c6e08a/Xbim.Geometry.Engine.Interop.Tests/IfcExtrudedAreaSolidTests.cs#L74

                using (var model = MemoryModel.OpenRead("YourModel.ifc"))
                {
                    var sweptDisk = model.Instances.OfType<IIfcSweptDiskSolid>().FirstOrDefault();
    
                    // Convert to a solid
                    var solid = geomEngine.CreateSolid(sweptDisk, logger);
                    solid.Volume.Should().BeApproximately(1234.56, 1e-7);
                }
    

    Clearly this is quite low level, and you'll need to account for voids (holes etc - using the Boolean cut capabilities in the engine), and account the many different geometry types (Sweeps, Breps, Extrusions etc). And remember this code above is a single geometric item that forms part of an Object and could be just one part of a entity's set of shapes. i.e. Objects are often represented by a composite of these individual representations.

    i.e. this Window is made up of 4 separate representations:

    Whole IfcWindow Whole window Sill Sill Outer Frame Outer Frame Inner Frame Inner Frame Glass Pane Glass Pane

    This is just one object and items are much more complex.

    So 'calculating the volume' may need a bit of clarifications.

    Ultimately your actual answer will depend on what you want to do with the volume data. Do you want to do a material-based quantity take off? Do you just want the overall volume of an object (bear in mind that something like a Wall could have multiple materials and voids)? Do you want a bounding box volume?

    There's quite a few improvements in the v6 Xbim.Geometry in this area so may be worth checking that netcore branch out. I believe there are some higher order implementations in that version.