public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
                _unit = (IfcNamedUnit)(value.EntityVal);
                return;

            case 1:
                _exponent = value.IntegerVal;
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
Ejemplo n.º 2
0
        public IfcNamedUnit GetUnitFor(IfcPhysicalSimpleQuantity quantity)
        {
            if (quantity.Unit != null)
            {
                return(quantity.Unit);
            }

            IfcUnitEnum?requiredUnit = null;

            // list of possible types taken from:
            // http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcquantityresource/lexical/ifcphysicalsimplequantity.htm
            //
            if (quantity is IfcQuantityLength)
            {
                requiredUnit = IfcUnitEnum.LENGTHUNIT;
            }
            else if (quantity is IfcQuantityArea)
            {
                requiredUnit = IfcUnitEnum.AREAUNIT;
            }
            else if (quantity is IfcQuantityVolume)
            {
                requiredUnit = IfcUnitEnum.VOLUMEUNIT;
            }
            else if (quantity is IfcQuantityCount) // really not sure what to do here.
            {
                return(null);
            }
            else if (quantity is IfcQuantityWeight)
            {
                requiredUnit = IfcUnitEnum.MASSUNIT;
            }
            else if (quantity is IfcQuantityTime)
            {
                requiredUnit = IfcUnitEnum.TIMEUNIT;
            }

            if (requiredUnit == null)
            {
                return(null);
            }

            IfcNamedUnit nu = Units.OfType <IfcSIUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit) ??
                              (IfcNamedUnit)Units.OfType <IfcConversionBasedUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit);

            return(nu);
        }
Ejemplo n.º 3
0
        public IfcNamedUnit GetUnitFor(IfcPropertySingleValue property)
        {
            if (property.Unit != null)
            {
                return((IfcNamedUnit)property.Unit);
            }

            // nominal value can be of types with subtypes:
            //	IfcMeasureValue, IfcSimpleValue, IfcDerivedMeasureValue

            IfcUnitEnum?requiredUnit;

            // types from http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcmeasureresource/lexical/ifcmeasurevalue.htm
            if (property.NominalValue is IfcVolumeMeasure)
            {
                requiredUnit = IfcUnitEnum.VOLUMEUNIT;
            }
            else if (property.NominalValue is IfcAreaMeasure)
            {
                requiredUnit = IfcUnitEnum.AREAUNIT;
            }
            else if (property.NominalValue is IfcLengthMeasure)
            {
                requiredUnit = IfcUnitEnum.LENGTHUNIT;
            }
            else if (property.NominalValue is IfcPositiveLengthMeasure)
            {
                requiredUnit = IfcUnitEnum.LENGTHUNIT;
            }
            else if (property.NominalValue is IfcAmountOfSubstanceMeasure)
            {
                requiredUnit = IfcUnitEnum.AMOUNTOFSUBSTANCEUNIT;
            }
            else if (property.NominalValue is IfcContextDependentMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here
            }
            else if (property.NominalValue is IfcCountMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here
            }
            else if (property.NominalValue is IfcDescriptiveMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here
            }
            else if (property.NominalValue is IfcElectricCurrentMeasure)
            {
                requiredUnit = IfcUnitEnum.ELECTRICCURRENTUNIT;
            }
            else if (property.NominalValue is IfcLuminousIntensityMeasure)
            {
                requiredUnit = IfcUnitEnum.LUMINOUSINTENSITYUNIT;
            }
            else if (property.NominalValue is IfcMassMeasure)
            {
                requiredUnit = IfcUnitEnum.MASSUNIT;
            }
            else if (property.NominalValue is IfcNormalisedRatioMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here
            }
            else if (property.NominalValue is IfcNumericMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here.
            }
            else if (property.NominalValue is IfcParameterValue)
            {
                requiredUnit = null; // todo: not sure what to do here.
            }
            else if (property.NominalValue is IfcPlaneAngleMeasure)
            {
                requiredUnit = IfcUnitEnum.PLANEANGLEUNIT;
            }
            else if (property.NominalValue is IfcPositiveRatioMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here.
            }
            else if (property.NominalValue is IfcPositivePlaneAngleMeasure)
            {
                requiredUnit = IfcUnitEnum.PLANEANGLEUNIT;
            }
            else if (property.NominalValue is IfcRatioMeasure)
            {
                requiredUnit = null; // todo: not sure what to do here.
            }
            else if (property.NominalValue is IfcSolidAngleMeasure)
            {
                requiredUnit = IfcUnitEnum.SOLIDANGLEUNIT;
            }
            else if (property.NominalValue is IfcThermodynamicTemperatureMeasure)
            {
                requiredUnit = IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT;
            }
            else if (property.NominalValue is IfcTimeMeasure)
            {
                requiredUnit = IfcUnitEnum.TIMEUNIT;
            }
            else if (property.NominalValue is IfcComplexNumber)
            {
                requiredUnit = null; // todo: not sure what to do here.
            }
            // types from IfcSimpleValue
            else if (property.NominalValue is IfcSimpleValue)
            {
                requiredUnit = null;
            }
            else
            {
                requiredUnit = null;
            }
            // more measures types to be taken from http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcmeasureresource/lexical/ifcderivedmeasurevalue.htm

            if (requiredUnit == null)
            {
                return(null);
            }

            IfcNamedUnit nu = Units.OfType <IfcSIUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit) ??
                              (IfcNamedUnit)Units.OfType <IfcConversionBasedUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit);

            return(nu);
        }