/// <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> /// Get or create the sub-category for a representation other than the body representation for a particular category. /// </summary> /// <param name="doc">The doument.</param> /// <param name="entityId">The entity id.</param> /// <param name="repId">The representation identifier.</param> /// <param name="category">The top-level category id for the element.</param> /// <returns>The sub-category. This allows shapes to have their visibility controlled by the sub-category.</param></returns> public static Category GetSubCategoryForRepresentation(Document doc, int entityId, IFCRepresentationIdentifier repId) { if (repId == IFCRepresentationIdentifier.Body || repId == IFCRepresentationIdentifier.Unhandled) throw new InvalidOperationException("Incorrect IFCRepresentationIdentifier: " + repId.ToString()); Category category = Importer.TheCache.GenericModelsCategory; if (category == null) return null; string subCategoryName = repId.ToString(); Category subCategory = GetOrCreateSubcategory(doc, entityId, subCategoryName); return subCategory; }
/// <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); } } }