コード例 #1
0
        /// <summary>
        /// Check that an IFCData is properly formatted to potentially be an IfcSegmentIndexSelect.
        /// </summary>
        /// <param name="segment"></param>
        /// <returns>The type of IfcSegmentIndexSelect, or null if invalid.</returns>
        /// <remarks>The calling function is responsible for logging errors.</remarks>
        private string ValidateSegment(IFCData segment)
        {
            if (segment.PrimitiveType != IFCDataPrimitiveType.Aggregate)
            {
                return(null);
            }

            if (!segment.HasSimpleType())
            {
                return(null);
            }

            return(segment.GetSimpleType());
        }
コード例 #2
0
        /// <summary>
        /// Gets the unit type from an IFC data.
        /// </summary>
        /// <param name="data">The IFC data.</param>
        /// <param name="defaultType">The default value, if no type is found.</param>
        /// <param name="propertyType">The string value of the simple type, returned for logging purposes.</param>
        /// <returns>The unit type.</returns>
        public static UnitType GetUnitTypeFromData(IFCData data, UnitType defaultType, out string propertyType)
        {
            UnitType unitType = UnitType.UT_Undefined;

            if (data.HasSimpleType())
            {
                propertyType = data.GetSimpleType();
                if (!MeasureCache.TryGetValue(propertyType, out unitType))
                {
                    unitType = defaultType;
                }
            }
            else
            {
                propertyType = "";
                unitType     = defaultType;
            }

            return(unitType);
        }
コード例 #3
0
ファイル: IFCDataUtil.cs プロジェクト: zhoyq/revit-ifc
        /// <summary>
        /// Gets the unit type from an IFC data.
        /// </summary>
        /// <param name="data">The IFC data.</param>
        /// <param name="defaultSpec">The default spec, if no spec is found.</param>
        /// <param name="propertyType">The string value of the simple type, returned for logging purposes.</param>
        /// <returns>The unit type.</returns>
        public static ForgeTypeId GetUnitTypeFromData(IFCData data, ForgeTypeId defaultSpec, out string propertyType)
        {
            ForgeTypeId specTypeId = new ForgeTypeId();

            if (data.HasSimpleType())
            {
                propertyType = data.GetSimpleType();
                if (!MeasureCache.TryGetValue(propertyType, out specTypeId))
                {
                    specTypeId = defaultSpec;
                }
            }
            else
            {
                propertyType = "";
                specTypeId   = defaultSpec;
            }

            return(specTypeId);
        }
コード例 #4
0
        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            IFCAnyHandle surfaceColour = IFCImportHandleUtil.GetRequiredInstanceAttribute(item, "SurfaceColour", false);

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(surfaceColour))
            {
                m_SurfaceColour = IFCColourRgb.ProcessIFCColourRgb(surfaceColour);
            }

            if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcSurfaceStyleRendering))
            {
                Transparency = IFCImportHandleUtil.GetOptionalNormalisedRatioAttribute(item, "Transparency", 0.0);

                IFCData diffuseColour = item.GetAttribute("DiffuseColour");
                if (diffuseColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                {
                    m_DiffuseColour = IFCColourRgb.ProcessIFCColourRgb(diffuseColour.AsInstance());
                }
                else if (diffuseColour.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    m_DiffuseColourFactor = diffuseColour.AsDouble();
                }

                IFCData transmissionColour = item.GetAttribute("TransmissionColour");
                if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                {
                    m_TransmissionColour = IFCColourRgb.ProcessIFCColourRgb(transmissionColour.AsInstance());
                }
                else if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    m_TransmissionColourFactor = transmissionColour.AsDouble();
                }

                IFCData diffuseTransmissionColour = item.GetAttribute("DiffuseTransmissionColour");
                if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                {
                    m_DiffuseTransmissionColour = IFCColourRgb.ProcessIFCColourRgb(diffuseTransmissionColour.AsInstance());
                }
                else if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    m_DiffuseTransmissionColourFactor = diffuseTransmissionColour.AsDouble();
                }

                IFCData reflectionColour = item.GetAttribute("ReflectionColour");
                if (reflectionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                {
                    m_ReflectionColour = IFCColourRgb.ProcessIFCColourRgb(reflectionColour.AsInstance());
                }
                else if (reflectionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    m_ReflectionColourFactor = reflectionColour.AsDouble();
                }

                IFCData specularColour = item.GetAttribute("SpecularColour");
                if (specularColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                {
                    m_SpecularColour = IFCColourRgb.ProcessIFCColourRgb(specularColour.AsInstance());
                }
                else if (specularColour.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    m_SpecularColourFactor = specularColour.AsDouble();
                }

                IFCData specularHighlight = item.GetAttribute("SpecularHighlight");
                if (specularHighlight.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    try
                    {
                        string simpleType = specularHighlight.GetSimpleType();
                        if (string.Compare(simpleType, "IfcSpecularExponent", true) == 0)
                        {
                            m_SpecularExponent = specularHighlight.AsDouble();
                        }
                        else if (string.Compare(simpleType, "IfcSpecularRoughness", true) == 0)
                        {
                            m_SpecularRoughness = specularHighlight.AsDouble();
                        }
                        else
                        {
                            Importer.TheLog.LogError(item.StepId, "Unknown type of specular highlight, ignoring.", false);
                        }
                    }
                    catch
                    {
                        Importer.TheLog.LogError(item.StepId, "Unspecified type of specular highlight, ignoring.", false);
                    }
                }
                else if (specularHighlight.HasValue)
                {
                    Importer.TheLog.LogError(item.StepId, "Unknown type of specular highlight, ignoring.", false);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets the unit type from an IFC data.
        /// </summary>
        /// <param name="data">The IFC data.</param>
        /// <param name="defaultType">The default value, if no type is found.</param>
        /// <param name="propertyType">The string value of the simple type, returned for logging purposes.</param>
        /// <returns>The unit type.</returns>
        public static UnitType GetUnitTypeFromData(IFCData data, UnitType defaultType, out string propertyType)
        {
            UnitType unitType = UnitType.UT_Undefined;

            if (data.HasSimpleType())
            {
                propertyType = data.GetSimpleType();
                if (!MeasureCache.TryGetValue(propertyType, out unitType))
                    unitType = defaultType;
            }
            else
            {
                propertyType = "";
                unitType = defaultType;
            }

            return unitType;
        }