Beispiel #1
0
        /// <summary>
        /// Does a top-level check to see if this styled item may be equivalent to another styled item.
        /// </summary>
        /// <param name="otherEntity">The other styled item.</param>
        /// <returns>False if they don't have the same handles, null otherwise.</returns>
        public override bool?MaybeEquivalentTo(IFCEntity otherEntity)
        {
            bool?maybeEquivalentTo = base.MaybeEquivalentTo(otherEntity);

            if (maybeEquivalentTo.HasValue)
            {
                return(maybeEquivalentTo.Value);
            }

            if (!(otherEntity is IFCStyledItem))
            {
                return(false);
            }

            IFCStyledItem other = otherEntity as IFCStyledItem;

            if (!IFCRoot.Equals(Item, other.Item))
            {
                return(false);
            }

            if (!IFCRoot.Equals(Styles, other.Styles))
            {
                return(false);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Does a top-level check to see if this styled item may be equivalent to another styled item.
        /// </summary>
        /// <param name="otherEntity">The other styled item.</param>
        /// <returns>False if they don't have the same handles, null otherwise.</returns>
        public override bool?MaybeEquivalentTo(IFCEntity otherEntity)
        {
            bool?maybeEquivalentTo = base.MaybeEquivalentTo(otherEntity);

            if (maybeEquivalentTo.HasValue)
            {
                return(maybeEquivalentTo.Value);
            }

            if (!(otherEntity is IFCStyledItem))
            {
                return(false);
            }

            IFCStyledItem other = otherEntity as IFCStyledItem;

            if (!Equals(Item, other.Item))
            {
                return(false);
            }

            IList <IFCPresentationStyle> otherStyles = other.Styles;

            if (Styles == null && otherStyles == null)
            {
                return(null);
            }

            // If only one is null, they are not equal.
            if (Styles == null || otherStyles == null)
            {
                return(false);
            }

            int thisCount  = Styles.Count;
            int otherCount = otherStyles.Count;

            if (thisCount != otherCount)
            {
                return(false);
            }

            // This could miss the case where the styles are the same but in different
            // orders.  At the moment, that would just lead to a spurious warning.
            for (int ii = 0; ii < thisCount; ii++)
            {
                if (!Equals(Styles[ii], otherStyles[ii]))
                {
                    return(false);
                }
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Processes an IfcRepresentationItem entity handle.
        /// </summary>
        /// <param name="ifcRepresentationItem">The IfcRepresentationItem handle.</param>
        /// <returns>The IFCRepresentationItem object.</returns>
        public static IFCRepresentationItem ProcessIFCRepresentationItem(IFCAnyHandle ifcRepresentationItem)
        {
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcBooleanResult))
            {
                return(IFCBooleanResult.ProcessIFCBooleanResult(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcCurve))
            {
                return(IFCCurve.ProcessIFCCurve(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcFaceBasedSurfaceModel))
            {
                return(IFCFaceBasedSurfaceModel.ProcessIFCFaceBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcGeometricSet))
            {
                return(IFCGeometricSet.ProcessIFCGeometricSet(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcMappedItem))
            {
                return(IFCMappedItem.ProcessIFCMappedItem(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcShellBasedSurfaceModel))
            {
                return(IFCShellBasedSurfaceModel.ProcessIFCShellBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcSolidModel))
            {
                return(IFCSolidModel.ProcessIFCSolidModel(ifcRepresentationItem));
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x2 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcStyledItem))
            {
                return(IFCStyledItem.ProcessIFCStyledItem(ifcRepresentationItem));
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC4 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTriangulatedFaceSet))
            {
                return(IFCTriangulatedFaceSet.ProcessIFCTriangulatedFaceSet(ifcRepresentationItem));
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC4Add2 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcPolygonalFaceSet))
            {
                return(IFCPolygonalFaceSet.ProcessIFCPolygonalFaceSet(ifcRepresentationItem));
            }

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTopologicalRepresentationItem))
            {
                return(IFCTopologicalRepresentationItem.ProcessIFCTopologicalRepresentationItem(ifcRepresentationItem));
            }

            Importer.TheLog.LogUnhandledSubTypeError(ifcRepresentationItem, IFCEntityType.IfcRepresentationItem, true);
            return(null);
        }
Beispiel #4
0
        /// <summary>
        /// Processes an IfcStyledItem entity handle.
        /// </summary>
        /// <param name="ifcStyledItem">The IfcStyledItem handle.</param>
        /// <returns>The IFCStyledItem object.</returns>
        public static IFCStyledItem ProcessIFCStyledItem(IFCAnyHandle ifcStyledItem)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcStyledItem))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcStyledItem);
                return(null);
            }

            IFCEntity styledItem;

            if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcStyledItem.StepId, out styledItem))
            {
                styledItem = new IFCStyledItem(ifcStyledItem);
            }
            return(styledItem as IFCStyledItem);
        }
        /// <summary>
        /// Gets the IFCSurfaceStyle, if available, for an associated material.
        /// TODO: Make this generic, add warnings.
        /// </summary>
        /// <returns>The IFCSurfaceStyle.</returns>
        public IFCSurfaceStyle GetSurfaceStyle()
        {
            IList <IFCRepresentation> representations = Representations;

            if (representations != null && representations.Count > 0)
            {
                IFCRepresentation             representation      = representations[0];
                IList <IFCRepresentationItem> representationItems = representation.RepresentationItems;
                if (representationItems != null && representationItems.Count > 0 && (representationItems[0] is IFCStyledItem))
                {
                    IFCStyledItem styledItem = representationItems[0] as IFCStyledItem;
                    return(styledItem.GetSurfaceStyle());
                }
            }

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

            LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(item);

            // IFC2x has a different representation for styled items which we don't support.
            ICollection <IFCAnyHandle> styledByItems = null;

            if (Importer.TheCache.StyledByItems.TryGetValue(item, out styledByItems))
            {
                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>
        /// Processes an IfcRepresentationItem entity handle.
        /// </summary>
        /// <param name="ifcRepresentationItem">The IfcRepresentationItem handle.</param>
        /// <returns>The IFCRepresentationItem object.</returns>
        public static IFCRepresentationItem ProcessIFCRepresentationItem(IFCAnyHandle ifcRepresentationItem)
        {
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcBooleanResult))
            {
                return(IFCBooleanResult.ProcessIFCBooleanResult(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcConnectedFaceSet))
            {
                return(IFCConnectedFaceSet.ProcessIFCConnectedFaceSet(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcCurve))
            {
                return(IFCCurve.ProcessIFCCurve(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcFaceBasedSurfaceModel))
            {
                return(IFCFaceBasedSurfaceModel.ProcessIFCFaceBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcGeometricSet))
            {
                return(IFCGeometricSet.ProcessIFCGeometricSet(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcMappedItem))
            {
                return(IFCMappedItem.ProcessIFCMappedItem(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcShellBasedSurfaceModel))
            {
                return(IFCShellBasedSurfaceModel.ProcessIFCShellBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcSolidModel))
            {
                return(IFCSolidModel.ProcessIFCSolidModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcStyledItem))
            {
                return(IFCStyledItem.ProcessIFCStyledItem(ifcRepresentationItem));
            }

            IFCImportFile.TheLog.LogUnhandledSubTypeError(ifcRepresentationItem, IFCEntityType.IfcRepresentationItem, true);
            return(null);
        }
        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(item, false);

            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>
        /// Return geometry for a particular representation item.
        /// </summary>
        /// <param name="shapeEditScope">The geometry creation scope.</param>
        /// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
        /// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
        /// <param name="guid">The guid of an element for which represntation is being created.</param>
        /// <returns>The created geometry.</returns>
        public IList <GeometryObject> CreateGeometry(
            IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
        {
            IList <GeometryObject> firstSolids = FirstOperand.CreateGeometry(shapeEditScope, lcs, scaledLcs, guid);

            if (firstSolids != null)
            {
                foreach (GeometryObject potentialSolid in firstSolids)
                {
                    if (!(potentialSolid is Solid))
                    {
                        Importer.TheLog.LogError((FirstOperand as IFCRepresentationItem).Id, "Can't perform Boolean operation on a Mesh.", false);
                        return(firstSolids);
                    }
                }
            }

            IList <GeometryObject> secondSolids = null;

            if (SecondOperand != null)
            {
                try
                {
                    using (IFCImportShapeEditScope.BuildPreferenceSetter setter =
                               new IFCImportShapeEditScope.BuildPreferenceSetter(shapeEditScope, IFCImportShapeEditScope.BuildPreferenceType.ForceSolid))
                    {
                        // Before we process the second operand, we are going to see if there is a uniform material set for the first operand
                        // (corresponding to the solid in the Boolean operation).  We will try to suggest the same material for the voids to avoid arbitrary
                        // setting of material information for the cut faces.
                        IFCStyledItem firstOperandStyledItem = GetStyledItemFromOperand(FirstOperand as IFCRepresentationItem);
                        using (IFCImportShapeEditScope.IFCMaterialStack stack =
                                   new IFCImportShapeEditScope.IFCMaterialStack(shapeEditScope, firstOperandStyledItem, null))
                        {
                            secondSolids = SecondOperand.CreateGeometry(shapeEditScope, lcs, scaledLcs, guid);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // We will allow something to be imported, in the case where the second operand is invalid.
                    // If the first (base) operand is invalid, we will still fail the import of this solid.
                    if (SecondOperand is IFCRepresentationItem)
                    {
                        Importer.TheLog.LogError((SecondOperand as IFCRepresentationItem).Id, ex.Message, false);
                    }
                    else
                    {
                        throw ex;
                    }
                    secondSolids = null;
                }
            }

            IList <GeometryObject> resultSolids = null;

            if (firstSolids == null)
            {
                resultSolids = secondSolids;
            }
            else if (secondSolids == null || BooleanOperator == null)
            {
                if (BooleanOperator == null)
                {
                    Importer.TheLog.LogError(Id, "Invalid BooleanOperationsType.", false);
                }
                resultSolids = firstSolids;
            }
            else
            {
                BooleanOperationsType booleanOperationsType = BooleanOperationsType.Difference;
                switch (BooleanOperator)
                {
                case IFCBooleanOperator.Difference:
                    booleanOperationsType = BooleanOperationsType.Difference;
                    break;

                case IFCBooleanOperator.Intersection:
                    booleanOperationsType = BooleanOperationsType.Intersect;
                    break;

                case IFCBooleanOperator.Union:
                    booleanOperationsType = BooleanOperationsType.Union;
                    break;

                default:
                    Importer.TheLog.LogError(Id, "Invalid BooleanOperationsType.", true);
                    break;
                }

                resultSolids = new List <GeometryObject>();
                foreach (GeometryObject firstSolid in firstSolids)
                {
                    Solid resultSolid = (firstSolid as Solid);

                    int secondId = (SecondOperand == null) ? -1 : (SecondOperand as IFCRepresentationItem).Id;
                    XYZ suggestedShiftDirection = (SecondOperand == null) ? null : SecondOperand.GetSuggestedShiftDirection(lcs);
                    foreach (GeometryObject secondSolid in secondSolids)
                    {
                        resultSolid = IFCGeometryUtil.ExecuteSafeBooleanOperation(Id, secondId, resultSolid, secondSolid as Solid, booleanOperationsType, suggestedShiftDirection);
                        if (resultSolid == null)
                        {
                            break;
                        }
                    }

                    if (resultSolid != null)
                    {
                        resultSolids.Add(resultSolid);
                    }
                }
            }

            return(resultSolids);
        }
Beispiel #10
0
        /// <summary>
        /// Processes an IfcRepresentationItem entity handle.
        /// </summary>
        /// <param name="ifcRepresentationItem">The IfcRepresentationItem handle.</param>
        /// <returns>The IFCRepresentationItem object.</returns>
        public static IFCRepresentationItem ProcessIFCRepresentationItem(IFCAnyHandle ifcRepresentationItem)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcRepresentationItem))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcRepresentationItem);
                return(null);
            }

            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcBooleanResult))
            {
                return(IFCBooleanResult.ProcessIFCBooleanResult(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcCurve))
            {
                return(IFCCurve.ProcessIFCCurve(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcFaceBasedSurfaceModel))
            {
                return(IFCFaceBasedSurfaceModel.ProcessIFCFaceBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcGeometricSet))
            {
                return(IFCGeometricSet.ProcessIFCGeometricSet(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcMappedItem))
            {
                return(IFCMappedItem.ProcessIFCMappedItem(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcShellBasedSurfaceModel))
            {
                return(IFCShellBasedSurfaceModel.ProcessIFCShellBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcSolidModel))
            {
                return(IFCSolidModel.ProcessIFCSolidModel(ifcRepresentationItem));
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x2 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcStyledItem))
            {
                return(IFCStyledItem.ProcessIFCStyledItem(ifcRepresentationItem));
            }

            if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC4 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTriangulatedFaceSet))
            {
                return(IFCTriangulatedFaceSet.ProcessIFCTriangulatedFaceSet(ifcRepresentationItem));
            }

            // There is no way to actually determine an IFC4Add2 file vs. a "vanilla" IFC4 file, which is
            // obsolete.  The try/catch here allows us to read these obsolete files without crashing.
            try
            {
                if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC4 && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcPolygonalFaceSet))
                {
                    return(IFCPolygonalFaceSet.ProcessIFCPolygonalFaceSet(ifcRepresentationItem));
                }
            }
            catch
            {
            }

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTopologicalRepresentationItem))
            {
                return(IFCTopologicalRepresentationItem.ProcessIFCTopologicalRepresentationItem(ifcRepresentationItem));
            }

            Importer.TheLog.LogUnhandledSubTypeError(ifcRepresentationItem, IFCEntityType.IfcRepresentationItem, true);
            return(null);
        }
        /// <summary>
        /// Processes an IfcRepresentationItem entity handle.
        /// </summary>
        /// <param name="ifcRepresentationItem">The IfcRepresentationItem handle.</param>
        /// <returns>The IFCRepresentationItem object.</returns>
        public static IFCRepresentationItem ProcessIFCRepresentationItem(IFCAnyHandle ifcRepresentationItem)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcRepresentationItem))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcRepresentationItem);
                return(null);
            }

            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcMappedItem))
            {
                return(IFCMappedItem.ProcessIFCMappedItem(ifcRepresentationItem));
            }
            if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC2x2) && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcStyledItem))
            {
                return(IFCStyledItem.ProcessIFCStyledItem(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTopologicalRepresentationItem))
            {
                return(IFCTopologicalRepresentationItem.ProcessIFCTopologicalRepresentationItem(ifcRepresentationItem));
            }

            // TODO: Move everything below to IFCGeometricRepresentationItem, once it is created.
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcBooleanResult))
            {
                return(IFCBooleanResult.ProcessIFCBooleanResult(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcCurve))
            {
                return(IFCCurve.ProcessIFCCurve(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcFaceBasedSurfaceModel))
            {
                return(IFCFaceBasedSurfaceModel.ProcessIFCFaceBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcGeometricSet))
            {
                return(IFCGeometricSet.ProcessIFCGeometricSet(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcPoint))
            {
                return(IFCPoint.ProcessIFCPoint(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcShellBasedSurfaceModel))
            {
                return(IFCShellBasedSurfaceModel.ProcessIFCShellBasedSurfaceModel(ifcRepresentationItem));
            }
            if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcSolidModel))
            {
                return(IFCSolidModel.ProcessIFCSolidModel(ifcRepresentationItem));
            }

            // TODO: Move the items below to IFCGeometricRepresentationItem->IFCTessellatedItem->IfcTessellatedFaceSet.
            if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC4Obsolete) && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcTriangulatedFaceSet))
            {
                return(IFCTriangulatedFaceSet.ProcessIFCTriangulatedFaceSet(ifcRepresentationItem));
            }
            // There is no way to actually determine an IFC4Add2 file vs. a "vanilla" IFC4 file, which is
            // obsolete.  The try/catch here allows us to read these obsolete files without crashing.
            try
            {
                if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC4) && IFCAnyHandleUtil.IsSubTypeOf(ifcRepresentationItem, IFCEntityType.IfcPolygonalFaceSet))
                {
                    return(IFCPolygonalFaceSet.ProcessIFCPolygonalFaceSet(ifcRepresentationItem));
                }
            }
            catch (Exception ex)
            {
                // Once we fail once, downgrade the schema so we don't try again.
                if (IFCImportFile.HasUndefinedAttribute(ex))
                {
                    IFCImportFile.TheFile.DowngradeIFC4SchemaTo(IFCSchemaVersion.IFC4Add1Obsolete);
                }
                else
                {
                    throw ex;
                }
            }

            Importer.TheLog.LogUnhandledSubTypeError(ifcRepresentationItem, IFCEntityType.IfcRepresentationItem, true);
            return(null);
        }
            /// <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);
            }
Beispiel #13
0
        /// <summary>
        /// Processes an IfcStyledItem entity handle.
        /// </summary>
        /// <param name="ifcStyledItem">The IfcStyledItem handle.</param>
        /// <returns>The IFCStyledItem object.</returns>
        public static IFCStyledItem ProcessIFCStyledItem(IFCAnyHandle ifcStyledItem)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcStyledItem))
            {
                IFCImportFile.TheLog.LogNullError(IFCEntityType.IfcStyledItem);
                return null;
            }

            IFCEntity styledItem;
            if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcStyledItem.StepId, out styledItem))
                styledItem = new IFCStyledItem(ifcStyledItem);
            return (styledItem as IFCStyledItem); 
        }