Ejemplo n.º 1
0
        public void QueueTravel(IntPoint positionToMoveTo)
        {
            GCodePath path = GetLatestPathWithConfig(travelConfig);

            if (forceRetraction)
            {
                path.Retract    = true;
                forceRetraction = false;
            }
            else if (outerPerimetersToAvoidCrossing != null)
            {
                Polygon pointList = new Polygon();
                if (outerPerimetersToAvoidCrossing.CreatePathInsideBoundary(LastPosition, positionToMoveTo, pointList))
                {
                    long lineLength_um = 0;
                    // we can stay inside so move within the boundary
                    for (int pointIndex = 0; pointIndex < pointList.Count; pointIndex++)
                    {
                        path.points.Add(new IntPoint(pointList[pointIndex], CurrentZ)
                        {
                            Width = 0
                        });
                        if (pointIndex > 0)
                        {
                            lineLength_um += (pointList[pointIndex] - pointList[pointIndex - 1]).Length();
                        }
                    }

                    // If the internal move is very long (20 mm), do a retraction anyway
                    if (lineLength_um > retractionMinimumDistance_um)
                    {
                        path.Retract = true;
                    }
                }
                else
                {
                    if ((LastPosition - positionToMoveTo).LongerThen(retractionMinimumDistance_um))
                    {
                        // We are moving relatively far and are going to cross a boundary so do a retraction.
                        path.Retract = true;
                    }
                }
            }
            else if (alwaysRetract)
            {
                if ((LastPosition - positionToMoveTo).LongerThen(retractionMinimumDistance_um))
                {
                    path.Retract = true;
                }
            }

            path.points.Add(new IntPoint(positionToMoveTo, CurrentZ)
            {
                Width = 0,
            });
            LastPosition = positionToMoveTo;
        }
Ejemplo n.º 2
0
        public void writeTravel(IntPoint positionToMoveTo)
        {
            GCodePath path = getLatestPathWithConfig(travelConfig);

            if (forceRetraction)
            {
                if (!(lastPosition - positionToMoveTo).ShorterThen(retractionMinimumDistance))
                {
                    path.retract = true;
                }
                forceRetraction = false;
            }
            else if (avaidCrossingPerimeters != null)
            {
                List <IntPoint> pointList = new List <IntPoint>();
                if (avaidCrossingPerimeters.CreatePathInsideBoundary(lastPosition, positionToMoveTo, pointList))
                {
                    long lineLength = 0;
                    // we can stay inside so move within the boundary
                    for (int pointIndex = 0; pointIndex < pointList.Count; pointIndex++)
                    {
                        path.points.Add(pointList[pointIndex]);
                        if (pointIndex > 0)
                        {
                            lineLength += (pointList[pointIndex] - pointList[pointIndex - 1]).Length();
                        }
                    }

                    // If the internal move is very long (20 mm), do a retration anyway
                    if (lineLength > (20 * 1000))
                    {
                        path.retract = true;
                    }
                }
                else
                {
                    if (!(lastPosition - positionToMoveTo).ShorterThen(retractionMinimumDistance))
                    {
                        // We are moving relatively far and are going to cross a boundary so do a retraction.
                        path.retract = true;
                    }
                }
            }
            else if (alwaysRetract)
            {
                if (!(lastPosition - positionToMoveTo).ShorterThen(retractionMinimumDistance))
                {
                    path.retract = true;
                }
            }

            path.points.Add(positionToMoveTo);
            lastPosition = positionToMoveTo;
        }