Example #1
0
        public static void Transform(double dx, double dy, double cx, double cy, double angle, ref double X, ref double Y)
        {
            GerberNumberFormat GNF = new GerberNumberFormat();

            double na = angle * (Math.PI * 2.0) / 360.0;;
            double SA = Math.Sin(na);
            double CA = Math.Cos(na);

            GNF.Multiplier = 1;
            GerberTransposer.GetTransformedCoord(dx, dy, cx, cy, angle, CA, SA, GNF, true, ref X, ref Y);
            double adx = dx;
            double ady = dy;
        }
Example #2
0
        private static void RotateFile(string filename, string outfile, string[] args)
        {
            double dx    = 0;
            double dy    = 0;
            double cx    = 0;
            double cy    = 0;
            double angle = 0;

            if (args.Count() > 2)
            {
                double.TryParse(args[2], out dx);
            }
            if (args.Count() > 3)
            {
                double.TryParse(args[3], out dy);
            }
            if (args.Count() > 4)
            {
                double.TryParse(args[4], out cx);
            }
            if (args.Count() > 5)
            {
                double.TryParse(args[5], out cy);
            }
            if (args.Count() > 6)
            {
                double.TryParse(args[6], out angle);
            }

            var T = Gerber.FindFileType(filename);

            if (T == BoardFileType.Drill)
            {
                ExcellonFile EF = new ExcellonFile();
                EF.Load(filename);
                EF.Write(outfile, dx, dy, cx, cy, angle);
            }
            else
            {
                BoardSide  Side;
                BoardLayer Layer;
                Gerber.DetermineBoardSideAndLayer(args[0], out Side, out Layer);

                GerberTransposer.Transform(filename, outfile, dx, dy, cx, cy, angle);

                var lines = PolyLineSet.SanitizeInputLines(System.IO.File.ReadAllLines(args[0]).ToList());
                System.IO.File.WriteAllLines(args[0] + "sanit.txt", lines);

                Gerber.SaveGerberFileToImage(outfile, outfile + "_render.png", 200, Color.Black, Color.White);
            }
        }