From 2c7045d6fc441e7d1dbbdf06bc9e46a010b18f15 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 31 Jan 2016 20:02:28 -1000 Subject: [PATCH] ShapeFuncSelection creates coordinate array using mgrid, not indices --- src/mceditlib/selection/__init__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/mceditlib/selection/__init__.py b/src/mceditlib/selection/__init__.py index ac6b0be..69d986e 100644 --- a/src/mceditlib/selection/__init__.py +++ b/src/mceditlib/selection/__init__.py @@ -606,20 +606,19 @@ class ShapeFuncSelection(BoundingBox): origin, shape = self.origin, self.size # we are returning indices for a Blocks array, so swap axes to YZX - outputShape = box.size - outputShape = (outputShape[1], outputShape[2], outputShape[0]) + sx, sy, sz = box.size shape = shape[1], shape[2], shape[0] # find requested box's coordinates relative to selection - offset = numpy.array(box.origin) - numpy.array(origin) - offset = offset[[1, 2, 0]] + ox, oy, oz = box.origin + dx, dy, dz = origin + ox -= dx + oy -= dy + oz -= dz - # create coordinate array - blockPositions = numpy.indices(outputShape, dtype=numpy.float32) - - # offset by requested box's origin - blockPositions += offset[:, None, None, None] + # create coordinate array, offset by requested box's origin + blockPositions = numpy.mgrid[float(oy):oy+sy, oz:oz+sz, ox:ox+sx] shape = numpy.array(shape, dtype='float32')