Merge pull request #5329 from belov-oleg/path_simulator

Path Simulator: A workaround of the bug while milling curves with small radius
This commit is contained in:
sliptonic
2022-01-10 10:30:32 -06:00
committed by GitHub

View File

@@ -164,7 +164,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,
@@ -340,7 +341,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
(