private static Task <Stream> ConvertIfcToCobieLiteUkAsync(IfcStore ifcStore)
        {
            return(Task.Run <Stream>(() =>
            {
                if (ifcStore.SchemaVersion == Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3)
                {
                    Ifc2x3IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore);
                }
                else
                {
                    Ifc4x1IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore);
                }

                var memStream = new MemoryStream();

                var facilities = new List <Facility>();
                var ifcToCoBieLiteUkExchanger = new IfcToCOBieLiteUkExchanger(ifcStore, facilities, null, null, null, EntityIdentifierMode.GloballyUniqueIds, SystemExtractionMode.System);
                facilities = ifcToCoBieLiteUkExchanger.Convert();

                var facility = facilities.ToArray()[0];

                facility.WriteXml(memStream);

                return new MemoryStream(memStream.ToArray());
            }));
        }
Ejemplo n.º 2
0
        private Task <String> ConvertIfcToCobieLiteUkAsync(IfcStore ifcStore, string fileName)
        {
            return(Task.Run <String>(() =>
            {
                var defaultExtSystem = "LIBAL";
                var siteName = "";
                var phase = "";

                var psetPropertyToUnitDictionary = new Dictionary <string, string>();
                bool isIfc2x3 = ifcStore.SchemaVersion == Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3;
                if (isIfc2x3)
                {
                    Ifc2x3IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore);
                    defaultExtSystem = Ifc2x3IfcEntityLabelGenerator.getExtSystem(ifcStore);
                    siteName = Ifc2x3IfcEntityLabelGenerator.getSiteName(ifcStore);
                    phase = Ifc2x3IfcEntityLabelGenerator.getPhase(ifcStore);


                    Ifc2x3QuantitySetGenerator.ResolveQuantitySet(ifcStore);
                    Ifc2x3UnitResolver.ResolveUnits(ifcStore, psetPropertyToUnitDictionary);
                }
                else
                {
                    Ifc4x1IfcEntityLabelGenerator.enrichModelWithIfcEntityLabel(ifcStore);
                    defaultExtSystem = Ifc4x1IfcEntityLabelGenerator.getExtSystem(ifcStore);
                    siteName = Ifc4x1IfcEntityLabelGenerator.getSiteName(ifcStore);
                    phase = Ifc4x1IfcEntityLabelGenerator.getPhase(ifcStore);

                    Ifc4x1QuantitySetGenerator.ResolveQuantitySet(ifcStore);
                    Ifc4x1UnitResolver.ResolveUnits(ifcStore, psetPropertyToUnitDictionary);
                }

                var memStream = new MemoryStream();
                var facilities = new List <Facility>();
                var ifcToCoBieLiteUkExchanger = new LibalIfcToCOBieLiteUkExchanger(ifcStore, facilities, null, null, null, EntityIdentifierMode.GloballyUniqueIds, SystemExtractionMode.System);

                facilities = ifcToCoBieLiteUkExchanger.Convert();
                var facility = facilities.ToArray()[0];

                if (facility.Site != null)
                {
                    facility.Site.Name = siteName;
                }
                facility.Phase = phase;

                AddUnitsToAttributes(facility, psetPropertyToUnitDictionary);
                CobieLiteUkAttributeResolver.resolveCobieAttributes(facility);
                ResolveContacts(facility, defaultExtSystem);
                MapSystems(ifcStore, ifcToCoBieLiteUkExchanger, facility);

                if (ifcStore.SchemaVersion == Xbim.Common.Step21.XbimSchemaVersion.Ifc2X3)
                {
                    Ifc2x3IfcEntityLabelGenerator.resolveExtObjectWithPredefinedType(ifcStore, facility);
                }
                else
                {
                    Ifc4x1IfcEntityLabelGenerator.resolveExtObjectWithPredefinedType(ifcStore, facility);
                }

                facility.ValidateUK2012(Console.Out, true);

                SetCorrectQSetName(facility);
                SetCorrectPsetName(facility);

                CleanupSystems(facility);
                CleanupZones(facility);

                // set ifc version in facility metadata
                facility.Metadata.Status = ifcStore.SchemaVersion.ToString();

                facility.WriteXml(memStream);

                _s3.Create(fileName, new MemoryStream(memStream.ToArray()));

                return "processed";
            }));
        }