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>
        /// 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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <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);
                        }
                    }
                }
            }
        }