Beispiel #1
0
        public static IFCAnyHandle GetOrCreateMaterialConstituentSet(IFCFile file, IFCAnyHandle instanceHandle, HashSet <IFCAnyHandle> constituentSet)
        {
            IFCAnyHandle constituentSetHnd = ExporterCacheManager.MaterialConstituentSetCache.Find(constituentSet);

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(constituentSetHnd))
            {
                constituentSetHnd = IFCInstanceExporter.CreateMaterialConstituentSet(file, constituentSet, name: "MaterialConstituentSet");
                ExporterCacheManager.MaterialConstituentSetCache.Register(constituentSet, constituentSetHnd);

                ElementId elementId = ElementId.InvalidElementId;
                if (IFCAnyHandleUtil.IsSubTypeOf(instanceHandle, IFCEntityType.IfcProduct))
                {
                    elementId = ExporterCacheManager.HandleToElementCache.Find(instanceHandle);
                }
                else if (IFCAnyHandleUtil.IsSubTypeOf(instanceHandle, IFCEntityType.IfcTypeProduct))
                {
                    ElementTypeKey eTypeKey = ExporterCacheManager.ElementTypeToHandleCache.Find(instanceHandle);
                    if (eTypeKey != null)
                    {
                        elementId = eTypeKey.Item1.Id;
                    }
                }

                if (elementId != ElementId.InvalidElementId)
                {
                    ExporterCacheManager.MaterialSetCache.RegisterConstituentSetHnd(elementId, constituentSetHnd);
                }
            }

            return(constituentSetHnd);
        }
        /// <summary>
        /// Finds the handle from the dictionary.
        /// </summary>
        /// <param name="elementId">
        /// The element elementId.
        /// </param>
        /// <returns>
        /// The handle.
        /// </returns>
        public IFCAnyHandle Find(ElementType elementType, IFCExportInfoPair exportType)
        {
            IFCAnyHandle handle;
            var          key = new ElementTypeKey(elementType, exportType.ExportType, exportType.ValidatedPredefinedType);

            if (m_ElementTypeToHandleDictionary.TryGetValue(key, out handle))
            {
                return(handle);
            }
            return(null);
        }
        /// <summary>
        /// Adds the handle to the dictionary.
        /// </summary>
        /// <param name="elementId">
        /// The element elementId.
        /// </param>
        /// <param name="handle">
        /// The handle.
        /// </param>
        public void Register(ElementType elementType, IFCExportInfoPair exportType, IFCAnyHandle handle)
        {
            var key = new ElementTypeKey(elementType, exportType.ExportType, exportType.ValidatedPredefinedType);

            if (m_ElementTypeToHandleDictionary.ContainsKey(key))
            {
                return;
            }

            m_ElementTypeToHandleDictionary[key] = handle;
            m_RegisteredElementType.Add(key.Item1);
        }