Skip to content
Snippets Groups Projects
Commit d26bb4d0 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

Bug fix, dependency graph working (fix #1)

parent dd9a03b5
No related merge requests found
......@@ -213,9 +213,9 @@ class DependencyGraph:
# add edges to graph showing dependencies
for n in self.G.nodes:
l = self.G.nodes[n]['layer']
# Add every contour from max_layers below to dependencies
if self.G.nodes[n]['layer'] >= max_layers:
if l >= max_layers:
for c in self.layers[l - max_layers]:
self.G.add_edge(c,n)
......@@ -224,7 +224,9 @@ class DependencyGraph:
continue
for c in self.layers[l-1]:
# If any waypoint is closer than the specified distance
if any([abs(a-b)<dep_range for a in contours[c].pos for b in contours[n].pos]):
if any([abs(a-b)<dep_range
for a in contours[c].pos
for b in contours[n].pos]):
self.G.add_edge(c,n)
# set variables to the starting state
......@@ -261,7 +263,7 @@ class DependencyGraph:
for _,c in self.G.out_edges(contour_id):
# If all dependencies have been done, make contour c available
if all([d in self.done_contours for d,_ in self.g.in_edges[c]]):
if all([d in self.done_contour_ids for d,_ in self.G.in_edges(c)]):
self.avail_contour_ids.append(c)
# save available contours
......
......@@ -3,7 +3,7 @@ import random
import time
start = time.time()
contours = gc.decode_gcode("benchy.gcode")
contours = gc.decode_gcode("pug_lowpoly.gcode")
print(len(contours))
print("Contours Read, Creating dependency graph...")
......@@ -14,5 +14,5 @@ print(end-start)
while len(tracker.available_contours)>0:
done_contours = [tracker.G.nodes[n]['contour'] for n in tracker.done_contour_ids]
gc.plot_contours(tracker.available_contours, done_contours)
gc.plot_contours([],[], tracker.available_contours, [], done_contours)
tracker.do_contour(random.choice(tracker.avail_contour_ids))
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment