add ChartRange to ClStrip.

This commit is contained in:
iamboss 2025-12-22 23:35:43 +08:00
parent 9f5f146841
commit 8d56a9984b
4 changed files with 35 additions and 33 deletions

View File

@ -2,7 +2,7 @@
using Hi.HiNcKits;
using Hi.Licenses;
using Hi.MongoUtils;
using Hi.Wpf.Disp;
using Hi.WpfPlus.Disp;
using System.Windows;
namespace Sample.Disp

View File

@ -25,11 +25,11 @@
<ProjectReference Include="..\HiMech\HiMech.csproj" />
<ProjectReference Include="..\HiUniNc\HiUniNc.csproj" />
<ProjectReference Include="..\HiNc\HiNc.csproj" />
<ProjectReference Include="..\Hi.Wpf\Hi.Wpf.csproj" />
<ProjectReference Include="..\Hi.WpfPlus\Hi.WpfPlus.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="HiNc" Version="3.1.*" />
<PackageReference Include="Hi.Wpf" Version="3.1.*" />
<PackageReference Include="Hi.WpfPlus" Version="3.1.*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Mech\" />

View File

@ -5,7 +5,7 @@ using Hi.Geom.Resolution;
using Hi.HiNcKits;
using Hi.MachiningProcs;
using Hi.Numerical.Acts;
using Hi.Wpf.Disp;
using Hi.WpfPlus.Disp;
using HiMachining.Milling;
using System;
using System.IO;
@ -42,21 +42,21 @@ namespace Sample.Machining
//var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
var projectPath = "C:/HiNC-Projects/demo-test-1/Main.hincproj";
Console.WriteLine($"Load Project: {projectPath}");
localProjectService.LoadProject(projectPath).ShowIfCatched(null);
localProjectService.LoadProject(projectPath);
var project = localProjectService.MachiningProject;
#endregion
var projectDisplayee = new MachiningProjectDisplayee(()=> localProjectService.MachiningProject);
var projectDisplayee = new MachiningProjectDisplayee(localProjectService);
var device = new ClMillingDevice();
project.MachiningEquipment.MachiningChain = device;
project.ClStrip.IsShowDot = true;
localProjectService.MachiningEquipment.MachiningChain = device;
localProjectService.ClStrip.IsShowDot = true;
double resolution_mm = 0.5;
var projectDir = Path.GetDirectoryName(projectPath);
project.Workpiece.InitGeom = new StlFile(stlFile_CylinderR20, projectDir);
project.Workpiece.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir);
project.Workpiece.InitResolution = resolution_mm;
localProjectService.Workpiece.InitGeom = new StlFile(stlFile_CylinderR20, projectDir);
localProjectService.Workpiece.IdealGeom = new StlFile(stlFile_CylinderR19, projectDir);
localProjectService.Workpiece.InitResolution = resolution_mm;
RuntimeApi runtimeApi = project.RuntimeApi;
RuntimeApi runtimeApi = localProjectService.RuntimeApi;
runtimeApi.SetNcResolutionFixed(9999, 15);
runtimeApi.EnableCollisionDetection = false;
runtimeApi.EnablePhysics = false;
@ -65,13 +65,13 @@ namespace Sample.Machining
//RunConsole(project, projectDisplayee, resolution_mm);
RunWindow(localProjectService, projectDisplayee, resolution_mm);
}
static void RunConsole(IProjectService projectService,
static void RunConsole(LocalProjectService projectService,
MachiningProjectDisplayee projectDisplayee, double resolution_mm)
{
RunSession(projectService, resolution_mm);
DispEngine dispEngine = new DispEngine(projectDisplayee);
dispEngine.SetViewToIsometricView();
dispEngine.SketchView = projectService.MachiningProject.ClStrip.GetFittingView(dispEngine.SketchView);
dispEngine.SketchView = projectService.ClStrip.GetFittingView(dispEngine.SketchView);
dispEngine.SketchView = dispEngine.SketchView.Scale(0.5);
dispEngine.Snapshot($"Cache/result.bmp", 1000, 1000);
@ -79,7 +79,7 @@ namespace Sample.Machining
LocalApp.AppEnd();
Console.WriteLine($"App exit.");
}
static void RunWindow(IProjectService projectService,
static void RunWindow(LocalProjectService projectService,
MachiningProjectDisplayee projectDisplayee, double resolution_mm)
{
var task = Task.Run(() =>
@ -106,16 +106,16 @@ namespace Sample.Machining
});
#endregion
}
static void RunSession(IProjectService projectService, double resolution_mm)
static void RunSession(LocalProjectService localProjectService, double resolution_mm)
{
var project=projectService.MachiningProject;
RuntimeApi runtimeApi = project.RuntimeApi;
var project=localProjectService.MachiningProject;
RuntimeApi runtimeApi = localProjectService.RuntimeApi;
project.BeginSession();
localProjectService.BeginSession();
double radius = 20;
double z = -1;
project.Act(new ActToolingTeleport(1));//equip tool
project.Act(new ActClTeleport(new DVec3d(radius, 0, z, 0, 0, 1)));//goto initial position
localProjectService.Act(new ActToolingTeleport(1));//equip tool
localProjectService.Act(new ActClTeleport(new DVec3d(radius, 0, z, 0, 0, 1)));//goto initial position
//run an arbitrary contour.
int divNum = 36;
for (int i = 0; i <= divNum; i++)
@ -125,16 +125,16 @@ namespace Sample.Machining
radius * Math.Sin(i * Math.PI * 2 / divNum), z,
0, 0, 1);
Console.WriteLine($"{cl.Point.CsvText},{cl.Normal.CsvText},");
project.Act(new ActClStep(cl));
localProjectService.Act(new ActClStep(cl));
}
double diffLimit_mm = resolution_mm * 2;
runtimeApi.Diff(resolution_mm * 2);
Console.WriteLine($"IsDifferenceAceptable: {IsDifferenceAceptable(project, diffLimit_mm)}");
project.EndSession();
Console.WriteLine($"IsDifferenceAceptable: {IsDifferenceAceptable(localProjectService, diffLimit_mm)}");
localProjectService.EndSession();
}
static bool IsDifferenceAceptable(MachiningProject project, double diffLimit)
static bool IsDifferenceAceptable(LocalProjectService localProjectService, double diffLimit)
{
foreach (var attachment in project.Workpiece.DiffAttachmentBag)
foreach (var attachment in localProjectService.Workpiece.DiffAttachmentBag)
{
if (double.IsNaN(attachment.Diff) || Math.Abs(attachment.Diff) > diffLimit)
{

View File

@ -1,4 +1,4 @@
using Hi.Wpf.Disp;
using Hi.WpfPlus.Disp;
using System;
using Hi.MachiningProcs;
using Hi.Common.FileLines;
@ -23,22 +23,24 @@ namespace Sample.Machining
static void Main(string[] args)
{
LocalApp.AppBegin();
LocalProjectService localProjectService = new LocalProjectService();
#region Load Machining Project
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
#region Load Machining Project
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
Console.WriteLine($"Load Project: {projectPath}");
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
localProjectService.LoadProject(projectPath);
MachiningProject machiningProject = localProjectService.MachiningProject;
machiningProject.RuntimeApi.MachiningStepSelected += (MachiningStep step) =>
localProjectService.RuntimeApi.MachiningStepSelected += (MachiningStep step) =>
{
var sourceCommand = step.SourceCommand;
Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
};
machiningProject.PacePlayer.Start();
localProjectService.PacePlayer.Start();
#endregion
#region Configure Rendering Options
var projectDisplayee = new MachiningProjectDisplayee(()=>machiningProject);
var projectDisplayee = new MachiningProjectDisplayee(localProjectService);
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = true;