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

SimplifyQuadricDecimation fixes #6163

Merged
merged 7 commits into from
Aug 15, 2023

Conversation

bjudeworley
Copy link
Contributor

@bjudeworley bjudeworley commented May 22, 2023

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

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

The existing Quadric Error Decimation code could create some faulty meshes under certain circumstances

  • Flipped Triangles - There is a check to prevent flipped triangles but it doesnt apply to all the relevant triangles
  • Degenerate Triangles - Triangles with 3 colinear points can be created, particularly when the existing vertices are arranged in a grid
  • Non-manifold edges - In some circumstances an edge collapse could create two equal triangles with opposite normals (ie back to back).

This PR fixes these three issues and clears a few vectors once they are finished being used to save a little memory.


This change is Reviewable

…oth vertices of the removed edge

The previous code checks if any triangles connected to the removed vertex are flipped in the process of collapsing the edge. However, since the remaining vertex on the collapsed edge can be moved during the operation, triangles connected to this vertex can flip as well. This commit puts the flip-checking code into a loop so we can check both sets of triangles.
This sets a threshold on how much any triangle can shrink in area during an edge collapse which should avoid creating degenerate triangles. The threshold is somewhat arbitrary, I found 0.001 worked well but it may make sense for this to become a function parameter.
When a vertex is connected to exactly 3 triangles and an edge of one of these triangles not connected to the vertex is collapsed, the remaining 2 triangles end up sharing the same vertices, with opposite normals. This creates a non-manifold location which is nearly always undesirable.
This commit adds a check to see if any of the triangles attached to the collapsing edge share an edge that is not connected to `vidx0` or `vidx1`
@update-docs
Copy link

update-docs bot commented May 22, 2023

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

@bjudeworley
Copy link
Contributor Author

Looks like the failing test (Ubuntu Wheel / Test wheel CPU (3.10, false)) failed because no runners were available, can someone manually rerun it?

…d for vbars & costs maps

Reduces the memory footprint by 27% in my tests runs ~15% faster as we remove a lot of allocations.
@ssheorey ssheorey requested a review from benjaminum June 1, 2023 17:40
Changing from tracking edges (`unordered_set<Vector2i>`) to vertices (`unordered_map<int, int>) gives a good performance increase
@benjaminum
Copy link
Contributor

@bjudeworley Thank you for this PR. Do you have an example to compare changes before and after this PR?

@benjaminum
Copy link
Contributor

Comparison between before and after applying this PR
image
Geometry near right eye looks faulty with the old code

Copy link
Contributor

@benjaminum benjaminum left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 2 files reviewed, all discussions resolved

@germanros1987 germanros1987 merged commit a89031c into isl-org:master Aug 15, 2023
35 of 37 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.

None yet

3 participants