Added function to build voxels from a mask array.

这个提交包含在:
Craig Warren
2016-07-15 13:36:04 +01:00
父节点 0986b876ef
当前提交 8ad75f888c

查看文件

@@ -702,3 +702,36 @@ cpdef void build_voxels_from_array(int xs, int ys, int zs, int numexistmaterials
numID += numexistmaterials
build_voxel(i, j, k, numID, numID, numID, numID, False, solid, rigidE, rigidH, ID)
cpdef void build_voxels_from_array_mask(int xs, int ys, int zs, int waternumID, int grassnumID, np.int8_t[:, :, ::1] mask, np.int16_t[:, :, ::1] data, np.uint32_t[:, :, ::1] solid, np.int8_t[:, :, :, ::1] rigidE, np.int8_t[:, :, :, ::1] rigidH, np.uint32_t[:, :, :, ::1] ID):
"""Builds Yee voxels by reading integers from an array.
Args:
xs, ys, zs (int): Cell coordinates of position of start of array in domain.
waternumID, grassnumID (int): Numeric ID of water and grass materials.
data (memoryview): Access to array containing numeric IDs of voxels to create.
mask (memoryview): Access to array containing a mask of voxels to create.
solid, rigidE, rigidH, ID (memoryviews): Access to solid, rigid and ID arrays.
"""
cdef Py_ssize_t i, j, k
cdef int xf, yf, zf, numID, numIDx, numIDy, numIDz
# Set upper bounds
xf = xs + data.shape[0]
yf = ys + data.shape[1]
zf = zs + data.shape[2]
for i in range(xs, xf):
for j in range(ys, yf):
for k in range(zs, zf):
if mask[i - xs, j - ys, k - zs] == 1:
numID = numIDx = numIDy = numIDz = data[i - xs, j - ys, k - zs]
build_voxel(i, j, k, numID, numIDx, numIDy, numIDz, False, solid, rigidE, rigidH, ID)
elif mask[i - xs, j - ys, k - zs] == 2:
numID = numIDx = numIDy = numIDz = waternumID
build_voxel(i, j, k, numID, numIDx, numIDy, numIDz, False, solid, rigidE, rigidH, ID)
elif mask[i - xs, j - ys, k - zs] == 3:
numID = numIDx = numIDy = numIDz = grassnumID
build_voxel(i, j, k, numID, numIDx, numIDy, numIDz, False, solid, rigidE, rigidH, ID)