Ejemplo n.º 1
0
        /// <summary>
        /// Creates a Brep product definition shape representation.
        /// </summary>
        /// <remarks>
        /// It will try to export the geometry as an extrusion if it is not exported as IFC 2x2 version.
        /// </remarks>
        /// <param name="application">
        /// The Revit application object.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="categoryId">
        /// The category id.
        /// </param>
        /// <param name="geometryElement">
        /// The geometry element.
        /// </param>
        /// <param name="bodyExporterOptions">
        /// The body exporter options.
        /// </param>
        /// <param name="extraReps">
        /// Extra representations (e.g. Axis, Boundary).  May be null.
        /// </param>
        /// <param name="extrusionCreationData">
        /// The extrusion creation data.
        /// </param>
        /// <param name="bodyData">
        /// The body data.
        /// </param>
        /// <returns>
        /// The handle.
        /// </returns>
        public static IFCAnyHandle CreateBRepProductDefinitionShape(Autodesk.Revit.ApplicationServices.Application application,
                                                                    ExporterIFC exporterIFC, Element element, ElementId categoryId,
                                                                    GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps, IFCExtrusionCreationData extrusionCreationData,
                                                                    out BodyData bodyData)
        {
            SolidMeshGeometryInfo  info   = null;
            IList <GeometryObject> solids = new List <GeometryObject>();

            if (!exporterIFC.ExportAs2x2)
            {
                info = GeometryUtil.GetSolidMeshGeometry(geometryElement, Transform.Identity);
                IList <Mesh> meshes = info.GetMeshes();
                if (meshes.Count == 0)
                {
                    IList <Solid> solidList = info.GetSolids();
                    foreach (Solid solid in solidList)
                    {
                        solids.Add(solid);
                    }
                }
            }

            IFCAnyHandle ret = null;

            if (solids.Count == 0)
            {
                IList <GeometryObject> geometryList = new List <GeometryObject>();
                geometryList.Add(geometryElement);
                ret = CreateBRepProductDefinitionShape(application, exporterIFC, element, categoryId,
                                                       geometryList, extraReps, bodyExporterOptions, extrusionCreationData, out bodyData);
            }
            else
            {
                bodyExporterOptions.TryToExportAsExtrusion = true;
                ret = CreateBRepProductDefinitionShape(application, exporterIFC, element, categoryId,
                                                       solids, extraReps, bodyExporterOptions, extrusionCreationData, out bodyData);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a SweptSolid, Brep, SolidModel or SurfaceModel product definition shape representation, based on the geometry and IFC version.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="categoryId">The category id.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="bodyExporterOptions">The body exporter options.</param>
        /// <param name="extraReps">Extra representations (e.g. Axis, Boundary).  May be null.</param>
        /// <param name="extrusionCreationData">The extrusion creation data.</param>
        /// <param name="bodyData">The body data.</param>
        /// <returns>The handle.</returns>
        public static IFCAnyHandle CreateAppropriateProductDefinitionShape(ExporterIFC exporterIFC, Element element, ElementId categoryId,
                                                                           GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList <IFCAnyHandle> extraReps,
                                                                           IFCExtrusionCreationData extrusionCreationData, out BodyData bodyData)
        {
            bodyData = null;
            SolidMeshGeometryInfo  info         = null;
            IList <GeometryObject> geometryList = new List <GeometryObject>();

            if (!exporterIFC.ExportAs2x2)
            {
                info = GeometryUtil.GetSplitSolidMeshGeometry(geometryElement, Transform.Identity);
                IList <Mesh> meshes = info.GetMeshes();
                if (meshes.Count == 0)
                {
                    IList <Solid> solidList = info.GetSolids();
                    foreach (Solid solid in solidList)
                    {
                        geometryList.Add(solid);
                    }
                }
            }

            if (geometryList.Count == 0)
            {
                geometryList.Add(geometryElement);
            }
            else
            {
                bodyExporterOptions.TryToExportAsExtrusion = true;
            }

            bodyData = BodyExporter.ExportBody(exporterIFC, element, categoryId, ElementId.InvalidElementId, geometryList,
                                               bodyExporterOptions, extrusionCreationData);
            IFCAnyHandle        bodyRep  = bodyData.RepresentationHnd;
            List <IFCAnyHandle> bodyReps = new List <IFCAnyHandle>();

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
            {
                if (extrusionCreationData != null)
                {
                    extrusionCreationData.ClearOpenings();
                }
            }
            else
            {
                bodyReps.Add(bodyRep);
            }

            if (extraReps != null)
            {
                foreach (IFCAnyHandle hnd in extraReps)
                {
                    bodyReps.Add(hnd);
                }
            }

            IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, Transform.Identity);

            if (boundingBoxRep != null)
            {
                bodyReps.Add(boundingBoxRep);
            }

            if (bodyReps.Count == 0)
            {
                return(null);
            }
            return(IFCInstanceExporter.CreateProductDefinitionShape(exporterIFC.GetFile(), null, null, bodyReps));
        }