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
4 changes: 3 additions & 1 deletion src/RvtIO/Ifc/IfcExporter.QuantitiesCurrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,10 @@ private List<QuantityValue> DoorWindowQuantitiesCurrent(QuantityContextCurrent c
{
var result = new List<QuantityValue>();
Element? type = TypeOfCurrent(element, context.Elements);
// A wall standing as a panel of a curtain wall is exported as one, but to its own doors and windows it is still a wall.
bool inCurtainWall = element.SerializedHostId is { } hostId
&& context.Products.TryGetValue(hostId, out var host) && host.ifcType == "IFCCURTAINWALL";
&& context.Products.TryGetValue(hostId, out var host) && host.ifcType == "IFCCURTAINWALL"
&& !(context.Elements.TryGetValue(hostId, out var hostElement) && IsCurtainPanelWall(hostElement, host.ifcType));
double? height = ExactNamedParameterFeetCurrent(element, type, "Height", true, -1001300, -1010300) * FeetToMetres
?? (inCurtainWall ? InstanceFrameExtentMetresCurrent(element, 2) : null);
// Without a parameter of its own (a panel of a curtain wall holds only a bounding-box estimate) the width is the extent of
Expand Down
36 changes: 26 additions & 10 deletions src/RvtIO/Ifc/IfcExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ int ResolveStorey(Element element, double[]? outline = null)
.Where(candidate => candidate.CategoryId == -2000011
&& visibleWallIds.Contains(candidate.Id)
&& !(curtainWallIds.Contains(candidate.Id)
&& candidate.Layers is not { Count: > 0 })
&& candidate.Layers is not { Count: > 0 }
|| curtainPanelWallIds.Contains(candidate.Id))
&& ShouldSuppressPhantomStoreyWallProduct(
"IFCWALLSTANDARDCASE", IntParam(candidate, -1001952), storeyIds)
// A project Level that is not a building story is a real level, not a phantom.
Expand Down Expand Up @@ -1886,8 +1887,6 @@ bool HasCompetingExactHostedWriterAuthority(

if (elem.CategoryId == -2000011 && !visibleWallIds.Contains(elem.Id))
{ Skip(elem, "wall-not-visible"); continue; }
if (curtainPanelWallIds.Contains(elem.Id))
{ Skip(elem, "curtain-panel-wall"); continue; }

if (elem.CategoryId is -2000171 or -2000170)
{
Expand All @@ -1911,8 +1910,9 @@ bool HasCompetingExactHostedWriterAuthority(
? "IFCOPENINGELEMENT"
// A serialized CompoundStructure is the defining body of a basic/stacked system
// wall.
: elem.CategoryId == -2000011 && curtainWallIds.Contains(elem.Id)
: elem.CategoryId == -2000011 && (curtainWallIds.Contains(elem.Id)
&& elem.Layers is not { Count: > 0 }
|| curtainPanelWallIds.Contains(elem.Id))
? "IFCCURTAINWALL"
: elem.CategoryId == -2000011 && ShouldExportAsIfcWall(elem, CurrentProfile)
? "IFCWALL"
Expand Down Expand Up @@ -6050,6 +6050,7 @@ int EnsureUnnamedMaterial() =>
bool agrees = (type.SerializedSystemTypeClassId, element.CategoryId, ifcType) switch
{
(512, -2000011, "IFCWALL" or "IFCWALLSTANDARDCASE") => true,
(512, -2000011, "IFCCURTAINWALL") when element.SerializedCurtainHostId is > 0 => true,
(1915, -2000032, "IFCSLAB") => true,
(1915, -2001300, "IFCSLAB" or "IFCROOF") => true,
(646, -2000038, "IFCCOVERING") => true,
Expand Down Expand Up @@ -6165,7 +6166,8 @@ int EnsureUnnamedMaterial() =>
var associated = CurrentProfile ? group.Where(item => item.Product.ifcType != "IFCWALL").ToList() : group.ToList();
if (associated.Count == 0) continue;

bool wallLayers = first.Product.ifcType is "IFCWALL" or "IFCWALLSTANDARDCASE";
bool wallLayers = first.Product.ifcType is "IFCWALL" or "IFCWALLSTANDARDCASE"
|| IsCurtainPanelWall(first.Element, first.Product.ifcType);
bool directLayerSet = first.Native != null && (CurrentProfile
? first.Element.CategoryId == -2000035
: first.Element.CategoryId == -2001300);
Expand Down Expand Up @@ -7040,6 +7042,9 @@ static string ParameterType(double parameter) =>
return true;
}

private static bool IsCurtainPanelWall(Element element, string ifcType) =>
ifcType == "IFCCURTAINWALL" && element.CategoryId == -2000011 && element.SerializedCurtainHostId is > 0;

/// <summary>
/// The layer-set cache keys native HostObjAttr sets by the own type, not by identical
/// material/thickness contents.
Expand All @@ -7048,7 +7053,9 @@ internal static string MaterialLayerSetGroupKey(
Element element, string ifcType, IReadOnlyDictionary<int, Element> elements,
IReadOnlyDictionary<int, int> counts)
{
string direction = ifcType is "IFCWALL" or "IFCWALLSTANDARDCASE" ? "AXIS2" : "AXIS3";
// A curtain panel wall has its own groups: the first member of a group names and orients the layers of all of them.
string direction = IsCurtainPanelWall(element, ifcType) ? "AXIS2|curtain-panel"
: ifcType is "IFCWALL" or "IFCWALLSTANDARDCASE" ? "AXIS2" : "AXIS3";
string layers = string.Join(';', (element.Layers ?? [])
.OrderBy(layer => layer.LayerIndex)
.Select(layer => $"{layer.MaterialId}:{layer.ThicknessMm.ToString("R", CultureInfo.InvariantCulture)}"));
Expand Down Expand Up @@ -7082,6 +7089,7 @@ internal static string MaterialLayerSetGroupKey(
bool agrees = (type.SerializedSystemTypeClassId, element.CategoryId, ifcType) switch
{
(512, -2000011, "IFCWALL" or "IFCWALLSTANDARDCASE") => true,
(512, -2000011, "IFCCURTAINWALL") when element.SerializedCurtainHostId is > 0 => true,
(1915, -2000032 or -2001300, "IFCSLAB") => true,
(646, -2000038, "IFCCOVERING") => true,
_ => false,
Expand Down Expand Up @@ -67427,6 +67435,8 @@ private static Dictionary<int, string> WriteTypeObjectsAndRelDefinesByTypeCoreFo
var typeGroupOrder = new List<(int typeId, int symbolId, string typeClass, int ownerId, int systemTypeId)>();
var predefinedTypes = new Dictionary<(int typeId, int symbolId, string typeClass, int ownerId, int systemTypeId), string>();
var exactSystemTypeGroups = new HashSet<(int typeId, int symbolId, string typeClass, int ownerId, int systemTypeId)>();
// Groups with a member that is not a wall standing as a panel of a curtain wall.
var nonPanelGroups = new HashSet<(int typeId, int symbolId, string typeClass, int ownerId, int systemTypeId)>();
var firstMemberElementId = new Dictionary<(int typeId, int symbolId, string typeClass, int ownerId, int systemTypeId), int>();
var connectedSystemTypes = currentProfile ? ResolveConnectedSystemTypes(elemById) : null;
var stairShapes = currentProfile ? ReadProductAttributes(w, exportedProducts,
Expand Down Expand Up @@ -67583,14 +67593,16 @@ private static Dictionary<int, string> WriteTypeObjectsAndRelDefinesByTypeCoreFo
if (!exactSystemType) exactSystemTypeGroups.Remove(key);
}
members.Add(product.entityId);
if (!IsCurtainPanelWall(instElem, product.ifcType))
nonPanelGroups.Add(key);
firstInstanceIfcType.TryAdd(key, product.ifcType);
firstMemberElementId[key] = firstMemberElementId.TryGetValue(key, out int earlier)
? Math.Min(earlier, elementId) : elementId;
}

// A native type may govern both walls and curtain walls.
var classCounts = typeGroupOrder.GroupBy(key => (key.typeId, key.symbolId, key.ownerId, key.systemTypeId))
.ToDictionary(group => group.Key, group => group.Select(key => key.typeClass).Distinct().Count());
var identities = typeGroupOrder.GroupBy(key => (key.typeId, key.symbolId, key.ownerId, key.systemTypeId))
.ToDictionary(group => group.Key, group => (Classes: group.Count(), NonPanelClasses: group.Count(nonPanelGroups.Contains)));
var guidClaimant = typeGroupOrder.Where(key => key.symbolId > 0)
.GroupBy(key => (key.symbolId, key.ownerId))
.ToDictionary(group => group.Key, group => group.MinBy(key => firstMemberElementId[key]));
Expand Down Expand Up @@ -67621,7 +67633,11 @@ private static Dictionary<int, string> WriteTypeObjectsAndRelDefinesByTypeCoreFo
: $"{typeElemId.ToString(CultureInfo.InvariantCulture)}:symbol:{originalSymbolId.ToString(CultureInfo.InvariantCulture)}";
if (ownerId > 0) identityKey += $":instance:{ownerId.ToString(CultureInfo.InvariantCulture)}";
if (systemTypeId > 0) identityKey += $":system:{systemTypeId.ToString(CultureInfo.InvariantCulture)}";
if (classCounts[(typeElemId, originalSymbolId, ownerId, systemTypeId)] > 1)
// The IfcCurtainWallType made for wall panels is an extra object beside the type of the other walls: it takes
// neither the identity nor the native GlobalId from them.
var (classes, nonPanelClasses) = identities[(typeElemId, originalSymbolId, ownerId, systemTypeId)];
bool extraPanelType = !nonPanelGroups.Contains(key) && classes > 1;
if (extraPanelType || nonPanelClasses > 1)
identityKey += $":{typeClass}";
string guidArg = S(IfcGuid.FromName($"type:{identityKey}"));
int firstElementId = firstMemberElementId[key];
Expand Down Expand Up @@ -67662,7 +67678,7 @@ private static Dictionary<int, string> WriteTypeObjectsAndRelDefinesByTypeCoreFo

// The GlobalId rule uses the original symbol's own ExportId for mapped types, except
// overrides/collisions.
bool typeElementGuid = exactSystemTypeGroups.Contains(key)
bool typeElementGuid = exactSystemTypeGroups.Contains(key) && !extraPanelType
|| typeClass is "IFCPIPESEGMENTTYPE" or "IFCCABLECARRIERSEGMENTTYPE"
|| currentProfile && (typeClass is "IFCDUCTSEGMENTTYPE" or "IFCSTAIRFLIGHTTYPE" or "IFCTYPEPRODUCT" or "IFCRAILINGTYPE"
|| typeClass == "IFCSLABTYPE" && typeElem.CategoryId == StairsLandingsCategoryId);
Expand Down
Loading
Loading