简体   繁体   中英

Creating a mesh out isovalues in python. Marching cubes

I have created a program that is able to predict given a set positions of shape nx3 , an it a isovalue of shape nx1 (n is the # of samples). Now I want to be able to visualize this and save it as a mesh, I have read that a way to find the vertices and faces of the isosurface is by using an algorithm called marching cubes, that I found it is in python skimage.measure. However I can't seem to understand how to utilize given my data, to give it to the measure.marching_cubes_lewiner, since it only says that accepts volumetric data (M,N,P).

I've tried to reshape my it into a 3d array but I have no idea how it should look like. I tried to do it as grid and failed. I feel it shouldn't be hard but I'm new to meshes and grids.


isovalue # nx1 array
isovalue = # how do I process this array(nx1) into marching cubes acceptable

print(isovalue.shape)


verts, faces, normals, values = measure.marching_cubes_lewiner(isovalue)

It always comes to the error that the marching cubes should be a 3D array instead what I tried to give it.

If someone is curious about this as well I found the answer myself. If you have 1D array of the of nx1 shape what you need to shape it as a volumetric array to input into measure.marching_cubes_lewiner, is reshape it to be a (cbrt(n),cbrt(n),cbrt(n)) is that easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM