Open3D
Open3D copied to clipboard
RemoveDuplicateVertices Implementation for TriangleMesh.
Functionality to remove duplicate vertices and update other vertex attributes and triangle indices is implemented. The C++ and python tests are also written to test the code.
On branch sganjugu/remdup2 Changes to be committed: modified: cpp/open3d/t/geometry/TriangleMesh.cpp modified: cpp/open3d/t/geometry/TriangleMesh.h modified: cpp/pybind/t/geometry/trianglemesh.cpp modified: cpp/tests/t/geometry/TriangleMesh.cpp modified: python/test/t/geometry/test_trianglemesh.py
Type
- [ ] Bug fix (non-breaking change which fixes an issue): Fixes #
- [x] New feature (non-breaking change which adds functionality). Resolves #
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #
Motivation and Context
Checklist:
- [ ] I have run
python util/check_style.py --apply
to apply Open3D code style to my code. - [x] This PR changes Open3D behavior or adds new functionality.
- [ ] Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is updated accordingly.
- [ ] I have added or updated C++ and / or Python unit tests OR included test results (e.g. screenshots or numbers) here.
- [ ] I will follow up and update the code if CI fails.
- [x] For fork PRs, I have selected Allow edits from maintainers.
Description
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.
Hi @intelshashi , this approach and implementation are sound and logical. Since Open3D needs to be performance portable on both CPU and GPU, we have added some optimized Tensor primitives to ease algorithm development. You can see some of these in
TriangleMesh::SelectFacesByMask
which solves a similar problem - keeping a subset of vertices. That approach ensures that these operations work on both CPU and GPU and are performant on the GPU. I would recommend switching to that approach before we merge this PR. Specifically:
- create a
vertex_mask
of vertices to be kept and useTensor::IndexGet
to subset vertices and attributes.- Use
utility::InclusivePrefixSum
to remap vertex indices.
For e.g., suppose, you had 9 vertices, and 8th (index 7, starting from 0), was a duplicate of 2nd (index 1, starting from 0). So, the vertex mask would look like this: Vertex indices: [0, 1, 2, 3, 4, 5, 6, 7, 8] Vertex mask: [1, 1, 1, 1, 1, 1, 1, 0, 1] Prefix sum: [0, 1, 2, 3, 4, 5, 6, 7, 7, 8] This gives an incorrect index map for 8th vertex. In fact it could be a duplicate of any of the previous vertices.