public override bool Equals(object obj) { if (obj == null) { return(false); } BodyGroupKey second = obj as BodyGroupKey; return(this == second); }
private static bool ProcessGroupMembership(ExporterIFC exporterIFC, IFCFile file, Element element, ElementId categoryId, IFCAnyHandle contextOfItems, IList<GeometryObject> geomList, BodyData bodyDataIn, out BodyGroupKey groupKey, out BodyGroupData groupData, out BodyData bodyData) { // Set back to true if all checks are passed. bool useGroupsIfPossible = false; groupKey = null; groupData = null; bodyData = null; Document doc = element.Document; Group group = doc.GetElement(element.GroupId) as Group; if (group != null) { ElementId elementId = element.Id; bool pristineGeometry = true; foreach (GeometryObject geomObject in geomList) { try { ICollection<ElementId> generatingElementIds = element.GetGeneratingElementIds(geomObject); int numGeneratingElements = generatingElementIds.Count; if ((numGeneratingElements > 1) || (numGeneratingElements == 1 && (generatingElementIds.First() != elementId))) { pristineGeometry = false; break; } } catch { pristineGeometry = false; break; } } if (pristineGeometry) { groupKey = new BodyGroupKey(); IList<ElementId> groupMemberIds = group.GetMemberIds(); int numMembers = groupMemberIds.Count; for (int idx = 0; idx < numMembers; idx++) { if (groupMemberIds[idx] == elementId) { groupKey.GroupMemberIndex = idx; break; } } if (groupKey.GroupMemberIndex >= 0) { groupKey.GroupTypeId = group.GetTypeId(); groupData = ExporterCacheManager.GroupElementGeometryCache.Find(groupKey); if (groupData == null) { groupData = new BodyGroupData(); useGroupsIfPossible = true; } else { ISet<IFCAnyHandle> groupBodyItems = new HashSet<IFCAnyHandle>(); foreach (IFCAnyHandle mappedRepHnd in groupData.Handles) { IFCAnyHandle mappedItemHnd = ExporterUtil.CreateDefaultMappedItem(file, mappedRepHnd); groupBodyItems.Add(mappedItemHnd); } bodyData = new BodyData(bodyDataIn); bodyData.RepresentationHnd = RepresentationUtil.CreateBodyMappedItemRep(exporterIFC, element, categoryId, contextOfItems, groupBodyItems); return true; } } } } return useGroupsIfPossible; }