ShapeFuncSelection creates coordinate array using mgrid, not indices

This commit is contained in:
David Vierra 2016-01-31 20:02:28 -10:00
parent 5a132b747f
commit 2c7045d6fc

View File

@ -606,20 +606,19 @@ class ShapeFuncSelection(BoundingBox):
origin, shape = self.origin, self.size origin, shape = self.origin, self.size
# we are returning indices for a Blocks array, so swap axes to YZX # we are returning indices for a Blocks array, so swap axes to YZX
outputShape = box.size sx, sy, sz = box.size
outputShape = (outputShape[1], outputShape[2], outputShape[0])
shape = shape[1], shape[2], shape[0] shape = shape[1], shape[2], shape[0]
# find requested box's coordinates relative to selection # find requested box's coordinates relative to selection
offset = numpy.array(box.origin) - numpy.array(origin) ox, oy, oz = box.origin
offset = offset[[1, 2, 0]] dx, dy, dz = origin
ox -= dx
oy -= dy
oz -= dz
# create coordinate array # create coordinate array, offset by requested box's origin
blockPositions = numpy.indices(outputShape, dtype=numpy.float32) blockPositions = numpy.mgrid[float(oy):oy+sy, oz:oz+sz, ox:ox+sx]
# offset by requested box's origin
blockPositions += offset[:, None, None, None]
shape = numpy.array(shape, dtype='float32') shape = numpy.array(shape, dtype='float32')