0

So, to explain the context ! what I'm trying to do is to generate a heightmap of a Voxelized Buildings mesh, to do that I tried getting the upper faces and their cell_centers so I can use each cell_center elevation as a height and do some math to calculate it.

The issue here is that I'm having a 32x32 ( x,y ) Voxelized mesh, which means I should have in total 1024 ( 32x32 ) cell center of the upper faces.

But when I try doing that, I get 1132 Elevations, and couldn't figure it out why and how to have only the ones I need.

This is the code I made to do that :

mesh = pv.read("voxeled_withfloor.obj")

elv = mesh.elevation(preference="cell")
elv.compute_normals(cell_normals=True)
face_normals = elv.cell_normals
upward_face_indices = np.where(face_normals[:, 2] > 0.0)[0]
upper_face_mesh = elv.extract_cells(upward_face_indices)
cell_centers = upper_face_mesh.cell_centers()
elevation = cell_centers.elevation()
elevation_array = elevation["Elevation"]
here = np.asarray(elevation_array)

num_arrays = len(elevation_array) // 32
string_array = elevation_array.astype(np.float64)


multidimensional_arrays = np.reshape(string_array[: num_arrays * 32], (num_arrays, 32))

When I use pyvista plotter to show the cell_centers I get this, which looks good and correct :

Cell_centers enter image description here

Number of Elevations

enter image description here

If anyone tried doing this before or knows how to do that please don't hesitate !

Thank you in advance.

I tried every possible way to do that, nothing is working

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
Sofiane
  • 3
  • 3
  • I doubt this can be answered without having access to your mesh. You derive everything from the mesh. If the mesh is dirty, your results will be off. For instance, I see an obvious artifact in the form of a triangular face in the top left. If cruft like that can be seen in the data, it's likely that there are other, more subtle issues as well. Fix your mesh and you'll probably fix the issue in this question. – Andras Deak -- Слава Україні Jul 20 '23 at 21:16
  • the mesh if perfect, I get that artifact just after the voxelization and still don't know why I'm having that ! The mesh looks like this before voxelization : https://i.imgur.com/MxTpBgs.png – Sofiane Jul 21 '23 at 08:13

0 Answers0