Account for center and proper layer height when displaying the sliced layers

This commit is contained in:
Arjen Hiemstra 2015-02-12 17:55:56 +01:00
parent 6f825598c1
commit 645a179bc3
2 changed files with 12 additions and 3 deletions

View file

@ -10,10 +10,11 @@ import numpy
import struct
class ProcessSlicedObjectListJob(Job):
def __init__(self, message):
def __init__(self, message, center):
super().__init__(description = 'Processing sliced object')
self._message = message
self._scene = Application.getInstance().getController().getScene()
self._center = center
def run(self):
objectIdMap = {}
@ -21,6 +22,8 @@ class ProcessSlicedObjectListJob(Job):
if type(node) is SceneNode and node.getMeshData():
objectIdMap[id(node)] = node
layerHeight = Application.getInstance().getMachineSettings().getSettingValueByKey('layer_height')
for object in self._message.objects:
mesh = objectIdMap[object.id].getMeshData()
@ -31,7 +34,9 @@ class ProcessSlicedObjectListJob(Job):
points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
points = numpy.asarray(points, dtype=numpy.float32)
points /= 1000
points = numpy.insert(points, 1, layer.id / 10, axis = 1)
points = numpy.insert(points, 1, layer.id * layerHeight, axis = 1)
points[:,0] -= self._center.x
points[:,2] -= self._center.z
layerData.addPolygon(layer.id, polygon.type, points)
mesh.layerData = layerData