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

closest point when duplicates #73

Open
gattia opened this issue Aug 28, 2023 · 4 comments
Open

closest point when duplicates #73

gattia opened this issue Aug 28, 2023 · 4 comments

Comments

@gattia
Copy link
Contributor

gattia commented Aug 28, 2023

When using code to get the closest point there are issues if points are duplicates. If points are duplicates (different point/vertex idx, but identical position) then the barycentric coordinates come back as nan - which makes sense. If the duplicates are removed using pcu.deduplicate_mesh_vertices, then it finds the face to interpolate the new barycentric coordinates but it can now refer to that same single point twice (the same point/vertex is considered for two point on the face/triangle). This still results in nan barycentric coordinates.

However, the note in the code indicates it can handle (for distances) these degenerate points face = [1 2 2] or [1 1 1] treating them as lines [1 2] and points [1] respectively. Is this only the case for the distances and not the barycentric coordinates?

I'm writing a little cleanup code that for barycentric coords with NAN, it searches to see how many unique points are on the respective face and calculates a new point based on a line if unique==2 and is just the single point if unique==1. This is skipping the bc value and just going straight to a new point in 3D space.

Thoughts on this? Or am I missing something in the code that should handle this?

@fwilliams
Copy link
Owner

A quick check is to see if the returned barycentric coordinates contain NaNs. If not, then the closest point function is returning correct values but the barycentric interpolation is failing (and we'll need to handle this there). Can you check if there are NaN values in the barycentric coordinates?

@fwilliams
Copy link
Owner

Any luck with this?

@ShuaibZyx
Copy link

ShuaibZyx commented Sep 26, 2024

Hello, I check the barycentric coordinates(bc), it is sometimes get nan value. If bc is nan then closest point also is nan. @fwilliams Please Help.

@gattia
Copy link
Contributor Author

gattia commented Sep 26, 2024

Apologies @fwilliams for not replying.

@ShuaibZyx i did make a manual fix to this that I should contribute back. The fix is here: https://github.com/gattia/pymskt/blob/51ec4a14d31e6c5a5b9e5352af5171425f6367ed/pymskt/mesh/meshTools.py#L1155

@fwilliams that fix is also inside of another function I wrote that tweaks your make_mesh_watertight function by projecting the points back onto the surface - I has posted before how make_mesh_watertight dilates the mesh. This could potentially be an addition that that is optional.

I can make a PR for the closest point issue, would you like me to make a PR for the watertight option to project back onto surface?

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

No branches or pull requests

3 participants