override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(item);

            List<IFCAnyHandle> styledByItems = IFCAnyHandleUtil.GetAggregateInstanceAttribute<List<IFCAnyHandle>>(item, "StyledByItem");
            if (styledByItems != null && styledByItems.Count > 0)
            {
                // We can only handle one styled item, but we allow the possiblity that there are duplicates.  Do a top-level check.
                foreach (IFCAnyHandle styledByItem in styledByItems)
                {
                    if (!IFCAnyHandleUtil.IsSubTypeOf(styledByItem, IFCEntityType.IfcStyledItem))
                    {
                        Importer.TheLog.LogUnexpectedTypeError(styledByItem, IFCEntityType.IfcStyledItem, false);
                        StyledByItem = null;
                        break;
                    }
                    else
                    {
                        if (StyledByItem == null)
                            StyledByItem = IFCStyledItem.ProcessIFCStyledItem(styledByItem);
                        else
                        {
                            IFCStyledItem compStyledByItem = IFCStyledItem.ProcessIFCStyledItem(styledByItem);
                            if (!StyledByItem.IsEquivalentTo(compStyledByItem))
                            {
                                Importer.TheLog.LogWarning(Id, "Multiple inconsistent styled items found for this item; using first one.", false);
                                break;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Check if two IFCPresentationLayerAssignments are equivalent, and warn if they aren't/
        /// </summary>
        /// <param name="originalAssignment">The original layer assignment in this representation.</param>
        /// <param name="layerAssignment">The layer assignment to add to this representation.</param>
        /// <returns>True if the layer assignments are consistent; false otherwise.</returns>
        static public bool CheckLayerAssignmentConsistency(IFCPresentationLayerAssignment originalAssignment, 
            IFCPresentationLayerAssignment layerAssignment, int id)
        {
            if ((originalAssignment != null) && (!originalAssignment.IsEquivalentTo(layerAssignment)))
            {
                Importer.TheLog.LogWarning(id, "Multiple inconsistent layer assignment items found for this item; using first one.", false);
                return false;
            }

            return true;
        }
 /// <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);
 }
            /// <summary>
            /// The constructor.
            /// </summary>
            /// <param name="scope">The associated shape edit scope.</param>
            /// <param name="item">The current styled item.</param>
            public IFCMaterialStack(IFCImportShapeEditScope scope, IFCStyledItem styledItem, IFCPresentationLayerAssignment layerAssignment)
            {
                m_Scope = scope;
                if (styledItem != null)
                    m_MaterialElementId = styledItem.GetMaterialElementId(scope);
                else if (layerAssignment != null)
                    m_MaterialElementId = layerAssignment.GetMaterialElementId(scope);

                if (m_MaterialElementId != ElementId.InvalidElementId)
                    m_Scope.PushMaterialId(m_MaterialElementId);
            }
Example #5
0
        /// <summary>
        /// Processes IfcRepresentation attributes.
        /// </summary>
        /// <param name="ifcRepresentation">The IfcRepresentation handle.</param>
        override protected void Process(IFCAnyHandle ifcRepresentation)
        {
            base.Process(ifcRepresentation);

            IFCAnyHandle representationContext = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentation, "ContextOfItems", false);
            if (representationContext != null)
                Context = IFCRepresentationContext.ProcessIFCRepresentationContext(representationContext);

            string identifier = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentation, "RepresentationIdentifier", null);
            Identifier = GetRepresentationIdentifier(identifier, ifcRepresentation);
            
            // Don't read in Box represenation unless options allow it.
            bool isBoundingBox = (Identifier == IFCRepresentationIdentifier.Box);
            if (isBoundingBox && !IFCImportFile.TheFile.Options.ProcessBoundingBoxGeometry)
                throw new InvalidOperationException("BoundingBox not imported with ProcessBoundingBoxGeometry=false");

            Type = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentation, "RepresentationType", null);

            HashSet<IFCAnyHandle> items =
                IFCAnyHandleUtil.GetAggregateInstanceAttribute<HashSet<IFCAnyHandle>>(ifcRepresentation, "Items");

            LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(ifcRepresentation);

            foreach (IFCAnyHandle item in items)
            {
                IFCRepresentationItem repItem = null;
                try
                {
                    if (NotAllowedInRepresentation(item))
                    {
                        IFCEntityType entityType = IFCAnyHandleUtil.GetEntityType(item);
                        IFCImportFile.TheLog.LogWarning(item.StepId, "Ignoring unhandled representation item of type " + entityType.ToString() + " in " +
                            Identifier.ToString() + " representation.", true);
                        continue;
                    }

                    // Special processing for bounding boxes - only IfcBoundingBox allowed.
                    if (isBoundingBox)
                    {
                        BoundingBox = ProcessBoundingBox(item);
                        if (BoundingBox != null)
                            break;
                    }
                    else
                        repItem = IFCRepresentationItem.ProcessIFCRepresentationItem(item);
                }
                catch (Exception ex)
                {
                    IFCImportFile.TheLog.LogError(item.StepId, ex.Message, false);
                }
                if (repItem != null)
                    RepresentationItems.Add(repItem);
            }
        }