private void BuildPass(ICommandGenerator generator, List <Point3d> points) { var point0 = Algorithms.NullPoint3d; var point = Algorithms.NullPoint3d; foreach (var p in points) { if (generator.IsUpperTool) { generator.Move(p.X, p.Y, angleC: ((Disk3DTechProcess)TechProcess).Angle); } if (point.IsNull()) { if (generator.ToolLocation.Point != p) { generator.GCommand(CommandNames.Penetration, 1, point: p, feed: TechProcess.PenetrationFeed); } } else if (point0 != point && point != p && !point0.GetVectorTo(point).IsCodirectionalTo(point.GetVectorTo(p))) { generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); point0 = point; } if (point0.IsNull()) { point0 = p; } point = p; } generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); }
private void BuildPass(ICommandGenerator generator, List <Point3d> points) { if (TechProcess.MachineType == MachineType.ScemaLogic) //Settongs.IsFrontPlaneZero { points = points.ConvertAll(p => new Point3d(p.X, p.Y + TechProcess.Tool.Thickness.Value, p.Z)); } var z = generator.ZSafety - TechProcess.ZSafety; bool isComplete; do { isComplete = true; z -= Penetration; var point0 = Algorithms.NullPoint3d; var point = Algorithms.NullPoint3d; foreach (var pt in points) { var p = pt; if (z > p.Z) { p = new Point3d(p.X, p.Y, z); isComplete = false; } if (generator.IsUpperTool) { generator.Move(p.X, p.Y, angleC: ((Disk3DTechProcess)TechProcess).Angle); } if (point.IsNull()) { if (generator.ToolLocation.Point != p) { generator.GCommand(CommandNames.Penetration, 1, point: p, feed: TechProcess.PenetrationFeed); } } else if (point0 != point && point != p && !point0.GetVectorTo(point).IsCodirectionalTo(point.GetVectorTo(p))) { generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); point0 = point; } if (point0.IsNull()) { point0 = p; } point = p; } generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); points.Reverse(); }while (!isComplete); generator.Uplifting(); }
private void BuildPass(ICommandGenerator generator, List <Point3d> points) { if (TechProcess.MachineType == MachineType.ScemaLogic) //Settongs.IsFrontPlaneZero { points = points.ConvertAll(p => new Point3d(p.X, p.Y + TechProcess.Tool.Thickness.Value, p.Z)); } var point0 = Algorithms.NullPoint3d; var point = Algorithms.NullPoint3d; foreach (var p in points) { if (generator.IsUpperTool) { generator.Move(p.X, p.Y, angleC: ((Disk3DTechProcess)TechProcess).Angle); } if (point.IsNull()) { if (generator.ToolLocation.Point != p) { generator.GCommand(CommandNames.Penetration, 1, point: p, feed: TechProcess.PenetrationFeed); } } else if (point0 != point && point != p && !point0.GetVectorTo(point).IsCodirectionalTo(point.GetVectorTo(p))) { generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); point0 = point; } if (point0.IsNull()) { point0 = p; } point = p; } generator.GCommand(CommandNames.Cutting, 1, point: point, feed: CuttingFeed); }
public override void BuildProcessing(ICommandGenerator generator) { for (int i = 0; i < PointsX.Count; i++) { generator.GCommand(CommandNames.Fast, 0, x: PointsX[i], y: PointsY[i], z: 80); generator.Command($"G0 Z80"); generator.Command("M131"); generator.Command($"DBL THICK{i} = %TastL.ZLastra - %TastL.ZBanco", "Измерение"); generator.Command($"G0 Z(THICK{i}/1000 + 100)"); } var s = String.Join(" + ", Enumerable.Range(0, PointsX.Count).Select(p => $"THICK{p}")); generator.Command($"DBL THICK = ({s})/{PointsX.Count}/1000"); generator.WithThick = true; }
public override void BuildProcessing(ICommandGenerator generator) { switch (CalcMethod) { case CalcMethodType.Average: for (int i = 0; i < PointsX.Count; i++) { generator.GCommand(CommandNames.Fast, 0, x: PointsX[i] + 230, y: PointsY[i] - 100 - TechProcess.Tool.Thickness.GetValueOrDefault()); generator.ToolLocation.Point -= new Vector3d(0, 0, 1); generator.GCommand("", 0, z: TechProcess.Thickness.GetValueOrDefault() + TechProcess.ZSafety); generator.Command("M131"); generator.Command($"DBL THICK{i} = %TastL.ZLastra - %TastL.ZBanco", "Измерение"); generator.Command($"G0 Z(THICK{i}/1000 + 100)"); } var s = String.Join(" + ", Enumerable.Range(0, PointsX.Count).Select(p => $"THICK{p}")); generator.Command($"DBL THICK = ({s})/{PointsX.Count}/1000"); break; case CalcMethodType.Minimum: for (int i = 0; i < PointsX.Count; i++) { generator.GCommand(CommandNames.Fast, 0, x: PointsX[i] + 230, y: PointsY[i] - 100 - TechProcess.Tool.Thickness.GetValueOrDefault()); generator.ToolLocation.Point -= new Vector3d(0, 0, 1); generator.GCommand("", 0, z: TechProcess.Thickness.GetValueOrDefault() + TechProcess.ZSafety); generator.Command("M131"); generator.Command($"DBL THICK{i} = %TastL.ZLastra - %TastL.ZBanco", "Измерение"); generator.Command($"G0 Z(THICK{i}/1000 + 100)"); if (i != 0) { generator.Command($"IF (THICK{i} < THICK0) THEN"); generator.Command($" THICK0 = THICK{i}"); generator.Command("ENDIF"); } } generator.Command("DBL THICK = THICK0/1000"); break; case CalcMethodType.Сorners: var points = PointsX.Select((p, i) => new Point2d(p, PointsY[i])).OrderBy(p => p.X).ToList(); var corners = points.Take(2).OrderBy(p => p.Y).Concat(points.Skip(2).OrderByDescending(p => p.Y)).ToList(); for (int i = 0; i < corners.Count; i++) { generator.GCommand(CommandNames.Fast, 0, x: corners[i].X + 230, y: corners[i].Y - 100 - TechProcess.Tool.Thickness.GetValueOrDefault()); generator.ToolLocation.Point -= new Vector3d(0, 0, 1); generator.GCommand("", 0, z: TechProcess.Thickness.GetValueOrDefault() + TechProcess.ZSafety); generator.Command("M131"); generator.Command($"DBL THICK{i} = (%TastL.ZLastra - %TastL.ZBanco)/1000", "Измерение"); generator.Command($"G0 Z(THICK{i} + 100)"); } var l1 = corners[3].X - corners[0].X; var l2 = corners[1].Y - corners[0].Y; generator.Command($"DBL KK1=(THICK3 - THICK0) / {l1}"); generator.Command($"DBL KK2=(THICK2 - THICK1) / {l1}"); generator.Command("DBL THICK"); generator.ThickCommand = $"THICK = (({{0}}-{corners[0].X})*KK2+THICK1)*({{1}}-{corners[0].Y})/{l2} + (({{0}}-{corners[0].X})*KK1+THICK0)*(1-({{1}}-{corners[0].Y})/{l2})"; break; } generator.WithThick = true; }
protected override void BuildProcessing(ICommandGenerator generator) { generator.ZSafety = ZSafety; if (MachineType.Value == CAM.MachineType.Donatoni) { generator.SetTool(2, Frequency, angleA: 90, hasTool: false); } else { generator.SetTool(1, Frequency, angleA: 0, hasTool: false); } var curves = ProcessingArea.Select(p => p.ObjectId).QOpenForRead <Curve>().ToList(); var bounds = ProcessingArea.Select(p => p.ObjectId).GetExtents(); var random = new Random(); var mainDir = Vector3d.XAxis.RotateBy(Angle1.ToRad(), Vector3d.ZAxis); var side = 1; var sign = -1; var basePoint = bounds.MinPoint + (bounds.GetCenter() - bounds.MinPoint).GetNormal() * 100; using (var ray = new Ray()) while (true) { ray.BasePoint = basePoint; ray.UnitDir = mainDir.RotateBy(Angle2.ToRad() * side, Vector3d.ZAxis); var points = ray.Intersect(curves).FindAll(p => p.DistanceTo(ray.BasePoint) > 10); if (!points.Any()) { break; } basePoint = points.First() + ray.UnitDir.Negate(); Cutting(ray.BasePoint, basePoint, ray.UnitDir, ray.UnitDir.GetPerpendicularVector() * side * sign); side *= -1; } void Cutting(Point3d point1, Point3d point2, Vector3d dir, Vector3d pv) { var z = 0; if (generator.IsUpperTool) { generator.Move(point1.X, point1.Y); generator.GCommand(CommandNames.Cutting, 1, x: point1.X, y: point1.Y, z: ZEntry, feed: Feed / 5); z = ZEntry; } var point0 = point1; var line = new Line(); var length = point1.DistanceTo(point2); var l = 0D; var a = 0D; var count = 10D; var stepA = Math.PI / count; var stepL = 0D; var amp = 0; var isInner = true; while (l < length) { if (Math.Abs(Math.Sin(a)) < Consts.Epsilon) { stepL = random.Next(StepMin, StepMax) / count; amp = random.Next(AmplitudeMin, AmplitudeMax); } l += stepL; a += stepA; var point = point1 + dir * l + pv * Math.Sin(a) * amp; line.StartPoint = point0; line.EndPoint = point; if (line.Intersect(curves).Any()) { isInner = !isInner; } if (isInner) { if (z > 0) { z--; } generator.GCommand(CommandNames.Cutting, 1, x: point.X, y: point.Y, z: z, feed: Feed); } point0 = point; } line.Dispose(); if (Math.Sin(a - stepA) > 0) { sign = -sign; } } //var ray = new Ray //{ // BasePoint = new Point3d(bounds.MinPoint.X, 0, 0), // UnitDir = Vector3d.YAxis //}; //var uppDir = true; //var random = new Random(); //while (true) //{ // var points = ray.Intersect(ProcessingArea.Select(p => p.ObjectId).QOpenForRead<Curve>().ToList(), Intersect.ExtendThis); // if (points.Count == 0) // break; // if (points.Count > 1) // { // points = (uppDir ? points.OrderBy(p => p.Y) : points.OrderByDescending(p => p.Y)).ToList(); // Cutting(points.First(), points.Last()); // } // ray.BasePoint += Vector3d.XAxis * Step1; //} //void Cutting(Point3d point1, Point3d point2) //{ // if (generator.IsUpperTool) // generator.Move(point1.X, point1.Y); // generator.GCommand(CommandNames.Cutting, 1, point: point1); // var length = point1.DistanceTo(point2); // var rnd = IsRandomStepCount ? (random.NextDouble() / 2 + 0.75) : 1; // var countCycles = (int)Math.Round(length * rnd / Step2 / 2) * 2; // var coodrs = Enumerable.Range(1, countCycles).Select(p => (double)p); // if (IsRandomStepParams) // coodrs = coodrs.Select(p => p + (p != countCycles ? (random.NextDouble() / 2 - 0.25) : 0)); // var coordArray = coodrs.ToArray(); // double l = 0; // double a = 0; // var count = 10; // var stepA = Math.PI / count; // for (int i = 0; i < coordArray.Length; i++) // { // var coord0 = i > 0 ? coordArray[i - 1] : 0; // var dl = coordArray[i] - coord0; // var stepL = dl * length / countCycles / count; // foreach (var j in Enumerable.Range(1, count)) // { // l += stepL; // a += stepA; // var point = point1 + new Vector3d(Math.Sin(a) * Amplitude * dl, uppDir ? l : -l, 0); // generator.GCommand(CommandNames.Cutting, 1, point: point, feed: Feed); // } // } //while(true) //{ // cnt++; // if (length - l < 2 * Step2) // { // } // var rnd = random.Next(5, 10) / 10D; // foreach (var i in Enumerable.Range(0, 10)) // { // var point = point1 + new Vector3d(Math.Sin(a) * Amplitude * rnd, uppDir ? l : -l, 0); // generator.GCommand(CommandNames.Cutting, 1, point: point, feed: Feed); // l += stepL / 10 * rnd; // a += stepA / 10; // } //} //foreach (var i in Enumerable.Range(0, count)) //{ // var point = point1 + new Vector3d(Math.Sin(a) * Amplitude, uppDir ? l : -l, 0); // generator.GCommand(CommandNames.Cutting, 1, point: point, feed: Feed); // l += stepL; // a += stepA; //} // uppDir = !uppDir; //} }