// [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); }
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)); }