Ejemplo n.º 1
0
        /// <summary>
        /// Filter IfcProduct and IfcTypeObject types
        /// </summary>
        /// <param name="obj">CobieObject</param>
        /// <param name="parent">Parent object</param>
        /// <param name="preDefinedType">strings for the ifcTypeObject predefinedtype enum property</param>
        /// <returns>bool, true = exclude</returns>
        public bool ObjFilter(CobieObject obj, CobieObject parent = null, string preDefinedType = null)
        {
            bool exclude = false;

            if (!string.IsNullOrEmpty(obj.ExternalEntity))
            {
                if (obj is Asset)
                {
                    exclude = IfcProductFilter.ItemsFilter(obj.ExternalEntity);
                    //check the element is not defined by a type which is excluded, by default if no type, then no element included
                    if (!exclude && parent is AssetType)
                    {
                        exclude = IfcTypeObjectFilter.ItemsFilter(parent.ExternalEntity, preDefinedType);
                    }
                }
                else if (obj is AssetType)
                {
                    exclude = IfcTypeObjectFilter.ItemsFilter(obj.ExternalEntity, preDefinedType);
                }
            }
            return(FlipResult ? !exclude : exclude);
        }
Ejemplo n.º 2
0
        //TODO: Check function below, see if it works!
        /// <summary>
        /// filter on IfcObjectDefinition objects
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="checkType"></param>
        /// <returns>bool true = exclude</returns>
        public bool ObjFilter(IIfcObjectDefinition obj, bool checkType = true)
        {
            bool exclude = false;

            if (obj is IIfcProduct)
            {
                exclude = IfcProductFilter.ItemsFilter(obj);
                //check the element is not defined by a type which is excluded, by default if no type, then no element included
                if (!exclude && checkType)
                {
                    var objType = Enumerable.OfType <IIfcRelDefinesByType>(((IIfcProduct)obj).IsDefinedBy).Select(rdbt => rdbt.RelatingType).FirstOrDefault(); //assuming only one IfcRelDefinesByType
                    if (objType != null)                                                                                                                       //if no type defined lets include it for now
                    {
                        exclude = IfcTypeObjectFilter.ItemsFilter(objType);
                    }
                }
            }
            else if (obj is IIfcTypeProduct)
            {
                exclude = IfcTypeObjectFilter.ItemsFilter(obj);
            }
            return(FlipResult ? !exclude : exclude);
        }