Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Export

        public bool Export(string fileName, IExchanger exchanger)
        {
            if (!IsValid)
            {
                Messages.Error("The etching mask data could not be generated.");
                return(false);
            }

            var exporter = exchanger as IDrawingExporter;

            if (exporter == null)
            {
                return(false);
            }

            Drawing.Drawing drawing = new()
            {
                Name = "Masks"
            };
            for (var layer = 0; layer < _Layers.Length; layer++)
            {
                BRepDrawing drawingLayer = new()
                {
                    Name   = $"Layer{layer}",
                    Source = new TopoDSBrepSource(_Layers[layer].BRep),
                    Stroke = new StrokeStyle(Color.Black, 0.1f, LineStyle.Solid),
                    Fill   = new FillStyle(Color.Black)
                };
                drawing.Add(drawingLayer);
            }
            return(exporter.DoExport(fileName, drawing));
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        bool DoExport(string filename, IDrawingExporter exporter)
        {
            try
            {
                var projection   = new Ax3(_Viewport.EyePoint, _Viewport.GetViewDirection().Reversed(), _Viewport.GetRightDirection());
                var hlrEdgeTypes = HlrEdgeTypes.None;

                if (Settings.VisibleOutline)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSharp;
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleOutline;
                }
                if (Settings.VisibleSmooth)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSmooth;
                }
                if (Settings.VisibleSewn)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.VisibleSewn;
                }
                if (Settings.HiddenOutline)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSharp;
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenOutline;
                }
                if (Settings.HiddenSmooth)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSmooth;
                }
                if (Settings.HiddenSewn)
                {
                    hlrEdgeTypes |= HlrEdgeTypes.HiddenSewn;
                }

                var source         = new TopoDSBrepSource(InteractiveContext.Current.WorkspaceController.VisualObjects.GetVisibleBReps().ToArray());
                var hlrBrepDrawing = HlrDrawing.Create(projection, hlrEdgeTypes, source);
                hlrBrepDrawing.UseTriangulation = Settings.UseTriangulation;

                var drawing = new Drawing();
                drawing.Add(hlrBrepDrawing);

                return(exporter.DoExport(filename, drawing));
            }
            catch (Exception e)
            {
                Messages.Exception("Exception while exporting line drawing from viewport.", e);
                return(false);
            }
        }