Ejemplo n.º 1
0
        /// <summary>
        /// Gets the host of a hosted element, if any.
        /// </summary>
        /// <param name="hostedElement">The hosted element.</param>
        /// <returns>The host, or null.</returns>
        static public IFCElement GetHost(IFCElement hostedElement)
        {
            if (hostedElement == null)
            {
                return(null);
            }

            IFCFeatureElementSubtraction fillsOpening = hostedElement.FillsOpening;

            if (fillsOpening == null)
            {
                return(null);
            }

            return(fillsOpening.VoidsElement);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the IFCElement associated via an IfcRelConnectsPortToElement handle to an IFCPort.
        /// </summary>
        /// <param name="ifcRelConnectsPortToElement">The IfcRelConnectsPortToElement handle.</param>
        /// <returns>The IFCElement class corresponding to the IfcElement handle, if any.</returns>
        static public IFCElement ProcessRelatedElement(IFCAnyHandle ifcRelConnectsPortToElement)
        {
            // Receiving apps need to decide whether to post an error or not.
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcRelConnectsPortToElement))
            {
                return(null);
            }

            IFCAnyHandle ifcRelatedElement = IFCAnyHandleUtil.GetInstanceAttribute(ifcRelConnectsPortToElement, "RelatedElement");

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcRelatedElement))
            {
                return(null);
            }

            IFCElement relatedElement = IFCElement.ProcessIFCElement(ifcRelatedElement);

            return(relatedElement);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the elements hosted by this host element, if any.
        /// </summary>
        /// <param name="hostElement">The host element.</param>
        /// <returns>The hosted elements, or null.  An unfilled opening counts as a hosted element.</returns>
        static public IList <IFCElement> GetHostedElements(IFCElement hostElement)
        {
            if (hostElement == null)
            {
                return(null);
            }

            ICollection <IFCFeatureElementSubtraction> openings = hostElement.Openings;

            if (openings == null || (openings.Count == 0))
            {
                return(null);
            }

            IList <IFCElement> hostedElements = new List <IFCElement>();

            foreach (IFCFeatureElementSubtraction opening in openings)
            {
                if (!(opening is IFCOpeningElement))
                {
                    hostedElements.Add(opening);
                }
                else
                {
                    IFCOpeningElement openingElement = opening as IFCOpeningElement;
                    if (openingElement.FilledByElement != null)
                    {
                        hostedElements.Add(openingElement.FilledByElement);
                    }
                    else
                    {
                        hostedElements.Add(openingElement);
                    }
                }
            }

            return(hostedElements);
        }