public SimpleGroup(IfcGroup group, SimpleGroup parent) { if (group == null) throw new ArgumentNullException(); _group = group; _parent = parent; Init(); }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: case 5: base.IfcParse(propIndex, value); break; case 6: _relatingGroup = (IfcGroup) value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: case 5: base.IfcParse(propIndex, value); break; case 6: _relatingGroup = (IfcGroup)value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: case 5: base.Parse(propIndex, value, nestedIndex); return; case 6: _relatingGroup = (IfcGroup)(value.EntityVal); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
public bool GroupElements(XmlDocument document, IfcGroup rootGroup) { if (document == null) throw new ArgumentNullException("XML document must be specified"); _xmlDoc = document; if (rootGroup != null) { if (((IPersistIfcEntity)rootGroup).ModelOf != _model) throw new Exception("Model of the group is different than model to be used."); _rootGroup = rootGroup; } else { _rootGroup = _model.Instances.New<IfcGroup>(g=> g.Name = "Root group"); } using (XbimReadWriteTransaction trans = _model.BeginTransaction("Elements to groups")) { bool result = PerformGrouping(); trans.Commit(); return result; } }
public bool GroupElements(string XMLfileName, IfcGroup rootGroup) { if (string.IsNullOrEmpty(XMLfileName)) throw new ArgumentNullException("File name cannot be null or empty."); _xmlDoc = new XmlDocument(); _xmlDoc.Load(XMLfileName); if (rootGroup != null) { if (((IPersistIfcEntity)rootGroup).ModelOf != _model) throw new Exception("Model of the group is different than model to be used."); _rootGroup = rootGroup; } else { _rootGroup = _model.Instances.New<IfcGroup>(g => g.Name = "Root group"); } using (XbimReadWriteTransaction trans = _model.BeginTransaction()) { bool result = PerformGrouping(); trans.Commit(); return result; } }
public void Load(XmlDocument document) { if (document == null) throw new ArgumentNullException("XML document must be specified"); _xmlDoc = document; _rootGroup = _model.Instances.New<IfcGroup>(g => g.Name = "Root group"); }
private void ClearGroups(IfcGroup root) { List<IfcElement> elements = root.GetGroupedObjects<IfcElement>().ToList(); int count = elements.Count; //must use for cycle instead of foreach because enumeration would collapse for (int i = 0; i < count; i++) { root.RemoveObjectFromGroup(elements[i]); } //recursive call for children IEnumerable<IfcGroup> children = root.GetGroupedObjects<IfcGroup>(); foreach (IfcGroup group in children) { ClearGroups(group); } }
//recursive function to find group with specified name in the scope of the root private IfcGroup GetGroup(string name, IfcGroup root) { if (root.Name == name) return root; else { IEnumerable<IfcGroup> children = root.GetGroupedObjects<IfcGroup>(); foreach (IfcGroup group in children) { IfcGroup result = GetGroup(name, group); if (result != null) return result; } return null; } }
public GroupViewModel(IfcGroup gr, IXbimViewModel parent) { this.group = gr; CreatingParent = parent; }
//create group and add it into the group hierarchy (top -> down creation) private IfcGroup CreateGroup(string groupName, string classification, IfcGroup parentGroup) { IfcGroup group = _model.Instances.Where<IfcGroup>(g => g.Name == groupName).FirstOrDefault(); if (group == null) group = _model.Instances.New<IfcGroup>(g => { g.Name = groupName; g.Description = classification; }); if (parentGroup != null) { //check if it is not already child group. IfcGroup child = parentGroup.GetGroupedObjects<IfcGroup>().Where(g => g.Name == groupName).FirstOrDefault(); if (child == null) //ad if it is not parentGroup.AddObjectToGroup(group); } //add to the root groups if this is root (there is no parent group) if (parentGroup == null) RootGroups.Add(group); _numCreated++; return group; }
//recursive function for groups creation private void ProcessGroups(XmlNodeList groupNodeList, IfcGroup parentGroup) { foreach (XmlNode groupNode in groupNodeList) { //check node type if (groupNode.Name != "my:group") { errLog.WriteLine("Unexpected node: " + groupNode.Name); continue; } XmlElement groupElement = groupNode as XmlElement; string name = groupElement.GetAttribute("my:name"); if (string.IsNullOrEmpty(name)) { errLog.WriteLine("Group with no name identified."); continue; } string classification = groupElement.GetAttribute("my:classification"); if (string.IsNullOrEmpty(classification)) { errLog.WriteLine("Group '"+name+"' does not have any classification code assigned."); } //create group IfcGroup group = CreateGroup(name, classification, parentGroup); //recursive call for the child nodes XmlNodeList children = groupNode.ChildNodes; if (children.Count != 0) ProcessGroups(children, group); } }