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

Added sampling point rendering to gcodeprocessor

parent 5f005bfe
......@@ -153,7 +153,8 @@ class Layer():
points = points + "".join(coords) + ('"\n\tstyle="fill:none;stroke:black;stroke-width:0.4;'
'stroke-linejoin:round;stroke-linecap:round" />\n')
f.write(points)
for point in zip(self.sample_points['x'], self.sample_points['y']):
f.write('\t<circle cx="{}" cy="{}" r="1" stroke="red" stroke-width="0" fill="red"></circle>\n'.format(point[0], point[1]))
f.write('</svg>')
def to_svg_inline(self, max_height, viewbox_width, viewbox_height):
......@@ -167,6 +168,8 @@ class Layer():
'stroke-linejoin:round;stroke-linecap:round" />\n')
out += points
for point in zip(self.sample_points['x'], self.sample_points['y']):
out += '\t<circle cx="{}" cy="{}" r="1" stroke="red" stroke-width="0" fill="red"></circle>\n'.format(point[0], point[1])
out += '</svg>'
return out
......
......@@ -16,16 +16,11 @@ model = gcp.parse_gcode(os.path.abspath("LM_rocktopus.gcode"), 5, 10)
print("Execution time: {} seconds".format(time.time()-start))
layer = model.layers[10]
pts = layer.get_points()
num_samples = 10
sample_pts = list(np.random.randint(0,pts['num_pts'],num_samples))
#model.layers[10].plot_layer()
for pt in sample_pts:
plt.plot(pts['x'][pt], pts['y'][pt], 'ro')
layer.to_svg(model.max_y, model.max_x, 'test.svg')
plt.show()
......
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