Path: Fix simulator bug workaround while milling curves with small radius.

Path Simulator produces out of trace artifacts while milling curves with small radius.
In VolSim.cpp the branch for curve radius smaller then tool radius is not implemented yet.
In this condition the simulator produces artifacts of higher radius while milling path using G2 or G3.
There is an implementation of G2 and G3 in python level.
This commit is contained in:
Oleg Belov
2022-01-07 21:12:37 +03:00
parent ad2169e5ae
commit 161da1d80a

View File

@@ -165,7 +165,8 @@ class PathSimulation:
maxlen = self.stock.BoundBox.XLength
if maxlen < self.stock.BoundBox.YLength:
maxlen = self.stock.BoundBox.YLength
self.voxSim.BeginSimulation(self.stock, 0.01 * self.accuracy * maxlen)
self.resolution = 0.01 * self.accuracy * maxlen
self.voxSim.BeginSimulation(self.stock, self.resolution)
(
self.cutMaterial.Mesh,
self.cutMaterialIn.Mesh,
@@ -343,7 +344,29 @@ class PathSimulation:
# for cmd in job.Path.Commands:
if cmd.Name in ["G0", "G1", "G2", "G3"]:
self.firstDrill = True
self.curpos = self.voxSim.ApplyCommand(self.curpos, cmd)
if cmd.Name in ['G2', 'G3'] and (cmd.k or 0) == 0:
cx = self.curpos.Base.x + (cmd.i or 0)
cy = self.curpos.Base.y + (cmd.j or 0)
a0 = math.atan2( self.curpos.Base.y - cy, self.curpos.Base.x - cx )
a1 = math.atan2( cmd.y - cy, cmd.x - cx )
da = a1 - a0
if cmd.Name == 'G3':
da = da % (2 * math.pi)
else:
da = -((-da) % (2 * math.pi))
r = math.sqrt( (cmd.i or 0) ** 2 + (cmd.j or 0) ** 2 )
n = math.ceil( math.sqrt( r / self.resolution * da * da ) )
da = da / n
dz = (cmd.z - self.curpos.Base.z) / n
cmd.Name = 'G1'
for i in range( n ):
a0 += da
cmd.x = cx + r * math.cos( a0 )
cmd.y = cy + r * math.sin( a0 )
cmd.z = self.curpos.Base.z + dz
self.curpos = self.voxSim.ApplyCommand(self.curpos, cmd)
else:
self.curpos = self.voxSim.ApplyCommand(self.curpos, cmd)
if not self.disableAnim:
self.cutTool.Placement = self.curpos
(