private void Abort() { ModelPrint = Visibility.Collapsed; ModelPrintDone = Visibility.Collapsed; if (RotateX != 0 || RotateY != 0 || RotateZ != 0) { CurrentModelPath = CurrentModelPath.Substring(0, CurrentModelPath.IndexOf("_rotated.stl")) + ".stl"; } }
private void GenerateGCODE() { rotatorManipulatorX.Visibility = Visibility.Collapsed; rotatorManipulatorY.Visibility = Visibility.Collapsed; rotatorManipulatorZ.Visibility = Visibility.Collapsed; ScaleXYZ.Visibility = Visibility.Collapsed; adp.HasFinished = false; ModelPrint = Visibility.Visible; ProgressString = adp.ProgressOutput = ""; ProgressValue = adp.ProgressValue = 0; AllowUIToUpdate(); adp.Config = PrintConfig; PrintConfig.ExtraConfiguration["scale"] = (ScaleFactor / 100).ToString(); if (RotateX == 0 && RotateY == 0 && RotateZ == 0) { } else { AdmeshAdapter.Rotate(CurrentModelPath, RotateX, RotateY, RotateZ); CurrentModelPath = CurrentModelPath.Substring(0, CurrentModelPath.IndexOf('.')) + "_rotated.stl"; } ThreadPool.QueueUserWorkItem((state) => { Thread.Sleep(200); while (adp.HasFinished == false) { ProgressString = adp.ProgressOutput; ProgressValue = adp.ProgressValue; AllowUIToUpdate(); } ProgressString = adp.ProgressOutput; ProgressValue = adp.ProgressValue; AllowUIToUpdate(); }); ThreadPool.QueueUserWorkItem((state) => { adp.GenerateGcode(); ModelPrintDone = Visibility.Visible; }); }
private void Prontercae() { CurrentGcodePath = currentModelPath.Substring(0, CurrentModelPath.IndexOf('.')) + ".gcode"; GcodeString = System.IO.File.ReadAllText(CurrentGcodePath); var LineList = GcodeString.Split('\n'); double currentX = 0; double currentY = 0; double currentZ = 0; MeshGeometry3D mesh = new MeshGeometry3D(); MeshBuilder builder = new MeshBuilder(false, false); List <Point3D> vrt = new List <Point3D>(); foreach (var item in LineList) { Point3D?point = GParser.getPoint(item.ToString()); if (point != null) { Point3D Point_XYZ = (Point3D)point; if (Point_XYZ.X == -1) { Point_XYZ.X = currentX; } else { currentX = Point_XYZ.X; } if (Point_XYZ.Y == -1) { Point_XYZ.Y = currentY; } else { currentY = Point_XYZ.Y; } if (Point_XYZ.Z == -1) { Point_XYZ.Z = currentZ; } else { currentZ = Point_XYZ.Z; } vrt.Add(Point_XYZ); // builder.AddNode(Point_XYZ, Point_XYZ.ToVector3D(),new Point(Point_XYZ.X,Point_XYZ.Y)); // builder.a } } //int pos = 0; //for (int i = 0; i < vrt.Count; i += 5, pos++) //{ // vrt[pos] = vrt[i]; //} //vrt.RemoveRange(pos, vrt.Count - pos); for (int i = 0; i < vrt.Count - 1; i++) { builder.AddPipe(vrt[i], vrt[i + 1], 0.25, 0.25, 18); } //builder.AddPolygon(vrt); // builder.AddRectangularMesh(vrt); //builder.AddBox(new Point3D(10, 10, 10), 20, 20, 20); CurrentMesh = new GeometryModel3D(builder.ToMesh(), Materials.Hue); RaisePropertyChanged("CurrentMesh"); }