Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBJ import bug: Index out of range #5015

Closed
kintel opened this issue Feb 26, 2024 · 1 comment
Closed

OBJ import bug: Index out of range #5015

kintel opened this issue Feb 26, 2024 · 1 comment

Comments

@kintel
Copy link
Member

kintel commented Feb 26, 2024

The OBJ importer uses PolySetBuilder to track vertices. This causes duplicate vertices to be merged, but the indices used are taken directly from the file, indexing unmerged vertices, and if any duplicate vertex is found in the file, it will result in an index out of range error.

Example file (two cubes touching in one vertex):

v 0 0 0
v 0 0 1
v 0 1 0
v 0 1 1
v 1 0 0
v 1 0 1
v 1 1 0
v 1 1 1
v 1 1 1
v 1 1 2
v 1 2 1
v 1 2 2
v 2 1 1
v 2 1 2
v 2 2 1
v 2 2 2
f  4 1 2
f  1 6 2
f  1 4 3
f  7 1 3
f  6 1 5
f  1 7 5
f  6 4 2
f  4 6 8
f  4 7 3
f  7 4 8
f  7 6 5
f  6 7 8
f  12 9 10
f  9 14 10
f  14 12 10
f  9 12 11
f  15 9 11
f  12 15 11
f  14 9 13
f  9 15 13
f  15 14 13
f  12 14 16
f  15 12 16
f  14 15 16

Error importing the file:

WARNING: Index /Users/kintel/code/OpenSCAD/openscad/build/tests/output/objpngtest/polyhedrons-touch-vertex.scad.obj out of range in Line 40
WARNING: Index /Users/kintel/code/OpenSCAD/openscad/build/tests/output/objpngtest/polyhedrons-touch-vertex.scad.obj out of range in Line 41
WARNING: Index /Users/kintel/code/OpenSCAD/openscad/build/tests/output/objpngtest/polyhedrons-touch-vertex.scad.obj out of range in Line 42

The imported is missing a few triangles because of this.

@gsohler
Copy link
Member

gsohler commented Feb 26, 2024

will propose easy fix to that soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants