/// <summary> /// Processes IfcProductRepresentation attributes. /// </summary> /// <param name="ifcProductRepresentation">The IfcProductRepresentation handle.</param> protected override void Process(IFCAnyHandle ifcProductRepresentation) { base.Process(ifcProductRepresentation); Name = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Name", null); Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Description", null); List <IFCAnyHandle> representations = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcProductRepresentation, "Representations"); if (representations != null) { foreach (IFCAnyHandle representationHnd in representations) { try { IFCRepresentation representation = IFCRepresentation.ProcessIFCRepresentation(representationHnd); if (representation != null) { if (representation.RepresentationItems.Count > 0 || representation.BoundingBox != null) { Representations.Add(representation); } } } catch (Exception ex) { string msg = ex.Message; // Ignore some specific errors. if (msg != null) { if (!msg.Contains("not imported")) { Importer.TheLog.LogError(Id, msg, false); } } } } } if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x3) { if (IFCAnyHandleUtil.IsSubTypeOf(ifcProductRepresentation, IFCEntityType.IfcMaterialDefinitionRepresentation)) { IFCAnyHandle representedMaterial = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcProductRepresentation, "RepresentedMaterial", false); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(representedMaterial)) { RepresentedMaterial = IFCMaterial.ProcessIFCMaterial(representedMaterial); } } } }
private Curve CreateTransformedCurve(Curve baseCurve, IFCRepresentation parentRep, Transform lcs) { Curve transformedCurve = (baseCurve != null) ? baseCurve.CreateTransformed(lcs) : null; if (transformedCurve == null) { Importer.TheLog.LogWarning(Id, "couldn't create curve for " + ((parentRep == null) ? "" : parentRep.Identifier.ToString()) + " representation.", false); } return(transformedCurve); }
/// <summary> /// Processes IfcRepresentationMap attributes. /// </summary> /// <param name="ifcRepresentationMap">The IfcRepresentationMap handle.</param> protected override void Process(IFCAnyHandle ifcRepresentationMap) { base.Process(ifcRepresentationMap); IFCAnyHandle mappingOrigin = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappingOrigin", false); if (mappingOrigin != null) MappingOrigin = IFCLocation.ProcessIFCAxis2Placement(mappingOrigin); else MappingOrigin = Transform.Identity; IFCAnyHandle mappedRepresentation = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappedRepresentation", false); if (mappedRepresentation != null) MappedRepresentation = IFCRepresentation.ProcessIFCRepresentation(mappedRepresentation); }
/// <summary> /// Create geometry for a particular representation item, and add to scope. /// </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> protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // Reject Axis curves - not yet supported. IFCRepresentation parentRep = shapeEditScope.ContainingRepresentation; IFCRepresentationIdentifier repId = (parentRep == null) ? IFCRepresentationIdentifier.Unhandled : parentRep.Identifier; bool createModelGeometry = (repId == IFCRepresentationIdentifier.Axis); if (createModelGeometry) { Importer.TheLog.LogWarning(Id, "Can't process Axis representation, ignoring.", true); return; } base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); IList <Curve> transformedCurves = new List <Curve>(); if (Curve != null) { Curve transformedCurve = CreateTransformedCurve(Curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } else if (CurveLoop != null) { foreach (Curve curve in CurveLoop) { Curve transformedCurve = CreateTransformedCurve(curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } } // TODO: set graphics style for footprint curves. ElementId gstyleId = ElementId.InvalidElementId; foreach (Curve curve in transformedCurves) { // Default: assume a plan view curve. shapeEditScope.AddFootprintCurve(curve); } }
/// <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); }
/// <summary> /// Processes IfcRepresentationMap attributes. /// </summary> /// <param name="ifcRepresentationMap">The IfcRepresentationMap handle.</param> protected override void Process(IFCAnyHandle ifcRepresentationMap) { base.Process(ifcRepresentationMap); IFCAnyHandle mappingOrigin = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappingOrigin", false); if (mappingOrigin != null) { MappingOrigin = IFCLocation.ProcessIFCAxis2Placement(mappingOrigin); } else { MappingOrigin = Transform.Identity; } IFCAnyHandle mappedRepresentation = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappedRepresentation", false); if (mappedRepresentation != null) { MappedRepresentation = IFCRepresentation.ProcessIFCRepresentation(mappedRepresentation); } }
private Curve CreateTransformedCurve(Curve baseCurve, IFCRepresentation parentRep, Transform lcs) { Curve transformedCurve = (baseCurve != null) ? baseCurve.CreateTransformed(lcs) : null; if (transformedCurve == null) { Importer.TheLog.LogWarning(Id, "couldn't create curve for " + ((parentRep == null) ? "" : parentRep.Identifier.ToString()) + " representation.", false); } return transformedCurve; }
/// <summary> /// The constructor. /// </summary> /// <param name="scope">The associated shape edit scope.</param> /// <param name="item">The current styled item.</param> public IFCContainingRepresentationSetter(IFCImportShapeEditScope scope, IFCRepresentation containingRepresentation) { if (scope != null) { m_Scope = scope; m_OldRepresentation = scope.ContainingRepresentation; scope.ContainingRepresentation = containingRepresentation; } }
/// <summary> /// Create geometry for a particular representation item, and add to scope. /// </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> protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); IFCRepresentation parentRep = shapeEditScope.ContainingRepresentation; IList <Curve> transformedCurves = new List <Curve>(); if (Curve != null) { Curve transformedCurve = CreateTransformedCurve(Curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } else if (CurveLoop != null) { foreach (Curve curve in CurveLoop) { Curve transformedCurve = CreateTransformedCurve(curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } } // TODO: set graphics style for footprint curves. IFCRepresentationIdentifier repId = (parentRep == null) ? IFCRepresentationIdentifier.Unhandled : parentRep.Identifier; bool createModelGeometry = (repId == IFCRepresentationIdentifier.Body) || (repId == IFCRepresentationIdentifier.Axis) || (repId == IFCRepresentationIdentifier.Unhandled); ElementId gstyleId = ElementId.InvalidElementId; if (createModelGeometry) { Category curveCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, parentRep.Identifier); if (curveCategory != null) { GraphicsStyle graphicsStyle = curveCategory.GetGraphicsStyle(GraphicsStyleType.Projection); if (graphicsStyle != null) { gstyleId = graphicsStyle.Id; } } } foreach (Curve curve in transformedCurves) { if (createModelGeometry) { curve.SetGraphicsStyleId(gstyleId); shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, curve)); } else { // Default: assume a plan view curve. shapeEditScope.AddFootprintCurve(curve); } } }