/// <summary> /// Create geometry for a particular representation. /// </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> public void CreateShape(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // Special handling for Box representation. We may decide to create an IFCBoundingBox class and stop this special treatment. if (BoundingBox != null) { CreateBoxShape(shapeEditScope, scaledLcs); } if (LayerAssignment != null) { LayerAssignment.Create(shapeEditScope); } // There is an assumption here that Process() weeded out any items that are invalid for this representation. using (IFCImportShapeEditScope.IFCMaterialStack stack = new IFCImportShapeEditScope.IFCMaterialStack(shapeEditScope, null, LayerAssignment)) { using (IFCImportShapeEditScope.IFCContainingRepresentationSetter repSetter = new IFCImportShapeEditScope.IFCContainingRepresentationSetter(shapeEditScope, this)) { foreach (IFCRepresentationItem representationItem in RepresentationItems) { representationItem.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } } } }
/// <summary> /// Return geometry for a particular representation item. /// </summary> /// <param name="shapeEditScope">The geometry creation scope.</param> /// <param name="unscaledLcs">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> /// <returns>Zero or more created geometries.</returns> protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform unscaledLcs, Transform scaledLcs, string guid) { Transform unscaledSweptDiskPosition = (unscaledLcs == null) ? Transform.Identity : unscaledLcs; Transform scaledSweptDiskPosition = (scaledLcs == null) ? Transform.Identity : scaledLcs; CurveLoop trimmedDirectrix = IFCGeometryUtil.TrimCurveLoop(Id, Directrix, StartParameter, EndParameter); if (trimmedDirectrix == null) { return(null); } CurveLoop trimmedDirectrixInWCS = IFCGeometryUtil.CreateTransformed(trimmedDirectrix, Id, unscaledSweptDiskPosition, scaledSweptDiskPosition); // Create the disk. Curve firstCurve = null; foreach (Curve curve in trimmedDirectrixInWCS) { firstCurve = curve; break; } double startParam = 0.0; IList <CurveLoop> profileCurveLoops = CreateProfileCurveLoopsForDirectrix(firstCurve, out startParam); if (profileCurveLoops == null) { return(null); } SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId); IList <GeometryObject> myObjs = new List <GeometryObject>(); try { Solid sweptDiskSolid = GeometryCreationUtilities.CreateSweptGeometry(trimmedDirectrixInWCS, 0, startParam, profileCurveLoops, solidOptions); if (sweptDiskSolid != null) { myObjs.Add(sweptDiskSolid); } } catch (Exception ex) { // If we can't create a solid, we will attempt to split the Solid into valid pieces (that will likely have some overlap). if (ex.Message.Contains("self-intersections")) { Importer.TheLog.LogWarning(Id, "The IfcSweptDiskSolid definition does not define a valid solid, likely due to self-intersections or other such problems; the profile probably extends too far toward the inner curvature of the sweep path. Creating the minimum number of solids possible to represent the geometry.", false); myObjs = SplitSweptDiskIntoValidPieces(trimmedDirectrixInWCS, profileCurveLoops, solidOptions); } else { throw ex; } } return(myObjs); }
/// <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.</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> override protected void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (XYZPoint == null) { return; } XYZ transformedPoint = scaledLcs.OfPoint(XYZPoint); if (transformedPoint == null) { return; } ElementId gstyleId = shapeEditScope.GraphicsStyleId; Category pointCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, shapeEditScope.ContainingRepresentation.Identifier); if (pointCategory != null) { GraphicsStyle graphicsStyle = pointCategory.GetGraphicsStyle(GraphicsStyleType.Projection); if (graphicsStyle != null) { gstyleId = graphicsStyle.Id; } } Point point = Point.Create(transformedPoint, gstyleId); if (point == null) { return; } shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, point)); }
/// <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) { base.CreateShapeInternal(shapeEditScope, scaledLcs, lcs, guid); // Ignoring Inner shells for now. if (Outer != null) { try { IList <GeometryObject> solids = CreateGeometry(shapeEditScope, scaledLcs, lcs, guid); if (solids != null) { foreach (GeometryObject solid in solids) { shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, solid)); } } else { Importer.TheLog.LogError(Outer.Id, "cannot create valid solid, ignoring.", false); } } catch (Exception ex) { Importer.TheLog.LogError(Outer.Id, ex.Message, false); } } }
/// <summary> /// Check for any occurence where distance of two vertices are too narrow (within the tolerance) /// </summary> /// <param name="entityId">The integer number representing the current IFC entity Id</param> /// <param name="shapeEditScope">the shapeEditScope</param> /// <param name="inputVerticesList">Input list of the vertices</param> /// <param name="outputVerticesList">Output List of the valid vertices, i.e. not vertices that are too close to each other</param> /// <returns></returns> public static void CheckAnyDistanceVerticesWithinTolerance(int entityId, IFCImportShapeEditScope shapeEditScope, IList <XYZ> inputVerticesList, out IList <XYZ> outputVerticesList) { // Check triangle that is too narrow (2 vertices are within the tolerance double shortSegmentTolerance = shapeEditScope.TryToCreateSolid() ? shapeEditScope.Document.Application.ShortCurveTolerance : shapeEditScope.Document.Application.VertexTolerance; int lastVertex = 0; IList <XYZ> vertList = new List <XYZ>(); outputVerticesList = vertList; for (int ii = 1; ii <= inputVerticesList.Count; ii++) { int currIdx = (ii % inputVerticesList.Count); double dist = inputVerticesList[lastVertex].DistanceTo(inputVerticesList[currIdx]); if (dist >= shortSegmentTolerance) { vertList.Add(inputVerticesList[lastVertex]); lastVertex = currIdx; } else { string distAsString = IFCUnitUtil.FormatLengthAsString(dist); string shortDistAsString = IFCUnitUtil.FormatLengthAsString(shortSegmentTolerance); string warningString = "Distance between vertices " + lastVertex + " and " + currIdx + " is " + distAsString + ", which is less than the minimum " + (shapeEditScope.TryToCreateSolid() ? "Solid" : "Mesh") + " distance of " + shortDistAsString + ", removing second point."; Importer.TheLog.LogComment(entityId, warningString, false); } } }
/// <summary> /// Create the Revit elements associated with this IfcPresentationLayerAssignment. /// </summary> /// <param name="shapeEditScope">The shape edit scope.</param> virtual public void Create(IFCImportShapeEditScope shapeEditScope) { if (!string.IsNullOrWhiteSpace(Name)) { shapeEditScope.PresentationLayerNames.Add(Name); } }
/// <summary> /// Create the Revit elements associated with this IfcPresentationLayerWithStyle. /// </summary> /// <param name="shapeEditScope">The shape edit scope.</param> override public void Create(IFCImportShapeEditScope shapeEditScope) { // TODO: support cut pattern id and cut pattern color. if (CreatedMaterialElementId != ElementId.InvalidElementId || !IsValidForCreation) { return; } base.Create(shapeEditScope); try { // If the styled item or the surface style has a name, use it. IFCSurfaceStyle surfaceStyle = GetSurfaceStyle(); if (surfaceStyle == null) { // We only handle surface styles at the moment; log file should already reflect any other unhandled styles. IsValidForCreation = true; return; } string forcedName = surfaceStyle.Name; if (string.IsNullOrWhiteSpace(forcedName)) { forcedName = Name; } CreatedMaterialElementId = surfaceStyle.Create(shapeEditScope.Document, forcedName, null, Id); } catch (Exception ex) { IsValidForCreation = false; Importer.TheLog.LogCreationError(this, ex.Message, false); } }
/// <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. /// </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> public void CreateShape(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // We are not yet displaying Axis information, but do (potentially) need the Axis curve for generating material layer-based extrusions. if (Identifier == IFCRepresentationIdentifier.Axis) { return; } if (LayerAssignment != null) { LayerAssignment.Create(shapeEditScope); } // There is an assumption here that Process() weeded out any items that are invalid for this representation. using (IFCImportShapeEditScope.IFCMaterialStack stack = new IFCImportShapeEditScope.IFCMaterialStack(shapeEditScope, null, LayerAssignment)) { using (IFCImportShapeEditScope.IFCContainingRepresentationSetter repSetter = new IFCImportShapeEditScope.IFCContainingRepresentationSetter(shapeEditScope, this)) { foreach (IFCRepresentationItem representationItem in RepresentationItems) { using (IFCImportShapeEditScope.IFCTargetSetter setter = new IFCImportShapeEditScope.IFCTargetSetter(shapeEditScope, TessellatedShapeBuilderTarget.AnyGeometry, TessellatedShapeBuilderFallback.Mesh)) { representationItem.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } } } } }
/// <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, 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> /// <returns>The created geometry.</returns> protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // since IFCAdvancedBrep must contain a closed shell, we set the BuildPreferenceType to be solid for now for (int pass = 0; pass < 2; pass++) { using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.BrepBuilder)) { BrepBuilderScope brepBuilderScope = bs as BrepBuilderScope; BRepType brepType = (pass == 0) ? BRepType.Solid : BRepType.OpenShell; brepBuilderScope.StartCollectingFaceSet(brepType); Outer.AllowInvalidFace = (pass == 0); Outer.CreateShape(shapeEditScope, lcs, scaledLcs, guid); IList <GeometryObject> geomObjs = null; geomObjs = brepBuilderScope.CreateGeometry(); // We'll return only if we have geometry; otherwise we'll try again with looser validation, if we can. if (geomObjs != null) { if (pass == 1) { Importer.TheLog.LogError(Id, "Some faces are missing from this Solid; reading in as an Open Shell instead.", false); } return(geomObjs); } } } return(null); }
/// <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(); }
/// <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, 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> /// <returns>The created geometry.</returns> /// <remarks>As this doesn't inherit from IfcSolidModel, this is a non-virtual CreateGeometry function.</remarks> protected IList <GeometryObject> CreateGeometry(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (Shells.Count == 0) { return(null); } IList <GeometryObject> geomObjs = null; using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.TessellatedShapeBuilder)) { TessellatedShapeBuilderScope tsBuilderScope = bs as TessellatedShapeBuilderScope; tsBuilderScope.StartCollectingFaceSet(); foreach (IFCConnectedFaceSet faceSet in Shells) { faceSet.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } geomObjs = tsBuilderScope.CreateGeometry(guid); } if (geomObjs == null || geomObjs.Count == 0) { return(null); } return(geomObjs); }
/// <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, 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> /// <returns>The created geometry.</returns> /// <remarks>As this doesn't inherit from IfcSolidModel, this is a non-virtual CreateGeometry function.</remarks> protected IList <GeometryObject> CreateGeometry(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (Shells.Count == 0) { return(null); } using (IFCImportShapeEditScope.IFCTargetSetter setter = new IFCImportShapeEditScope.IFCTargetSetter(shapeEditScope, TessellatedShapeBuilderTarget.AnyGeometry, TessellatedShapeBuilderFallback.Mesh)) { shapeEditScope.StartCollectingFaceSet(); foreach (IFCConnectedFaceSet faceSet in Shells) { faceSet.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } IList <GeometryObject> geomObjs = shapeEditScope.CreateGeometry(guid); if (geomObjs == null || geomObjs.Count == 0) { return(null); } return(geomObjs); } }
/// <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, 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> /// <returns>The created geometry.</returns> protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (Outer == null || Outer.Faces.Count == 0) { return(null); } Tuple <IList <GeometryObject>, bool> faceInfo = CollectFaces(shapeEditScope, lcs, scaledLcs, guid); IList <GeometryObject> geomObjs = faceInfo.Item1; if (geomObjs == null || geomObjs.Count == 0) { if (faceInfo.Item2) // canRevertToMesh { using (IFCImportShapeEditScope.BuildPreferenceSetter setter = new IFCImportShapeEditScope.BuildPreferenceSetter(shapeEditScope, IFCImportShapeEditScope.BuildPreferenceType.AnyMesh)) { faceInfo = CollectFaces(shapeEditScope, lcs, scaledLcs, guid); geomObjs = faceInfo.Item1; } } } if (geomObjs == null || geomObjs.Count == 0) { // Couldn't use fallback, or fallback didn't work. Importer.TheLog.LogWarning(Id, "Couldn't create any geometry.", false); return(null); } return(geomObjs); }
private Tuple <IList <GeometryObject>, bool> CollectFaces(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.TessellatedShapeBuilder)) { TessellatedShapeBuilderScope tsBuilderScope = bs as TessellatedShapeBuilderScope; tsBuilderScope.StartCollectingFaceSet(); Outer.CreateShape(shapeEditScope, lcs, scaledLcs, guid); IList <GeometryObject> geomObjs = null; bool canRevertToMesh = tsBuilderScope.CanRevertToMesh(); int numCreatedFaces = tsBuilderScope.CreatedFacesCount; int numExpectedFaces = Outer.Faces.Count; if (numCreatedFaces == numExpectedFaces || (!canRevertToMesh && numCreatedFaces > 0)) { geomObjs = tsBuilderScope.CreateGeometry(guid); if (numCreatedFaces < numExpectedFaces) { Importer.TheLog.LogWarning(Outer.Id, "Processing " + numCreatedFaces + " valid faces out of " + numExpectedFaces + " total.", false); } } return(Tuple.Create(geomObjs, canRevertToMesh)); } }
private void CreateBoxShape(IFCImportShapeEditScope shapeEditScope, Transform scaledLcs) { using (IFCImportShapeEditScope.IFCContainingRepresentationSetter repSetter = new IFCImportShapeEditScope.IFCContainingRepresentationSetter(shapeEditScope, this)) { // Get the material and graphics style based in the "Box" sub-category of Generic Models. // We will create the sub-category if this is our first time trying to use it. // Note that all bounding boxes are controlled by a sub-category of Generic Models. We may revisit that decision later. // Note that we hard-wire the identifier to "Box" because older files may have bounding box items in an obsolete representation. SolidOptions solidOptions = null; Category bboxCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, IFCRepresentationIdentifier.Box); if (bboxCategory != null) { ElementId materialId = (bboxCategory.Material == null) ? ElementId.InvalidElementId : bboxCategory.Material.Id; GraphicsStyle graphicsStyle = bboxCategory.GetGraphicsStyle(GraphicsStyleType.Projection); ElementId gstyleId = (graphicsStyle == null) ? ElementId.InvalidElementId : graphicsStyle.Id; solidOptions = new SolidOptions(materialId, gstyleId); } Solid bboxSolid = IFCGeometryUtil.CreateSolidFromBoundingBox(scaledLcs, BoundingBox, solidOptions); if (bboxSolid != null) { IFCSolidInfo bboxSolidInfo = IFCSolidInfo.Create(Id, bboxSolid); shapeEditScope.AddGeometry(bboxSolidInfo); } } return; }
/// <summary> /// Creates or populates Revit elements based on the information contained in this class. /// </summary> /// <param name="doc">The document.</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> public void CreateProductRepresentation(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // TODO: separate representations. foreach (IFCRepresentation representation in Representations) { representation.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } }
/// <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, 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> /// <returns>Zero or more created geometries.</returns> public IList <GeometryObject> CreateGeometry(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (StyledByItem != null) { StyledByItem.Create(shapeEditScope); } return(CreateGeometryInternal(shapeEditScope, lcs, scaledLcs, guid)); }
/// <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> /// <remarks>This currently assumes that we are creating plan view curves.</remarks> protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); foreach (IFCCurve curve in Curves) { curve.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } }
protected List <GeometryObject> CreateConformalGeometryIfPossible( IFCImportShapeEditScope shapeEditScope, Transform unscaledLcs) { Transform unscaledSweptDiskPosition = (unscaledLcs == null) ? Transform.Identity : unscaledLcs; IList <CurveLoop> trimmedDirectrices = IFCGeometryUtil.TrimCurveLoops(Id, Directrix, StartParameter, EndParameter); if (trimmedDirectrices == null) { return(null); } List <GeometryObject> myObjs = null; bool isIdentity = unscaledSweptDiskPosition.IsIdentity; foreach (CurveLoop trimmedDirectrix in trimmedDirectrices) { // Create the disk. Curve firstCurve = null; foreach (Curve curve in trimmedDirectrix) { firstCurve = curve; break; } double startParam = 0.0; IList <CurveLoop> profileCurveLoops = CreateProfileCurveLoopsForDirectrix(firstCurve, out startParam); if (profileCurveLoops == null) { return(null); } SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId); myObjs = new List <GeometryObject>(); try { Solid sweptDiskSolid = GeometryCreationUtilities.CreateSweptGeometry(trimmedDirectrix, 0, startParam, profileCurveLoops, solidOptions); if (!isIdentity) { sweptDiskSolid = SolidUtils.CreateTransformed(sweptDiskSolid, unscaledSweptDiskPosition); } if (sweptDiskSolid != null) { myObjs.Add(sweptDiskSolid); } } catch { return(null); } } return(myObjs); }
protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (TreeRootExpression != null) { return(TreeRootExpression.CreateGeometry(shapeEditScope, lcs, scaledLcs, guid)); } return(null); }
protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (BooleanResult != null) { return(BooleanResult.CreateGeometry(shapeEditScope, lcs, scaledLcs, guid)); } return(null); }
/// <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, 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> /// <returns>The created geometries.</returns> public IList <GeometryObject> CreateGeometry( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // A HalfSpaceSolid must always be a Solid, regardless of input. using (IFCImportShapeEditScope.IFCTargetSetter setter = new IFCImportShapeEditScope.IFCTargetSetter(shapeEditScope, TessellatedShapeBuilderTarget.Solid, TessellatedShapeBuilderFallback.Abort)) { return(CreateGeometryInternal(shapeEditScope, lcs, scaledLcs, guid)); } }
/// <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, 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> /// <returns>Zero or more created geometries.</returns> public IList <GeometryObject> CreateGeometry(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (StyledByItem != null) { StyledByItem.Create(shapeEditScope); } using (IFCImportShapeEditScope.IFCMaterialStack stack = new IFCImportShapeEditScope.IFCMaterialStack(shapeEditScope, StyledByItem, null)) { return(CreateGeometryInternal(shapeEditScope, lcs, scaledLcs, guid)); } }
/// <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) { base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); IList <GeometryObject> extrudedGeometries = CreateGeometryInternal(shapeEditScope, lcs, scaledLcs, guid); if (extrudedGeometries != null) { foreach (GeometryObject extrudedGeometry in extrudedGeometries) { shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, extrudedGeometry)); } } }
/// <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, 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> /// <returns>The created geometry.</returns> protected override IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { shapeEditScope.StartCollectingFaceSet(); Outer.CreateShape(shapeEditScope, lcs, scaledLcs, guid); IList <GeometryObject> geomObjs = shapeEditScope.CreateGeometry(guid); if (geomObjs == null || geomObjs.Count == 0) { return(null); } return(geomObjs); }
/// <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.BuilderScope == null) { throw new InvalidOperationException("BuilderScope has not been initialised"); } base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); Bound.CreateShape(shapeEditScope, lcs, scaledLcs, guid); IsValidForCreation = Bound.IsValidForCreation; if (shapeEditScope.BuilderType == IFCShapeBuilderType.TessellatedShapeBuilder) { CreateTessellatedShapeInternal(shapeEditScope, scaledLcs); } }
/// <summary> /// Creates or populates Revit elements based on the information contained in this class. /// </summary> /// <param name="doc">The document.</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> public void CreateProductRepresentation(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { // Partially sort the representations so that we create: Body, Box, then the rest of the representations in that order. // This allows us to skip Box representations if any of the Body representations create 3D geometry. Until we have UI in place, // this will disable creating extra 3D (bounding box) geometry that clutters the display, is only marginally useful and is hard to turn off. List <IFCRepresentation> sortedReps = new List <IFCRepresentation>(); // Double usage as body rep list. IList <IFCRepresentation> boxReps = new List <IFCRepresentation>(); IList <IFCRepresentation> otherReps = new List <IFCRepresentation>(); foreach (IFCRepresentation representation in Representations) { switch (representation.Identifier) { case IFCRepresentationIdentifier.Body: sortedReps.Add(representation); break; case IFCRepresentationIdentifier.Box: boxReps.Add(representation); break; default: otherReps.Add(representation); break; } } // Add back the other representations. sortedReps.AddRange(boxReps); sortedReps.AddRange(otherReps); foreach (IFCRepresentation representation in sortedReps) { // Since we process all Body representations first, the misnamed "Solids" field will contain 3D geometry. // If this isn't empty, then we'll skip the bounding box, unless we are always importing bounding box geometry. // Note that we process Axis representations later since they create model geometry also, // but we don't consider Axis or 2D geometry in our decision to import bounding boxes. // Note also that we will only read in the first bounding box, which is the maximum of Box representations allowed. if ((representation.Identifier == IFCRepresentationIdentifier.Box) && IFCImportFile.TheFile.Options.ProcessBoundingBoxGeometry != IFCProcessBBoxOptions.Always && shapeEditScope.Creator.Solids.Count > 0) { continue; } representation.CreateShape(shapeEditScope, lcs, scaledLcs, guid); } }
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> /// 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); } }