/// <summary>
        /// Instantiates a new IIfcToCOBieLiteUkExchanger class.
        /// </summary>
        public IfcToCoBieExpressExchanger(IfcStore source, IModel 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 COBieExpressHelper(this, ReportProgress, filter, configFile, extId, sysMode);
            Helper.Init();

            _classify = classify;
        }
Beispiel #2
0
        /// <summary>
        /// Get system name from a IfcObjectDefinition
        /// </summary>
        /// <param name="helper">CoBieLiteUkHelper</param>
        /// <param name="ifcObjects"></param>
        /// <returns></returns>
        private static string GetSystemName(COBieExpressHelper helper, IEnumerable <IIfcObjectDefinition> ifcObjects)
        {
            var name     = string.Empty;
            var propMaps = helper.GetPropMap("SystemMaps").ToList();

            if (!propMaps.Any())
            {
                return(name);
            }

            propMaps = propMaps.Concat(propMaps.ConvertAll(s => s.Split('.')[0] + ".System Classification")).ToList();
            var propNameOrder = propMaps.Select(s => s.Split('.')[1]).Distinct().ToList();

            foreach (var atts in ifcObjects.Select(helper.GetAttributesObj))
            {
                if (atts != null)
                {
                    //get propery values as system name
                    var values = atts.Properties
                                 .Where(prop => propMaps.Contains(prop.Key))
                                 .Select(prop => prop.Value)
                                 .OfType <IIfcPropertySingleValue>()
                                 .Where(propSv => propSv.NominalValue != null && !string.IsNullOrEmpty(propSv.NominalValue.ToString()))
                                 .Select(propSv => propSv.Name.ToString() + ":" + propSv.NominalValue.ToString())
                                 .Distinct()
                                 .OrderBy(s => propNameOrder.IndexOf(s.Split(':')[0]));
                    if (values.Any())
                    {
                        name = values.First();//string.Join(":", value);
                    }
                    else //no name so try proprty names
                    {
                        //Try and get the property names as system name
                        values = atts.Properties
                                 .Where(prop => propMaps.Contains(prop.Key))
                                 .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 (values.Any())
                        {
                            name = string.Join(":", values);
                        }
                    }
                }
                if (!string.IsNullOrEmpty(name))
                {
                    break;                              //exit loop if name can be constructed
                }
            }
            return(name);
        }
        /// <summary>
        /// Instantiates a new IIfcToCOBieLiteUkExchanger class.
        /// </summary>
        public IfcToCoBieExpressExchanger(IModel source, IModel 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)
        {
            // make sure there are some loggers in the models
            target.Logger = target.Logger ?? NullLogger.Instance;
            source.Logger = source.Logger ?? NullLogger.Instance;

            ReportProgress.Progress = reportProgress; //set reporter
            Helper = new COBieExpressHelper(this, ReportProgress, target.Logger, filter, configFile, extId, sysMode);
            Helper.Init();

            _classify = classify;
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="typeObject"></param>
 /// <param name="typeName"></param>
 public XbimIfcProxyTypeObject(COBieExpressHelper helper, IIfcTypeObject typeObject, string typeName)
 {
     _ifcTypeObject = typeObject;
     _helper        = helper;
     _name          = typeName;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="name"></param>
 internal XbimIfcProxyTypeObject(COBieExpressHelper helper, string name)
 {
     _name   = name;
     _helper = helper;
 }
        //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 static IEnumerable <IIfcZone> GetAllZones(IEnumerable <IIfcSpace> allSpaces, COBieExpressHelper helper)
        {
            var allZones = new HashSet <IIfcZone>();

            foreach (var space in allSpaces)
            {
                foreach (var zone in helper.GetZones(space))
                {
                    allZones.Add(zone);
                }
            }
            return(allZones);
        }