private PrinterSummaryControl PushPrinterInControl(int summaryHeight, AtumPrinter atumPrinter) { var printerSummaryControl = new PrinterSummaryControl(); printerSummaryControl.ID = atumPrinter.ID; printerSummaryControl.onSelected += PrinterSummaryControl_onSelected; printerSummaryControl.SelectedPrinter = atumPrinter; printerSummaryControl.Left = 0; printerSummaryControl.Top = summaryHeight; this.newGUIContentSplitContainerBase1.LeftPanel.Controls.Add(printerSummaryControl); return(printerSummaryControl); }
internal static void GeneratePrintJob(string printerId, string printerName, string jobName, string netFabbFilePath) { if (!string.IsNullOrEmpty(printerId) && !string.IsNullOrEmpty(printerName)) { AtumPrinter selectPrinter = null; var availablePrinters = PrinterManager.AvailablePrinters; var existingPrinter = availablePrinters.Where(x => x.SerialNumber == printerId).FirstOrDefault(); if (existingPrinter != null) { selectPrinter = existingPrinter; } else { selectPrinter = CalibratePrinter(printerId, printerName); } PrintJobManager.SelectedPrinter = selectPrinter; } else { //set printer if no printer has been selected in PrintJobManager var defaultPrinter = UserProfileManager.UserProfile.SelectedPrinter; if (defaultPrinter != null) { if (PrintJobManager.SelectedPrinter == null) { PrintJobManager.SelectedPrinter = defaultPrinter; } } } Material selectedMaterial = null; if (UserProfileManager.UserProfile.SelectedMaterial != null && UserProfileManager.UserProfile.SelectedMaterial.Id != Guid.Empty) { selectedMaterial = MaterialManager.Catalog.FindMaterialById(UserProfileManager.UserProfile.SelectedMaterial.Id); } if (selectedMaterial == null) { selectedMaterial = MaterialManager.Catalog.First().Materials.First(); } RenderEngine.PrintJob.Name = jobName; RenderEngine.PrintJob.Material = selectedMaterial; OpenProject(netFabbFilePath); while (!_closeMainApplication) { Thread.Sleep(500); } }
public PrinterAddControl(AtumPrinter atumPrinter) { InitializeComponent(); BindData(); IsValidState(); ChangeDisplayNamePanelBorder(); ChangeSerialNumberPanelBorder(); this.btnCancel.BorderColor = this.btnCancel.ForeColor = BrandingManager.Button_BackgroundColor_Dark; this._newPrinter = atumPrinter; }
public static void ShowPrinters() { AtumPrinter currentPrinter = null; if (UserProfileManager.UserProfile != null && UserProfileManager.UserProfile.SelectedPrinter != null) { currentPrinter = UserProfileManager.UserProfile.SelectedPrinter; } using (var printerEditor = new frmPrinterEditor()) { printerEditor.LoadPrinters(currentPrinter); printerEditor.ShowDialog(); } }
public frmCalibratePrinter(AtumPrinter atumPrinter) { InitializeComponent(); this.AtumPrinter = atumPrinter; this.btnClose.Image = SVGParser.GetBitmapFromSVG(Resources.SVGImages.cross_white, btnClose.Size); this.pbHelp.Image = SVGParser.GetBitmapFromSVG(Resources.SVGImages.help_white, pbHelp.Size); this.btnExport.BorderColor = this.btnExport.ForeColor = this.btnCheck.BackColor = BrandingManager.Button_BackgroundColor_Dark; this.plPrinterCalibrationOverview.BackgroundImage = BrandingManager.Printer_Calibration_Image; CalcCalibrationDefaults(); if (this.AtumPrinter.TrapeziumCorrectionRawInputA == 0) { this.AtumPrinter.TrapeziumCorrectionRawInputA = _calibrationModelSideY; } if (this.AtumPrinter.TrapeziumCorrectionRawInputB == 0) { this.AtumPrinter.TrapeziumCorrectionRawInputB = _calibrationModelSideX; } if (this.AtumPrinter.TrapeziumCorrectionRawInputC == 0) { this.AtumPrinter.TrapeziumCorrectionRawInputC = _calibrationModelSideY; } if (this.AtumPrinter.TrapeziumCorrectionRawInputD == 0) { this.AtumPrinter.TrapeziumCorrectionRawInputD = _calibrationModelSideX; } if (this.AtumPrinter.TrapeziumCorrectionRawInputE == 0) { this.AtumPrinter.TrapeziumCorrectionRawInputE = this.AtumPrinter.TrapeziumCorrectionRawInputF = CalcDiagonals(_calibrationModelSideY, _calibrationModelSideX, _calibrationModelSideY, _calibrationModelSideX); } BindMaterials(); BindTrapeziumValues(); ValidateCorrectionInput(false); this.trapezoidSizeA.TextValueChanged += TrapezoidSize_TextValueChanged; this.trapezoidSizeB.TextValueChanged += TrapezoidSize_TextValueChanged; this.trapezoidSizeC.TextValueChanged += TrapezoidSize_TextValueChanged; this.trapezoidSizeD.TextValueChanged += TrapezoidSize_TextValueChanged; }
internal void CalcSlicesIndexes(Material selectedMaterial, AtumPrinter selectedPrinter, float bottomPoint, float topPoint, int sliceIndexModulus = 1) { this.CalcSliceIndexes(selectedMaterial, true); var firstSliceIndex = 0; var firstSliceHeight = 0f; foreach (var sliceHeight in this.SliceIndexes.Keys) { if (sliceHeight > bottomPoint) { firstSliceHeight = sliceHeight; break; } firstSliceIndex++; } var lastSliceHeight = 0f; foreach (var sliceHeight in this.SliceIndexes.Keys) { if (sliceHeight > topPoint) { lastSliceHeight = sliceHeight; break; } } Parallel.ForEach(MagsAIEngine.SliceHeightsWithModulus.Keys, sliceHeightAsync => { var sliceHeight = sliceHeightAsync; var sliceIndex = firstSliceIndex; if (sliceHeight >= firstSliceHeight && sliceHeight <= lastSliceHeight) { PolyTree sliceAngledContours = null; var sliceContours = GetSliceContours(sliceIndex, sliceHeight, selectedPrinter, selectedMaterial, out sliceAngledContours); ModelContours.TryAdd(sliceHeight, sliceContours); sliceIndex++; } }); }
internal void CalcSlicesContours(Material selectedMaterial, AtumPrinter selectedPrinter) { var contours = new SortedDictionary <float, PolyTree>(); foreach (var triangle in this.Triangles[0]) { triangle.CalcMinMaxZ(); } this.CalcSliceIndexes(selectedMaterial, false); var sliceIndex = 0; foreach (var sliceHeight in this.SliceIndexes.Keys) { contours.Add(sliceHeight, STLModel3D.GetSliceContoursForBaseSTLModel3D(this, sliceIndex, sliceHeight, selectedPrinter)); sliceIndex++; } this.SliceContours = contours; }
internal static void UpdateGroundPane(AtumPrinter selectedPrinter) { if (selectedPrinter != null) { var groundPaneObject = new GroundPane((selectedPrinter.ProjectorResolutionX / 10) * selectedPrinter.TrapeziumCorrectionFactorX, (selectedPrinter.ProjectorResolutionY / 10) * selectedPrinter.TrapeziumCorrectionFactorY, 0.02f); if (ObjectView.Objects3D.Count > 0 && ObjectView.Objects3D[0] is GroundPane) { ((GroundPane)ObjectView.Objects3D[0]).Triangles = groundPaneObject.Triangles; groundPaneObject = ((GroundPane)ObjectView.Objects3D[0]); } else { ObjectView.Objects3D.Insert(0, groundPaneObject); } if (groundPaneObject.VBOIndexes == null) { groundPaneObject.BindModel(); } groundPaneObject.UpdateBinding(); } }
public static void CalculateTransformationMatrix(AtumPrinter selectedPrinter) { if (selectedPrinter.LensWarpingCorrection.TransformationVectors == null) { var measureBlockSizeX = 12.8f; var measureBlockSizeY = 8f; var fitDataMatrixWidth = selectedPrinter.ProjectorResolutionX; var fitDataMatrixHeight = selectedPrinter.ProjectorResolutionY; // Create the test points. var rowMeasurePoints = new List <float> { 0, 319, 575, 831, 1087, 1343, 1599, 1919 }; var columnMeasurePoints = new List <float> { 0, 200, 360, 520, 680, 840, 1000, 1199 }; var measurementsXMatrix = CalcFitMatrix(selectedPrinter.LensWarpingCorrection.HorizontalValues, measureBlockSizeX, rowMeasurePoints, columnMeasurePoints, fitDataMatrixWidth, fitDataMatrixHeight, "X"); var measurementsXMatrixPixelSizeInPercentages = ConvertFixMatrixValuesToPercentages(measurementsXMatrix, measureBlockSizeX, fitDataMatrixWidth, fitDataMatrixHeight); var measurementsYMatrix = CalcFitMatrix(selectedPrinter.LensWarpingCorrection.VerticalValues, measureBlockSizeY, rowMeasurePoints, columnMeasurePoints, fitDataMatrixWidth, fitDataMatrixHeight, "Y"); var measurementsYMatrixPixelSizeInPercentages = ConvertFixMatrixValuesToPercentages(measurementsYMatrix, measureBlockSizeY, fitDataMatrixWidth, fitDataMatrixHeight); //PlotFitData(measurementsXMatrix, measurementsYMatric); //dispose opbjects measurementsXMatrix = null; measurementsYMatrix = null; var matrixIntersectionPoints = CalcIntersectionPoints(measurementsXMatrixPixelSizeInPercentages, measurementsYMatrixPixelSizeInPercentages, fitDataMatrixWidth, fitDataMatrixHeight, "intersections"); measurementsXMatrixPixelSizeInPercentages = null; measurementsYMatrixPixelSizeInPercentages = null; var matrixTransformationVectors = CalcTransformationVectors(matrixIntersectionPoints, fitDataMatrixWidth, fitDataMatrixHeight, "transformation_vectors"); //DrawValidation(matrixTransformationVectors, fitDataMatrixWidth, fitDataMatrixHeight); selectedPrinter.LensWarpingCorrection.TransformationVectors = matrixTransformationVectors; } }
public static void InitializeRenderEngine() { AtumPrinter atumPrinter = null; if (UserProfileManager.UserProfile != null && UserProfileManager.UserProfile.SelectedPrinter != null) { var defaultPrinter = UserProfileManager.UserProfile.SelectedPrinter; if (defaultPrinter != null) { atumPrinter = defaultPrinter; } } Material material = null; if (UserProfileManager.UserProfile != null && UserProfileManager.UserProfile.SelectedMaterial != null) { var defaultMaterial = UserProfileManager.UserProfile.SelectedMaterial; if (defaultMaterial != null) { material = defaultMaterial; } } if (material == null) { material = MaterialManager.Catalog.First().Materials.First(); } var printJob = new PrintJob(); printJob.Name = "Untitled"; printJob.SelectedPrinter = atumPrinter; printJob.Material = material; RenderEngine.PrintJob = printJob; }
public static List <MagsAIPolyLines> FromListOfModelIntersectionsUsingPolyLines(float sliceHeight, List <SlicePolyLine3D> intersectionPoints, SupportProfile selectedMaterialProfile, AtumPrinter selectedPrinter, bool usePixelsAsValues = true) { var result = new List <MagsAIPolyLines>(); var intersectionLines = VectorHelper.Get2dLinesAsPixels(intersectionPoints, selectedPrinter); if (intersectionLines.Count > 0) { //convert intersectionLines to fast indexes var intersectionLookUp = new Dictionary <Vector3Class, List <Line3D> >(); foreach (var intersectionPoint in intersectionLines) { if (!intersectionLookUp.ContainsKey(intersectionPoint.StartPoint)) { intersectionLookUp.Add(intersectionPoint.StartPoint, new List <Line3D>()); } intersectionLookUp[intersectionPoint.StartPoint].Add(intersectionPoint); if (!intersectionLookUp.ContainsKey(intersectionPoint.EndPoint)) { intersectionLookUp.Add(intersectionPoint.EndPoint, new List <Line3D>()); } intersectionLookUp[intersectionPoint.EndPoint].Add(intersectionPoint); } var polygonTriangleIndexes = new TriangeConnectionsIndexed(); var p1 = intersectionLookUp.Keys.First(); var currentLine = intersectionLookUp[p1].First(); var p2 = currentLine.StartPoint == p1 ? currentLine.EndPoint : currentLine.StartPoint; RemoveFromIntersectionLookup(p1, p2, currentLine, intersectionLookUp); //if (intersectionLookUp.ContainsKey(p1)) //{ // intersectionLookUp[p1].Remove(currentLine); // if (intersectionLookUp[p1].Count == 0) // { // intersectionLookUp.Remove(p1); // } //} //if (intersectionLookUp.ContainsKey(p2)) //{ // intersectionLookUp[p2].Remove(currentLine); // if (intersectionLookUp[p2].Count == 0) // { // intersectionLookUp.Remove(p2); // } //} var polyLine = new MagsAIPolyLines(); polyLine.Add(new MagsAIPolyLine() { P1 = currentLine.StartPoint, P2 = currentLine.EndPoint, Normal = currentLine.Normal }); while (intersectionLookUp.Count > 0) { //find neighbors using P1 and P2 Line3D neightborP1 = null; if (intersectionLookUp.ContainsKey(p1)) { neightborP1 = intersectionLookUp[p1].FirstOrDefault(); if (neightborP1 != null) { polyLine.Insert(0, new MagsAIPolyLine() { P1 = neightborP1.StartPoint == p1 ? neightborP1.EndPoint : neightborP1.StartPoint, P2 = p1, Normal = neightborP1.Normal }); p1 = neightborP1.StartPoint == p1 ? neightborP1.EndPoint : neightborP1.StartPoint; RemoveFromIntersectionLookup(neightborP1.StartPoint, neightborP1.EndPoint, neightborP1, intersectionLookUp); } } Line3D neightborP2 = null; if (intersectionLookUp.ContainsKey(p2)) { neightborP2 = intersectionLookUp[p2].FirstOrDefault(); if (neightborP2 != null) { polyLine.Add(new MagsAIPolyLine() { P1 = p2, P2 = neightborP2.StartPoint == p2 ? neightborP2.EndPoint : neightborP2.StartPoint, Normal = neightborP2.Normal }); p2 = neightborP2.StartPoint == p2 ? neightborP2.EndPoint : neightborP2.StartPoint; RemoveFromIntersectionLookup(neightborP2.StartPoint, neightborP2.EndPoint, neightborP2, intersectionLookUp); } } //no lines found start new polyline if (neightborP1 == null && neightborP2 == null && polyLine.Count > 0) { if (polyLine.Count > 1) { if (polyLine[0].P1 == polyLine.Last().P1&& polyLine[0].P2 == polyLine.Last().P2) { polyLine.RemoveAt(0); polyLine.ClosedLine = true; } if (polyLine[0].P1 == polyLine.Last().P2) { polyLine.ClosedLine = true; } } if (polyLine.Length > 5f) { result.Add(polyLine); } polyLine = new MagsAIPolyLines(); if (intersectionLookUp.Count > 0) { p1 = intersectionLookUp.Keys.First(); currentLine = intersectionLookUp[p1].First(); p2 = currentLine.StartPoint == p1 ? currentLine.EndPoint : currentLine.StartPoint; RemoveFromIntersectionLookup(p1, p2, currentLine, intersectionLookUp); polyLine.Add(new MagsAIPolyLine() { P1 = currentLine.StartPoint, P2 = currentLine.EndPoint, Normal = currentLine.Normal }); } } } if (polyLine.Count > 0) { if (polyLine.Count > 1) { if (polyLine[0].P1 == polyLine.Last().P1&& polyLine[0].P2 == polyLine.Last().P2) { polyLine.RemoveAt(0); polyLine.ClosedLine = true; } if (polyLine[0].P1 == polyLine.Last().P2) { polyLine.ClosedLine = true; } } //check length of polyLine if (polyLine.Length > 5f) { result.Add(polyLine); } } } var objectIndex = 0; foreach (var r in result) { r.CalcPolyNode(selectedMaterialProfile, selectedPrinter, sliceHeight, objectIndex); objectIndex++; } return(result); }
/// <summary> /// this function converts all the 3d polyines to 2d lines so we can process everything /// This is the equivanlant of a 3d->2d projection function /// </summary> /// <param name="sp"></param> /// <returns></returns> internal static List <Line3D> Get2dLinesAsPixels(List <SlicePolyLine3D> polyLines3D, AtumPrinter selectedPrinter) { var lst = new List <Line3D>(); int hxres = selectedPrinter.ProjectorResolutionX / 2; int hyres = selectedPrinter.ProjectorResolutionY / 2; foreach (var polyLine3D in polyLines3D) { if (polyLine3D.Points[0].X == polyLine3D.Points[1].X && polyLine3D.Points[0].Y == polyLine3D.Points[1].Y) { } else { var ln = new Line3D(new Vector3Class((float)(polyLine3D.Points[0].X * 10.0) + 1 + hxres, (float)(polyLine3D.Points[0].Y * 10.0) + 1 + hyres, 0), //point1 new Vector3Class((float)(polyLine3D.Points[1].X * 10.0) + 1 + hxres, (float)(polyLine3D.Points[1].Y * 10.0) + 1 + hyres, 0), //point2 polyLine3D.Normal); //normal ln.TriangleConnection = polyLine3D.TriangleConnection; lst.Add(ln); } } return(lst); // return the list }
internal static Vector3Class GetModelPointFromPixelPoint(Vector3Class pixelPoint, AtumPrinter selectedPrinter) { int hxres = RenderEngine.PrintJob.SelectedPrinter.ProjectorResolutionX / 2; int hyres = RenderEngine.PrintJob.SelectedPrinter.ProjectorResolutionY / 2; pixelPoint = pixelPoint - new Vector3Class(hxres + 1, hyres + 1, 0); pixelPoint.X /= 10f; pixelPoint.Y /= 10f; return(pixelPoint); }
internal static Vector3Class GetPixelPointFromModelPoint(Vector3Class modelPoint, AtumPrinter selectedPrinter) { int hxres = RenderEngine.PrintJob.SelectedPrinter.ProjectorResolutionX / 2; int hyres = RenderEngine.PrintJob.SelectedPrinter.ProjectorResolutionY / 2; return(new Vector3Class((float)(modelPoint.X * 10.0) + 1 + hxres, (float)(modelPoint.Y * 10.0) + 1 + hyres, modelPoint.Z)); }
internal void ConvertModelBleedingIntersectionsToPolyTrees(float sliceHeight, AtumPrinter selectedPrinter, bool usePixelsAsValues = true) { var angledSides = new List <List <PolylineWithNormal> >(); var wallSides = new List <List <PolylineWithNormal> >(); var facingDownSides = new List <PolyNode>(); this.ModelBleedingPolyTrees[0] = PolyTree.FromListOfModelIntersectionsUsingPolygons(sliceHeight, this._modelBleedingZIntersections, selectedPrinter, null, null, out angledSides, out wallSides, usePixelsAsValues); }
internal void ConvertModelIntersectionsToPolyTrees(float sliceHeight, AtumPrinter selectedPrinter, Material selectedMaterial, SupportProfile selectedMaterialProfile, List <float[]> angleSideAngles, List <float[]> wallSideAngles, bool usePixelsAsValues = true, bool includeAngledSide = false, bool includeWallSides = false) { var angledSides = new List <List <PolylineWithNormal> >(); var wallSides = new List <List <PolylineWithNormal> >(); this.ModelPolyTrees[0] = PolyTree.FromListOfModelIntersectionsUsingPolygons(sliceHeight, this._modelIntersectionsZ, selectedPrinter, angleSideAngles, wallSideAngles, out angledSides, out wallSides, usePixelsAsValues, processUnion: true, includeAngledSides: includeAngledSide, includeWallSides: includeWallSides); if (includeAngledSide && angledSides.Count > 0) { this.ModelAnglesPolyTree = new PolyTree(); var clipperOffset = new ClipperOffset(); var clipperResult = new PolyTree(); foreach (var angledSide in angledSides) { var polyList = new List <IntPoint>(); foreach (var angledPolygon in angledSide) { polyList.Add(angledPolygon.Point); } ReducePointsInPath(polyList, MagsAIEngine.PixelOffsetOptimisation); clipperOffset.AddPath(polyList, JoinType.jtMiter, EndType.etOpenButt); } clipperOffset.Execute(ref clipperResult, (selectedMaterialProfile.SupportOverhangDistance) * (CONTOURPOINT_TO_VECTORPOINT_FACTOR)); clipperResult = IntersectModelSliceLayer(this.ModelPolyTrees[0][0], clipperResult); this.ModelAnglesPolyTree = clipperResult; ReducePointsInPolyTree(this.ModelAnglesPolyTree, MagsAIEngine.PixelOffsetOptimisation); } //polytree using polygon offset if (includeWallSides && wallSides.Count > 0) { var clipperOffset = new ClipperOffset(); foreach (var wallSide in wallSides) { var polyList = new List <IntPoint>(); foreach (var wallPolygon in wallSide) { polyList.Add(wallPolygon.Point); } ReducePointsInPath(polyList, MagsAIEngine.PixelOffsetOptimisation); clipperOffset.AddPath(polyList, JoinType.jtMiter, EndType.etOpenButt); } var clipperResult = new PolyTree(); clipperOffset.Execute(ref clipperResult, (selectedMaterialProfile.SupportOverhangDistance / 2) * (CONTOURPOINT_TO_VECTORPOINT_FACTOR)); clipperResult = IntersectModelSliceLayer(this.ModelWallPolyTree, clipperResult); this.ModelWallPolyTree = clipperResult; ReducePointsInPolyTree(this.ModelWallPolyTree, MagsAIEngine.PixelOffsetOptimisation); //TriangleHelper.SavePolyNodesContourToPng(this.ModelWallPolyTree._allPolys, "wall_" + sliceHeight.ToString("00.00")); } }
internal List <MagsAIPolyLines> ConvertModelIntersectionsToPolyLines(float sliceHeight, SupportProfile selectedMaterialProfile, AtumPrinter selectedPrinter, bool usePixelsAsValues = true) { return(MagsAIPolyLines.FromListOfModelIntersectionsUsingPolyLines(sliceHeight, this._modelIntersectionsZ, selectedMaterialProfile, selectedPrinter, usePixelsAsValues)); }
private static void PrintJobProperties_SelectedPrinterChanged(object sender, AtumPrinter e) { SelectedPrinterChanged?.Invoke(sender, e); }
private void RenderJob(Material selectedMaterial, AtumPrinter selectedPrinter, DriveInfo selectedDrive) { //load calibration model for (var objectViewModelIndex = ObjectView.Objects3D.Count - 1; objectViewModelIndex > 1; objectViewModelIndex--) { ObjectView.Objects3D.RemoveAt(objectViewModelIndex); } RenderEngine.PrintJob = new DAL.Print.PrintJob(); RenderEngine.PrintJob.Name = "Calibration"; RenderEngine.PrintJob.Material = selectedMaterial; RenderEngine.PrintJob.SelectedPrinter = this.AtumPrinter; var basicCorrection = new BasicCorrectionModel(); basicCorrection.Open((string)null, false, selectedMaterial.ModelColor, ObjectView.NextObjectIndex, basicCorrection.Triangles, enableProgressStatus: false); basicCorrection.UpdateBoundries(); for (var modelIndex = ObjectView.Objects3D.Count - 1; modelIndex > 0; modelIndex--) { ObjectView.Objects3D.RemoveAt(modelIndex); } ObjectView.AddModel(basicCorrection, false, false, false); RenderEngine.RenderAsync(); try { while (RenderEngine.TotalAmountSlices != RenderEngine.TotalProcessedSlices && !RenderEngine.PrintJob.PostRenderCompleted) { var progress = (((decimal)RenderEngine.TotalProcessedSlices / (decimal)RenderEngine.TotalAmountSlices) * 100); Thread.Sleep(250); } } catch (Exception exc) { Atum.DAL.Managers.LoggingManager.WriteToLog("GeneratePrintJobAsync", "Exc", exc); new frmMessageBox("GeneratePrintJobAsync", exc.Message, MessageBoxButtons.OK, MessageBoxDefaultButton.Button2).ShowDialog(); } try { var usbPrintjobPath = string.Format(@"{0}{1}", selectedDrive.Name, RenderEngine.PrintJob.Name); var pathPrinterJobXml = Path.Combine(Path.GetTempPath(), "printjob.xml"); //serialize first to temp var serializer = new System.Xml.Serialization.XmlSerializer(typeof(DAL.Print.PrintJob)); using (var streamWriter = new StreamWriter(pathPrinterJobXml, false)) { serializer.Serialize(streamWriter, RenderEngine.PrintJob); } var pathPrinterJobChecksumXml = Path.Combine(System.IO.Path.GetTempPath(), "checksum.crc"); using (var checksumWriter = new StreamWriter(pathPrinterJobChecksumXml, false)) { checksumWriter.WriteLine(DateTime.Now.Ticks.ToString()); } var osPathSeparator = "\\"; if (!Directory.Exists(usbPrintjobPath)) { Directory.CreateDirectory(usbPrintjobPath); } var zipCopied = false; while (!zipCopied) { try { File.Copy(RenderEngine.PrintJob.SlicesPath, usbPrintjobPath + osPathSeparator + "slices.zip", true); File.Copy(pathPrinterJobXml, usbPrintjobPath + osPathSeparator + "printjob.apj", true); File.Copy(pathPrinterJobChecksumXml, usbPrintjobPath + osPathSeparator + "checksum.crc", true); zipCopied = true; } catch { Thread.Sleep(250); } } } catch (Exception exc) { new frmMessageBox("Failed to save printjob", "Failed to save printjob", MessageBoxButtons.OK, MessageBoxDefaultButton.Button2).ShowDialog(); } }
public BindingList <MaterialsBySupplier> GetMaterialsByResolution(AtumPrinter selectedPrinter) { var materialsByResolution = new BindingList <MaterialsBySupplier>(); foreach (var material in this.Materials) { if (material.XYResolution == selectedPrinter.PrinterXYResolutionAsInt && selectedPrinter is AtumDLPStation5 && !string.IsNullOrEmpty(material.PrinterHardwareType)) { var materialBySupplier = new MaterialsBySupplier(); materialBySupplier.Supplier = this.Supplier; materialBySupplier.Materials.Add(material); materialsByResolution.Add(materialBySupplier); } else if (material.XYResolution == selectedPrinter.PrinterXYResolutionAsInt && ((selectedPrinter is AtumV15Printer) || (selectedPrinter is AtumV20Printer)) && string.IsNullOrEmpty(material.PrinterHardwareType)) { var materialBySupplier = new MaterialsBySupplier(); materialBySupplier.Supplier = this.Supplier; if (material.SupportProfiles == null) { material.SupportProfiles = new List <SupportProfile>(); } if (material.SupportProfiles.Count == 0) { material.SupportProfiles.Add(SupportProfile.CreateDefault()); } materialBySupplier.Materials.Add(material); materialsByResolution.Add(materialBySupplier); } else if (material.XYResolution == selectedPrinter.PrinterXYResolutionAsInt && selectedPrinter is LoctiteV10 && !string.IsNullOrEmpty(material.PrinterHardwareType)) { var materialBySupplier = new MaterialsBySupplier(); materialBySupplier.Supplier = this.Supplier; if (material.SupportProfiles == null) { material.SupportProfiles = new List <SupportProfile>(); } if (material.SupportProfiles.Count == 0) { material.SupportProfiles.Add(SupportProfile.CreateDefault()); } materialBySupplier.Materials.Add(material); materialsByResolution.Add(materialBySupplier); } } var orderedBindingList = new BindingList <MaterialsBySupplier>(); if (materialsByResolution.Count > 0) { var orderedList = materialsByResolution.OrderBy(s => s.Materials[0].Name).ToList(); foreach (var orderedMaterial in orderedList) { orderedBindingList.Add(orderedMaterial); } } return(orderedBindingList); }
internal void CalcPolyNode(SupportProfile selectedMaterialProfile, AtumPrinter selectedPrinter, float sliceHeight, int objectIndex) { this.PolyTree = new PolyTree(); var polygonPoints = new List <IntPoint>(); foreach (var polyLinePart in this) { var tStart = (polyLinePart.P1 - new Vector3Class(selectedPrinter.ProjectorResolutionX / 2, selectedPrinter.ProjectorResolutionY / 2, 0)) / 10f; tStart -= new Vector3Class(0.1f, 0.1f, 0); DebugPoints.Add(tStart); polygonPoints.Add(new IntPoint(tStart + new Vector3Class(0, 0, sliceHeight))); } //add the end of the line var tEnd = (this.Last().P2 - new Vector3Class(selectedPrinter.ProjectorResolutionX / 2, selectedPrinter.ProjectorResolutionY / 2, 0)) / 10f; tEnd -= new Vector3Class(0.1f, 0.1f, 0); polygonPoints.Add(new IntPoint(tEnd)); //when not closed use normals to create offset points if (!ClosedLine) { this.Reverse(); // this.Reverse(); var normalVector = new Vector3Class(); foreach (var polyLinePart in this) { normalVector += polyLinePart.Normal; normalVector.Z = 0; normalVector.Normalize(); normalVector *= selectedMaterialProfile.SupportOverhangDistance / 2; //do point offset var tPoint = normalVector + ((polyLinePart.P1 - new Vector3Class(selectedPrinter.ProjectorResolutionX / 2, selectedPrinter.ProjectorResolutionY / 2, 0)) / 10f); tPoint -= new Vector3Class(0.1f, 0.1f, 0); DebugPoints.Add(tPoint + new Vector3Class(0, 0, sliceHeight)); polygonPoints.Add(new IntPoint(tPoint)); normalVector = polyLinePart.Normal; } var polyTreeOffset = new PolyTree(); var polyNode = new PolyNode(); polyNode.m_polygon = polygonPoints; polyTreeOffset._allPolys.Add(polyNode); var c = new Clipper(); c.AddPath(polyTreeOffset._allPolys[0].Contour, PolyType.ptClip, true); c.AddPath(new List <IntPoint>(), PolyType.ptSubject, true); c.Execute(ClipType.ctXor, this.PolyTree, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd); //if (sliceHeight >=13 && sliceHeight <=15f) // TriangleHelper.SavePolyNodesContourToPng(this.PolyTree._allPolys, sliceHeight.ToString("0.00") + "-" + objectIndex.ToString() + "-t2"); } else { var polyTreeOffset = new PolyTree(); var polyNode = new PolyNode(); polyNode.m_polygon = polygonPoints; polyTreeOffset._allPolys.Add(polyNode); polyTreeOffset = MagsAIEngine.ClipperOffset(polyTreeOffset, selectedMaterialProfile.SupportOverhangDistance / 2); if (polyTreeOffset._allPolys.Count > 0) { var c = new Clipper(); c.AddPath(polygonPoints, PolyType.ptClip, true); c.AddPath(polyTreeOffset._allPolys[0].Contour, PolyType.ptClip, true); c.AddPath(new List <IntPoint>(), PolyType.ptSubject, true); c.Execute(ClipType.ctXor, this.PolyTree, PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd); } } }
private void tbWizard_Selecting(object sender, TabControlCancelEventArgs e) { if (e.TabPage == tbPrinterProperties) { if (this._selectedPrinter == null) { this._selectedPrinter = this.printerConnectionWelcomeTabPanel1.ManualUSBPrinterType; this._selectedPrinter.CreateProperties(); this._selectedPrinter.CreateProjectors(); } this.printerConnectionPropertiesTabPanel1.Dock = DockStyle.Fill; this.printerConnectionPropertiesTabPanel1.DataSource = this._selectedPrinter; } else if (e.TabPage == tbCalibration) { this.printerConnectionAdjustTabPanel1.DataSource = this._selectedPrinter; this._selectedPrinter.DisplayName = this.printerConnectionPropertiesTabPanel1.DataSource.DisplayName; this._selectedPrinter.Description = this.printerConnectionPropertiesTabPanel1.DataSource.Description; if (MaterialManager.Catalog != null) { var materialCatalog = new DAL.Materials.MaterialsCatalog(); foreach (var supplier in MaterialManager.Catalog) { var materialSupplier = new DAL.Materials.MaterialsBySupplier(); var selectedPrinterResolution = this._selectedPrinter.PrinterXYResolutionAsInt; //filter on printer type if (!(this._selectedPrinter is DAL.Hardware.AtumDLPStation5) && !(this._selectedPrinter is DAL.Hardware.LoctiteV10)) { //un filtered foreach (var material in supplier.Materials.Where(m => string.IsNullOrEmpty(m.PrinterHardwareType))) { materialSupplier.Materials.Add(material); } } else { //filter on hardwaretype and resolution var amountOfMaterialBySelectedPrinterTypeAndResolution = supplier.Materials.Count(m => m.XYResolution == selectedPrinterResolution && m.PrinterHardwareType == this._selectedPrinter.PrinterHardwareType); if (amountOfMaterialBySelectedPrinterTypeAndResolution > 0) { foreach (var material in supplier.Materials.Where(m => m.XYResolution == selectedPrinterResolution && m.PrinterHardwareType == this._selectedPrinter.PrinterHardwareType)) { materialSupplier.Materials.Add(material); } } } if (materialSupplier.Materials.Count > 0) { materialSupplier.Supplier = supplier.Supplier; materialCatalog.Add(materialSupplier); } } this.printerConnectionMaterialTabPanel1.MaterialCatalog = materialCatalog; } //this.printerConnectionAdjustTabPanel1.DataSource = this._selectedPrinter; this.printerConnectionFinishedTabPanel1.printername = this._selectedPrinter.DisplayName; } else if (e.TabPage == tbAdjust) { // From calibration to adjust if (printerConnectionMaterialTabPanel1.SelectedDrive == null) { e.Cancel = true; return; } else { selectedDrive = (Core.Drive.USBDrive)printerConnectionMaterialTabPanel1.SelectedDrive; if (!selectedDrive.DriveFormat.StartsWith("FAT") && !selectedDrive.DriveFormat.ToLower().StartsWith("msdos")) { MessageBox.Show("Selected drive format is not supported. Only FAT(32) is currently supported", "Disk format type error"); e.Cancel = true; return; } } //MaterialManager.CurrentMaterial = printerConnectionMaterialTabPanel1.SelectedMaterial; //MaterialManager.CurrentMaterial.IsDefault = true; RenderJob(); } if ((e.TabPageIndex - currenttabindex) > 0 && (e.TabPageIndex - currenttabindex > 1)) { e.Cancel = true; } else { currenttabindex = e.TabPageIndex; } }
internal void CalcSlicesContours(Material selectedMaterial, AtumPrinter selectedPrinter) { var resultAB = new SortedDictionary <float, PolyTree>(); var abSegmentAsSTLModel = new SupportCone(); abSegmentAsSTLModel.Triangles = this.ASegment.Triangles; //abSegmentAsSTLModel.Triangles[0].AddRange(this.ASegmentCap[0]); abSegmentAsSTLModel.Triangles[0].AddRange(this.BSegment[0]); abSegmentAsSTLModel.Triangles[0].AddRange(this.BSegmentCap[0]); foreach (var triangle in abSegmentAsSTLModel.Triangles[0]) { triangle.CalcMinMaxZ(); } abSegmentAsSTLModel.UpdateBoundries(); abSegmentAsSTLModel.CalcSliceIndexes(selectedMaterial, false); var sliceIndex = 0; foreach (var sliceHeight in abSegmentAsSTLModel.SliceIndexes.Keys) { resultAB.Add(sliceHeight, STLModel3D.GetSliceContoursForSupportConeV2(abSegmentAsSTLModel, sliceIndex, sliceHeight, selectedPrinter)); sliceIndex++; } //c segment var cSegmentAsSTLModel = new SupportCone(); cSegmentAsSTLModel.Triangles = this.CSegment.Triangles; foreach (var triangle in cSegmentAsSTLModel.Triangles[0]) { triangle.CalcMinMaxZ(); triangle.CalcMinMaxX(); triangle.CalcMinMaxY(); triangle.CalcCenter(); } cSegmentAsSTLModel.UpdateBoundries(); cSegmentAsSTLModel.CalcSliceIndexes(selectedMaterial, false); var resultC = new SortedDictionary <float, PolyTree>(); sliceIndex = 0; foreach (var sliceHeight in cSegmentAsSTLModel.SliceIndexes.Keys) { resultC.Add(sliceHeight, STLModel3D.GetSliceContoursForSupportConeV2(cSegmentAsSTLModel, sliceIndex, sliceHeight, selectedPrinter)); sliceIndex++; } //defg segment var defgSegmentAsSTLModel = new SupportCone(); defgSegmentAsSTLModel.Triangles = this.DSegment; defgSegmentAsSTLModel.Triangles[0].AddRange(this.TopSupportCone[0]); defgSegmentAsSTLModel.Triangles[0].AddRange(this.MiddleSupportCone[0]); defgSegmentAsSTLModel.Triangles[0].AddRange(this.BottomSupportCone[0]); foreach (var triangle in defgSegmentAsSTLModel.Triangles[0]) { triangle.CalcMinMaxZ(); } defgSegmentAsSTLModel.UpdateBoundries(); defgSegmentAsSTLModel.CalcSliceIndexes(selectedMaterial, false); var resultDEFG = new SortedDictionary <float, PolyTree>(); sliceIndex = 0; foreach (var sliceHeight in defgSegmentAsSTLModel.SliceIndexes.Keys) { resultDEFG.Add(sliceHeight, STLModel3D.GetSliceContoursForSupportConeV2(defgSegmentAsSTLModel, sliceIndex, sliceHeight, selectedPrinter)); sliceIndex++; } //combine all foreach (var sliceHeight in resultC.Keys) { if (!resultAB.ContainsKey(sliceHeight)) { resultAB.Add(sliceHeight, resultC[sliceHeight]); } else { resultAB[sliceHeight] = ContourHelper.UnionModelSliceLayer(resultAB[sliceHeight], resultC[sliceHeight]); } } foreach (var sliceHeight in resultDEFG.Keys) { if (!resultAB.ContainsKey(sliceHeight)) { resultAB.Add(sliceHeight, resultDEFG[sliceHeight]); } else { resultAB[sliceHeight] = ContourHelper.UnionModelSliceLayer(resultAB[sliceHeight], resultDEFG[sliceHeight]); } } this.SliceContours = resultAB; foreach (var interlinkConnectionIndex in this.InterlinkConnections) { if (interlinkConnectionIndex.Value != null) { foreach (var interlinkConnection in interlinkConnectionIndex.Value) { if (interlinkConnection != null) { interlinkConnection.CalcSlicesContours(selectedMaterial, selectedPrinter); } } } } }