From 822df5ba92b1973627dbcfc81f630216bdabf590 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 22 Nov 2021 12:45:10 +0200 Subject: [PATCH] - fixed the Travelling Salesman algorithm such that it does not add duplicated points that are next to each other --- CHANGELOG.md | 1 + camlib.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 673b0197..f90f0d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta - in AppTextEditor made some changes (added some placeholders and a message popup when reaching the end of document) - when viewing GCode the Find field can now keep the focus +- fixed the Travelling Salesman algorithm such that it does not add duplicated points that are next to each other 21.11.2021 diff --git a/camlib.py b/camlib.py index ff8586b2..4b678aef 100644 --- a/camlib.py +++ b/camlib.py @@ -3153,7 +3153,10 @@ class CNCjob(Geometry): # must_visit.remove(start) while must_visit: nearest = min(must_visit, key=lambda x: distance(path[-1], x)) - path.append(nearest) + # fixed the Travelling Salesman algorithm such that it does not add duplicated points + # that are next to each other + if nearest != path[-1]: + path.append(nearest) must_visit.remove(nearest) return path @@ -3706,6 +3709,7 @@ class CNCjob(Geometry): flat_geometry = flat_ext_geo + flat_ints_geo # flat_geometry = self.flatten(geometry, reset=True, pathonly=True) log.debug("%d paths" % len(flat_geometry)) + if tool_offset != 0.0: # for it in flat_geometry: # # if the geometry is a closed shape then create a Polygon out of it