/// <summary> /// Return geometry for a particular representation item. /// </summary> /// <param name="shapeEditScope">The shape edit scope.</param> /// <param name="lcs">Local coordinate system for the geometry.</param> /// <param name="guid">The guid of an element for which represntation is being created.</param> /// <returns>One or more created geometries.</returns> /// <remarks>The scaledLcs is only partially supported in this routine; it allows scaling the depth of the extrusion, /// which is commonly found in ACA files.</remarks> protected override IList<GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (Direction == null) { Importer.TheLog.LogError(Id, "Error processing IfcExtrudedAreaSolid, can't create geometry.", false); return null; } Transform origLCS = (lcs == null) ? Transform.Identity : lcs; Transform origScaledLCS = (scaledLcs == null) ? Transform.Identity : scaledLcs; Transform extrusionPosition = (Position == null) ? origLCS : origLCS.Multiply(Position); Transform scaledExtrusionPosition = (Position == null) ? origScaledLCS : origScaledLCS.Multiply(Position); XYZ extrusionDirection = extrusionPosition.OfVector(Direction); ISet<IList<CurveLoop>> disjointLoops = GetTransformedCurveLoops(extrusionPosition); if (disjointLoops == null || disjointLoops.Count() == 0) return null; IList<GeometryObject> extrusions = new List<GeometryObject>(); foreach (IList<CurveLoop> loops in disjointLoops) { SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId); XYZ scaledDirection = scaledExtrusionPosition.OfVector(Direction); double currDepth = Depth * scaledDirection.GetLength(); GeometryObject extrusionObject = null; try { // We may try to create separate extrusions, one per layer here. bool shouldWarn = false; ElementId overrideMaterialId = ElementId.InvalidElementId; IList<GeometryObject> extrusionLayers = CreateGeometryFromMaterialLayerUsage(shapeEditScope, extrusionPosition, loops, extrusionDirection, currDepth, out overrideMaterialId, out shouldWarn); if (extrusionLayers == null || extrusionLayers.Count == 0) { if (shouldWarn) Importer.TheLog.LogWarning(Id, "Couldn't process associated IfcMaterialLayerSetUsage, using body geometry instead.", false); if (overrideMaterialId != ElementId.InvalidElementId) solidOptions.MaterialId = overrideMaterialId; extrusionObject = GeometryCreationUtilities.CreateExtrusionGeometry(loops, extrusionDirection, currDepth, solidOptions); } else { foreach (GeometryObject extrusionLayer in extrusionLayers) extrusions.Add(extrusionLayer); } } catch (Exception ex) { if (shapeEditScope.MustCreateSolid()) throw ex; Importer.TheLog.LogError(Id, "Extrusion has an invalid definition for a solid; reverting to mesh.", false); MeshFromGeometryOperationResult meshResult = TessellatedShapeBuilder.CreateMeshByExtrusion( loops, extrusionDirection, currDepth, GetMaterialElementId(shapeEditScope)); // will throw if mesh is not available extrusionObject = meshResult.GetMesh(); } if (extrusionObject != null) extrusions.Add(extrusionObject); } return extrusions; }