override protected void Process(IFCAnyHandle styledItem) { base.Process(styledItem); IFCAnyHandle item = IFCImportHandleUtil.GetOptionalInstanceAttribute(styledItem, "Item"); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(item)) { Item = IFCRepresentationItem.ProcessIFCRepresentationItem(item); } Name = IFCImportHandleUtil.GetOptionalStringAttribute(styledItem, "Name", null); List <IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(styledItem, "Styles"); if (styles == null || styles.Count == 0 || IFCAnyHandleUtil.IsNullOrHasNoValue(styles[0])) { Importer.TheLog.LogMissingRequiredAttributeError(styledItem, "Styles", true); } if (styles.Count > 1) { Importer.TheLog.LogWarning(styledItem.StepId, "Multiple presentation styles found for IfcStyledItem - using first.", false); } Styles = IFCPresentationStyleAssignment.ProcessIFCPresentationStyleAssignment(styles[0]); }
override protected void Process(IFCAnyHandle styledItem) { base.Process(styledItem); IFCAnyHandle item = IFCImportHandleUtil.GetOptionalInstanceAttribute(styledItem, "Item"); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(item)) { Item = IFCRepresentationItem.ProcessIFCRepresentationItem(item); } Name = IFCImportHandleUtil.GetOptionalStringAttribute(styledItem, "Name", null); List <IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(styledItem, "Styles"); if (styles == null || styles.Count == 0) { Importer.TheLog.LogMissingRequiredAttributeError(styledItem, "Styles", true); } foreach (IFCAnyHandle style in styles) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(style)) { continue; } if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC4Obsolete) && IFCAnyHandleUtil.IsValidSubTypeOf(style, IFCEntityType.IfcPresentationStyle)) { Styles.Add(IFCPresentationStyle.ProcessIFCPresentationStyle(style)); } else { if (Styles.Count != 0) { Importer.TheLog.LogWarning(styledItem.StepId, "Multiple presentation styles found for IfcStyledItem - using first.", false); continue; } IFCPresentationStyleAssignment presentationStyleAssignment = IFCPresentationStyleAssignment.ProcessIFCPresentationStyleAssignment(style); if (presentationStyleAssignment != null && presentationStyleAssignment.Styles != null) { Styles.AddRange(presentationStyleAssignment.Styles); } } } }
/// <summary> /// Get the styled item corresponding to the solid inside of an IFCRepresentationItem. /// </summary> /// <param name="repItem">The representation item.</param> /// <returns>The corresponding IFCStyledItem, or null if not found.</returns> /// <remarks>This function is intended to work on an IFCBooleanResult with an arbitrary number of embedded /// clipping operations. We will take the first StyledItem that corresponds to either an IFCBooleanResult, /// or the contained solid. We explicitly do not want any material associated specifically with the void.</remarks> private IFCStyledItem GetStyledItemFromOperand(IFCRepresentationItem repItem) { if (repItem == null) { return(null); } if (repItem.StyledByItem != null) { return(repItem.StyledByItem); } if (repItem is IFCBooleanResult) { IIFCBooleanOperand firstOperand = (repItem as IFCBooleanResult).FirstOperand; if (firstOperand is IFCRepresentationItem) { return(GetStyledItemFromOperand(firstOperand as IFCRepresentationItem)); } } return(null); }
/// <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); Type = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentation, "RepresentationType", null); HashSet <IFCAnyHandle> items = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcRepresentation, "Items"); LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(ifcRepresentation, true); foreach (IFCAnyHandle item in items) { IFCRepresentationItem repItem = null; try { if (NotAllowedInRepresentation(item)) { IFCEntityType entityType = IFCAnyHandleUtil.GetEntityType(item); Importer.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 (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcBoundingBox)) { // Don't read in Box represenation unless options allow it. if (IFCImportFile.TheFile.Options.ProcessBoundingBoxGeometry == IFCProcessBBoxOptions.Never) { Importer.TheLog.LogWarning(item.StepId, "BoundingBox not imported with ProcessBoundingBoxGeometry=Never", false); } else { if (BoundingBox != null) { Importer.TheLog.LogWarning(item.StepId, "Found second IfcBoundingBox representation item, ignoring.", false); continue; } BoundingBox = ProcessBoundingBox(item); } } else { repItem = IFCRepresentationItem.ProcessIFCRepresentationItem(item); } } catch (Exception ex) { Importer.TheLog.LogError(item.StepId, ex.Message, false); } if (repItem != null) { RepresentationItems.Add(repItem); } } }
/// <summary> /// Get the styled item corresponding to the solid inside of an IFCRepresentationItem. /// </summary> /// <param name="repItem">The representation item.</param> /// <returns>The corresponding IFCStyledItem, or null if not found.</returns> /// <remarks>This function is intended to work on an IFCBooleanResult with an arbitrary number of embedded /// clipping operations. We will take the first StyledItem that corresponds to either an IFCBooleanResult, /// or the contained solid. We explicitly do not want any material associated specifically with the void.</remarks> private IFCStyledItem GetStyledItemFromOperand(IFCRepresentationItem repItem) { if (repItem == null) return null; if (repItem.StyledByItem != null) return repItem.StyledByItem; if (repItem is IFCBooleanResult) { IIFCBooleanOperand firstOperand = (repItem as IFCBooleanResult).FirstOperand; if (firstOperand is IFCRepresentationItem) return GetStyledItemFromOperand(firstOperand as IFCRepresentationItem); } return null; }