Exemplo n.º 1
0
        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            NormalisedRed   = IFCImportHandleUtil.GetOptionalNormalisedRatioAttribute(item, "Red", 0.5);
            NormalisedGreen = IFCImportHandleUtil.GetOptionalNormalisedRatioAttribute(item, "Green", 0.5);
            NormalisedBlue  = IFCImportHandleUtil.GetOptionalNormalisedRatioAttribute(item, "Blue", 0.5);
        }
        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);
                }
            }
        }