chiark / gitweb /
Save a lot of memory by storing the loaded GCode as numpy arrays instead of python...
authordaid303 <daid303@gmail.com>
Wed, 1 May 2013 15:18:45 +0000 (17:18 +0200)
committerdaid303 <daid303@gmail.com>
Wed, 1 May 2013 15:18:45 +0000 (17:18 +0200)
Cura/gui/sceneView.py
Cura/util/gcodeInterpreter.py

index 72ed1b0371cf615fc108c0ca90f0f42b02fdd373..22961d9e8435ae003845d8e1565bfff4a82ab5bc 100644 (file)
@@ -1030,7 +1030,7 @@ void main(void)
                        pointList = numpy.zeros((0,3), numpy.float32)
                        for path in layer:
                                if path.type == 'extrude' and path.pathType == extrudeType:
-                                       a = numpy.array(path.points, numpy.float32)
+                                       a = path.points
                                        a = numpy.concatenate((a[:-1], a[1:]), 1)
                                        a = a.reshape((len(a) * 2, 3))
                                        pointList = numpy.concatenate((pointList, a))
@@ -1046,7 +1046,7 @@ void main(void)
                        pointList = numpy.zeros((0,3), numpy.float32)
                        for path in layer:
                                if path.type == 'extrude' and path.pathType == extrudeType:
-                                       a = numpy.array(path.points, numpy.float32)
+                                       a = path.points
                                        if extrudeType == 'FILL':
                                                a[:,2] += 0.01
 
index 5348c3cef010ff5fd0d19804b70d6720bc4e9134..e119f85f0ea696a95eb0096585cbf34051e82432 100644 (file)
@@ -4,6 +4,7 @@ import sys
 import math
 import os
 import time
+import numpy
 
 from Cura.util import profile
 
@@ -88,13 +89,18 @@ class gcode(object):
                                elif comment == 'skirt':
                                        pathType = 'SKIRT'
                                if comment.startswith('LAYER:'):
+                                       currentPath = gcodePath(moveType, pathType, layerThickness, currentPath.points[-1])
+                                       currentPath.extruder = currentExtruder
+                                       for path in currentLayer:
+                                               path.points = numpy.array(path.points, numpy.float32)
+                                               path.extrusion = numpy.array(path.extrusion, numpy.float32)
                                        self.layerList.append(currentLayer)
                                        if self.progressCallback is not None:
                                                if self.progressCallback(float(gcodeFile.tell()) / float(self._fileSize)):
                                                        #Abort the loading, we can safely return as the results here will be discarded
                                                        gcodeFile.close()
                                                        return
-                                       currentLayer = []
+                                       currentLayer = [currentPath]
                                line = line[0:line.find(';')]
                        T = getCodeInt(line, 'T')
                        if T is not None:
@@ -254,6 +260,9 @@ class gcode(object):
                                                        extrudeAmountMultiply = s / 100.0
                                        else:
                                                print "Unknown M code:" + str(M)
+               for path in currentLayer:
+                       path.points = numpy.array(path.points, numpy.float32)
+                       path.extrusion = numpy.array(path.extrusion, numpy.float32)
                self.layerList.append(currentLayer)
                if self.progressCallback is not None and self._fileSize > 0:
                        self.progressCallback(float(gcodeFile.tell()) / float(self._fileSize))