Esempio n. 1
0
        void OnPosChangeFast(float x, float y, float z, float e)
        {
            if (!ana.drawing || ana.layer < minLayer || ana.layer > maxLayer)
            {
                lastx = x;
                lasty = y;
                lastz = z;
                laste = ana.activeExtruder.emax;
                lastLayer = ana.layer;
                return;
            }
            float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
            bool isLastPos = locDist < 0.00001;
            int segpos = ana.activeExtruderId;
            bool isTravel = (FormPrinterSettings.ps.printerType == 3 ? Math.Max(z,lastz) - ana.zOffset >= FormPrinterSettings.ps.cncZTop : !ana.eChanged);
            if (segpos < 0 || segpos >= MaxExtruder) segpos = 0;
            LinkedList<GCodePath> seg = segments[segpos];
            if (isTravel)
            {
                GCodeTravel travel = new GCodeTravel();
                travel.fline = GCodePoint.toFileLine(fileid, actLine);
                travel.p1.X = lastx;
                travel.p1.Y = lasty;
                travel.p1.Z = lastz;
                travel.p2.X = x;
                travel.p2.Y = y;
                travel.p2.Z = z;
                travelMoves.Add(travel);
                if (FormPrinterSettings.ps.printerType == 3 && z - ana.zOffset < FormPrinterSettings.ps.cncZTop) // End od travel moves
                { // Start new milling move sequence
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                }
            }

            //if (!act.hasG || (act.G > 1 && act.G != 28)) return;
            if (lastLayer == minLayer - 1 && (laste < e || FormPrinterSettings.ps.printerType == 3))
            {
                GCodePath p = new GCodePath();
                p.Add(new Vector3(lastx, lasty, lastz), laste, totalDist, GCodePoint.toFileLine(fileid, actLine));

                if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                {
                    seg.RemoveLast();
                }
                seg.AddLast(p);
            }

            if (seg.Count == 0 || (laste >= ana.activeExtruder.e && FormPrinterSettings.ps.printerType != 3)) // start new segment
            {
                if (!isLastPos) // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Count>0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                    //changed = true;
                }
            }
            else
            {
                if (!isLastPos && (FormPrinterSettings.ps.printerType != 3 || !isTravel))
                {
                    totalDist += locDist;
                    seg.Last.Value.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    //changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.activeExtruder.emax;
            lastLayer = ana.layer;
        }
Esempio n. 2
0
        void OnPosChangeFast(float x, float y, float z, float e)
        {
            if (!ana.drawing || ana.layer < minLayer || ana.layer > maxLayer)
            {
                lastx = x;
                lasty = y;
                lastz = z;
                laste = ana.emax;
                lastLayer = ana.layer;
                return;
            }
            float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
            bool isLastPos = locDist < 0.00001;
            int segpos = ana.activeExtruder;
            if (ana.eChanged == false)
            {
                GCodeTravel travel = new GCodeTravel();
                travel.fline = GCodePoint.toFileLine(fileid, actLine);
                travel.p1.X = lastx;
                travel.p1.Y = lasty;
                travel.p1.Z = lastz;
                travel.p2.X = x;
                travel.p2.Y = y;
                travel.p2.Z = z;
                travelMoves.Add(travel);
            }
            if (segpos < 0 || segpos >= MaxExtruder) segpos = 0;
            LinkedList<GCodePath> seg = segments[segpos];
            //if (!act.hasG || (act.G > 1 && act.G != 28)) return;
            if (lastLayer == minLayer - 1 && laste < e)
            {
                GCodePath p = new GCodePath();
                p.Add(new Vector3(lastx, lasty, lastz), laste, totalDist, GCodePoint.toFileLine(fileid, actLine));

                if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                {
                    seg.RemoveLast();
                }
                seg.AddLast(p);
            }

            if (seg.Count == 0 || laste >= ana.e) // start new segment
            {
                if (!isLastPos) // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                    //changed = true;
                }
            }
            else
            {
                if (!isLastPos)
                {
                    totalDist += locDist;
                    seg.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    //changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.emax;
            lastLayer = ana.layer;
        }