/// <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); }
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> /// 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); }