Exemplo n.º 1
0
        public static IFCMaterialProfileWithOffsets ProcessIFCMaterialProfileWithOffsets(IFCAnyHandle ifcMaterialProfileWithOffsets)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialProfileWithOffsets))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcMaterialProfileWithOffsets);
                return(null);
            }

            IFCEntity materialProfileWithOffsets;

            if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcMaterialProfileWithOffsets.StepId, out materialProfileWithOffsets))
            {
                materialProfileWithOffsets = new IFCMaterialProfileWithOffsets(ifcMaterialProfileWithOffsets);
            }
            return(materialProfileWithOffsets as IFCMaterialProfileWithOffsets);
        }
Exemplo n.º 2
0
        protected override void Process(IFCAnyHandle ifcMaterialProfileSet)
        {
            base.Process(ifcMaterialProfileSet);

            IList <IFCAnyHandle> ifcMaterialProfiles =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcMaterialProfileSet, "MaterialProfiles");

            if (ifcMaterialProfiles == null)
            {
                Importer.TheLog.LogError(ifcMaterialProfileSet.Id, "Expected at least 1 MaterialProfile, found none.", false);
                return;
            }

            foreach (IFCAnyHandle ifcMaterialProfile in ifcMaterialProfiles)
            {
                IFCMaterialProfile materialProfile = null;
                if (IFCAnyHandleUtil.IsTypeOf(ifcMaterialProfile, IFCEntityType.IfcMaterialProfileWithOffsets))
                {
                    materialProfile = IFCMaterialProfileWithOffsets.ProcessIFCMaterialProfileWithOffsets(ifcMaterialProfile);
                }
                else
                {
                    materialProfile = IFCMaterialProfile.ProcessIFCMaterialProfile(ifcMaterialProfile);
                }

                if (materialProfile != null)
                {
                    MaterialProfileSet.Add(materialProfile);
                }
            }

            Name        = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialProfileSet, "Name", null);
            Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialProfileSet, "Description", null);
            IFCAnyHandle compositeProfileHnd = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcMaterialProfileSet, "CompositeProfile");

            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(compositeProfileHnd))
            {
                CompositeProfile = IFCCompositeProfile.ProcessIFCCompositeProfile(compositeProfileHnd);
            }
        }
        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);
        }