Skip to content

For TriangleMesh triangle_material_ids_ do not relate to the materials_ #5924

@dbs4261

Description

@dbs4261

Checklist

Describe the issue

The triangle_material_ids_ vector contain indices for which texture should be applied. However because materials are stored in an unordered_map, the indices cannot be used to access the corresponding material. It would be better to store a vector<pair<string, Material>> that way it is indexable, but materials could still be accessed by name using find with a lambda comparing names.

Steps to reproduce the bug

`class TriangleMesh {
    ...
    std::unordered_map<std::string, Material> materials_;
    /// List of material ids.
    std::vector<int> triangle_material_ids_;
    /// Textures of the image.
    std::vector<Image> textures_;
}`
By examining the values with a debugger, the triangle_material_ids_ match up with the textures_ but there is no mechanism for accessing the material associated with it.

Error message

No response

Expected behavior

No response

Open3D, Python and System information

- Operating system: Ubuntu 22.04
- Python version: Python 3.11
- Open3D version: bbae9e31fefac1c2fe04759d30b81c30d927dbeb
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc 11.3

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot a build issue, this is likely a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions