private List <BHC.Construction> ReadConstructions(BHX.GBXML gbx, List <string> ids = null) { List <BHC.Construction> constructions = new List <BHC.Construction>(); if (gbx.Construction != null) { if (gbx.Layer != null) { foreach (BHX.Construction c in gbx.Construction) { BHX.Layer gbLayer = gbx.Layer.Where(x => x.ID == c.LayerID.LayerIDRef).FirstOrDefault(); if (gbLayer != null && gbLayer.MaterialID != null) { List <BHX.Material> gbMaterials = gbx.Material.Where(x => gbLayer.MaterialID.Where(y => y.MaterialIDRef == x.ID).FirstOrDefault() != null).ToList(); if (gbMaterials.Count > 0) { List <BHC.Layer> layers = gbMaterials.Select(x => x.FromGBXML()).ToList(); constructions.Add(c.FromGBXML(layers)); } } } } } return(constructions); }
private List <BHE.Space> ReadSpaces(BHX.GBXML gbx, List <string> ids = null) { //ToDo - Fix this! List <BHE.Space> s = new List <BHE.Space>(); if (gbx.Campus != null) { foreach (BHX.Building b in gbx.Campus.Building) { foreach (BHX.Space space in b.Space) { BHE.Space bhomS = space.FromGBXML(); if (bhomS.Perimeter.IControlPoints().Count == 1) { //Pulling from IES probably means it's wrong... List <Panel> panelsAsSpace = space.SpaceBoundary.Select(x => gbx.Campus.Surface.Where(y => y.ID == x.SurfaceIDRef).FirstOrDefault().FromGBXML()).ToList(); bhomS.Perimeter = panelsAsSpace.FloorGeometry(); } s.Add(bhomS); } } } return(s); }
/*private List<BH.oM.Physical.Properties.Material> ReadMaterials(BHX.GBXML gbx, List<string> ids = null) * { * if (gbx.Material != null) * return gbx.Material.Select(x => x.ToBHoM()).ToList(); * else * return new List<BH.oM.Environment.Materials.Material>(); * }*/ private List <BHG.SettingOut.Level> ReadLevels(BHX.GBXML gbx, List <string> ids = null) { if (gbx.Campus.Building.Length > 0 && gbx.Campus.Building[0].BuildingStorey != null) { return(gbx.Campus.Building[0].BuildingStorey.Select(x => x.FromGBXML()).ToList()); } else { return(new List <BHG.SettingOut.Level>()); } }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <IBHoMObject> ReadFullXMLFile(BH.Adapter.XML.GBXMLSchema.GBXML gbx, List <string> ids = null) { List <IBHoMObject> objects = new List <IBHoMObject>(); objects.AddRange(ReadBuilding(gbx)); objects.AddRange(ReadPanels(gbx)); objects.AddRange(ReadConstructions(gbx)); //objects.AddRange(ReadMaterials(gbx)); objects.AddRange(ReadLevels(gbx)); objects.AddRange(ReadSpaces(gbx)); return(objects); }
private List <BHE.Building> ReadBuilding(BHX.GBXML gbx, List <string> ids = null) { if (gbx.Campus != null) { return new List <BHE.Building>() { gbx.Campus.Location.FromGBXML() } } ; else { return(new List <BHE.Building>()); } }
private IEnumerable <IBHoMObject> ReadGBXML(Type type = null, XMLConfig config = null) { BH.Adapter.XML.GBXMLSchema.GBXML gbx = null; TextReader reader = new StreamReader(_fileSettings.GetFullFileName()); XmlSerializer szer = new XmlSerializer(typeof(BH.Adapter.XML.GBXMLSchema.GBXML)); gbx = (BH.Adapter.XML.GBXMLSchema.GBXML)szer.Deserialize(reader); reader.Close(); if (type == null) { return(ReadFullXMLFile(gbx)); } else if (type == typeof(BHE.Building)) { return(ReadBuilding(gbx)); } else if (type == typeof(BHE.Panel)) { return(ReadPanels(gbx)); } /*else if (type == typeof(BHC.Construction)) * return ReadConstructions(gbx); * else if (type == typeof(BH.oM.Physical.Properties.Material)) * return ReadMaterials(gbx);*/ else if (type == typeof(BHG.SettingOut.Level)) { return(ReadLevels(gbx)); } else if (type == typeof(BHE.Space)) { return(ReadSpaces(gbx)); } else { return(ReadFullXMLFile(gbx)); } }
private List <BHE.Panel> ReadPanels(BHX.GBXML gbx, List <string> ids = null) { List <BHE.Panel> panels = new List <BHE.Panel>(); if (gbx.Campus != null && gbx.Campus.Surface != null) { foreach (BHX.Surface s in gbx.Campus.Surface) { BHE.Panel p = s.FromGBXML(); if (gbx.Construction != null) { BHX.Construction c = gbx.Construction.Where(x => x.ID == s.ConstructionIDRef).FirstOrDefault(); if (c != null) { BHX.Layer gbLayer = gbx.Layer.Where(x => x.ID == c.LayerID.LayerIDRef).FirstOrDefault(); if (gbLayer != null && gbLayer.MaterialID != null) { List <BHX.Material> gbMaterials = gbx.Material.Where(x => gbLayer.MaterialID.Where(y => y.MaterialIDRef == x.ID).FirstOrDefault() != null).ToList(); if (gbMaterials.Count > 0) { List <BHC.Layer> layers = gbMaterials.Select(x => x.FromGBXML()).ToList(); p.Construction = c.FromGBXML(layers); } } } } foreach (BHX.Opening gbxOpening in s.Opening) { p.Openings.Add(gbxOpening.FromGBXML()); } panels.Add(p); } } return(panels); }