private Mesh GetMeshBackup(IFCImportShapeEditScope shapeEditScope, IList <CurveLoop> loops, XYZ scaledExtrusionDirection, double currDepth) { if (shapeEditScope.MustCreateSolid()) { return(null); } Importer.TheLog.LogError(Id, "Extrusion has an invalid definition for a solid; reverting to mesh.", false); MeshFromGeometryOperationResult meshResult = TessellatedShapeBuilder.CreateMeshByExtrusion( loops, scaledExtrusionDirection, currDepth, GetMaterialElementId(shapeEditScope)); // will throw if mesh is not available return(meshResult.GetMesh()); }
/// <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); }
protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // Note that lcs is unused. if (XLength < MathUtil.Eps() || YLength < MathUtil.Eps() || ZLength < MathUtil.Eps()) { return(null); } Transform scaledExtrusionPosition = (scaledLcs == null) ? Transform.Identity : scaledLcs; XYZ llPoint = scaledExtrusionPosition.OfPoint(XYZ.Zero); XYZ lrPoint = scaledExtrusionPosition.OfPoint(new XYZ(XLength, 0, 0)); XYZ urPoint = scaledExtrusionPosition.OfPoint(new XYZ(XLength, YLength, 0)); XYZ ulPoint = scaledExtrusionPosition.OfPoint(new XYZ(0, YLength, 0)); CurveLoop outerLoop = new CurveLoop(); outerLoop.Append(Line.CreateBound(llPoint, lrPoint)); outerLoop.Append(Line.CreateBound(lrPoint, urPoint)); outerLoop.Append(Line.CreateBound(urPoint, ulPoint)); outerLoop.Append(Line.CreateBound(ulPoint, llPoint)); IList <CurveLoop> loops = new List <CurveLoop>(); loops.Add(outerLoop); XYZ scaledExtrusionDirection = scaledExtrusionPosition.OfVector(XYZ.BasisZ); SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId); GeometryObject block = null; try { block = GeometryCreationUtilities.CreateExtrusionGeometry(loops, scaledExtrusionDirection, ZLength, solidOptions); } catch (Exception ex) { if (shapeEditScope.MustCreateSolid()) { throw ex; } Importer.TheLog.LogError(Id, "Block has an invalid definition for a solid; reverting to mesh.", false); MeshFromGeometryOperationResult meshResult = TessellatedShapeBuilder.CreateMeshByExtrusion( loops, scaledExtrusionDirection, ZLength, GetMaterialElementId(shapeEditScope)); // will throw if mesh is not available block = meshResult.GetMesh(); } IList <GeometryObject> blocks = new List <GeometryObject>(); if (block != null) { blocks.Add(block); } return(blocks); }