public void AddFile(MemoryStream L, string filename)
        {
            L.Seek(0, SeekOrigin.Begin);

            var T = GerberLibrary.Gerber.FindFileTypeFromStream(new StreamReader(L), filename);

            switch (T)
            {
            case GerberLibrary.Core.BoardFileType.Drill:
            {
                GerberLibrary.ExcellonFile EF = new GerberLibrary.ExcellonFile();
                L.Seek(0, SeekOrigin.Begin);

                EF.Load(new StreamReader(L));
                DrillCount += EF.TotalDrillCount();
            }
            break;

            case GerberLibrary.Core.BoardFileType.Gerber:
            {
                GerberLibrary.Core.BoardSide  Side;
                GerberLibrary.Core.BoardLayer Layer;
                GerberLibrary.Gerber.DetermineBoardSideAndLayer(filename, out Side, out Layer);
                if (Layer == GerberLibrary.Core.BoardLayer.Outline || Layer == GerberLibrary.Core.BoardLayer.Mill)
                {
                    L.Seek(0, SeekOrigin.Begin);
                    var G = GerberLibrary.PolyLineSet.LoadGerberFileFromStream(new StreamReader(L), filename);
                    Box.AddBox(G.BoundingBox);
                }
            }
            break;
            }
        }
        public void AddFile(string L)
        {
            var T = GerberLibrary.Gerber.FindFileType(L);

            switch (T)
            {
            case GerberLibrary.Core.BoardFileType.Drill:
            {
                GerberLibrary.ExcellonFile EF = new GerberLibrary.ExcellonFile();
                EF.Load(L);
                DrillCount += EF.TotalDrillCount();
            }
            break;

            case GerberLibrary.Core.BoardFileType.Gerber:
            {
                GerberLibrary.Core.BoardSide  Side;
                GerberLibrary.Core.BoardLayer Layer;
                GerberLibrary.Gerber.DetermineBoardSideAndLayer(L, out Side, out Layer);
                if (Layer == GerberLibrary.Core.BoardLayer.Outline || Layer == GerberLibrary.Core.BoardLayer.Mill)
                {
                    var G = GerberLibrary.PolyLineSet.LoadGerberFile(L);
                    Box.AddBox(G.BoundingBox);
                }
                else
                {
                    var G = GerberLibrary.PolyLineSet.LoadGerberFile(L);
                }
            }
            break;
            }
        }
Exemple #3
0
        private static void MultiMerge(string file1, List <string> otherfiles, string output, ProgressLog Log)
        {
            int MM = Log.PushActivity("Excellon MultiMerge");

            if (File.Exists(file1) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file1));
                Log.PopActivity(MM);
                return;
            }
            foreach (var otherfile in otherfiles)
            {
                if (File.Exists(otherfile) == false)
                {
                    Log.AddString(String.Format("{0} not found! stopping process!", otherfile));
                    Log.PopActivity(MM);
                    return;
                }
            }

            Log.AddString(String.Format("Reading {0}:", file1));
            ExcellonFile File1Parsed = new ExcellonFile();

            File1Parsed.Load(Log, file1);
            List <ExcellonFile> OtherFilesParsed = new List <ExcellonFile>();

            foreach (var otherfile in otherfiles)
            {
                Log.AddString(String.Format("Reading {0}:", otherfile));
                ExcellonFile OtherFileParsed = new ExcellonFile();
                OtherFileParsed.Load(Log, otherfile);
                OtherFilesParsed.Add(OtherFileParsed);
            }
            int MaxID = 0;

            foreach (var D in File1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }
            foreach (var F in OtherFilesParsed)
            {
                foreach (var D in F.Tools)
                {
                    File1Parsed.AddToolWithHoles(D.Value);;
                    //                D.Value.ID += MaxID;
                    //              File1Parsed.Tools[D.Value.ID] = D.Value;
                }
            }
            File1Parsed.Write(output, 0, 0, 0, 0);

            Log.PopActivity(MM);
        }
Exemple #4
0
        public static void WriteContainedOnly(string inputfile, PolyLine Boundary, string outputfilename, ProgressLog Log)
        {
            if (File.Exists(inputfile) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", Path.GetFileName(inputfile));
                return;
            }
            Log.AddString(String.Format("Clipping {0} to {1}", Path.GetFileName(inputfile), Path.GetFileName(outputfilename)));

            ExcellonFile EF = new ExcellonFile();

            EF.Load(Log, inputfile);
            EF.WriteContained(Boundary, outputfilename, Log);
        }
Exemple #5
0
        private static void MultiMerge(string file1, List <string> otherfiles, string output, IProgressLog log)
        {
            if (File.Exists(file1) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file1);
                return;
            }
            foreach (var otherfile in otherfiles)
            {
                if (File.Exists(otherfile) == false)
                {
                    Console.WriteLine("{0} not found! stopping process!", otherfile);
                    return;
                }
            }

            Console.WriteLine("*** Reading {0}:", file1);
            ExcellonFile file1Parsed = new ExcellonFile();

            file1Parsed.Load(file1);
            List <ExcellonFile> otherFilesParsed = new List <ExcellonFile>();

            foreach (var otherfile in otherfiles)
            {
                Console.WriteLine("*** Reading {0}:", otherfile);
                ExcellonFile otherFileParsed = new ExcellonFile();
                otherFileParsed.Load(otherfile);
                otherFilesParsed.Add(otherFileParsed);
            }
            int maxID = 0;

            foreach (var D in file1Parsed.Tools)
            {
                if (D.Value.ID > maxID)
                {
                    maxID = D.Value.ID + 1;
                }
            }
            foreach (var F in otherFilesParsed)
            {
                foreach (var D in F.Tools)
                {
                    file1Parsed.AddToolWithHoles(D.Value);;
                    // D.Value.ID += MaxID;
                    // File1Parsed.Tools[D.Value.ID] = D.Value;
                }
            }
            file1Parsed.Write(output, 0, 0, 0, 0);
        }
Exemple #6
0
        public static void Merge(string file1, string file2, string outputfile, ProgressLog Log)
        {
            Log.PushActivity("Excellon Merge");
            if (File.Exists(file1) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file1));
                Log.PopActivity();
                return;
            }

            if (File.Exists(file2) == false)
            {
                Log.AddString(String.Format("{0} not found! stopping process!", file2));
                Log.PopActivity();
                return;
            }

            Log.AddString(String.Format("Reading {0}:", file1));
            ExcellonFile File1Parsed = new ExcellonFile();

            File1Parsed.Load(Log, file1);
            Log.AddString(String.Format("Reading {0}:", file2));
            ExcellonFile File2Parsed = new ExcellonFile();

            File2Parsed.Load(Log, file2);

            Log.AddString(String.Format("Merging {0} with {1}", file1, file2));

            int MaxID = 0;

            foreach (var D in File1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }

            foreach (var D in File2Parsed.Tools)
            {
                D.Value.ID += MaxID;
                File1Parsed.Tools[D.Value.ID] = D.Value;
            }

            File1Parsed.Write(outputfile, 0, 0, 0, 0);

            Log.PopActivity();
        }
Exemple #7
0
        public static void Merge(string file1, string file2, string outputfile, IProgressLog log)
        {
            if (File.Exists(file1) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file1);
                return;
            }
            if (File.Exists(file2) == false)
            {
                Console.WriteLine("{0} not found! stopping process!", file2);
                return;
            }
            log.AddString(String.Format("*** Merging {0} with {1}", file1, file2));

            Console.WriteLine("*** Reading {0}:", file1);
            ExcellonFile file1Parsed = new ExcellonFile();

            file1Parsed.Load(file1);
            Console.WriteLine("*** Reading {0}:", file2);
            ExcellonFile file2Parsed = new ExcellonFile();

            file2Parsed.Load(file2);

            int MaxID = 0;

            foreach (var D in file1Parsed.Tools)
            {
                if (D.Value.ID > MaxID)
                {
                    MaxID = D.Value.ID + 1;
                }
            }

            foreach (var D in file2Parsed.Tools)
            {
                D.Value.ID += MaxID;
                file1Parsed.Tools[D.Value.ID] = D.Value;
            }

            file1Parsed.Write(outputfile, 0, 0, 0, 0);
        }