protected override void BuildProcessing(ICommandGenerator generator) { var rail = Rail != null?Rail.GetCurve() as Line : new Line(Point3d.Origin, new Point3d(Length.Value, 0, 0)); var startRail = rail.StartPoint; var railVector = rail.Delta.GetNormal(); if (rail.Angle >= Math.PI) { startRail = rail.EndPoint; railVector = railVector.Negate(); } var startPass = startRail - railVector * Departure; var passVector = railVector * (rail.Length + 2 * Departure); var railAngle = railVector.GetAngleTo(Vector3d.XAxis); if (Rail == null) { rail.Dispose(); } var profile = ProcessingArea[0].GetCurve(); var profileLength = profile.Length(); startPass = new Point3d(startPass.X, startPass.Y - profile.StartPoint.X, profile.StartPoint.Y); generator.ZSafety += profile.StartPoint.Y; double dist = 0; var engineSide = Side.None; double angleC; do { var point = profile.GetPointAtDist(dist); var tangent = profile.GetFirstDerivative(point); var angleA = Math.Abs(tangent.GetAngleTo(Vector3d.XAxis).ToDeg()); var side = tangent.Y < 0 ? Side.Left : Side.Right; if (engineSide != side) { engineSide = side; angleC = BuilderUtils.CalcToolAngle(railAngle, side); if (!generator.IsUpperTool) { generator.Uplifting(); } var sp = GetStartPoint(point, tangent); generator.Move(sp.X, sp.Y, angleC: angleC, angleA: angleA); } var startPoint = GetStartPoint(point, tangent); generator.Cutting(startPoint, startPoint + passVector, CuttingFeed, PenetrationFeed, angleA: angleA); dist += Step; }while (dist < profileLength); generator.Uplifting(); Point3d GetStartPoint(Point3d point, Vector3d tangent) { if (engineSide == Side.Left) { point += tangent.GetNormal() * Tool.Thickness.Value; } var profileVector = point - profile.StartPoint; return(startPass + railVector.RotateBy(Math.PI / 2, -Vector3d.ZAxis).RotateBy(profileVector.GetAngleTo(Vector3d.XAxis), railVector) * profileVector.Length); } }