Dogbone resiliency against comments between moves
This commit is contained in:
@@ -39,8 +39,8 @@ Part = LazyLoader('Part', globals(), 'Part')
|
||||
|
||||
LOG_MODULE = PathLog.thisModule()
|
||||
|
||||
PathLog.setLevel(PathLog.Level.NOTICE, LOG_MODULE)
|
||||
#PathLog.trackModule(LOG_MODULE)
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
|
||||
PathLog.trackModule(LOG_MODULE)
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
@@ -301,6 +301,9 @@ class Chord (object):
|
||||
def isAPlungeMove(self):
|
||||
return not PathGeom.isRoughly(self.End.z, self.Start.z)
|
||||
|
||||
def isANoopMove(self):
|
||||
return PathGeom.pointsCoincide(self.Start, self.End)
|
||||
|
||||
def foldsBackOrTurns(self, chord, side):
|
||||
direction = chord.getDirectionOf(self)
|
||||
PathLog.info(" - direction = %s/%s" % (direction, side))
|
||||
@@ -439,7 +442,7 @@ class ObjectDressup:
|
||||
|
||||
# Answer true if a dogbone could be on either end of the chord, given its command
|
||||
def canAttachDogbone(self, cmd, chord):
|
||||
return cmd.Name in movestraight and not chord.isAPlungeMove()
|
||||
return cmd.Name in movestraight and not chord.isAPlungeMove() and not chord.isANoopMove()
|
||||
|
||||
def shouldInsertDogbone(self, obj, inChord, outChord):
|
||||
return outChord.foldsBackOrTurns(inChord, self.theOtherSideOf(obj.Side))
|
||||
@@ -809,6 +812,8 @@ class ObjectDressup:
|
||||
commands.append(lastCommand)
|
||||
lastCommand = thisCommand
|
||||
lastBone = None
|
||||
elif thisChord.isANoopMove():
|
||||
PathLog.info(" dropping noop move")
|
||||
else:
|
||||
PathLog.info(" nope")
|
||||
if lastCommand:
|
||||
@@ -823,12 +828,13 @@ class ObjectDressup:
|
||||
|
||||
lastChord = thisChord
|
||||
else:
|
||||
PathLog.info(" Clean slate")
|
||||
if lastCommand:
|
||||
commands.append(lastCommand)
|
||||
lastCommand = None
|
||||
if thisCommand.Name[0] != '(':
|
||||
PathLog.info(" Clean slate")
|
||||
if lastCommand:
|
||||
commands.append(lastCommand)
|
||||
lastCommand = None
|
||||
lastBone = None
|
||||
commands.append(thisCommand)
|
||||
lastBone = None
|
||||
# for cmd in commands:
|
||||
# PathLog.debug("cmd = '%s'" % cmd)
|
||||
path = Path.Path(commands)
|
||||
|
||||
@@ -56,7 +56,15 @@ class TestDressupDogbone(PathTestBase):
|
||||
|
||||
def test00(self):
|
||||
'''Verify bones are inserted for simple moves.'''
|
||||
base = TestProfile('Inside', 'CW', 'G0 X10 Y10 Z10\nG1 Z0\nG1 Y100\nG1 X12\nG1 Y10\nG1 X10\nG1 Z10')
|
||||
base = TestProfile('Inside', 'CW', '''
|
||||
G0 X10 Y10 Z10
|
||||
G1 Z0
|
||||
G1 Y100
|
||||
G1 X12
|
||||
G1 Y10
|
||||
G1 X10
|
||||
G1 Z10
|
||||
''')
|
||||
obj = TestFeature()
|
||||
db = PathDressupDogbone.ObjectDressup(obj, base)
|
||||
db.setup(obj, True)
|
||||
@@ -69,7 +77,15 @@ class TestDressupDogbone(PathTestBase):
|
||||
|
||||
def test01(self):
|
||||
'''Verify bones are inserted if hole ends with rapid move out.'''
|
||||
base = TestProfile('Inside', 'CW', 'G0 X10 Y10 Z10\nG1 Z0\nG1 Y100\nG1 X12\nG1 Y10\nG1 X10\nG0 Z10')
|
||||
base = TestProfile('Inside', 'CW', '''
|
||||
G0 X10 Y10 Z10
|
||||
G1 Z0
|
||||
G1 Y100
|
||||
G1 X12
|
||||
G1 Y10
|
||||
G1 X10
|
||||
G0 Z10
|
||||
''')
|
||||
obj = TestFeature()
|
||||
db = PathDressupDogbone.ObjectDressup(obj, base)
|
||||
db.setup(obj, True)
|
||||
@@ -149,11 +165,11 @@ class TestDressupDogbone(PathTestBase):
|
||||
base = TestProfile('Inside', 'CW', '''
|
||||
G0 X10 Y10 Z10
|
||||
G1 Z0
|
||||
G1 X0
|
||||
G1 X0 ( start)
|
||||
G1 Y0
|
||||
G1 X15
|
||||
G1 Y10
|
||||
G1 X10
|
||||
G1 X10 ( straight line move to start)
|
||||
G0 Z10
|
||||
''')
|
||||
obj = TestFeature()
|
||||
@@ -161,3 +177,45 @@ class TestDressupDogbone(PathTestBase):
|
||||
db.setup(obj, True)
|
||||
db.execute(obj, False)
|
||||
self.assertEqual(len(db.bones), 0)
|
||||
|
||||
def test04(self):
|
||||
'''Verify can handle comments between moves'''
|
||||
base = TestProfile('Inside', 'CW', '''
|
||||
G0 X10 Y10 Z10
|
||||
G1 Z0
|
||||
G1 X20
|
||||
G1 Y0
|
||||
G1 X10
|
||||
G1 Y10
|
||||
G1 Z10
|
||||
''')
|
||||
obj = TestFeature()
|
||||
db = PathDressupDogbone.ObjectDressup(obj, base)
|
||||
db.setup(obj, True)
|
||||
db.execute(obj, False)
|
||||
self.assertEqual(len(db.bones), 4)
|
||||
self.assertEqual("1: (20.00, 10.00)", self.formatBone(db.bones[0]))
|
||||
self.assertEqual("2: (20.00, 0.00)", self.formatBone(db.bones[1]))
|
||||
self.assertEqual("3: (10.00, 0.00)", self.formatBone(db.bones[2]))
|
||||
self.assertEqual("4: (10.00, 10.00)", self.formatBone(db.bones[3]))
|
||||
|
||||
base = TestProfile('Inside', 'CW', '''
|
||||
G0 X10 Y10 Z10
|
||||
G1 Z0
|
||||
G1 X20
|
||||
G1 Y0
|
||||
G1 X10
|
||||
(some comment or other should not change the output)
|
||||
G1 Y10
|
||||
G1 Z10
|
||||
''')
|
||||
obj = TestFeature()
|
||||
db = PathDressupDogbone.ObjectDressup(obj, base)
|
||||
db.setup(obj, True)
|
||||
db.execute(obj, False)
|
||||
self.assertEqual(len(db.bones), 4)
|
||||
self.assertEqual("1: (20.00, 10.00)", self.formatBone(db.bones[0]))
|
||||
self.assertEqual("2: (20.00, 0.00)", self.formatBone(db.bones[1]))
|
||||
self.assertEqual("3: (10.00, 0.00)", self.formatBone(db.bones[2]))
|
||||
self.assertEqual("4: (10.00, 10.00)", self.formatBone(db.bones[3]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user