Example #1
0
        //--------------------------------------------------------------------------------------------------

        #region Helper

        MemoryStream RunExporter(bool useTriangulation, Ax3 projection, TopoDS_Shape[] shapes)
        {
            var helper = new DrawingExportHelper(useTriangulation, projection);

            helper.IncludeEdgeType(HlrEdgeType.VisibleSharp);
            helper.IncludeEdgeType(HlrEdgeType.VisibleOutline);
            helper.IncludeEdgeType(HlrEdgeType.VisibleSmooth);
            helper.IncludeEdgeType(HlrEdgeType.HiddenSharp);
            helper.IncludeEdgeType(HlrEdgeType.HiddenOutline);

            var layers = helper.PrepareExportLayers(shapes);

            if (layers == null || layers.Length == 0)
            {
                return(new MemoryStream("!HLRExporterError!".ToUtf8Bytes()));
            }

            return(SvgVectorExporter.Export(VectorExportTemplate.Drawing, layers));
        }
        //--------------------------------------------------------------------------------------------------

        bool DoExport(string filename, IVectorExporter exporter)
        {
            try
            {
                var projection   = new Ax3(_Viewport.EyePoint, _Viewport.GetViewDirection().Reversed(), _Viewport.GetRightDirection());
                var exportHelper = new DrawingExportHelper(Settings.UseTriangulation, projection);

                if (Settings.VisibleOutline)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.VisibleSharp);
                    exportHelper.IncludeEdgeType(HlrEdgeType.VisibleOutline);
                }
                if (Settings.VisibleSmooth)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.VisibleSmooth);
                }
                if (Settings.VisibleSewn)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.VisibleSewn);
                }
                if (Settings.HiddenOutline)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.HiddenSharp);
                    exportHelper.IncludeEdgeType(HlrEdgeType.HiddenOutline);
                }
                if (Settings.HiddenSmooth)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.HiddenSmooth);
                }
                if (Settings.HiddenSewn)
                {
                    exportHelper.IncludeEdgeType(HlrEdgeType.HiddenSewn);
                }

                return(exportHelper.Export(filename, exporter, InteractiveContext.Current.WorkspaceController.VisualShapes.GetVisibleBReps()));
            }
            catch (Exception e)
            {
                Messages.Exception("Exception while exporting line drawing from viewport.", e);
                return(false);
            }
        }