Esempio n. 1
0
        /// <summary>
        /// Finds all related objects in IfcRelAssigns.
        /// </summary>
        /// <param name="ifcRelAssigns">The IfcRelAssigns handle.</param>
        /// <returns>The related objects, or null if not found.</returns>
        static public ICollection <IFCObjectDefinition> ProcessRelatedObjects(IFCAnyHandle ifcRelAssignsOrAggregates)
        {
            try
            {
                ValidateIFCRelAssignsOrAggregates(ifcRelAssignsOrAggregates);
            }
            catch
            {
                //LOG: ERROR: Couldn't find valid IfcRelAssignsToGroup for IfcGroup.
                return(null);
            }

            HashSet <IFCAnyHandle> relatedObjects = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                    <HashSet <IFCAnyHandle> >(ifcRelAssignsOrAggregates, "RelatedObjects");

            // Receiving apps need to decide whether to post an error or not.
            if (relatedObjects == null)
            {
                return(null);
            }

            ICollection <IFCObjectDefinition> relatedObjectSet = new HashSet <IFCObjectDefinition>();

            foreach (IFCAnyHandle relatedObject in relatedObjects)
            {
                IFCObjectDefinition objectDefinition = IFCObjectDefinition.ProcessIFCObjectDefinition(relatedObject);
                if (objectDefinition != null)
                {
                    relatedObjectSet.Add(objectDefinition);
                }
            }

            return(relatedObjectSet);
        }
Esempio n. 2
0
        /// <summary>
        /// Finds all related objects in IfcRelAssigns.
        /// </summary>
        /// <param name="relatedTo">The entity receiving the collection of objects and the IFCObjectDefinition will record the inverse relationship</param>
        /// <param name="ifcRelAssignsOrAggregates">The IfcRelAssigns handle.</param>
        /// <returns>The related objects, or null if not found.</returns>
        static public ICollection <IFCObjectDefinition> ProcessRelatedObjects(IFCObjectDefinition relatedTo, IFCAnyHandle ifcRelAssignsOrAggregates)
        {
            try
            {
                ValidateIFCRelAssignsOrAggregates(ifcRelAssignsOrAggregates);
            }
            catch
            {
                //LOG: ERROR: Couldn't find valid IfcRelAssignsToGroup for IfcGroup.
                return(null);
            }

            HashSet <IFCAnyHandle> relatedObjects = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                                    <HashSet <IFCAnyHandle> >(ifcRelAssignsOrAggregates, "RelatedObjects");

            // Receiving apps need to decide whether to post an error or not.
            if (relatedObjects == null)
            {
                return(null);
            }

            ICollection <IFCObjectDefinition> relatedObjectSet = new HashSet <IFCObjectDefinition>();

            // If relatedTo is an IFCGroup then it will be added to the list of group that the relatedObject is assigned to.
            // else it will become the relatedObject's composing object
            bool relatedIsGroup = relatedTo is IFCGroup;

            foreach (IFCAnyHandle relatedObject in relatedObjects)
            {
                if (relatedObject.Id == relatedTo.Id)
                {
                    Importer.TheLog.LogError(ifcRelAssignsOrAggregates.Id, "An objected is related to itself, ignoring.", false);
                    continue;
                }

                IFCObjectDefinition objectDefinition = IFCObjectDefinition.ProcessIFCObjectDefinition(relatedObject);
                if (objectDefinition != null)
                {
                    if (relatedIsGroup)
                    {
                        objectDefinition.AssignmentGroups.Add(relatedTo as IFCGroup);
                    }
                    else
                    {
                        objectDefinition.Decomposes = relatedTo;
                    }
                    relatedObjectSet.Add(objectDefinition);
                }
            }

            return(relatedObjectSet);
        }