Commit 9475ccdc authored by Nicholas Gar Hei Chan's avatar Nicholas Gar Hei Chan
Browse files

Removed timing and added color differentiation

parent c8500283
......@@ -13,7 +13,6 @@ try:
import matplotlib.pyplot as plt
except:
print("Matplotlib not installed")
import time
class Model():
"""Model class for storing layer and max/min data"""
......@@ -191,8 +190,12 @@ class Layer():
for line in self.lines:
points = '\t<polyline points="'
coords = [f"{x},{y} " for x,y in zip(line.x, line.y)]
points = points + "".join(coords) + ('"\n\tstyle="fill:none;stroke:black;stroke-width:0.4;'
'stroke-linejoin:round;stroke-linecap:round" />\n')
if line.line_type == "regular":
points = points + "".join(coords) + ('"\n\tstyle="fill:none;stroke:black;stroke-width:0.4;'
'stroke-linejoin:round;stroke-linecap:round" />\n')
if line.line_type == "infill":
points = points + "".join(coords) + ('"\n\tstyle="fill:none;stroke:blue;stroke-width:0.4;'
'stroke-linejoin:round;stroke-linecap:round" />\n')
out += points
for point in zip(self.sample_points['x'], self.sample_points['y']):
......@@ -283,7 +286,6 @@ def parse_gcode(filename, sample_spacing, samples_per_layer, method):
prev_z = 0
prev_e = 0
start = time.time()
with open(filename) as f: # Open GCODE file
file = f.readlines()
......@@ -332,7 +334,6 @@ def parse_gcode(filename, sample_spacing, samples_per_layer, method):
es.append(e_loc)
else:
es.append(prev_e)
print("Import time: {} seconds".format(time.time()-start))
[layer_heights.append(height) for height in set(zs)] # Find the unique Z heights in the GCODE file
layer_heights.sort() # Make it a sorted list
......@@ -345,12 +346,10 @@ def parse_gcode(filename, sample_spacing, samples_per_layer, method):
layers[index[zs[i]]].append_coords(xs[i],ys[i],es[i],Gs[i]) # Append each command into the model list
layers = [layer for layer in layers if layer.len() > 0]
print("Regen time: {} seconds".format(time.time()-start))
for i in range(len(layers)):
if (i % sample_spacing) == 0 and (i != 0):
layers[i].gen_sample_points(method, samples_per_layer)
else:
layers[i].gen_sample_points("none", 0)
print("Total time: {} seconds".format(time.time()-start))
model = Model(layers, max(xs), max(ys), max(zs), min(xs), min(ys), min(zs))
return model
Supports Markdown
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