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

Implement t::geometry::TriangleMesh::RemoveUnreferencedVertices #6640

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

nsaiapova
Copy link
Collaborator

The algorithm mimics the one in
geometry::TriangleMesh::RemoveUnreferencedVertices. We first build a mask of vertices and then update all vertex attributes by that mask. Triangles are left untouched.

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • 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

Implement missing method t::geometry::TriangleMesh::RemoveUnreferencedVertices. The method is defined in the legacy API.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • 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.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Copy link

update-docs bot commented Feb 6, 2024

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@nsaiapova nsaiapova force-pushed the wip/remove-unreferenced-verts branch from eee30b6 to 28aeb0f Compare February 20, 2024 13:20
@nsaiapova
Copy link
Collaborator Author

In the last push I also added "device" argument to tensor initialization in cpp tests.

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some minor comments.

def test_remove_unreferenced_vertices(device):
for int_t in [o3c.int32, o3c.int64]:
for float_t in [o3c.float32, o3c.float64]:
check_no_unreferenced_vertices(device, int_t, float_t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use nested parametrize in pytest. No need for the two for loops.

@pytest.mark.parametrize("device", list_devices())
@pytest.mark.parametrize("int_t", (o3c.int32, o3c.int64))
@pytest.mark.parametrize("float_t", (o3c.float32, o3c.float64))

https://docs.pytest.org/en/7.3.x/how-to/parametrize.html

for (auto item : GetVertexAttr()) {
SetVertexAttr(item.first, item.second.IndexGet({vertex_mask}));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add LogDebug message about how many vertices were removed.


if (!HasTriangleIndices() || GetTriangleIndices().GetLength() == 0) {
utility::LogWarning(
"[RemoveUnreferencedVertices] TriangleMesh has no triangles.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[RemoveUnreferencedVertices] TriangleMesh has no triangles. Removing all vertices."

@nsaiapova nsaiapova force-pushed the wip/remove-unreferenced-verts branch 2 times, most recently from e60a07a to 664ef13 Compare March 12, 2024 13:29
The algorithm mimics the one in
geometry::TriangleMesh::RemoveUnreferencedVertices.
We first build a mask of vertices and then update all vertex attributes
by that mask. Triangles are left untouched.
@nsaiapova nsaiapova force-pushed the wip/remove-unreferenced-verts branch from 664ef13 to d477ab8 Compare March 12, 2024 15:02
@ssheorey ssheorey merged commit e8661f7 into isl-org:main Mar 18, 2024
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants