Beispiel #1
0
            public override bool ProcessLine(byte[] line)
            {
                double X1, Y1, X2, Y2, width;
                int    net;
                Layers layer;
                bool   InComponent = false;
                Int16  component   = 0;

                base.ProcessLine();
                net = B2UInt16(line, 3 + 5);
                if (net == 0x0000FFFF)
                {
                    net = 0;
                }
                else
                {
                    net++;
                }
                component   = B2Int16(line, 7 + 5);
                InComponent = (component != -1);
                X1          = Math.Round(ToMM(line, 13 + 5) - originX, Precision);
                Y1          = Math.Round(ToMM(line, 17 + 5) - originY, Precision);
                X2          = Math.Round(ToMM(line, 21 + 5) - originX, Precision);
                Y2          = Math.Round(ToMM(line, 25 + 5) - originY, Precision);

                CheckMinMax(X1 + originX, Y1 + originY);
                CheckMinMax(X2 + originX, Y2 + originY);
                width = Math.Round(ToMM(line, 29 + 5), Precision);

                layer = (Layers)line[5];
                string Layer           = Brd.GetLayer(layer);
                int    ComponentNumber = 0;

                if (InComponent)
                {
                    // belongs to a component definition
                    ComponentNumber = component;
                }
                // check for and reject very short tracks
                if (Length(X1, Y1, X2, Y2) <= 0.001)
                {
                    OutputError($"Zero length track rejected at X1={X1} Y1={-Y1} X2={X2} y2={-Y2} ");
                    return(true);
                }
                if (!InComponent)
                {
                    if (net == 0)
                    {
                        if (!Brd.OnInnerLayer(layer))
                        {
                            if ((Layer != "Edge.Cuts") || !Brd.CheckExistingLine(X1, -Y1, X2, -Y2))
                            {
                                List <string> Layers = Brd.GetLayers(Layer);
                                foreach (var L in Layers)
                                {
                                    Line Line = new Line(X1, Y1, X2, Y2, L, width, net);
                                    LinesL.Add(Line);
                                }
                            }
                        }
                    }
                    else
                    {
                        Line Line = new Line(X1, Y1, X2, Y2, Brd.GetLayer(layer), width, net);
                        LinesL.Add(Line);
                        //tracks.Append($"  (segment (start {X1} {-Y1}) (end {X2} {-Y2}) (width {width}) (layer {Layer}) (net {net}))\n");
                        //track_count++;
                    }
                }
                else
                {
                    Line Line = new Line(X1, Y1, X2, Y2, Brd.GetLayer(layer), width);
                    ModulesL[ComponentNumber].Lines.Add(Line);
                }
                return(true);
            }