Ejemplo n.º 1
0
        protected virtual ElementLocation FindLoopEntryPoint(FillLoop poly, Vector2d currentPos2)
        {
            int startIndex;

            if (Settings.Part.ZipperAlignedToPoint && poly.FillType.IsEntryLocationSpecified())
            {
                // split edges to position zipper closer to the desired point?
                // TODO: Enter midsegment
                Vector2d zipperLocation = new Vector2d(Settings.Part.ZipperLocationX, Settings.Part.ZipperLocationY);
                startIndex = CurveUtils2.FindNearestVertex(zipperLocation, poly.Vertices(true));
            }
            else if (Settings.Part.ShellRandomizeStart && poly.FillType.IsEntryLocationSpecified())
            {
                // split edges for a actual random location along the perimeter instead of a random vertex?
                Random rnd = new Random();
                startIndex = rnd.Next(poly.ElementCount);
            }
            else
            {
                // use the vertex closest to the current nozzle position
                startIndex = CurveUtils2.FindNearestVertex(currentPos2, poly.Vertices(true));
            }

            return(new ElementLocation(startIndex, 0));
        }
Ejemplo n.º 2
0
 protected virtual void BuildLoop(FillLoop loop, double useSpeed)
 {
     if (!(loop is FillLoop <FillSegment> o))
     {
         throw new NotImplementedException($"FillPathScheduler2d does not support type {loop.GetType()}.");
     }
     BuildLoopConcrete(o, useSpeed);
 }
Ejemplo n.º 3
0
 protected virtual FillLoop SelectLoopDirection(FillLoop loop)
 {
     if (loop.IsHoleShell != loop.IsClockwise())
     {
         return(loop.Reversed());
     }
     return(loop);
 }
Ejemplo n.º 4
0
        // [TODO] no reason we couldn't start on edge midpoint??
        public virtual void AppendFillLoop(FillLoop loop)
        {
            AssertValidLoop(loop);

            var oriented = SelectLoopDirection(loop);
            var rolled   = SelectLoopEntry(oriented, Builder.Position.xy);

            AppendTravel(Builder.Position.xy, rolled.Entry);

            double useSpeed = SelectSpeed(rolled);

            BuildLoop(rolled, useSpeed);
        }
Ejemplo n.º 5
0
        protected void AssertValidLoop(FillLoop curve)
        {
            int N = curve.ElementCount;

            if (N < 2)
            {
                StackFrame frame  = new StackFrame(1);
                var        method = frame.GetMethod();
                var        type   = method.DeclaringType;
                var        name   = method.Name;
                throw new ArgumentException($"{type}.{name}: degenerate loop; must have at least 2 edges");
            }
        }
Ejemplo n.º 6
0
 public void Append(FillLoop loop)
 {
     Loops.Add(loop);
 }
Ejemplo n.º 7
0
        protected virtual FillLoop SelectLoopEntry(FillLoop loop, Vector2d currentPosition)
        {
            var location = FindLoopEntryPoint(loop, currentPosition);

            return(loop.RollBetweenVertices(location));
        }
Ejemplo n.º 8
0
 protected virtual void BuildLoopConcrete <TSegment>(FillLoop <TSegment> rolled, double useSpeed) where TSegment : IFillSegment, new()
 {
     Builder.AppendExtrude(rolled.Vertices(true).ToList(), useSpeed, rolled.FillType, null);
 }