wolph / numpy-stl

Simple library to make working with STL files (and 3D objects in general) fast and easy.
http://numpy-stl.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
605 stars 103 forks source link

Creating Mesh objects from a list of vertices and faces fails on float Positions #134

Closed SandUhrGucker closed 3 years ago

SandUhrGucker commented 4 years ago

You describe on https://pypi.org/project/numpy-stl/ howto "Creating Mesh objects from a list of vertices and faces".

The folowing error ocurs if using float-coordinates:

    cube.vectors[i][j] = vertices[f[j],:]
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Describe the bug Doesnt work with floats (Which is motly used in RL I think).

Expected behavior normal operation.

To Reproduce Just modify some Verticses and Faces coordinates to floats.

My Platform Ubuntu 10Buster tested with python 2.7,with numpy 1.16.6

Ubuntu 10Buster and python 3.6, with numpy 1.18.5

Windows 10 python 3.8.3 with numpy 1.18.4

wolph commented 4 years ago

The list of faces in that example reference the vertices, so they shouldn't ever be floats.

Simply put:

wolph commented 4 years ago

To take a small portion of the example:

vertices = np.array([\
    [-1, -1, -1],  <-- first point of the triangle below
    [+1, -1, -1], <-- last point of the triangle below
    [+1, +1, -1],
    [-1, +1, -1], <-- second point of the triangle below
    [-1, -1, +1],
    [+1, -1, +1],
    [+1, +1, +1],
    [-1, +1, +1]])
# Define the 12 triangles composing the cube
faces = np.array([\
    [0,3,1],