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()); }
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(); } }); }
void CutToBoxes(GameObject cloud_go) { // using linked list so we can change order on the fly ImportedCloud iCloud = cloud_go.GetComponent<ImportedCloud>(); slices = new LinkedList<Slice>( iCloud.slices ); maxTodoCount = cutBoxes.Count * Prefs.MaxCompactSize; done = 0; portionCount = 0; Progressor prog = new Progressor ("Cutting " + cloud_go.name + " according to boxes"); // open the original file for reading origReader = new CloudStream.Reader( new FileStream( Prefs.ImportedBin(cloud_go.name) , FileMode.Open, FileAccess.Read)); try { // since we get rid of full boxes and exhausted slices ... while( cutBoxHelpers.Count > 0 && slices.Count > 0 ) { // iterate over remaining slices LinkedListNode<Slice> slice_iter = slices.First; do { // deal with this once slice ... SortSlicePortion(slice_iter, cutBoxHelpers, shadowBoxHelpers); prog.Progress( (float)done/(float)maxTodoCount, "Sorting..."); } while (cutBoxHelpers.Count > 0 && (slice_iter = slice_iter.Next) != null); portionCount++; } // close remaining boxes foreach (BoxHelper box in cutBoxHelpers) box.Finish (); foreach (BoxHelper box in shadowBoxHelpers) box.Finish (); } finally { prog.Done(); } }