From a589be64d9cdc5f3cdcf64f9cc07fec5313d95ca Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Mon, 15 Mar 2021 22:37:03 -0700 Subject: [PATCH] Dogbone resiliency against noop moves --- .../Path/PathScripts/PathDressupDogbone.py | 8 ++-- .../Path/PathTests/TestPathDressupDogbone.py | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDressupDogbone.py b/src/Mod/Path/PathScripts/PathDressupDogbone.py index 6200ca03aa..a5a46d6058 100644 --- a/src/Mod/Path/PathScripts/PathDressupDogbone.py +++ b/src/Mod/Path/PathScripts/PathDressupDogbone.py @@ -39,8 +39,8 @@ Part = LazyLoader('Part', globals(), 'Part') LOG_MODULE = PathLog.thisModule() -PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) -PathLog.trackModule(LOG_MODULE) +PathLog.setLevel(PathLog.Level.NOTICE, LOG_MODULE) +#PathLog.trackModule(LOG_MODULE) # Qt translation handling @@ -302,6 +302,7 @@ class Chord (object): return not PathGeom.isRoughly(self.End.z, self.Start.z) def isANoopMove(self): + PathLog.debug("{}.isANoopMove(): {}".format(self, PathGeom.pointsCoincide(self.Start, self.End))) return PathGeom.pointsCoincide(self.Start, self.End) def foldsBackOrTurns(self, chord, side): @@ -813,7 +814,8 @@ class ObjectDressup: lastCommand = thisCommand lastBone = None elif thisChord.isANoopMove(): - PathLog.info(" dropping noop move") + PathLog.info(" ignoring and dropping noop move") + continue else: PathLog.info(" nope") if lastCommand: diff --git a/src/Mod/Path/PathTests/TestPathDressupDogbone.py b/src/Mod/Path/PathTests/TestPathDressupDogbone.py index 89ac002c53..68a213ccc4 100644 --- a/src/Mod/Path/PathTests/TestPathDressupDogbone.py +++ b/src/Mod/Path/PathTests/TestPathDressupDogbone.py @@ -219,3 +219,45 @@ class TestDressupDogbone(PathTestBase): self.assertEqual("3: (10.00, 0.00)", self.formatBone(db.bones[2])) self.assertEqual("4: (10.00, 10.00)", self.formatBone(db.bones[3])) + + def test05(self): + '''Verify can handle noops 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 + 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])) +