Esempio n. 1
0
        public ProcessCommand Play(ITechProcess techProcess, int commandIndex)
        {
            var commands   = techProcess.ProcessCommands.Skip(commandIndex).ToList();
            var progressor = new Progressor("Проигрывание обработки", commands.Count);

            foreach (var command in commands)
            {
                Acad.RegenToolObject(techProcess.Tool, command.HasTool, command.ToolLocation, techProcess.MachineType == MachineType.Donatoni);
                if (!progressor.Progress(false))
                {
                    SelectProcessCommand(techProcess, command);
                    return(command);
                }
                System.Threading.Thread.Sleep(30);
            }
            progressor.Stop();
            return(commands.First());
        }
Esempio n. 2
0
 public static void CloseProgressor() => _progressor.Stop();
Esempio n. 3
0
        public override void BuildProcessing(ICommandGenerator generator)
        {
            var disk3DTechProcess = (Disk3DTechProcess)TechProcess;

            var offsetSurface = CreateOffsetSurface();

            var matrix = Matrix3d.Rotation(disk3DTechProcess.Angle.ToRad(), Vector3d.ZAxis, Point3d.Origin);

            if (disk3DTechProcess.Angle != 0)
            {
                offsetSurface.TransformBy(matrix);
            }
            var bounds   = offsetSurface.GeometricExtents;
            var minPoint = bounds.MinPoint;
            var maxPoint = bounds.MaxPoint;

            var PassList = new List <List <Point3d> >();
            var startY   = minPoint.Y - (disk3DTechProcess.IsExactlyBegin ? 0 : (TechProcess.Tool.Thickness.Value - StepPass));
            var endY     = maxPoint.Y - (disk3DTechProcess.IsExactlyEnd ? TechProcess.Tool.Thickness : 0);

            var progressor = new Progressor("Расчет обработки по техпроцессу Диск 3D", (int)((endY - startY) / StepPass));

            for (var y = startY; y < endY; y += StepPass)
            {
                progressor.Progress();
                var points = new Point3dCollection();
                for (var x = minPoint.X; x <= maxPoint.X; x += StepLong)
                {
                    double z = 0;
                    for (var s = 0; s <= TechProcess.Tool.Thickness; s += 1)
                    {
                        if (y + s < minPoint.Y + Consts.Epsilon || y + s > maxPoint.Y - Consts.Epsilon)
                        {
                            continue;
                        }
                        offsetSurface.RayTest(new Point3d(x, y + s, minPoint.Z), Vector3d.ZAxis, 0.0001, out SubentityId[] col, out DoubleCollection par);
                        if (par.Count == 0)
                        {
                            z = 0;
                            break;
                        }
                        z = par[par.Count - 1] > z ? par[par.Count - 1] : z;
                    }
                    if (z > 0)
                    {
                        var point = new Point3d(x, y, minPoint.Z + z);
                        var ind   = points.Count - 1;
                        if (ind > 0 && points[ind - 1].GetVectorTo(points[ind]).IsCodirectionalTo(points[ind].GetVectorTo(point)))
                        {
                            points[ind] = point;
                        }
                        else
                        {
                            points.Add(point);
                        }
                    }
                }
                if (points.Count > 1)
                {
                    PassList.Add(CalcOffsetPoints(points, bounds));
                }
            }
            offsetSurface.Dispose();
            progressor.Stop();

            matrix = matrix.Inverse();
            PassList.ForEach(p =>
            {
                var tp  = disk3DTechProcess.Angle != 0 ? p.ConvertAll(x => x.TransformBy(matrix)) : p;
                var loc = generator.ToolLocation;
                if (loc.IsDefined && loc.Point.DistanceTo(tp.First()) > loc.Point.DistanceTo(tp.Last()))
                {
                    tp.Reverse();
                }

                BuildPass(generator, tp);

                if (IsUplifting)
                {
                    generator.Uplifting();
                }
            });
        }