cpederkoff / stl-to-voxel

Turn STL files into voxels, images, and videos
MIT License
138 stars 75 forks source link

IndexError in slice.mesh_to_plane #53

Closed whoosher closed 6 months ago

whoosher commented 1 year ago

Hello, Thanks for your great work! I have some problem to use the stltovoxel library. During stl voxelization with 256 resolution, I encounter the problem concerned with indexError of slice.mesh_to_plane. I change the "def calculate_scale_and_shift" for size of bounding box (specifically, bounding_box[2] -> max(bounding_box) - slice.py, line 131.) I have tried to write the try-except sentence for exception handling because the little resolution change (256->255, 256->257) can be helpful to settle the errors. Can you help me?

PATH is my personal driver path

-------------------------Error--------------------------- multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "PATH\lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "PATH\lib\site-packages\stltovoxel\slice.py", line 54, in paint_z_plane perimeter.lines_to_voxels(lines, pixels) File "PATH\lib\site-packages\stltovoxel\perimeter.py", line 10, in lines_to_voxels paint_y_axis(lines, pixels, x) File "PATH\site-packages\stltovoxel\perimeter.py", line 48, in paint_y_axis pixels[target_y][x] = True IndexError: index 255 is out of bounds for axis 0 with size 255 """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "PATH", line 146, in vox= stl_voxelizer(STL_PATH,res=256) File "PATH", line 61, in stl_voxelizer vol, scale, shift = convert_meshes(meshes, mesh_res) File "PATH", line 44, in convert_meshes cur_vol = stltovoxel.slice.mesh_to_plane(org_mesh, shape, parallel) File "PATH\lib\site-packages\stltovoxel\slice.py", line 37, in mesh_to_plane results = [r.get() for r in result_ids] File "PATH\lib\site-packages\stltovoxel\slice.py", line 37, in results = [r.get() for r in result_ids] File "PATH\lib\multiprocessing\pool.py", line 771, in get raise self._value IndexError: index 255 is out of bounds for axis 0 with size 255

Process finished with exit code 1

cpederkoff commented 1 year ago

Hi @whoosher thanks for reporting the issue. Couple of questions: Which version of the software you are using? If you are using the version on PyPI could you try installing the version from this git repo using python3 -m pip install 'stl-to-voxel @ git+https://github.com/cpederkoff/stl-to-voxel@master' and trying again to see if that fixes the issue? If that doesn't work, would you be able to post the model and args you are using to help reproduce the problem?

cpederkoff commented 6 months ago

Closing due to inactivity