private void generateHoleMilling(IGeometryOutput sb) { sb.BeginGroup("generateHoleMilling"); float dia = (float)(work.mainMill.diameter * 0.5); sb.MoveTo(new PointF(0, dia)); sb.SetDepth(0); double pd = 0; bool running = true; while (running) { pd += work.mainMill.passDepth; if (pd >= work.dimensions.stockThickness + cutThroughMargin) { pd = work.dimensions.stockThickness; running = false; } sb.SetDepth((float)-pd); sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false); sb.SetDepth(0); } sb.SetDepth((float)-(work.dimensions.stockThickness + cutThroughMargin)); sb.ArcTo(new PointF(0, dia), new PointF(0, 0), false); sb.SetDepth(0); sb.SetDepth(0.1f); sb.EndGroup(); }
private void generateToothTopMilling(IGeometryOutput sb) { double cDep = work.dimensions.stockThickness - work.dimensions.plateThickness - work.dimensions.toothThickness; if (cDep <= 0) { return; } sb.BeginGroup("generateToothTopMilling"); double iRad = work.calc.radius - work.calc.dedendum - work.dimensions.ridgeMargin + work.mainMill.diameter * 0.5f; double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin + work.mainMill.diameter * 0.5f; if (oRad < iRad) { oRad = iRad; } sb.SetDepth(0.1f); sb.MoveTo(new PointF(0, (float)iRad)); double rDep = cDep - work.dimensions.ridgeThickness; sb.SetDepth((float)-rDep); for (double d = rDep; d < cDep;) { d += work.mainMill.passDepth; if (d > cDep) { d = cDep; } // plunge slowly sb.SetDepth((float)-d); bool running = true; bool first = true; for (double r = iRad; running; r += work.mainMill.stepOver) { if (r >= oRad) { r = oRad; running = false; } bool clockwise = true; if (first) { clockwise = false; first = false; } sb.LineTo(new PointF(0, (float)r)); sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise); } } sb.SetDepth(0); sb.SetDepth(0.1f); sb.EndGroup(); }
PointF LineOrArc(IGeometryOutput sb, PointF p, PointF curPos) { float sz = Distance2(p, curPos); if (sz < 9e-8) { return(curPos); } float dl = Math.Abs(Length2(p) - Length2(curPos)); double a1 = Math.Atan2(p.Y, p.X); double a2 = Math.Atan2(curPos.Y, curPos.X); if (a1 < a2 - Math.PI) { a1 += 2 * Math.PI; } else if (a1 > a2 + Math.PI) { a1 -= 2 * Math.PI; } bool clockwise = false; if (a1 < a2) { clockwise = true; } if (dl < 1e-3 && dl < sz * 0.125f && sz > 4e-6) { sb.ArcTo(p, new PointF(0, 0), clockwise); } else { sb.LineTo(p); } return(p); }
PointF LineOrArc(IGeometryOutput sb, PointF p, PointF curPos) { float sz = Distance2(p, curPos); if (sz < 9e-8) { return curPos; } float dl = Math.Abs(Length2(p) - Length2(curPos)); double a1 = Math.Atan2(p.Y, p.X); double a2 = Math.Atan2(curPos.Y, curPos.X); if (a1 < a2 - Math.PI) { a1 += 2 * Math.PI; } else if (a1 > a2 + Math.PI) { a1 -= 2 * Math.PI; } bool clockwise = false; if (a1 < a2) { clockwise = true; } if (dl < 1e-3 && dl < sz * 0.125f && sz > 4e-6) { sb.ArcTo(p, new PointF(0, 0), clockwise); } else { sb.LineTo(p); } return p; }
private void generatePlateMilling(IGeometryOutput sb) { if (work.dimensions.plateThickness <= 0) { return; } double cDep = work.dimensions.stockThickness; if (cDep <= 0) { return; } sb.BeginGroup("generatePlateMilling"); double iRad = work.calc.radius + work.calc.addendum + work.mainMill.diameter * 0.5f; double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin + work.mainMill.diameter * 0.5f; if (oRad < iRad) { oRad = iRad; } sb.SetDepth(0.1f); sb.MoveTo(new PointF(0, (float)iRad)); double rDep = cDep - work.dimensions.plateThickness; sb.SetDepth((float)-rDep); for (double d = rDep; d < cDep; ) { d += work.mainMill.passDepth; if (d > cDep) { d = cDep; } // plunge slowly sb.SetDepth((float)-d); bool running = true; bool first = true; for (double r = iRad; running; r += work.mainMill.stepOver) { if (r >= oRad) { r = oRad; running = false; } bool clockwise = true; if (first) { clockwise = false; first = false; } if (work.dimensions.stockThickness - tabHeight < d && r > oRad - work.mainMill.stepOver) { // mill with tabs sb.Comment("todo: mill with tabs"); } sb.LineTo(new PointF(0, (float)r)); sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise); } } sb.SetDepth(0); sb.SetDepth(0.1f); sb.EndGroup(); }
private void generateRidgeTopMilling(IGeometryOutput sb) { double cDep = work.dimensions.stockThickness - work.dimensions.plateThickness - work.dimensions.toothThickness - work.dimensions.ridgeThickness; if (cDep <= 0) { return; } sb.BeginGroup("generateRidgeTopMilling"); double iRad = work.calc.radius - work.calc.dedendum - work.dimensions.ridgeMargin - work.dimensions.ridgeThickness + work.mainMill.diameter * 0.5f; double oRad = work.calc.radius + work.calc.addendum + work.dimensions.plateMargin + work.mainMill.diameter * 0.5f; if (oRad < iRad) { oRad = iRad; } sb.SetDepth(0.1f); sb.MoveTo(new PointF(0, (float)iRad)); sb.SetDepth(0); for (double d = 0; d < cDep;) { d += work.mainMill.passDepth; if (d > cDep) { d = cDep; } // plunge slowly sb.SetDepth((float)-d); bool running = true; bool first = true; for (double r = iRad; running; r += work.mainMill.stepOver) { if (r >= oRad) { r = oRad; running = false; } bool clockwise = true; if (first) { clockwise = false; first = false; } sb.LineTo(new PointF(0, (float)r)); sb.ArcTo(new PointF(0, (float)r), new PointF(0, 0), clockwise); } } sb.SetDepth(0); sb.SetDepth(0.1f); sb.EndGroup(); }