/// <summary> /// Gets representation of a product handle. /// </summary> /// <param name="productHandle">The product handle.</param> /// <returns>The representation handle.</returns> public static IFCAnyHandle GetRepresentation(IFCAnyHandle productHandle) { if (productHandle == null) { throw new ArgumentNullException("productHandle"); } if (!productHandle.HasValue) { throw new ArgumentException("Invalid handle."); } if (!IsSubTypeOf(productHandle, IFCEntityType.IfcProduct)) { throw new ArgumentException("The operation is not valid for this handle."); } IFCData ifcData = productHandle.GetAttribute("Representation"); if (ifcData.PrimitiveType == IFCDataPrimitiveType.Instance) { return(ifcData.AsInstance()); } return(null); }
/// <summary> /// Gets ContextOfItems of a representation handle. /// </summary> /// <param name="representation">The representation.</param> /// <returns>The ContextOfItems handle.</returns> public static IFCAnyHandle GetContextOfItems(IFCAnyHandle representation) { if (representation == null) { throw new ArgumentNullException("representation"); } if (!representation.HasValue) { throw new ArgumentException("Invalid handle."); } if (!IsSubTypeOf(representation, IFCEntityType.IfcRepresentation)) { throw new ArgumentException("The operation is not valid for this handle."); } IFCData ifcData = representation.GetAttribute("ContextOfItems"); if (ifcData.PrimitiveType == IFCDataPrimitiveType.Instance) { return(ifcData.AsInstance()); } return(null); }
/// <summary> /// Gets an arbitrary instance attribute. /// </summary> /// <param name="name">The handle.</param> /// <param name="name">The attribute name.</param> /// <returns>The handle to the attribute.</returns> public static IFCAnyHandle GetInstanceAttribute(IFCAnyHandle hnd, string name) { if (hnd == null) { throw new ArgumentNullException("hnd"); } if (!hnd.HasValue) { throw new ArgumentException("Invalid handle."); } IFCData ifcData = hnd.GetAttribute(name); if (ifcData.PrimitiveType == IFCDataPrimitiveType.Instance) { return(ifcData.AsInstance()); } return(null); }
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); } } }