Ejemplo n.º 1
0
        /// <summary>
        /// Find a Non ABS supertype entity from the input type name
        /// </summary>
        /// <param name="context">the IFC schema context</param>
        /// <param name="typeName">the type name</param>
        /// <returns>the non-abs supertype instance node</returns>
        static public IfcSchemaEntityNode FindNonAbsInstanceSuperType(string context, string typeName)
        {
            IfcSchemaEntityTree ifcEntitySchemaTree = GetEntityDictFor(context);
            IfcSchemaEntityNode res = null;

            // Note: Implementer's agreement #CV-2x3-166 changes IfcSpaceHeaterType from IfcEnergyConversionDevice to IfcFlowTerminal.
            if (context.Equals(Ifc2x3Schema, StringComparison.InvariantCultureIgnoreCase) &&
                typeName.Equals("IfcSpaceHeaterType", StringComparison.InvariantCultureIgnoreCase))
            {
                res = ifcEntitySchemaTree.Find("IfcFlowTerminal");
                if (res.isAbstract)
                {
                    return(null);
                }
                return(res);
            }

            string theTypeName          = typeName.Substring(typeName.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase) ? typeName : typeName + "Type";
            IfcSchemaEntityNode entNode = ifcEntitySchemaTree.Find(theTypeName);

            if (entNode != null)
            {
                while (true)
                {
                    res = entNode.GetParent();
                    // no more parent node to get
                    if (res == null)
                    {
                        break;
                    }

                    entNode = ifcEntitySchemaTree.Find(res.Name.Substring(0, res.Name.Length - 4));
                    if (entNode != null && !entNode.isAbstract)
                    {
                        res = entNode;
                        break;
                    }
                    else
                    {
                        entNode = res; // put back the Type Node
                    }
                }
            }

            return(res);
        }
Ejemplo n.º 2
0
        static public IList <IfcSchemaEntityNode> FindAllSuperTypes(string context, string entityName, params string[] stopNode)
        {
            IfcSchemaEntityTree         ifcEntitySchemaTree = GetEntityDictFor(context);
            IList <IfcSchemaEntityNode> res = new List <IfcSchemaEntityNode>();

            IfcSchemaEntityNode entNode = ifcEntitySchemaTree.Find(entityName);

            if (entNode != null)
            {
                // return the list when it reaches the stop node
                foreach (string stopCond in stopNode)
                {
                    if (entNode.Name.Equals(stopCond, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(res);
                    }
                }

                bool continueSearch = true;
                while (continueSearch)
                {
                    entNode = entNode.GetParent();
                    // no more parent node to get
                    if (entNode == null)
                    {
                        break;
                    }

                    // Stop the search when it reaches the stop node
                    foreach (string stopCond in stopNode)
                    {
                        if (entNode.Name.Equals(stopCond, StringComparison.InvariantCultureIgnoreCase))
                        {
                            continueSearch = false;
                            break;
                        }
                    }
                    if (entNode != null)
                    {
                        res.Add(entNode);
                    }
                }
            }
            return(res);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find a Non-Abstract Super Type in the current IFC Schema
        /// </summary>
        /// <param name="context">the IFC schema context</param>
        /// <param name="typeName">the entity name</param>
        /// <param name="stopNode">optional list of entity name(s) to stop the search</param>
        /// <returns>the appropriate node or null</returns>
        static public IfcSchemaEntityNode FindNonAbsSuperType(string context, string entityName, params string[] stopNode)
        {
            IfcSchemaEntityTree ifcEntitySchemaTree = GetEntityDictFor(context);
            IfcSchemaEntityNode res = null;

            IfcSchemaEntityNode entNode = ifcEntitySchemaTree.Find(entityName);

            if (entNode != null)
            {
                foreach (string stopCond in stopNode)
                {
                    if (entNode.Name.Equals(stopCond, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(res);
                    }
                }

                while (true)
                {
                    entNode = entNode.GetParent();
                    // no more parent node to get
                    if (entNode == null)
                    {
                        break;
                    }

                    foreach (string stopCond in stopNode)
                    {
                        if (entNode.Name.Equals(stopCond, StringComparison.InvariantCultureIgnoreCase))
                        {
                            break;
                        }
                    }

                    if (entNode != null && !entNode.isAbstract)
                    {
                        res = entNode;
                        break;
                    }
                }
            }
            return(res);
        }