コード例 #1
0
 /// <summary>
 /// Deal with missing "LayerAssignments" in IFC2x3 EXP file.
 /// </summary>
 /// <param name="layerAssignment">The layer assignment to add to this representation.</param>
 public void PostProcessLayerAssignment(IFCPresentationLayerAssignment layerAssignment)
 {
     if (LayerAssignment == null)
     {
         LayerAssignment = layerAssignment;
     }
     else
     {
         IFCImportDataUtil.CheckLayerAssignmentConsistency(LayerAssignment, layerAssignment, Id);
     }
 }
コード例 #2
0
        /// <summary>
        /// Get the one layer assignment associated to this handle, if it is defined.
        /// </summary>
        /// <param name="ifcLayeredItem">The handle assumed to be an IfcRepresentation or IfcRepresentationItem.</param>
        /// <param name="isIFCRepresentation">True if the handle is an IfcRepresentation.  This determines the name of the inverse attribute.</param>
        /// <returns>The associated IfcLayerAssignment.</returns>
        /// <remarks>This deals with the issues that:
        /// 1. the default IFC2x3 EXP file doesn't have this inverse attribute set.
        /// 2. The name changed in IFC4.
        /// 3. The attribute didn't exist before IFC2x3.</remarks>
        static public IFCPresentationLayerAssignment GetTheLayerAssignment(IFCAnyHandle ifcLayeredItem, bool isIFCRepresentation)
        {
            IFCPresentationLayerAssignment theLayerAssignment = null;
            IList <IFCAnyHandle>           layerAssignments   = null;

            if (IFCImportFile.TheFile.Options.AllowUseLayerAssignments)
            {
                // Inverse attribute changed names in IFC4 for IfcRepresentationItem only.
                string layerAssignmentsAttributeName = (isIFCRepresentation || IFCImportFile.TheFile.SchemaVersion < IFCSchemaVersion.IFC4) ? "LayerAssignments" : "LayerAssignment";
                try
                {
                    layerAssignments = IFCAnyHandleUtil.GetAggregateInstanceAttribute
                                       <List <IFCAnyHandle> >(ifcLayeredItem, layerAssignmentsAttributeName);
                }
                catch
                {
                    IFCImportFile.TheFile.Options.AllowUseLayerAssignments = false;
                    layerAssignments = null;
                }
            }

            if (layerAssignments != null && layerAssignments.Count > 0)
            {
                // We can only handle one layer assignment, but we allow the possiblity that there are duplicates.  Do a top-level check.
                foreach (IFCAnyHandle layerAssignment in layerAssignments)
                {
                    if (!IFCAnyHandleUtil.IsSubTypeOf(layerAssignment, IFCEntityType.IfcPresentationLayerAssignment))
                    {
                        Importer.TheLog.LogUnexpectedTypeError(layerAssignment, IFCEntityType.IfcStyledItem, false);
                        theLayerAssignment = null;
                        break;
                    }
                    else
                    {
                        IFCPresentationLayerAssignment compLayerAssignment = IFCPresentationLayerAssignment.ProcessIFCPresentationLayerAssignment(layerAssignment);
                        if (theLayerAssignment == null)
                        {
                            theLayerAssignment = compLayerAssignment;
                            continue;
                        }

                        if (!IFCImportDataUtil.CheckLayerAssignmentConsistency(theLayerAssignment, compLayerAssignment, ifcLayeredItem.StepId))
                        {
                            break;
                        }
                    }
                }
            }

            return(theLayerAssignment);
        }