static IfcMaterial extractMaterial(IfcMaterialSelect materialSelect)         //To be enabled in opensource Library
        {
            IfcMaterial material = materialSelect as IfcMaterial;

            if (material != null)
            {
                return(material);
            }
            IfcMaterialProfile profile = materialSelect as IfcMaterialProfile;

            if (profile != null)
            {
                return(profile.Material);
            }
            IfcMaterialProfileSet profileSet = materialSelect as IfcMaterialProfileSet;

            if (profileSet == null)
            {
                IfcMaterialProfileSetUsage profileUsage = materialSelect as IfcMaterialProfileSetUsage;
                if (profileUsage != null)
                {
                    profileSet = profileUsage.ForProfileSet;
                }
            }
            if (profileSet != null)
            {
                return(profileSet.PrimaryMaterial());
            }
            IfcMaterialLayer layer = materialSelect as IfcMaterialLayer;

            if (layer != null)
            {
                return(layer.Material);
            }
            IfcMaterialLayerSet layerSet = materialSelect as IfcMaterialLayerSet;

            if (layerSet != null)
            {
                return(layerSet.PrimaryMaterial());
            }
            IfcMaterialLayerSetUsage layerSetUsage = materialSelect as IfcMaterialLayerSetUsage;

            if (layerSetUsage != null)
            {
                return(layerSetUsage.PrimaryMaterial());
            }
            IfcMaterialList list = materialSelect as IfcMaterialList;

            if (list != null)
            {
                return(list.PrimaryMaterial());
            }
            IfcMaterialConstituent constituent = materialSelect as IfcMaterialConstituent;

            if (constituent != null)
            {
                return(constituent.PrimaryMaterial());
            }
            IfcMaterialConstituentSet constituentSet = materialSelect as IfcMaterialConstituentSet;

            if (constituentSet != null)
            {
                return(constituentSet.PrimaryMaterial());
            }
            return(null);
        }