stackoverflow in Xbim3DModelContext.CreateContext() when trying to load IFC model with XBim.Geometry
When I try to load geometry from a large IFC file, it dies in BRepBuilderAPI_MakeFace.{ctor} in Xbim3DModelContext.CreateContext() with stackoverflow. Various other IFC-viewers can load and display the file and make geometry for it, including IFC.js.
Assemblies and versions affected:
It happens with XBim.Geometry version 5.1.437, used with XBim.Gltf.IO.
Steps (or code) to reproduce the issue:
I don't have sample data, as the IFC file is 750M of private customer data. The code however is simple:
..
static FileInfo CreateGeometry_XBimFile(FileInfo ifcSource, bool adjustWcs_mode, bool useAlternativeExtruder) {
IfcStore.ModelProviderFactory.UseHeuristicModelProvider();
using (IfcStore ifcStore = IfcStore.Open(ifcSource.FullName)) {
Xbim3DModelContext c = new Xbim3DModelContext(ifcStore);
// then it dies here:
c.CreateContext(progDelegate:null, adjustWcs:adjustWcs_mode);
..
Minimal file to reproduce the issue:
IFC files need to be zipped to be uploaded. Then just drag & drop here
static FileInfo CreateGeometry_XBimFile(FileInfo ifcSource, bool adjustWcs_mode, bool useAlternativeExtruder) {
IfcStore.ModelProviderFactory.UseHeuristicModelProvider();
using (IfcStore ifcStore = IfcStore.Open(ifcSource.FullName)) {
Xbim3DModelContext c = new Xbim3DModelContext(ifcStore);
c.CreateContext(progDelegate:null, adjustWcs:adjustWcs_mode);
var newName_XBIM_File = Path.ChangeExtension(ifcSource.FullName, adjustWcs_mode + ".xbim");
ifcStore.SaveAs(newName_XBIM_File);
return new FileInfo(newName_XBIM_File);
}
}
Expected behavior:
An IFC model loaded into memory, to generate GLTF output.
Actual behavior or exception details:
Stack overflow.
at <Module>.BRepBuilderAPI_MakeFace.{ctor}(BRepBuilderAPI_MakeFace*, gp_Pln*, TopoDS_Wire*, Boolean)
at Xbim.Geometry.XbimCompound.InitFaces(TopoDS_Shape*, System.Collections.Generic.IEnumerable1<Xbim.Ifc4.Interfaces.IIfcFace>, Xbim.Ifc4.Interfaces.IIfcRepresentationItem, Microsoft.Extensions.Logging.ILogger) at Xbim.Geometry.XbimCompound.Init(Xbim.Ifc4.Interfaces.IIfcClosedShell, Microsoft.Extensions.Logging.ILogger) at Xbim.Geometry.XbimCompound.Init(Xbim.Ifc4.Interfaces.IIfcManifoldSolidBrep, Microsoft.Extensions.Logging.ILogger) at Xbim.Geometry.XbimCompound..ctor(Xbim.Ifc4.Interfaces.IIfcManifoldSolidBrep, Microsoft.Extensions.Logging.ILogger) at Xbim.Geometry.XbimGeometryCreator.Create(Xbim.Ifc4.Interfaces.IIfcGeometricRepresentationItem, Xbim.Ifc4.Interfaces.IIfcAxis2Placement3D, Microsoft.Extensions.Logging.ILogger) at Xbim.Geometry.Engine.Interop.XbimGeometryEngine.Create(Xbim.Ifc4.Interfaces.IIfcGeometricRepresentationItem, Microsoft.Extensions.Logging.ILogger) at Xbim.ModelGeometry.Scene.Xbim3DModelContext+<>c__DisplayClass39_0.<WriteShapeGeometries>b__0(Int32) at System.Threading.Tasks.Parallel+<>c__DisplayClass44_02[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<PartitionerForEachWorker>b__1(System.Collections.IEnumerator ByRef, Int32, Boolean ByRef)
at System.Threading.Tasks.TaskReplicator+Replica.Execute()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
C:\Apache24\htdocs\other\ifc2gltf\bin\Debug\net7.0\ifc2gltf.exe (process 27252) exited with code -1073741819. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . .
Additional Details
Optional, details of the root cause if known. Delete this section if you have no additional details to add.
Sounds like Xbim.gltf is using an older Geometry engine (To be fair it's the latest master version in nuget).
It would be worthwhile explicitly referencing our latest 5.1 geometry engine from Myget as there have been a number of fixes since 5.1.437. The latest 5.1.730-develop.
Will also look to get 5.1 updates out to nuget so Claudio can do an update to GLTF
Equally we can share models under NDA if that helps. Email me if interested
Please tell how to download/install from Myget?
Add this file to your solution root: https://github.com/xBimTeam/XbimGeometry/blob/master/nuget.config
(You may have to restart visual studio after). Then when doing a nuget install you'll have the choice of our Myget repos as well as Nuget
Sounds like Xbim.gltf is using an older Geometry engine (To be fair it's the latest master version in nuget).
It would be worthwhile explicitly referencing our latest 5.1 geometry engine from Myget as there have been a number of fixes since 5.1.437. The latest 5.1.730-develop.
Will also look to get 5.1 updates out to nuget so Claudio can do an update to GLTF
How do I know which issues have been solved? 5.1.730-develop uses, I would assume, the develop branch, correct?
But the latest commit in the develop branch was 10 months ago. https://github.com/xBimTeam/XbimGeometry/commits/develop/