Esempio n. 1
0
def voxelize(mesh: Trimesh, dims:int = 14) -> ndarray:
    workdir = mkdtemp()
    TMP_FILE_NAME = workdir + '/voxelization'
    TMP_STL_FILE_NAME = TMP_FILE_NAME + '.stl'
    TMP_BINVOX_FILE_NAME = TMP_FILE_NAME + '.binvox'
    mesh.export(TMP_STL_FILE_NAME, 'stl')
    cmd_std = sh(dirname(realpath(__file__)) + "/binvox", '-d' , str(dims) , TMP_STL_FILE_NAME)
    vox_matrix = read_as_3d_array(open(TMP_BINVOX_FILE_NAME, 'rb'), fix_coords=True)
    return vox_matrix
Esempio n. 2
0
def store_mesh(path, mesh: trimesh.Trimesh):
    mesh.export(path, "glb")
    mesh.visual = trimesh.visual.ColorVisuals(mesh, None, (0,0,0))