Skip to content

Commit 2de707b

Browse files
committed
Make sure all voxels are assigned to grains
1 parent f37b071 commit 2de707b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/kanapy/voxelization.py

+8
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,16 @@ def poly2vox():
379379
for igr, vlist in mesh.grain_dict.items():
380380
vlist = np.array(vlist) - 1
381381
gr_arr[vlist] = igr
382+
ind = np.nonzero(gr_arr == 0)[0]
383+
if len(ind) > 0:
384+
# some voxels have not been assigned to grains, check is assignment is required
385+
if prec_vf is None:
386+
for iv in ind:
387+
gr_arr[iv] = gr_arr[iv-1] # assign voxel to neighbor grain
388+
print(f'Warning: Assigned voxel {iv} to grain {gr_arr[iv-1]}.')
382389
mesh.grains = np.reshape(gr_arr, mesh.dim, order='C')
383390

391+
384392
# generate array of voxelized structure with phase numbers
385393
# and dict of phase numbers for each grain
386394
# empty voxels will get phase number 1 and be assigned to grain with key 0

0 commit comments

Comments
 (0)