/// <summary> /// Procees an IFC schema from the IFCXML schema /// </summary> /// <param name="f">IFCXML schema file</param> private void processSchema(FileInfo f) { IfcSchemaEntityTree entityTree = new IfcSchemaEntityTree(); ProcessIFCXMLSchema.ProcessIFCSchema(f, ref entityTree); string schemaName = f.Name.Replace(".xsd", ""); if (checkBox_outputSchemaTree.IsChecked == true) { string treeDump = entityTree.DumpTree(); File.WriteAllText(outputFolder + @"\entityTree" + schemaName + ".txt", treeDump); } if (checkBox_outputSchemaEnum.IsChecked == true) { string dictDump = entityTree.DumpEntityDict(schemaName); File.WriteAllText(outputFolder + @"\entityEnum" + schemaName + ".cs", dictDump); } // Add aggregate of the entity list into a set foreach (KeyValuePair <string, IfcSchemaEntityNode> entry in entityTree.IfcEntityDict) { aggregateEntities.Add(entry.Key); } }
/// <summary> /// This method generates object hierarchy based on the ifcshema /// </summary> /// <param name="ifcSchemaFile"></param> /// <returns>List of object hierarchies</returns> public List <ObjectHierarchy> GenerateObjectHierarchy(string ifcSchemaFile) { if (string.IsNullOrEmpty(ifcSchemaFile)) { return(new List <ObjectHierarchy>()); } FileInfo schemaFileInfo = new FileInfo(ifcSchemaFile); bool newLoad = ProcessIFCXMLSchema.ProcessIFCSchema(schemaFileInfo); if (newLoad) { string ifcVersion = Path.GetFileNameWithoutExtension(schemaFileInfo.Name); List <ObjectHierarchy> objectHierarchies = new List <ObjectHierarchy>(); foreach (var entityDict in IfcSchemaEntityTree.EntityDict) { IfcSchemaEntityNode parentEntityNode = entityDict.Value; if (parentEntityNode.Name.Contains("IfcProduct") || parentEntityNode.Name.Contains("IfcTypeProduct") || parentEntityNode.Name.Contains("IfcGroup")) { //check if current has a child IList <IfcSchemaEntityNode> childNodes = parentEntityNode.GetChildren(); if (childNodes.Count == 0) { objectHierarchies.Add(new ObjectHierarchy(ifcVersion, parentEntityNode.Name, parentEntityNode.Name, parentEntityNode.isAbstract, 0)); continue; } foreach (IfcSchemaEntityNode childNode in childNodes) { List <ObjectHierarchy> hierarchies = CollectObjectHierarchies(childNode, ifcVersion, parentEntityNode.Name); objectHierarchies.AddRange(hierarchies); } } } return(objectHierarchies); } return(new List <ObjectHierarchy>()); }