private static void WriteGeometry(XbimModel model, ConcurrentDictionary<int, int[]> written, IXbimGeometryModel geomModel, ref XbimRect3D bounds, XbimMatrix3D m3d, IfcProduct product, double deflection) { XbimTriangulatedModelCollection tm = geomModel.Mesh(deflection); XbimRect3D bb = tm.Bounds; byte[] matrix = m3d.ToArray(true); short? typeId = IfcMetaData.IfcTypeId(product); XbimGeometryCursor geomTable = model.GetGeometryTable(); XbimLazyDBTransaction transaction = geomTable.BeginLazyTransaction(); int[] geomIds = new int[tm.Count + 1]; geomIds[0] = geomTable.AddGeometry(product.EntityLabel, XbimGeometryType.BoundingBox, typeId.Value, matrix, bb.ToDoublesArray(), 0, geomModel.SurfaceStyleLabel); bb = XbimRect3D.TransformBy(bb, m3d); if (bounds.IsEmpty) bounds = bb; else bounds.Union(bb); short subPart = 0; foreach (XbimTriangulatedModel b in tm) { geomIds[subPart + 1] = geomTable.AddGeometry(product.EntityLabel, XbimGeometryType.TriangulatedMesh, typeId.Value, matrix, b.Triangles, subPart, b.SurfaceStyleLabel); subPart++; } transaction.Commit(); written.AddOrUpdate(geomModel.RepresentationLabel, geomIds, (k, v) => v = geomIds); model.FreeTable(geomTable); }