xBIM Geometry is an optional component of the XBIM Toolkit providing support for generation of 3D Geometry from Ifc4 and Ifc2x3 representations. Use this package to update your XBim IModels to contain geometry that can be visualised in 3D. Currently this library supports IFC2x2, IFC2x3, IFC4 Addendum 2 TC1 and IFC4.3 ADD2.
$ dotnet add package Xbim.GeometryXbimGeometry is part of the Xbim Toolkit.
This package is the top level nuget package for the xbim Geometry Engine which includes the xbim Geometry engine itself plus the interop layer, and the unmanaged OCC geometry kernel, as well as the .NET ModelGeometry.Scene.
It contains the the Geometry Engine and Scene processing, which provide geometric and topological operations to enable users to visualise models in 3D models, typically as a Tesselated scene or mesh.
The native Geometry Engine is built around the open source Open Cascade library which performs much of the boolean operations involved in generating 3D solids. This technology is included under a licence which permits the use as part of a larger work, compatible with xbim's open source CDDL licence.
Before using this library you should register the Geometry Engine with the xbim ServiceProvider.
// Either configure the internal Services
XbimServices.Current.ConfigureServices(opt => opt.AddXbimToolkit(conf =>
conf.AddGeometryServices()
));
// or configure your services and register the provider with xbim:
services.AddXbimToolkit(conf => conf.AddGeometryServices());
// Once the DI container is built
XbimServices.Current.UseExternalServiceProvider(serviceProvider);
using System.IO;
using Xbim.Ifc;
using Xbim.ModelGeometry.Scene;
const string fileName = "SampleHouse.ifc";
using (var model = IfcStore.Open(fileName))
{
var context = new Xbim3DModelContext(model);
context.CreateContext();
// Now access tessellated geometry / Save wexbim etc
var wexBimFilename = Path.ChangeExtension(fileName, "wexBIM");
using (var wexBiMfile = File.Create(wexBimFilename))
{
using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile))
{
model.SaveAsWexBim(wexBimBinaryWriter);
wexBimBinaryWriter.Close();
}
wexBiMfile.Close();
}
}