Ejemplo n.º 1
0
        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, SimpleSweptSolidAnalyzer sweptAnalyzer)
        {
            try
            {
                if (sweptAnalyzer == null)
                {
                    return(null);
                }

                SweptSolidExporter sweptSolidExporter = null;

                IList <Revit.IFC.Export.Utility.GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                IList <CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                string profileName = null;
                if (element != null)
                {
                    ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                    if (type != null)
                    {
                        profileName = type.Name;
                    }
                }

                // Is it really an extrusion?
                if (sweptAnalyzer.PathCurve is Line)
                {
                    Line line = sweptAnalyzer.PathCurve as Line;

                    // invalid case
                    if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                    {
                        return(null);
                    }

                    sweptSolidExporter = new SweptSolidExporter();
                    sweptSolidExporter.m_IsExtrusion = true;
                    Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                    sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                                                                                                                 line.Direction, UnitUtil.ScaleLength(line.Length));
                }
                else
                {
                    sweptSolidExporter = new SweptSolidExporter();
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                    {
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                    }
                    else
                    {
                        sweptSolidExporter.m_Facets = CreateSimpleSweptSolidAsBRep(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                    }
                }
                return(sweptSolidExporter);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, SimpleSweptSolidAnalyzer sweptAnalyzer, GeometryObject geomObject)
        {
            try
            {
                if (sweptAnalyzer == null)
                {
                    return(null);
                }

                SweptSolidExporter sweptSolidExporter = null;

                IList <Revit.IFC.Export.Utility.GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                IList <CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                string profileName = null;
                if (element != null)
                {
                    ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                    if (type != null)
                    {
                        profileName = type.Name;
                    }
                }

                // Is it really an extrusion?
                if (sweptAnalyzer.PathCurve is Line)
                {
                    Line line = sweptAnalyzer.PathCurve as Line;

                    // invalid case
                    if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.FaceNormal))
                    {
                        return(null);
                    }

                    sweptSolidExporter = new SweptSolidExporter();
                    sweptSolidExporter.RepresentationType = ShapeRepresentationType.SweptSolid;
                    Plane plane = new Plane(sweptAnalyzer.ProfileFace.FaceNormal, sweptAnalyzer.ProfileFace.Origin);
                    sweptSolidExporter.RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                                                                                                               line.Direction, UnitUtil.ScaleLength(line.Length), false);
                }
                else
                {
                    sweptSolidExporter = new SweptSolidExporter();
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                    {
                        // Use tessellated geometry in IFC Reference View
                        if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
                        {
                            // TODO: Create CreateSimpleSweptSolidAsTessellation routine that takes advantage of the superior tessellation of this class.
                            BodyExporterOptions options = new BodyExporterOptions(false, ExportOptionsCache.ExportTessellationLevel.ExtraLow);
                            sweptSolidExporter.RepresentationItem = BodyExporter.ExportBodyAsTriangulatedFaceSet(exporterIFC, element, options, geomObject);
                            sweptSolidExporter.RepresentationType = ShapeRepresentationType.Tessellation;
                        }
                        else
                        {
                            sweptSolidExporter.RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                            sweptSolidExporter.RepresentationType = ShapeRepresentationType.AdvancedSweptSolid;
                        }
                    }
                    else
                    {
                        sweptSolidExporter.Facets             = CreateSimpleSweptSolidAsBRep(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                        sweptSolidExporter.RepresentationType = ShapeRepresentationType.Brep;
                    }
                }
                return(sweptSolidExporter);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, SimpleSweptSolidAnalyzer sweptAnalyzer, GeometryObject geomObject)
        {
            try
            {
                if (sweptAnalyzer == null)
                    return null;

                SweptSolidExporter sweptSolidExporter = null;

                IList<Revit.IFC.Export.Utility.GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                string profileName = null;
                if (element != null)
                {
                    ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                    if (type != null)
                        profileName = type.Name;
                }

                // Is it really an extrusion?
                if (sweptAnalyzer.PathCurve is Line)
                {
                    Line line = sweptAnalyzer.PathCurve as Line;

                    // invalid case
                    if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.FaceNormal))
                        return null;

                    sweptSolidExporter = new SweptSolidExporter();
                    sweptSolidExporter.RepresentationType = ShapeRepresentationType.SweptSolid;
                    Plane plane = new Plane(sweptAnalyzer.ProfileFace.FaceNormal, sweptAnalyzer.ProfileFace.Origin);
                    sweptSolidExporter.RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                        line.Direction, UnitUtil.ScaleLength(line.Length));
                }
                else
                {
                    sweptSolidExporter = new SweptSolidExporter();
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                    {
                        // Use tessellated geometry in IFC Reference View
                        if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
                        {
                            // TODO: Create CreateSimpleSweptSolidAsTessellation routine that takes advantage of the superior tessellation of this class.
                            BodyExporterOptions options = new BodyExporterOptions(false);
                            sweptSolidExporter.RepresentationItem = BodyExporter.ExportBodyAsTriangulatedFaceSet(exporterIFC, element, options, geomObject);
                            sweptSolidExporter.RepresentationType = ShapeRepresentationType.Tessellation;
                        }
                        else
                        {
                            sweptSolidExporter.RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                            sweptSolidExporter.RepresentationType = ShapeRepresentationType.AdvancedSweptSolid;
                        }
                    }
                    else
                    {
                        sweptSolidExporter.Facets = CreateSimpleSweptSolidAsBRep(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                        sweptSolidExporter.RepresentationType = ShapeRepresentationType.Brep;
                    }
                }
                return sweptSolidExporter;
            }
            catch (Exception)
            {
                return null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, SimpleSweptSolidAnalyzer sweptAnalyzer)
        {
            try
            {
                if (sweptAnalyzer == null)
                    return null;

                SweptSolidExporter sweptSolidExporter = null;

                IList<Revit.IFC.Export.Utility.GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                string profileName = null;
                if (element != null)
                {
                    ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                    if (type != null)
                        profileName = type.Name;
                }

                // Is it really an extrusion?
                if (sweptAnalyzer.PathCurve is Line)
                {
                    Line line = sweptAnalyzer.PathCurve as Line;

                    // invalid case
                    if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                        return null;

                    sweptSolidExporter = new SweptSolidExporter();
                    sweptSolidExporter.m_IsExtrusion = true;
                    Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                    sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                        line.Direction, UnitUtil.ScaleLength(line.Length));
                }
                else
                {
                    sweptSolidExporter = new SweptSolidExporter();
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                    else
                        sweptSolidExporter.m_Facets = CreateSimpleSweptSolidAsBRep(exporterIFC, profileName, faceBoundaries, sweptAnalyzer.ReferencePlaneNormal, sweptAnalyzer.PathCurve);
                }
                return sweptSolidExporter;
            }
            catch (Exception)
            {
                return null;
            }
        }