pyvista converting multiple stacked objects into a single voxel grid

256 Views Asked by At

I have several 3D (.ply) files, each sit on top of each other (consider them to be geological layers), I want to convert them into a single voxelised representation.

In pyvista I use the following to visualise 2 vector layers as voxels:

v = []
colours = ["lightblue", "red", "green", "blue", "yellow", "orange"]
p = pv.Plotter()
# meshes already read into a list using pv.read()
for surface in meshes:
    colour = random.choice(colours)
    voxels = pv.voxelize(surface, density=density)
    voxels["density"] = np.full(voxels.n_cells, random.uniform(0.01, 1.00))
    v.append(voxels)
# for testing perposes, np.vstack did not work to combine all list items, e.g. arr = np.vstack(v)
v_merge = v[0] + v[1]

p.add_mesh_clip_plane(v_merge, assign_to_axis='x', opacity=opacity, scalars="density")
p.show()
return v

enter image description here

As you can see there are issues

  1. The two sets of voxels are on different grids so at the interface the voxels overlap.
  2. This highlights that there are overlapping voxels, this is inevitable as the vector files have a shared boundary, so once both are on the same grid I'd like to keep the voxels from the top layer and remove from the lower layer.
  3. I want to keep the voxels coloured by their layer, this is set in the add_mesh stage, I would like to add a scalar value to the voxels outside of a pv.Plotter().

For point 1 I have tried first merging the two vector surfaces, but this results in Surface is not closed warning.

Thank you for any help on these points, I'm just getting into pyvista so I jave some learning to do.

0

There are 0 best solutions below