Skip to content

OBJ reader fix#954

Merged
andrsd merged 3 commits intoOpen-Sn:mainfrom
andrsd:obj-reader-fix
Mar 3, 2026
Merged

OBJ reader fix#954
andrsd merged 3 commits intoOpen-Sn:mainfrom
andrsd:obj-reader-fix

Conversation

@andrsd
Copy link
Copy Markdown
Collaborator

@andrsd andrsd commented Feb 25, 2026

Closes #953

@andrsd andrsd self-assigned this Feb 25, 2026
@andrsd andrsd added the bug-fix PR fixing a bug label Feb 25, 2026
@andrsd andrsd marked this pull request as draft February 25, 2026 14:46
@andrsd
Copy link
Copy Markdown
Collaborator Author

andrsd commented Feb 25, 2026

@quocdang1998 This fixes the bug in the OBJ reader. However:

  1. parmetis does not seem to do its job and then we fail inside PETSc with adjacency issues. This is why I have the KBA partitioner in the example/test.
  2. I see:
    *** WARNING ***  Cell quality checks detected 210 negative volume sub-elements (sub-triangle or sub-tetrahedron). This issue could result in incorrect quantities under some circumstances.
    
    This may indicate that the orientations of the elements are not correct. So, you may want to double check that.

Also pulling in @wdhawkins and @ragusa

@andrsd
Copy link
Copy Markdown
Collaborator Author

andrsd commented Feb 27, 2026

If you guys are ok with this, there is small refactoring I want do in the reader. Some of the parsing code would deserve a bit of improvement...

@andrsd andrsd marked this pull request as ready for review February 27, 2026 16:09
@andrsd
Copy link
Copy Markdown
Collaborator Author

andrsd commented Feb 27, 2026

Made 2 changes:

  1. the way the parser works: we read a line, split it and process the parts rather than splitting with the same code inside the "subblock"
  2. when conversion from string to a number fails, we stop now. The old version reported a warning and continued. the user would see:
    [0]  Making Unpartitioned mesh from wavefront file ../../../assets/mesh/cube.obj
    [0]  *** WARNING ***  Failed to convert vertex in line v a1.000000 -1.000000 -1.000000
    [0]  Max material id: 0
    [0]  **** ERROR ****  RuntimeError: Cannot normalize a zero-length vector.
    [0]  **** ERROR ****  
    [0]  **** ERROR ****  At:
    [0]  **** ERROR ****    read_wavefront_obj2.py(20): <module>
    
    Now they see:
    [0]  Making Unpartitioned mesh from wavefront file ../../../assets/mesh/cube.obj
    [0]  **** ERROR ****  RuntimeError: Failed to convert string to floating-point number in ../../../assets/mesh/cube.obj, line 5
    [0]  **** ERROR ****  
    [0]  **** ERROR ****  
    [0]  **** ERROR ****  At:
    [0]  **** ERROR ****    read_wavefront_obj2.py(20): <module>
    

Individual elements may have different format:
- `<n>`
- `<n>/<m>`
- `<n>/<m>/<o>`
- `<n>//<o>`

We need the `<n>` part only which refers to the vertex number.
We read a line, we split it on a space into a std::vector<std:string>.
Then, we process the individual parts, rather then repeating the
"parsing" code over and over in each section.
@andrsd andrsd merged commit a53db1f into Open-Sn:main Mar 3, 2026
7 checks passed
@andrsd andrsd deleted the obj-reader-fix branch March 3, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OBJ reader fails to read files that use simple face vertex specification

2 participants