pmneila / PyMCubes

Marching cubes (and related tools) for Python
BSD 3-Clause "New" or "Revised" License
692 stars 87 forks source link

ValueError: vertex or face count are zero: terminating marching cubes #15

Closed akjagadish closed 5 years ago

akjagadish commented 6 years ago

Was trying to extract vertices, faces and triangles from voxel information and was getting this error.

import numpy as np import mcubes from marching_cubes import march import collada import pymesh import sys

inp_file = "../datasets/output/surface-recon/result.dat" x = np.fromfile(inp_file, dtype=np.uint8) dim = x[:3] %Extract necessary elements voxels = x[12:-16] voxels = voxels.reshape((dim[0], dim[1], dim[2])) vertices, normals, triangles = march(voxels, 0)

On running the aforementioned script I get: ValueError: vertex or face count are zero: terminating marching cubes

pmneila commented 5 years ago

Hi,

While you are importing mcubes, you are actually using another implementation of the marching cubes different from mine (marching_cubes). The correct way of using mcubes would be

vertices, triangles = mcubes.marching_cubes(voxels, 0)

The marching_cubes library you are using is the one from ilastik. Check https://github.com/ilastik/marching_cubes.