コード例 #1
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);
        }
コード例 #2
0
ファイル: ParsedGerber.cs プロジェクト: pysco68/GerberTools
        internal Tuple <double, PolyLine> FindLargestPolygon()
        {
            if (OutlineShapes.Count == 0)
            {
                return(null);
            }

            List <Tuple <double, PolyLine> > Polies = new List <Tuple <double, PolyLine> >();

            foreach (var a in OutlineShapes)
            {
                var area   = Core.Helpers.PolygonSurfaceArea(a.Vertices);
                var bounds = new Bounds();
                bounds.FitPoint(a.Vertices);
                Polies.Add(new Tuple <double, PolyLine>(bounds.Area(), a));
            }

            return((from a in Polies orderby a.Item1 descending select a).First());
        }