Commit 7c3250a9 authored by Guillaume Seguin's avatar Guillaume Seguin

Add lineno => (layer, layer_line) mapping to gcoder

parent be10cff3
...@@ -131,6 +131,7 @@ class GCode(object): ...@@ -131,6 +131,7 @@ class GCode(object):
lines = None lines = None
layers = None layers = None
all_layers = None all_layers = None
idxs = None
def __init__(self,data): def __init__(self,data):
self.lines = [Line(l2) for l2 in self.lines = [Line(l2) for l2 in
...@@ -169,6 +170,10 @@ class GCode(object): ...@@ -169,6 +170,10 @@ class GCode(object):
def _create_layers(self): def _create_layers(self):
layers = {} layers = {}
all_layers = [] all_layers = []
idxs = []
layer_id = 0
layer_line = 0
prev_z = None prev_z = None
cur_z = 0 cur_z = 0
...@@ -189,8 +194,12 @@ class GCode(object): ...@@ -189,8 +194,12 @@ class GCode(object):
old_lines += cur_lines old_lines += cur_lines
layers[prev_z] = old_lines layers[prev_z] = old_lines
cur_lines = [] cur_lines = []
layer_id += 1
layer_line = 0
cur_lines.append(line) cur_lines.append(line)
idxs.append((layer_id, layer_line))
layer_line += 1
prev_z = cur_z prev_z = cur_z
if cur_lines: if cur_lines:
...@@ -213,6 +222,7 @@ class GCode(object): ...@@ -213,6 +222,7 @@ class GCode(object):
self.all_layers = all_layers self.all_layers = all_layers
self.layers = layers self.layers = layers
self.idxs = idxs
def num_layers(self): def num_layers(self):
return len(self.layers) return len(self.layers)
......
Markdown is supported
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