isl-org / isl-org/Open3D

read_triangle_mesh enable_post_processing=false just reduces post processing but does not turn off.

Open
#6,137 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
#2614 is related.
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### Describe the issue

When storing a triangle mesh in `.obj` which contains unused vertices and reading back than all unused vertices are removed by read_triangle_mesh even if enable_post_processing is set to false.

This is not acceptable when there exists additional data not storeable in .obj format which is attached to individual vertices including those not touched by any surface triangle. The enforced magic removal of vertices breaks any link between vertices and data which is only based on the weak index based relationship. Data can be electrical field parameters defined per vertex, can be information about type of vertex or whether vertex needs further processing etc.

### Steps to reproduce the bug

```python
import open3d as o3d

mesh = o3d.geometry.TriangleMesh(
o3d.utility.Vector3dVector(
[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
),
o3d.utility.Vector3iVector(
[[0,1,2],[1,2,5],[2,5,6]]
)
)
# the next two would not be necessary, just there for being closer to realistic scenario
mesh.compute_vertex_normals()
mesh.paint_uinform_color([1,0,0])
o3d.io.write_triangle_mesh('test.obj',write_vertex_normals=True,write_vertex_colors=True)
mesh2 = o3d.io.read_triangle_mesh('test.obj',enable_post_processing=false)
assert len(mesh.vertices) == len(mesh2.vertices)
```

### Error message

AssertionError indicating that unused vertices in mesh have been magically removed. mesh2 will only contain 5 vertices compared to mehs which has 8 therof 3 unused.

### Expected behavior

That `'test.obj'` is loaded as is without any post processing. not even any removal of unused or identical vertices when `enable_post_processing=false` is used.

Or at least an `read_triangle_mesh_ex` function which allows direct access to all assimp `aiProcess_*` flags affecting `read_triangle_mesh` by which caller can control which postprocessing is applied if it is not desired to extend existing interface by additional `none` value for `enable_post_processing`. which even disables `aiProcess_JoinIdenticalVertices`. In exchange id expect a `remove_duplicate_points` on `o3d.geometry.PointCloud` which uses an L2 metric to figure based upon a definable epsilon whether two points are identical or not. Would be a better solution compared to hard-coded magic vertex dropping on read.

### Open3D, Python and System information

```markdown
- Operating system: Ubuntu 20.04
- Python version: Python 3.8 (not really relevant as originating from core c/cpp files)
- Open3D version: output from python: `print(open3d.__version__)` 0.16 (not relevant either as originating form core c/ccp file)
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: pip
- Compiler version (if built from source): N/R
```

### Additional information

The whole is caused by the ` unsigned int post_process_flags = kPostProcessFlags_compulsory;` hardcoded on line 162 of file [cpp/open3d/io/file_format/FileASSIMP.cpp](https://github.com/isl-org/Open3D/blob/03231bb99b1b02fbca5ca79285e4a2e3d157218e/cpp/open3d/io/file_format/FileASSIMP.cpp). The `kPostProcessFlags_compulaory` mapps on lines 39,40 to `const unsigned int kPostProcessFlags_compulsory = aiProcess_JoinIdenticalVertices; ` which requests libassimp to join identical vertices and makes it drop unused vertices.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.