internal void Set(string name, double val) { if (Has(name) == false) { Pairs[name] = new GerberNumberPairList(); Pairs[name].Command = name; } Pairs[name].Numbers.Add(new GerberNumberPair() { Number = val, Command = name, Orig = name }); }
internal void Split(string p, GerberNumberFormat form, bool hasdecimalpoint = false) { try { bool wasnumber = false; bool isnumber = false; string running = ""; for (int i = 0; i < p.Length; i++) { char current = p[i]; if (char.IsNumber(current) || current == '+' || current == '-' || (hasdecimalpoint && current == '.')) { isnumber = true; } else { isnumber = false; } if (isnumber != wasnumber) { if (isnumber) { GNP.Command = running; GNP.Orig = running; } else { GNP.Orig += running; GNP.Parse(running, form, hasdecimalpoint); if (Pairs.ContainsKey(GNP.Command) == false) { GerberNumberPairList GNPL = new GerberNumberPairList(); GNPL.Command = GNP.Command; GNPL.Orig = GNP.Orig; Pairs[GNP.Command] = GNPL; } Pairs[GNP.Command].Numbers.Add(GNP); CommandsInOrder.Add(GNP.Command); GNP = new GerberNumberPair(); } wasnumber = isnumber; running = ""; } if (current != '+') { running += current; } } if (GNP.Command.Length > 0) { GNP.Parse(running, form, hasdecimalpoint); if (Pairs.ContainsKey(GNP.Command) == false) { GerberNumberPairList GNPL = new GerberNumberPairList(); GNPL.Command = GNP.Command; GNPL.Orig = GNP.Orig; Pairs[GNP.Command] = GNPL; } Pairs[GNP.Command].Numbers.Add(GNP); CommandsInOrder.Add(GNP.Command); } } catch (Exception) { Console.WriteLine("this line does not seem to contain gerber: {0}", p); } }