support stepdown greater than total depth, 2nd try
This commit is contained in:
parent
96dc57c068
commit
fea0e02fc1
|
@ -35,6 +35,7 @@ from DraftGeomUtils import geomType
|
||||||
import PathScripts
|
import PathScripts
|
||||||
from PathScripts import PathJob
|
from PathScripts import PathJob
|
||||||
# import itertools
|
# import itertools
|
||||||
|
import numpy
|
||||||
|
|
||||||
def cleanedges(splines, precision):
|
def cleanedges(splines, precision):
|
||||||
'''cleanedges([splines],precision). Convert BSpline curves, Beziers, to arcs that can be used for cnc paths.
|
'''cleanedges([splines],precision). Convert BSpline curves, Beziers, to arcs that can be used for cnc paths.
|
||||||
|
@ -840,27 +841,53 @@ class depth_params:
|
||||||
'''returns a list of depths to be used in order from first to last.
|
'''returns a list of depths to be used in order from first to last.
|
||||||
equalstep=True: all steps down before the finish pass will be equalized.'''
|
equalstep=True: all steps down before the finish pass will be equalized.'''
|
||||||
|
|
||||||
depths = []
|
|
||||||
if self.user_depths is not None:
|
if self.user_depths is not None:
|
||||||
depths = self.user_depths
|
return self.user_depths
|
||||||
else:
|
|
||||||
total_depth = self.start_depth - self.final_depth
|
total_depth = self.start_depth - self.final_depth
|
||||||
if total_depth <= 0:
|
|
||||||
return depths
|
if total_depth < 0:
|
||||||
layers_required = int((total_depth - self.z_finish_step) / self.step_down)
|
return []
|
||||||
partial_steplayer = (total_depth - self.z_finish_step) % self.step_down
|
|
||||||
if equalstep is True and partial_steplayer > 0:
|
depths = [self.final_depth]
|
||||||
layerstep = float((total_depth - self.z_finish_step) / (layers_required + 1))
|
|
||||||
|
# apply finish step if necessary
|
||||||
|
if self.z_finish_step > 0:
|
||||||
|
if self.z_finish_step < total_depth:
|
||||||
|
depths.append(self.z_finish_step + self.final_depth)
|
||||||
else:
|
else:
|
||||||
layerstep = self.step_down
|
return depths
|
||||||
|
|
||||||
for step in range(layers_required):
|
if equalstep:
|
||||||
d = self.start_depth - ((step +1) * layerstep)
|
depths += self.__equal_steps(self.start_depth, depths[-1], self.step_down)[1:]
|
||||||
depths.append(d)
|
else:
|
||||||
|
depths += self.__fixed_steps(self.start_depth, depths[-1], self.step_down)[1:]
|
||||||
if self.z_finish_step != 0 and depths[-1] != self.final_depth + self.z_finish_step:
|
|
||||||
depths.append(self.final_depth + self.z_finish_step)
|
|
||||||
if depths[-1] != self.final_depth:
|
|
||||||
depths.append(self.final_depth)
|
|
||||||
|
|
||||||
|
depths.reverse()
|
||||||
return depths
|
return depths
|
||||||
|
|
||||||
|
def __equal_steps(self, start, stop, max_size):
|
||||||
|
'''returns a list of depths beginning with the bottom (included), ending
|
||||||
|
with the top (not included).
|
||||||
|
all steps are of equal size, which is as big as possible but not bigger
|
||||||
|
than max_size.'''
|
||||||
|
|
||||||
|
steps_needed = math.ceil((start - stop) / max_size)
|
||||||
|
depths = numpy.linspace(stop, start, steps_needed, endpoint=False)
|
||||||
|
|
||||||
|
return depths.tolist()
|
||||||
|
|
||||||
|
def __fixed_steps(self, start, stop, size):
|
||||||
|
'''returns a list of depths beginning with the bottom (included), ending
|
||||||
|
with the top (not included).
|
||||||
|
all steps are of size 'size' except the one at the bottom wich can be
|
||||||
|
smaller.'''
|
||||||
|
|
||||||
|
fullsteps = int((start - stop) / size)
|
||||||
|
last_step = start - (fullsteps * size)
|
||||||
|
depths = numpy.linspace(last_step, start, fullsteps, endpoint=False)
|
||||||
|
|
||||||
|
if last_step == stop:
|
||||||
|
return depths.tolist()
|
||||||
|
else:
|
||||||
|
return [stop] + depths.tolist()
|
||||||
|
|
|
@ -73,7 +73,7 @@ class depthTestCases(unittest.TestCase):
|
||||||
final_depth = 10
|
final_depth = 10
|
||||||
user_depths = None
|
user_depths = None
|
||||||
|
|
||||||
expected =[]
|
expected =[10]
|
||||||
|
|
||||||
d = PU.depth_params(clearance_height, rapid_safety_space, start_depth, step_down, z_finish_step, final_depth, user_depths)
|
d = PU.depth_params(clearance_height, rapid_safety_space, start_depth, step_down, z_finish_step, final_depth, user_depths)
|
||||||
r = d.get_depths()
|
r = d.get_depths()
|
||||||
|
@ -109,7 +109,7 @@ class depthTestCases(unittest.TestCase):
|
||||||
self.assertListEqual (r, expected)
|
self.assertListEqual (r, expected)
|
||||||
|
|
||||||
def test40(self):
|
def test40(self):
|
||||||
'''Finish depth passed in.'''
|
'''z_finish_step passed in.'''
|
||||||
clearance_height= 10
|
clearance_height= 10
|
||||||
rapid_safety_space = 5
|
rapid_safety_space = 5
|
||||||
|
|
||||||
|
@ -161,3 +161,23 @@ class depthTestCases(unittest.TestCase):
|
||||||
r = d.get_depths(equalstep=True)
|
r = d.get_depths(equalstep=True)
|
||||||
self.assertListEqual (r, expected)
|
self.assertListEqual (r, expected)
|
||||||
|
|
||||||
|
def test70(self):
|
||||||
|
'''stepping down with stepdown greater than total depth'''
|
||||||
|
clearance_height= 10
|
||||||
|
rapid_safety_space = 5
|
||||||
|
|
||||||
|
start_depth = 10
|
||||||
|
step_down = 20
|
||||||
|
z_finish_step = 1
|
||||||
|
final_depth = 0
|
||||||
|
user_depths = None
|
||||||
|
|
||||||
|
expected =[1.0, 0]
|
||||||
|
|
||||||
|
d = PU.depth_params(clearance_height, rapid_safety_space, start_depth, step_down, z_finish_step, final_depth, user_depths)
|
||||||
|
r = d.get_depths(equalstep=True)
|
||||||
|
self.assertListEqual (r, expected)
|
||||||
|
|
||||||
|
d = PU.depth_params(clearance_height, rapid_safety_space, start_depth, step_down, z_finish_step, final_depth, user_depths)
|
||||||
|
r = d.get_depths()
|
||||||
|
self.assertListEqual (r, expected)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user