Пример #1
0
        static string getSIUnitRepStr(IIfcUnit unitDef)
        {
            // Initialize the static Dicts, if it is still empty upon the first use. These Dicts do not need to be reset
            setupUnitRep();

            IIfcSIUnit siUnit     = unitDef as IIfcSIUnit;
            string     unitRepStr = string.Empty;

            m_SIUnitNameRep.TryGetValue(siUnit.Name, out unitRepStr);
            if (siUnit.Prefix.HasValue)
            {
                string prefixStr = string.Empty;
                m_SIPrefixRep.TryGetValue(siUnit.Prefix.Value, out prefixStr);
                unitRepStr = prefixStr + unitRepStr;
            }
            return(unitRepStr);
        }
Пример #2
0
        public IfcLocationData(string path)
        {
            using (IfcStore model = IfcStore.Open(path))
            {
                if (model.SchemaVersion == XbimSchemaVersion.Ifc2X3)
                {
                    Schema            = "Ifc 2x3";
                    SchemaIsSupported = true;
                }
                else if (model.SchemaVersion == XbimSchemaVersion.Ifc4)
                {
                    Schema            = "Ifc4";
                    SchemaIsSupported = false;
                    return;
                }
                else
                {
                    Schema            = model.SchemaVersion.ToString();
                    SchemaIsSupported = false;
                    return;
                }
                IIfcProject project             = model.Instances.FirstOrDefault <IIfcProject>();
                string      applicationFullname = project.OwnerHistory.OwningApplication.ApplicationFullName;
                if (applicationFullname == null)
                {
                    AuthoringTool = "N/A";
                }
                else
                {
                    AuthoringTool = project.OwnerHistory.OwningApplication.ApplicationFullName;
                }


                IIfcSIUnit lengtUnit = project.UnitsInContext.Units.FirstOrDefault <IIfcSIUnit>(q => q.UnitType == IfcUnitEnum.LENGTHUNIT);
                LengthUnit = lengtUnit.FullName;

                IIfcSite site = model.Instances.FirstOrDefault <IIfcSite>();
                if (site.RefElevation.HasValue)
                {
                    refElevation = site.RefElevation.Value;
                }
                else
                {
                    refElevation = double.NaN;
                }
                IIfcLocalPlacement   placement      = site.ObjectPlacement as IIfcLocalPlacement;
                IIfcAxis2Placement3D axis2Placement = placement.RelativePlacement as IIfcAxis2Placement3D;
                double x     = axis2Placement.RefDirection.DirectionRatios.GetAt(0);
                double y     = axis2Placement.RefDirection.DirectionRatios.GetAt(1);
                double angle = 360 - Math.Atan2(y, x) * 180 / Math.PI;
                if (angle.Equals(360))
                {
                    angle = 0;
                }
                Orientation = angle;

                EW        = axis2Placement.Location.Coordinates.GetAt(0);
                NS        = axis2Placement.Location.Coordinates.GetAt(1);
                elevation = axis2Placement.Location.Coordinates.GetAt(2);
            }
        }
Пример #3
0
        public static string GetSymbol(IIfcSIUnit unit)
        {
            string prefix = string.Empty;

            if (unit.Prefix.HasValue)
            {
                prefix = unit.Prefix.Value switch
                {
                    IfcSIPrefix.EXA => "E",
                    IfcSIPrefix.PETA => "P",
                    IfcSIPrefix.TERA => "T",
                    IfcSIPrefix.GIGA => "G",
                    IfcSIPrefix.MEGA => "M",
                    IfcSIPrefix.KILO => "k",
                    IfcSIPrefix.HECTO => "h",
                    IfcSIPrefix.DECA => "da",
                    IfcSIPrefix.DECI => "d",
                    IfcSIPrefix.CENTI => "c",
                    IfcSIPrefix.MILLI => "m",
                    IfcSIPrefix.MICRO => "µ",
                    IfcSIPrefix.NANO => "n",
                    IfcSIPrefix.PICO => "p",
                    IfcSIPrefix.FEMTO => "f",
                    IfcSIPrefix.ATTO => "a",
                    _ => throw new ArgumentOutOfRangeException("Unexpected SI unit prefix"),
                };
            }

            string name = unit.Name switch
            {
                IfcSIUnitName.AMPERE => "A",
                IfcSIUnitName.BECQUEREL => "Bq",
                IfcSIUnitName.CANDELA => "cd",
                IfcSIUnitName.COULOMB => "C",
                IfcSIUnitName.CUBIC_METRE => "m³",
                IfcSIUnitName.DEGREE_CELSIUS => "°C",
                IfcSIUnitName.FARAD => "F",
                IfcSIUnitName.GRAM => "g",
                IfcSIUnitName.GRAY => "Gy",
                IfcSIUnitName.HENRY => "H",
                IfcSIUnitName.HERTZ => "Hz",
                IfcSIUnitName.JOULE => "J",
                IfcSIUnitName.KELVIN => "K",
                IfcSIUnitName.LUMEN => "lm",
                IfcSIUnitName.LUX => "lx",
                IfcSIUnitName.METRE => "m",
                IfcSIUnitName.MOLE => "mol",
                IfcSIUnitName.NEWTON => "N",
                IfcSIUnitName.OHM => "Ω",
                IfcSIUnitName.PASCAL => "Pa",
                IfcSIUnitName.RADIAN => "rad",
                IfcSIUnitName.SECOND => "s",
                IfcSIUnitName.SIEMENS => "S",
                IfcSIUnitName.SIEVERT => "Sv",
                IfcSIUnitName.SQUARE_METRE => "m²",
                IfcSIUnitName.STERADIAN => "sr",
                IfcSIUnitName.TESLA => "T",
                IfcSIUnitName.VOLT => "V",
                IfcSIUnitName.WATT => "W",
                IfcSIUnitName.WEBER => "Wb",
                _ => throw new ArgumentOutOfRangeException("Unexpected SI unit prefix"),
            };

            return(prefix + name);
        }
Пример #4
0
        public string GetSILengthUnit()
        {
            IIfcSIUnit si = _model.Instances.OfType <IIfcSIUnit>().Where(unit => unit.UnitType == IfcUnitEnum.LENGTHUNIT).First();

            return(si.Prefix.ToString() + si.Name.ToString());
        }