예제 #1
0
        protected override void Process(IFCAnyHandle ifcMaterialProfileSetUsageTapering)
        {
            base.Process(ifcMaterialProfileSetUsageTapering);

            IFCAnyHandle ifcMaterialProfileSet = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialProfileSetUsageTapering, "ForProfileEndSet", true);

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialProfileSet))
            {
                ForProfileSet = IFCMaterialProfileSet.ProcessIFCMaterialProfileSet(ifcMaterialProfileSet);
            }

            bool found = false;

            CardinalPoint = IFCImportHandleUtil.GetOptionalIntegerAttribute(ifcMaterialProfileSetUsageTapering, "CardinalEndPoint", out found);
        }
예제 #2
0
        /// <summary>
        /// Processes an IFCMaterialProfileSet entity.
        /// </summary>
        /// <param name="IFCMaterialProfileSet">The IFCMaterialProfileSet handle.</param>
        /// <returns>The IFCMaterialProfileSet object.</returns>
        public static IFCMaterialProfileSet ProcessIFCMaterialProfileSet(IFCAnyHandle ifcMaterialProfileSet)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialProfileSet))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcMaterialProfileSet);
                return(null);
            }

            IFCEntity materialProfileSet;

            if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcMaterialProfileSet.StepId, out materialProfileSet))
            {
                materialProfileSet = new IFCMaterialProfileSet(ifcMaterialProfileSet);
            }
            return(materialProfileSet as IFCMaterialProfileSet);
        }
예제 #3
0
        /// <summary>
        /// Processes IfcRelAssociatesMaterial.
        /// </summary>
        /// <param name="ifcRelAssociatesMaterial">The IfcRelAssociatesMaterial handle.</param>
        void ProcessIFCRelAssociatesMaterial(IFCAnyHandle ifcRelAssociatesMaterial)
        {
            IFCAnyHandle ifcMaterialSelect = IFCAnyHandleUtil.GetInstanceAttribute(ifcRelAssociatesMaterial, "RelatingMaterial");

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialSelect))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcRelAssociatesMaterial);
                return;
            }

            // Deal with various types of IFCMaterialSelect.
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterial))
            {
                MaterialSelect = IFCMaterial.ProcessIFCMaterial(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayer))
            {
                MaterialSelect = IFCMaterialLayer.ProcessIFCMaterialLayer(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayerSet))
            {
                MaterialSelect = IFCMaterialLayerSet.ProcessIFCMaterialLayerSet(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialLayerSetUsage))
            {
                MaterialSelect = IFCMaterialLayerSetUsage.ProcessIFCMaterialLayerSetUsage(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialList))
            {
                MaterialSelect = IFCMaterialList.ProcessIFCMaterialList(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialProfile))
            {
                MaterialSelect = IFCMaterialProfile.ProcessIFCMaterialProfile(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialProfileSet))
            {
                MaterialSelect = IFCMaterialProfileSet.ProcessIFCMaterialProfileSet(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialProfileSetUsage))
            {
                if (IFCAnyHandleUtil.IsTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialProfileSetUsageTapering))
                {
                    MaterialSelect = IFCMaterialProfileSetUsageTapering.ProcessIFCMaterialProfileSetUsageTapering(ifcMaterialSelect);
                }
                else
                {
                    MaterialSelect = IFCMaterialProfileSetUsage.ProcessIFCMaterialProfileSetUsage(ifcMaterialSelect);
                }
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialConstituent))
            {
                MaterialSelect = IFCMaterialConstituent.ProcessIFCMaterialConstituent(ifcMaterialSelect);
            }
            else if (IFCAnyHandleUtil.IsSubTypeOf(ifcMaterialSelect, IFCEntityType.IfcMaterialConstituentSet))
            {
                MaterialSelect = IFCMaterialConstituentSet.ProcessIFCMaterialConstituentSet(ifcMaterialSelect);
            }
            else
            {
                Importer.TheLog.LogUnhandledSubTypeError(ifcMaterialSelect, "IfcMaterialSelect", false);
            }
        }
예제 #4
0
        /// <summary>
        /// Return the materials' names and thicknesses if the object is created with IFCMaterialLayerSetUsage information.
        /// The thickness is returned as a string followed by its unit
        /// If the object is not created with IFCMaterialLayerSetUsage information, then only the materials' names are returned
        /// </summary>
        /// <returns>A list in which each entry is the material's names followed by their thicknesses if the thicknesses are available</returns>
        public IList <string> GetMaterialsNamesAndThicknesses()
        {
            IList <string> result = new List <string>();

            string thickness = null;
            string name      = null;

            // If this object is created with IFCMaterialLayerSetUsage information
            // then the material layer thickness will be added after the name of each layer.
            if (MaterialSelect is IFCMaterialLayerSetUsage)
            {
                IFCMaterialLayerSet      materialLayerSet = (MaterialSelect as IFCMaterialLayerSetUsage).MaterialLayerSet;
                IList <IFCMaterialLayer> materialLayers;
                IFCMaterial material;

                if (materialLayerSet != null)
                {
                    materialLayers = materialLayerSet.MaterialLayers;
                }
                else
                {
                    materialLayers = new List <IFCMaterialLayer>();
                }

                foreach (IFCMaterialLayer materialLayer in materialLayers)
                {
                    if (materialLayer == null)
                    {
                        continue;
                    }
                    material = materialLayer.Material;
                    if (material == null || string.IsNullOrWhiteSpace(material.Name))
                    {
                        continue;
                    }
                    name      = material.Name;
                    thickness = IFCUnitUtil.FormatLengthAsString(materialLayer.LayerThickness);
                    result.Add(name + ": " + thickness);
                }
            }
            else if (MaterialSelect is IFCMaterialProfileSetUsage)
            {
                IFCMaterialProfileSet      materialProfileSet = (MaterialSelect as IFCMaterialProfileSetUsage).ForProfileSet;
                IList <IFCMaterialProfile> materialProfiles;
                IFCMaterial material;

                if (materialProfileSet != null)
                {
                    materialProfiles = materialProfileSet.MaterialProfileSet;
                }
                else
                {
                    materialProfiles = new List <IFCMaterialProfile>();
                }

                foreach (IFCMaterialProfile materialProfile in materialProfiles)
                {
                    if (materialProfile == null)
                    {
                        continue; // Skip if it is null
                    }
                    material = materialProfile.Material;
                    IFCProfileDef profile = materialProfile.Profile;
                    if (material == null)
                    {
                        continue;
                    }
                    name = material.Name;
                    string profileName;
                    if (profile != null)
                    {
                        profileName = profile.ProfileName;
                    }
                    else
                    {
                        profileName = profile.ProfileType.ToString();
                    }
                    result.Add(name + " (" + profileName + ")");
                }
            }
            else
            {
                IList <IFCMaterial> materials = GetMaterials();
                foreach (IFCMaterial material in materials)
                {
                    name = material.Name;
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        continue;
                    }

                    result.Add(name);
                }
            }

            return(result);
        }
        private GeometryObject CreateGeometryFromMateriaProfile(IFCImportShapeEditScope shapeEditScope,
                                                                IList <CurveLoop> loops, XYZ extrusionDirection, double currDepth, SolidOptions solidOptions, out bool shouldWarn)
        {
            GeometryObject extrusionSolid = null;

            try
            {
                shouldWarn = true; // invalid input

                IIFCMaterialSelect materialSelect = shapeEditScope.Creator.MaterialSelect;
                if (materialSelect == null)
                {
                    return(null);
                }

                IFCMaterialProfileSetUsage matProfSetUsage = materialSelect as IFCMaterialProfileSetUsage;
                if (matProfSetUsage == null)
                {
                    return(null);
                }

                IFCMaterialProfileSet matProfSet = matProfSetUsage.ForProfileSet;
                if (matProfSet == null)
                {
                    return(null);
                }

                IList <IFCMaterialProfile> matProfList = matProfSet.MaterialProfileSet;
                if (matProfList.Count == 0)
                {
                    return(null);
                }

                Transform         transformByOffset = Transform.Identity;
                IList <CurveLoop> newloops          = new List <CurveLoop>();

                ElementId materialId = null;
                foreach (IFCMaterialProfile matProf in matProfList)
                {
                    if (this.SweptArea.Id == matProf.Profile.Id)
                    {
                        // This is the same id (same profile), use the material name for creation of this geometry
                        IFCMaterial theMaterial = matProf.Material;
                        if (theMaterial != null)
                        {
                            materialId = theMaterial.GetMaterialElementId();
                            solidOptions.MaterialId = materialId; // Override the original option if the profile has a specific material id
                        }

                        // Here we will handle special case if the Material Profile has Offset
                        if (matProf is IFCMaterialProfileWithOffsets)
                        {
                            IFCMaterialProfileWithOffsets matProfOffset = matProf as IFCMaterialProfileWithOffsets;
                            double startOffset = matProfOffset.OffsetValues[0];
                            double endOffset   = 0;
                            if (matProfOffset.OffsetValues.Count > 1)
                            {
                                endOffset = matProfOffset.OffsetValues[1];
                            }

                            // To handle offset, we need to move the start point (extrusion position) to the startOffset value along the axis (extrusion direction)
                            // For the end offset, we will have to re-calculate the extrusion
                            currDepth = currDepth - startOffset + endOffset;
                            transformByOffset.Origin += startOffset * extrusionDirection;
                            foreach (CurveLoop loop in loops)
                            {
                                CurveLoop newLoop = CurveLoop.CreateViaTransform(loop, transformByOffset);
                                newloops.Add(newLoop);
                            }
                        }
                        break;
                    }
                }

                if (newloops.Count == 0)
                {
                    extrusionSolid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, extrusionDirection, currDepth, solidOptions);
                }
                else
                {
                    extrusionSolid = GeometryCreationUtilities.CreateExtrusionGeometry(newloops, extrusionDirection, currDepth, solidOptions);
                }
            }
            catch
            {
                // Ignore the specific exception, but let the user know there was a problem processing the IfcMaterialLayerSetUsage.
                shouldWarn = true;
                return(null);
            }

            return(extrusionSolid);
        }