refactor(Sample.Wpf): use WorkpieceService and CatchExceptions in DemoMillingByCutterLocation

Made-with: Cursor
This commit is contained in:
iamboss 2026-04-11 11:19:38 +08:00
parent b21da87ded
commit 58f3a19232

View File

@ -53,8 +53,8 @@ namespace Sample.Machining
localProjectService.ClStrip.IsShowDot = true; localProjectService.ClStrip.IsShowDot = true;
double resolution_mm = 0.5; double resolution_mm = 0.5;
var projectDir = Path.GetDirectoryName(projectPath); var projectDir = Path.GetDirectoryName(projectPath);
localProjectService.Workpiece.InitGeom = new StlFile(stlFile_CylinderR20, projectDir); localProjectService.WorkpieceService.InitGeom = new StlFile(stlFile_CylinderR20, projectDir);
localProjectService.Workpiece.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir); localProjectService.WorkpieceService.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir);
localProjectService.Workpiece.InitResolution = resolution_mm; localProjectService.Workpiece.InitResolution = resolution_mm;
RuntimeApi runtimeApi = localProjectService.RuntimeApi; RuntimeApi runtimeApi = localProjectService.RuntimeApi;
@ -87,7 +87,7 @@ namespace Sample.Machining
{ {
RunSession(projectService, resolution_mm); RunSession(projectService, resolution_mm);
Console.WriteLine($"task done."); Console.WriteLine($"task done.");
}).ShowIfCatched(null); }).CatchExceptions(ex => Console.WriteLine(ex));
#region Create and Run WPF Application #region Create and Run WPF Application
Application app = new Application Application app = new Application
@ -135,7 +135,7 @@ namespace Sample.Machining
} }
static bool IsDifferenceAceptable(LocalProjectService localProjectService, double diffLimit) static bool IsDifferenceAceptable(LocalProjectService localProjectService, double diffLimit)
{ {
foreach (var attachment in localProjectService.Workpiece.DiffAttachmentBag) foreach (var attachment in localProjectService.WorkpieceService.DiffAttachmentBag)
{ {
if (double.IsNaN(attachment.Diff) || Math.Abs(attachment.Diff) > diffLimit) if (double.IsNaN(attachment.Diff) || Math.Abs(attachment.Diff) > diffLimit)
{ {