Example #1
0
 internal void CopyFrom(ParsedGerber p)
 {
     Shapes         = CopyPolylines(p.Shapes);
     DisplayShapes  = CopyPolylines(p.DisplayShapes);
     OutlineShapes  = CopyPolylines(p.OutlineShapes);
     ZerosizePoints = CopyPoints(p.ZerosizePoints);
 }
Example #2
0
        private bool InventOutline(ProgressLog log)
        {
            double       largest = 0;
            ParsedGerber Largest = null;
            PolyLine     Outline = null;

            foreach (var a in PLSs)
            {
                var P = a.FindLargestPolygon();
                if (P != null)
                {
                    if (P.Item1 > largest)
                    {
                        largest = P.Item1;
                        Largest = a;
                        Outline = P.Item2;
                    }
                }
            }

            if (largest < BoundingBox.Area() / 3.0)
            {
                return(false);
            }
            bool zerowidth  = true;
            bool precombine = true;

            log.AddString(String.Format("Note: Using {0} to extract outline file", Path.GetFileName(Largest.Name)));
            if (Largest.Layer == BoardLayer.Mill)
            {
                Largest.OutlineShapes.Remove(Outline);
                Largest.Shapes.Remove(Outline);
            }

            var b = AddBoardToSet(log, Largest.Name, zerowidth, precombine, 1.0);

            b.Layer = BoardLayer.Outline;
            b.Side  = BoardSide.Both;
            b.DisplayShapes.Clear();
            b.OutlineShapes.Clear();
            b.Shapes.Clear();
            Outline.Close();
            b.Shapes.Add(Outline);
            b.OutlineShapes.Add(Outline);
            //b.DisplayShapes.Add(Outline);
            //b.BuildBoundary();
            b.FixPolygonWindings();
            b.CalcPathBounds();

            return(true);
        }
Example #3
0
        private bool InventOutlineFromMill()
        {
            double       largest = 0;
            ParsedGerber Largest = null;
            PolyLine     Outline = null;

            foreach (var a in PLSs.Where(x => x.Layer == BoardLayer.Mill))
            {
                var P = a.FindLargestPolygon();
                if (P != null)
                {
                    if (P.Item1 > largest)
                    {
                        largest = P.Item1;
                        Largest = a;
                        Outline = P.Item2;
                    }
                }
            }
            if (Largest == null)
            {
                return(false);
            }
            // if (largest < BoundingBox.Area() / 3.0) return false;
            bool zerowidth  = true;
            bool precombine = true;

            Console.WriteLine("Note: Using {0} to extract outline file", Path.GetFileName(Largest.Name));

            var b = AddBoardToSet(Largest.Name, zerowidth, precombine, 1.0);

            b.Layer = BoardLayer.Outline;
            b.Side  = BoardSide.Both;
            //b.DisplayShapes.Clear();
            //b.OutlineShapes.Clear();
            //b.Shapes.Clear();
            // Outline.Close();
            // b.Shapes.Add(Outline);
            // b.OutlineShapes.Add(Outline);
            //b.DisplayShapes.Add(Outline);
            //b.BuildBoundary();
            // b.FixPolygonWindings();
            // b.CalcPathBounds();

            return(true);
        }
Example #4
0
 public void CreateBoxOutline()
 {
     PolyLine Box = new PolyLine( PolyLine.PolyIDs.Outline);
     Box.MakeRectangle(BoundingBox.Width(), BoundingBox.Height());
     Box.Translate(BoundingBox.TopLeft.X + BoundingBox.Width() / 2.0, BoundingBox.TopLeft.Y + BoundingBox.Height() / 2.0);
     Box.Hole = false;
     //Box.Close();
     // Box.Vertices.Reverse();
     ParsedGerber PLS = new ParsedGerber();
     PLS.Name = "Generated BoundingBox";
     PLS.DisplayShapes.Add(Box);
     PLS.OutlineShapes.Add(Box);
     PLS.Shapes.Add(Box);
     PLS.Layer = BoardLayer.Outline;
     PLS.Side = BoardSide.Both;
     //      PLS.FixPolygonWindings();
     PLS.CalcPathBounds();
     PLSs.Add(PLS);
 }