Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to the `IfcIO` library are documented in this file.
## [Unreleased]

### Fixed
- Element factories allocate IDs across the model rather than per storey; the writer avoids generated GlobalId
collisions, and clash storey filters no longer confuse distinct elements that share a caller-assigned ID.
- IFC export declares feet and inches as conversion-based length units and respects the selected plane angle unit.
Revolved-solid geometry converts between the file's angle unit and radians in memory. The CLI labels storey elevations in the model's units.
- Length quantities follow the model length unit after import, and metre-based cost quantities retain their explicit unit.
Expand Down
5 changes: 5 additions & 0 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ declaration. For a file known to have this legacy error, use
`IfcModel.Open(path, new IfcReadOptions { LegacyIfcIoRevolvedAnglesInRadians = true })`, then save the model, or run
`ifcio patch old.ifc --legacy-ifcio-radian-sweeps -o repaired.ifc`.

Factory methods allocate element IDs across a model's storeys, including after import. Create storeys with
`IfcModel.AddStorey`, or pass a caller-created storey to a model factory before calling its own factories.
Factory calls reserve IDs already in the registered storeys' element and space lists. Export avoids collisions
among generated product GlobalIds and does not rewrite explicit GlobalIds.

## Geometry & Representation

| Type | Description |
Expand Down
46 changes: 5 additions & 41 deletions src/IfcIO/Api/IfcApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static void AssignContainer(IfcBuildingStorey storey, params IfcElement[]
{
if (!storey.Elements.Contains(el))
{
storey.Elements.Add(el);
storey.AddExistingElement(el);
}
}
}
Expand All @@ -143,64 +143,28 @@ public static IfcBuildingStorey CreateStorey(IfcModel model, string name, double
public static IfcElement CreateWall(IfcBuildingStorey storey, string name, IfcMesh? mesh = null, IfcMaterial? material = null)
{
ArgumentNullException.ThrowIfNull(storey);
var wall = new IfcElement
{
Id = storey.Elements.Count + 1,
Name = name,
IfcType = "IFCWALL",
Mesh = mesh,
Material = material
};
storey.Elements.Add(wall);
return wall;
return storey.AddWall(name, mesh, material);
}

/// <summary>Creates and adds an IFCSLAB element to a storey.</summary>
public static IfcElement CreateSlab(IfcBuildingStorey storey, string name, IfcMesh? mesh = null, IfcMaterial? material = null)
{
ArgumentNullException.ThrowIfNull(storey);
var slab = new IfcElement
{
Id = storey.Elements.Count + 1,
Name = name,
IfcType = "IFCSLAB",
Mesh = mesh,
Material = material
};
storey.Elements.Add(slab);
return slab;
return storey.AddSlab(name, mesh, material);
}

/// <summary>Creates and adds an IFCCOLUMN element to a storey.</summary>
public static IfcElement CreateColumn(IfcBuildingStorey storey, string name, IfcMesh? mesh = null, IfcMaterial? material = null)
{
ArgumentNullException.ThrowIfNull(storey);
var column = new IfcElement
{
Id = storey.Elements.Count + 1,
Name = name,
IfcType = "IFCCOLUMN",
Mesh = mesh,
Material = material
};
storey.Elements.Add(column);
return column;
return storey.AddColumn(name, mesh, material);
}

/// <summary>Creates and adds an IFCBEAM element to a storey.</summary>
public static IfcElement CreateBeam(IfcBuildingStorey storey, string name, IfcMesh? mesh = null, IfcMaterial? material = null)
{
ArgumentNullException.ThrowIfNull(storey);
var beam = new IfcElement
{
Id = storey.Elements.Count + 1,
Name = name,
IfcType = "IFCBEAM",
Mesh = mesh,
Material = material
};
storey.Elements.Add(beam);
return beam;
return storey.AddBeam(name, mesh, material);
}
}
}
14 changes: 7 additions & 7 deletions src/IfcIO/Compatibility/Clash/IfcClashDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static IfcClashReport DetectClashes(IfcModel modelA, IfcModel modelB, Ifc
new IfcVector3(boxA.Max.X + tol, boxA.Max.Y + tol, boxA.Max.Z + tol)
);

storeyMapA.TryGetValue(elemA.Id, out var sA);
storeyMapA.TryGetValue(elemA, out var sA);

foreach (var (elemB, meshB) in elemsB)
{
Expand All @@ -55,7 +55,7 @@ public static IfcClashReport DetectClashes(IfcModel modelA, IfcModel modelB, Ifc
continue;
}

if (options.ExcludeSameStorey && sA is not null && storeyMapB.TryGetValue(elemB.Id, out var sB) && sA.Name.Equals(sB.Name, StringComparison.OrdinalIgnoreCase))
if (options.ExcludeSameStorey && sA is not null && storeyMapB.TryGetValue(elemB, out var sB) && sA.Name.Equals(sB.Name, StringComparison.OrdinalIgnoreCase))
{
continue;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public static IfcClashReport DetectClashes(IfcModel model, IfcClashOptions? opti
new IfcVector3(boxA.Max.X + tol, boxA.Max.Y + tol, boxA.Max.Z + tol)
);

storeyMap.TryGetValue(elemA.Id, out var sA);
storeyMap.TryGetValue(elemA, out var sA);

for (int j = i + 1; j < count; j++)
{
Expand All @@ -131,7 +131,7 @@ public static IfcClashReport DetectClashes(IfcModel model, IfcClashOptions? opti
continue;
}

if (options.ExcludeSameStorey && sA is not null && storeyMap.TryGetValue(elemB.Id, out var sB) && sA.Name.Equals(sB.Name, StringComparison.OrdinalIgnoreCase))
if (options.ExcludeSameStorey && sA is not null && storeyMap.TryGetValue(elemB, out var sB) && ReferenceEquals(sA, sB))
{
continue;
}
Expand Down Expand Up @@ -188,14 +188,14 @@ private static bool BoxesOverlap(IfcBoundingBox a, IfcBoundingBox b)
return list;
}

private static Dictionary<int, IfcBuildingStorey> BuildStoreyMap(IfcModel model)
private static Dictionary<IfcElement, IfcBuildingStorey> BuildStoreyMap(IfcModel model)
{
var map = new Dictionary<int, IfcBuildingStorey>();
var map = new Dictionary<IfcElement, IfcBuildingStorey>(ReferenceEqualityComparer.Instance);
foreach (var storey in model.Storeys)
{
foreach (var elem in storey.Elements)
{
map[elem.Id] = storey;
map[elem] = storey;
}
}
return map;
Expand Down
Loading