// [TODO] no reason we couldn't start on edge midpoint?? public virtual void AppendPolygon2d(FillPolygon2d poly) { Vector3d currentPos = Builder.Position; Vector2d currentPos2 = currentPos.xy; int N = poly.VertexCount; if (N < 2) { throw new Exception("PathScheduler.AppendPolygon2d: degenerate curve!"); } int iNearest = CurveUtils2.FindNearestVertex(currentPos2, poly.Vertices); Vector2d startPt = poly[iNearest]; Builder.AppendTravel(startPt, Settings.RapidTravelSpeed); List <Vector2d> loopV = new List <Vector2d>(N + 1); for (int i = 0; i <= N; i++) { int k = (iNearest + i) % N; loopV.Add(poly[k]); } double useSpeed = select_speed(poly); Builder.AppendExtrude(loopV, useSpeed, poly.TypeFlags, null); }
public void SortAndAppendTo(Vector2d startPoint, IFillPathScheduler2d scheduler) { var saveHint = scheduler.SpeedHint; OutPoint = startPoint; List <Index3i> sorted = find_short_path_v1(startPoint); foreach (Index3i idx in sorted) { FillCurveSet2d paths = new FillCurveSet2d(); SchedulerSpeedHint pathHint = SchedulerSpeedHint.Default; if (idx.a == 0) // loop { PathLoop loop = Loops[idx.b]; pathHint = loop.speedHint; if (idx.c != 0) { int iStart = idx.c; FillPolygon2d o = new FillPolygon2d(); int N = loop.curve.VertexCount; for (int i = 0; i < N; ++i) { o.AppendVertex(loop.curve[(i + iStart) % N]); } o.TypeFlags = loop.curve.TypeFlags; paths.Append(o); OutPoint = o.Vertices[0]; } else { paths.Append(loop.curve); OutPoint = loop.curve.Vertices[0]; } } else // span { PathSpan span = Spans[idx.b]; if (idx.c == 1) { span.curve.Reverse(); } paths.Append(span.curve); OutPoint = span.curve.End; pathHint = span.speedHint; } scheduler.SpeedHint = pathHint; scheduler.AppendCurveSets(new List <FillCurveSet2d>() { paths }); } scheduler.SpeedHint = saveHint; }
public void Append(FillPolygon2d loop) { Loops.Add(loop); }