/// <summary>
        /// Creates a property from the calculator.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="exporterIFC">The ExporterIFC.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element.</param>
        /// <param name="elementType">The element type.</param>
        /// <param name="handle">The handle for which we calculate the property.</param>
        /// <returns>The property handle.</returns>
        IFCAnyHandle CreatePropertyFromCalculator(IFCFile file, ExporterIFC exporterIFC, IFCExtrusionCreationData extrusionCreationData, Element element,
                                                  ElementType elementType, IFCAnyHandle handle, PropertyType propertyType, PropertyValueType valueType, Type propertyEnumerationType, string propertyName)
        {
            IFCAnyHandle propHnd = null;

            if (PropertyCalculator == null)
            {
                return(propHnd);
            }

            if (PropertyCalculator.GetParameterFromSubelementCache(element, handle) ||
                PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType))
            {
                switch (propertyType)
                {
                case PropertyType.Label:
                {
                    if (PropertyCalculator.CalculatesMutipleValues)
                    {
                        propHnd = PropertyUtil.CreateLabelProperty(file, propertyName, PropertyCalculator.GetStringValues(), valueType, propertyEnumerationType);
                    }
                    else
                    {
                        bool cacheLabel = PropertyCalculator.CacheStringValues;
                        propHnd = PropertyUtil.CreateLabelPropertyFromCache(file, null, propertyName, PropertyCalculator.GetStringValue(), valueType, cacheLabel, propertyEnumerationType);
                    }
                    break;
                }

                case PropertyType.Text:
                {
                    propHnd = PropertyUtil.CreateTextPropertyFromCache(file, propertyName, PropertyCalculator.GetStringValue(), valueType);
                    break;
                }

                case PropertyType.Identifier:
                {
                    propHnd = PropertyUtil.CreateIdentifierPropertyFromCache(file, propertyName, PropertyCalculator.GetStringValue(), valueType);
                    break;
                }

                case PropertyType.Boolean:
                {
                    propHnd = PropertyUtil.CreateBooleanPropertyFromCache(file, propertyName, PropertyCalculator.GetBooleanValue(), valueType);
                    break;
                }

                case PropertyType.Logical:
                {
                    propHnd = PropertyUtil.CreateLogicalPropertyFromCache(file, propertyName, PropertyCalculator.GetLogicalValue(), valueType);
                    break;
                }

                case PropertyType.Integer:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, propertyName, PropertyCalculator.GetIntValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, propertyName, PropertyCalculator.GetIntValue(), valueType);
                    }
                    break;
                }

                case PropertyType.Real:
                {
                    propHnd = PropertyUtil.CreateRealPropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Length:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateLengthMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateLengthMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    }
                    break;
                }

                case PropertyType.PositiveLength:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    }
                    break;
                }

                case PropertyType.NormalisedRatio:
                {
                    propHnd = PropertyUtil.CreateNormalisedRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PositiveRatio:
                {
                    propHnd = PropertyUtil.CreatePositiveRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Ratio:
                {
                    propHnd = PropertyUtil.CreateRatioMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PlaneAngle:
                {
                    propHnd = PropertyUtil.CreatePlaneAngleMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PositivePlaneAngle:
                {
                    propHnd = PositivePlaneAnglePropertyUtil.CreatePositivePlaneAngleMeasurePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Area:
                {
                    propHnd = PropertyUtil.CreateAreaMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Count:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateCountMeasureProperty(file, propertyName, PropertyCalculator.GetIntValue(propertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateCountMeasureProperty(file, propertyName, PropertyCalculator.GetIntValue(), valueType);
                    }
                    break;
                }

                case PropertyType.Frequency:
                {
                    propHnd = FrequencyPropertyUtil.CreateFrequencyProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Power:
                {
                    propHnd = PropertyUtil.CreatePowerPropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.ThermodynamicTemperature:
                {
                    propHnd = PropertyUtil.CreateThermodynamicTemperaturePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.ThermalTransmittance:
                {
                    propHnd = PropertyUtil.CreateThermalTransmittancePropertyFromCache(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.VolumetricFlowRate:
                {
                    propHnd = PropertyUtil.CreateVolumetricFlowRateMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.LinearVelocity:
                {
                    propHnd = PropertyUtil.CreateLinearVelocityMeasureProperty(file, propertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                default:
                    throw new InvalidOperationException();
                }
            }

            return(propHnd);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a property from the calculator.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="exporterIFC">The ExporterIFC.</param>
        /// <param name="extrusionCreationData">The IFCExtrusionCreationData.</param>
        /// <param name="element">The element.</param>
        /// <param name="elementType">The element type.</param>
        /// <returns>The property handle.</returns>
        IFCAnyHandle CreatePropertyFromCalculator(IFCFile file, ExporterIFC exporterIFC,
                                                  IFCExtrusionCreationData extrusionCreationData, Element element, ElementType elementType)
        {
            IFCAnyHandle propHnd = null;

            if (PropertyCalculator != null && PropertyCalculator.Calculate(exporterIFC, extrusionCreationData, element, elementType))
            {
                PropertyType      propertyType = PropertyType;
                PropertyValueType valueType    = PropertyValueType;

                switch (propertyType)
                {
                case PropertyType.Label:
                {
                    if (PropertyCalculator.CalculatesMutipleValues)
                    {
                        propHnd = PropertyUtil.CreateLabelProperty(file, PropertyName, PropertyCalculator.GetStringValues(), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateLabelPropertyFromCache(file, PropertyName, PropertyCalculator.GetStringValue(), valueType, false);
                    }
                    break;
                }

                case PropertyType.Identifier:
                {
                    propHnd = PropertyUtil.CreateIdentifierPropertyFromCache(file, PropertyName, PropertyCalculator.GetStringValue(), valueType);
                    break;
                }

                case PropertyType.Boolean:
                {
                    propHnd = PropertyUtil.CreateBooleanPropertyFromCache(file, PropertyName, PropertyCalculator.GetBooleanValue(), valueType);
                    break;
                }

                case PropertyType.Integer:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, PropertyName, PropertyCalculator.GetIntValue(PropertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreateIntegerPropertyFromCache(file, PropertyName, PropertyCalculator.GetIntValue(), valueType);
                    }
                    break;
                }

                case PropertyType.Real:
                {
                    double scale = exporterIFC.LinearScale;
                    propHnd = PropertyUtil.CreateRealPropertyFromCache(file, scale, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PositiveLength:
                {
                    if (PropertyCalculator.CalculatesMultipleParameters)
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, PropertyName, PropertyCalculator.GetDoubleValue(PropertyName), valueType);
                    }
                    else
                    {
                        propHnd = PropertyUtil.CreatePositiveLengthMeasureProperty(file, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    }
                    break;
                }

                case PropertyType.PositiveRatio:
                {
                    propHnd = PropertyUtil.CreatePositiveRatioMeasureProperty(file, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.PlaneAngle:
                {
                    propHnd = PropertyUtil.CreatePlaneAngleMeasurePropertyFromCache(file, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                case PropertyType.Area:
                {
                    propHnd = PropertyUtil.CreateAreaMeasureProperty(file, PropertyName, PropertyCalculator.GetDoubleValue(), valueType);
                    break;
                }

                default:
                    throw new InvalidOperationException();
                }
            }

            return(propHnd);
        }