pymartini icon indicating copy to clipboard operation
pymartini copied to clipboard

IndexError: tuple index out of range

Open sugizo opened this issue 1 month ago • 4 comments

env google colab

steps

pip install -U pymartini meshio
!wget -c https://raw.githubusercontent.com/kylebarron/pymartini/master/test/data/fuji.png

code

import imageio.v2 as imageio
import meshio
from pymartini import decode_ele, Martini, rescale_positions

path = './fuji.png'
fuji = imageio.imread(path)
terrain = decode_ele(fuji, 'mapbox')
martini = Martini(fuji.shape[0] + 1)
tile = martini.create_tile(terrain)
vertices, triangles = tile.get_mesh(10)
cells = [("triangle", triangles) ]
mesh = meshio.Mesh(vertices, cells)
mesh.write('fuji.stl')

result

IndexError                                Traceback (most recent call last)
[<ipython-input-11-c748460129cb>](https://localhost:8080/#) in <cell line: 13>()
     11 cells = [("triangle", triangles) ]
     12 mesh = meshio.Mesh(vertices, cells)
---> 13 mesh.write('fuji.stl')

1 frames
[/usr/local/lib/python3.10/dist-packages/meshio/_helpers.py](https://localhost:8080/#) in write(filename, mesh, file_format, **kwargs)
    175         value = cell_block.data
    176         if key in num_nodes_per_cell:
--> 177             if value.shape[1] != num_nodes_per_cell[key]:
    178                 raise WriteError(
    179                     f"Unexpected cells array shape {value.shape} for {key} cells. "

IndexError: tuple index out of range

n.b. the same steps work fine with pydelatin

best regards

sugizo avatar May 09 '24 23:05 sugizo