Commit 54b2c037 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

implemented work around for some edge cases

parent baf8dddd
......@@ -130,7 +130,7 @@ def contour2dict(c):
return {'pos':c.pos, 'time':c.time}
def vox_section_area(voxels, mesh_file_name):
def vox_section_area(voxels, mesh_file_name, vox_dim=3):
mesh = pv.read(mesh_file_name)
tu.transform_to_bed_centre(mesh, [110, 110, 0])
tu.transform_to_z0(mesh)
......@@ -142,7 +142,6 @@ def vox_section_area(voxels, mesh_file_name):
while 0 in SecArea:
i = np.where(SecArea==0)[0][0]
c = voxels.iloc[i,1:4].to_numpy()
print(c)
# if new slice required
if c[2] != z:
......@@ -162,10 +161,20 @@ def vox_section_area(voxels, mesh_file_name):
SecArea[i] = poly.area
if SecArea[i] == 0:
# TODO HACK so it uses neighbour's SecArea
c1 = voxels.iloc[i-1,1:4].to_numpy()
d1 = abs(sum(c-c1))/vox_dim
c2 = voxels.iloc[i+1,1:4].to_numpy()
d2 = abs(sum(c-c2))/vox_dim
if d1 <1.001:
SecArea[i] = SecArea[i-1]
elif d2 < 1.001:
SecArea[i] = SecArea[i+1]
else:
print("Uh OH rogue voxel")
SecArea[i] = 1e7
if z>3:
if z>20:
print(set(SecArea))
break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment