/// <summary> /// Create geometry for a particular representation item. /// </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) { if (shapeEditScope.BuilderType != IFCShapeBuilderType.TessellatedShapeBuilder) { throw new InvalidOperationException("Currently BrepBuilder is only used to support IFCAdvancedFace"); } base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); // we would only be in this code if we are not processing and IfcAdvancedBrep, since IfcAdvancedBrep must have IfcAdvancedFace if (shapeEditScope.BuilderScope == null) { throw new InvalidOperationException("BuilderScope has not been initialized"); } TessellatedShapeBuilderScope tsBuilderScope = shapeEditScope.BuilderScope as TessellatedShapeBuilderScope; bool addFace = true; bool canTriangulate = (Bounds.Count == 1); ElementId materialId = GetMaterialElementId(shapeEditScope); // We can only really triangulate faces with one boundary with 4 vertices, // but we don't really know how many vertices the boundary has until later. // So this is just the first block. Later, we can try to extend to generic // polygons. tsBuilderScope.StartCollectingFace(materialId, canTriangulate); foreach (IFCFaceBound faceBound in Bounds) { faceBound.CreateShape(shapeEditScope, lcs, scaledLcs, guid); // If we can't create the outer face boundary, we will abort the creation of this face. // In that case, return, unless we can triangulate it. if (!tsBuilderScope.HaveActiveFace()) { addFace = false; break; } } tsBuilderScope.StopCollectingFace(addFace, false); IList <List <XYZ> > delayedFaceBoundaries = CreateTriangulation(tsBuilderScope.DelayedFaceBoundary); if (delayedFaceBoundaries != null) { bool extraFace = false; foreach (List <XYZ> delayedBoundary in delayedFaceBoundaries) { bool addTriangulatedFace = true; tsBuilderScope.StartCollectingFace(GetMaterialElementId(shapeEditScope), false); if (!tsBuilderScope.AddLoopVertices(Id, delayedBoundary)) { Importer.TheLog.LogComment(Id, "Bounded loop plane is slightly non-planar, couldn't triangulate.", false); addTriangulatedFace = false; } tsBuilderScope.StopCollectingFace(addTriangulatedFace, extraFace); extraFace = true; } } }
/// <summary> /// Create geometry for a particular representation item. /// </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) { if (shapeEditScope.BuilderType != IFCShapeBuilderType.TessellatedShapeBuilder) { throw new InvalidOperationException("Currently BrepBuilder is only used to support IFCAdvancedFace"); } base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); // we would only be in this code if we are not processing and IfcAdvancedBrep, since IfcAdvancedBrep must have IfcAdvancedFace if (shapeEditScope.BuilderScope == null) { throw new InvalidOperationException("BuilderScope has not been initialized"); } TessellatedShapeBuilderScope tsBuilderScope = shapeEditScope.BuilderScope as TessellatedShapeBuilderScope; tsBuilderScope.StartCollectingFace(GetMaterialElementId(shapeEditScope)); foreach (IFCFaceBound faceBound in Bounds) { faceBound.CreateShape(shapeEditScope, lcs, scaledLcs, guid); // If we can't create the outer face boundary, we will abort the creation of this face. In that case, return. if (!tsBuilderScope.HaveActiveFace()) { tsBuilderScope.AbortCurrentFace(); return; } } tsBuilderScope.StopCollectingFace(); }