/// <summary> /// Writes out a contact, /// </summary> /// <param name="actor"></param> /// <param name="helper"></param> public ContactConverter(IfcActorSelect actor, CoBieLiteUkHelper helper) { var personAndOrganization = actor as IfcPersonAndOrganization; var person = actor as IfcPerson; var organisation = actor as IfcOrganization; if (personAndOrganization != null) { ConvertOrganisation(personAndOrganization.TheOrganization, helper); ConvertPerson(personAndOrganization.ThePerson, helper); } else if (person != null) { ConvertPerson(person, helper); } else if (organisation != null) { ConvertOrganisation(organisation, helper); } ////Attributes //AttributeType[] ifcAttributes = helper.GetAttributes(actor); //if (ifcAttributes != null && ifcAttributes.Length > 0) // ContactAttributes = new AttributeCollectionType { Attribute = ifcAttributes }; }
private void ConvertOrganisation(IfcOrganization ifcOrganization, CoBieLiteUkHelper helper) { if (ifcOrganization.Addresses != null) { var telecom = ifcOrganization.Addresses.OfType<IfcTelecomAddress>(); var postal = ifcOrganization.Addresses.OfType<IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";",ifcTelecomAddresses.SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) Email = emailAddresses; var phoneNums = string.Join(";", ifcTelecomAddresses.SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) Phone = phoneNums; //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // URL= url; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";",ifcPostalAddresses.Where(p=>p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) Department = deptNames; var streetNames = string.Join(";",ifcPostalAddresses.Where(p=>p.AddressLines!=null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) Street = streetNames; var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) PostalBox = postalBox; var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) Town = town; var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) StateRegion = region; var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) PostalCode = postalCode; } } if (ifcOrganization.Roles != null) { var roles = ifcOrganization.Roles; if (roles.Any()) { Categories = new List<Category>(roles.Count); foreach (var role in roles) Categories.Add(new Category {Classification = "Role", Code=role.Role.ToString(), Description = role.Description}); } } Company = ifcOrganization.Name; }
//private static HashSet<IfcTypeObject> AllAssetTypesInThisFacility(IfcBuilding ifcBuilding, //HashSet<IfcElement> allAssetsinThisFacility, CoBieLiteUkHelper helper) //{ // var allAssetTypes = helper.DefiningTypeObjectMap; // var allAssetTypesInThisFacility = new HashSet<IfcTypeObject>(); // foreach (var assetTypeKeyValue in allAssetTypes) // { // //if any defining type has an object in this building/facility then we need to include it // if (assetTypeKeyValue.Value.Any(allAssetsinThisFacility.Contains)) // allAssetTypesInThisFacility.Add(assetTypeKeyValue.Key); // } // return allAssetTypesInThisFacility; //} private IEnumerable <IfcZone> GetAllZones(IEnumerable <IfcSpace> allSpaces, CoBieLiteUkHelper helper) { var allZones = new HashSet <IfcZone>(); foreach (var space in allSpaces) { foreach (var zone in helper.GetZones(space)) { allZones.Add(zone); } } return(allZones); }
/// <summary> /// Get system name from a IfcObjectDefinition /// </summary> /// <param name="helper">CoBieLiteUkHelper</param> /// <param name="ifcObjects">List of IfcObjectDefinitions</param> /// <returns></returns> private static string GetSystemName(CoBieLiteUkHelper helper, IList <IIfcObjectDefinition> ifcObjects) { string name = string.Empty; var propMaps = helper.GetPropMap("SystemMaps").ToList(); if (propMaps.Count() > 0) { propMaps = propMaps.Concat(propMaps.ConvertAll(s => s.Split(new Char[] { '.' })[0] + ".System Classification")).ToList(); var propNameOrder = propMaps.Select(s => s.Split(new Char[] { '.' })[1]).Distinct().ToList(); foreach (var obj in ifcObjects) { var atts = helper.GetAttributesObj(obj); if (atts != null) { //get propery values as system name var value = atts.Properties.Where(prop => propMaps.Contains(prop.Key)) //properties which match mappings .Select(prop => prop.Value).OfType <IIfcPropertySingleValue>() .Where(propSV => propSV.NominalValue != null && !string.IsNullOrEmpty(propSV.NominalValue.ToString())) //has a value .Select(propSV => propSV.Name.ToString() + ":" + propSV.NominalValue.ToString()) .Distinct().OrderBy(s => propNameOrder.IndexOf(s.Split(new Char[] { ':' })[0])); if (value.Any()) { name = value.First();//string.Join(":", value); } else //no name so try proprty names { //Try and get the property names as system name value = atts.Properties.Where(prop => propMaps.Contains(prop.Key)) //properties which match mappings .Select(prop => prop.Value).OfType <IIfcPropertySingleValue>() .Where(propSV => propSV.Name != null && !string.IsNullOrEmpty(propSV.Name.ToString())) .Select(prop => prop.Name.ToString()) .Distinct().OrderBy(s => propNameOrder.IndexOf(s)); if (value.Any()) { name = string.Join(":", value); } } } if (!string.IsNullOrEmpty(name)) { break; //exit loop if name can be constructed } } } return(name); }
/// <summary> /// Writes out a contact, /// </summary> /// <param name="actor"></param> /// <param name="helper"></param> public ContactConverter(IfcActorSelect actor, CoBieLiteUkHelper helper) { var personAndOrganization = actor as IfcPersonAndOrganization; var person = actor as IfcPerson; var organisation = actor as IfcOrganization; if (personAndOrganization != null) { ConvertOrganisation(personAndOrganization.TheOrganization, helper); ConvertPerson(personAndOrganization.ThePerson, helper); } else if(person!=null) ConvertPerson(person, helper); else if(organisation!=null) ConvertOrganisation(organisation, helper); ////Attributes //AttributeType[] ifcAttributes = helper.GetAttributes(actor); //if (ifcAttributes != null && ifcAttributes.Length > 0) // ContactAttributes = new AttributeCollectionType { Attribute = ifcAttributes }; }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="typeObject"></param> /// <param name="typeName"></param> public XbimIfcProxyTypeObject(CoBieLiteUkHelper helper, IfcTypeObject typeObject, string typeName) { _ifcTypeObject = typeObject; _helper = helper; _name = typeName; }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="name"></param> public XbimIfcProxyTypeObject(CoBieLiteUkHelper helper, string name) { _name = name; _helper = helper; }
/// <summary> /// Instantiates a new IfcToCOBieLiteUkExchanger class. /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <param name="reportProgress"></param> /// <param name="filter"></param> /// <param name="configFile"></param> /// <param name="extId"></param> /// <param name="sysMode"></param> /// <param name="classify"></param> public IfcToCOBieLiteUkExchanger(XbimModel source, List <Facility> target, ReportProgressDelegate reportProgress = null, OutPutFilters filter = null, string configFile = null, EntityIdentifierMode extId = EntityIdentifierMode.IfcEntityLabels, SystemExtractionMode sysMode = SystemExtractionMode.System | SystemExtractionMode.Types, bool classify = false) : base(source, target) { ReportProgress.Progress = reportProgress; //set reporter Helper = new CoBieLiteUkHelper(source, ReportProgress, filter, configFile, extId, sysMode); this._classify = classify; }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteUkHelper helper) { FamilyName = ifcPerson.FamilyName; GivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType<IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType<IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.Where(t => t.ElectronicMailAddresses != null).SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) Email = string.Join(";", emailAddresses, Email ?? ""); var phoneNums = string.Join(";", ifcTelecomAddresses.Where(t => t.TelephoneNumbers!=null).SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) Phone = string.Join(";", phoneNums, Phone ?? ""); //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // ContactURL = string.Join(";", url, ContactURL ?? ""); ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) Department = string.Join(";", deptNames,Department??""); var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) Street = string.Join(";", streetNames,Street ?? ""); var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) PostalBox = string.Join(";", postalBox, PostalBox ?? ""); var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) Town = string.Join(";", town, Town ?? ""); var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) StateRegion = string.Join(";", region, StateRegion ?? ""); var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) PostalCode = string.Join(";", postalCode, PostalCode ?? ""); } } if (ifcPerson.Roles != null) { var roles = ifcPerson.Roles; if (roles.Any()) { Categories = new List<Category>(roles.Count); foreach (var role in roles) Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } }
private void ConvertOrganisation(IfcOrganization ifcOrganization, CoBieLiteUkHelper helper) { if (ifcOrganization.Addresses != null) { var telecom = ifcOrganization.Addresses.OfType <IfcTelecomAddress>(); var postal = ifcOrganization.Addresses.OfType <IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) { Email = emailAddresses; } var phoneNums = string.Join(";", ifcTelecomAddresses.SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) { Phone = phoneNums; } //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // URL= url; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) { Department = deptNames; } var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) { Street = streetNames; } var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) { PostalBox = postalBox; } var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) { Town = town; } var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) { StateRegion = region; } var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) { PostalCode = postalCode; } } } if (ifcOrganization.Roles != null) { var roles = ifcOrganization.Roles; if (roles.Any()) { Categories = new List <Category>(roles.Count); foreach (var role in roles) { Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } } Company = ifcOrganization.Name; }
private void ConvertPerson(IfcPerson ifcPerson, CoBieLiteUkHelper helper) { FamilyName = ifcPerson.FamilyName; GivenName = ifcPerson.GivenName; if (ifcPerson.Addresses != null) { var telecom = ifcPerson.Addresses.OfType <IfcTelecomAddress>(); var postal = ifcPerson.Addresses.OfType <IfcPostalAddress>(); var ifcTelecomAddresses = telecom as IfcTelecomAddress[] ?? telecom.ToArray(); if (ifcTelecomAddresses.Any()) { var emailAddresses = string.Join(";", ifcTelecomAddresses.Where(t => t.ElectronicMailAddresses != null).SelectMany(t => t.ElectronicMailAddresses)); if (!string.IsNullOrWhiteSpace(emailAddresses)) { Email = string.Join(";", emailAddresses, Email ?? ""); } var phoneNums = string.Join(";", ifcTelecomAddresses.Where(t => t.TelephoneNumbers != null).SelectMany(t => t.TelephoneNumbers)); if (!string.IsNullOrWhiteSpace(phoneNums)) { Phone = string.Join(";", phoneNums, Phone ?? ""); } //var url = string.Join(";", ifcTelecomAddresses.Where(p => p.WWWHomePageURL.HasValue).SelectMany(p => p.WWWHomePageURL.ToString())); //if (!string.IsNullOrWhiteSpace(url)) // ContactURL = string.Join(";", url, ContactURL ?? ""); ; } var ifcPostalAddresses = postal as IfcPostalAddress[] ?? postal.ToArray(); if (ifcPostalAddresses.Any()) { var deptNames = string.Join(";", ifcPostalAddresses.Where(p => p.InternalLocation.HasValue).SelectMany(p => p.InternalLocation.ToString())); if (!string.IsNullOrWhiteSpace(deptNames)) { Department = string.Join(";", deptNames, Department ?? ""); } var streetNames = string.Join(";", ifcPostalAddresses.Where(p => p.AddressLines != null).SelectMany(p => p.AddressLines.ToString())); if (!string.IsNullOrWhiteSpace(streetNames)) { Street = string.Join(";", streetNames, Street ?? ""); } var postalBox = string.Join(";", ifcPostalAddresses.Where(p => p.PostalBox.HasValue).SelectMany(p => p.PostalBox.ToString())); if (!string.IsNullOrWhiteSpace(postalBox)) { PostalBox = string.Join(";", postalBox, PostalBox ?? ""); } var town = string.Join(";", ifcPostalAddresses.Where(p => p.Town.HasValue).SelectMany(p => p.Town.ToString())); if (!string.IsNullOrWhiteSpace(town)) { Town = string.Join(";", town, Town ?? ""); } var region = string.Join(";", ifcPostalAddresses.Where(p => p.Region.HasValue).SelectMany(p => p.Region.ToString())); if (!string.IsNullOrWhiteSpace(region)) { StateRegion = string.Join(";", region, StateRegion ?? ""); } var postalCode = string.Join(";", ifcPostalAddresses.Where(p => p.PostalCode.HasValue).SelectMany(p => p.PostalCode.ToString())); if (!string.IsNullOrWhiteSpace(postalCode)) { PostalCode = string.Join(";", postalCode, PostalCode ?? ""); } } } if (ifcPerson.Roles != null) { var roles = ifcPerson.Roles; if (roles.Any()) { Categories = new List <Category>(roles.Count); foreach (var role in roles) { Categories.Add(new Category { Classification = "Role", Code = role.Role.ToString(), Description = role.Description }); } } } }
public LibalIfcToCOBieLiteUkExchanger(IModel source, List <Facility> target, ReportProgressDelegate reportProgress = null, OutPutFilters filter = null, string configFile = null, EntityIdentifierMode extId = EntityIdentifierMode.GloballyUniqueIds, SystemExtractionMode sysMode = SystemExtractionMode.System | SystemExtractionMode.Types) : base(source, target, reportProgress, filter, configFile, extId, sysMode) { ReportProgress.Progress = reportProgress; Helper = new CoBieLiteUkHelper(source, ReportProgress, filter, configFile, extId, sysMode); }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="typeObject"></param> /// <param name="typeName"></param> public XbimIfcProxyTypeObject(CoBieLiteUkHelper helper, IfcTypeObject typeObject, string typeName) { _ifcTypeObject = typeObject; _helper = helper; _name = typeName; }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="name"></param> public XbimIfcProxyTypeObject(CoBieLiteUkHelper helper, string name) { _name = name; _helper = helper; }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="target"></param> public IfcToCOBieLiteUkExchanger(XbimModel source, List <Facility> target) : base(source, target) { Helper = new CoBieLiteUkHelper(source); }