orbingol / NURBS-Python

Object-oriented pure Python B-Spline and NURBS library
https://onurraufbingol.com/NURBS-Python/
MIT License
603 stars 153 forks source link

Import obj fails with ValueError invalid literal for `int()` with base 10 '1//1' #160

Closed yves-chevallier closed 1 year ago

yves-chevallier commented 1 year ago

Describe the bug I'd like to import an obj file generated from an STL. I get an error with the import_obj method.

To Reproduce

In [10]: curve.degree = 4
    ...: curve.ctrlpts = exchange.import_obj("switzerland.obj")

Configuration:

Additional Details (Optional)

In [11]: %debug
> /home/ycr/.local/lib/python3.8/site-packages/geomdl/exchange.py(450)<listcomp>()
    448         if data[0] == "f":
    449             on_face = True
--> 450             triangle = elements.Triangle(*[vertices[int(fidx) - 1] for fidx in data[1:]], id=tri_idx)
    451             triangles.append(triangle)
    452             tri_idx += 1

ipdb> fidx
'1//1'
ipdb> int(fidx)
*** ValueError: invalid literal for int() with base 10: '1//1'

In the obj file I have the following. The import fails on the first line f 1//1 2//2 3//3

# Number of triangle: 98632
g Suisse_96mm_elev_x5
f 1//1 2//2 3//3
f 4//4 5//5 6//6
f 7//7 8//8 9//9
f 10//10 7//7 9//9
f 11//11 10//10 9//9
f 12//12 13//13 14//14
f 12//12 14//14 15//15
f 12//12 15//15 16//16
f 17//17 18//18 19//19
f 20//20 21//21 22//22
f 20//20 23//23 21//21
orbingol commented 1 year ago

Thanks for reporting this issue, but I don't think import_obj works in the way you would expect. I'd have to admit that the version published as open-source might not work at all. I don't think I had a change to complete the pipeline which imports any OBJ file and convert the result into a NURBS surface or a volume. I am pretty sure I had left some experimental code back at the university years ago, but I don't have access to them anymore.

Sorry for the inconvenience!