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

Vertex handle usage after vertex removal #52

Open
weigangd opened this issue Jan 13, 2020 · 1 comment
Open

Vertex handle usage after vertex removal #52

weigangd opened this issue Jan 13, 2020 · 1 comment

Comments

@weigangd
Copy link

Hello,

first of all thank you for sharing this library!

For my usecase I need to remove vertices often. But I also need to store some vertex handles for later. Like written in your documentation the removal function will invalidate all Handles.
Do you have a workaround for this like should i store points instead of the vertex handles.

If I were to try try alter the implementation, so that removal doesn't invalidate all handles, where should I start to look at. Do you have any hints for me?

Thanks

@Stoeoef
Copy link
Owner

Stoeoef commented Jan 15, 2020

Those are good points that you raise there. That use case certainly crossed my mind before (although I didn't need it myself yet).

Like written in your documentation the removal function will invalidate all Handles.

Well, there are a few more details that the docs (purposefully) don't mention:

  • All (fixed) handles (vertex, edge, faces) are usize values behind the scenes
  • The first inserted vertex has the handle value 0, the second 1... and so on. Inserting into a triangulation with n points will return a new handle with value n. (Exception: A vertex with the same position already exists, then the existing handle is returned)
  • Removing a vertex will swap remove the vertex. That means: Only the vertex with the highest value is being invalidated and gets re-assigned the handle of the removed vertex. The vertex with the highest handle value is always triangulation.num_vertices() - 1 (prior to removal). This information may already be enough to track and update any stored vertex handle.
  • Removing a vertex will also remove edges and faces. Their handles are swap removed as well. This is harder to track as multiple edges and faces get removed.

The reason why all of this is glossed over in the docs is to keep it as an implementation secret. However, there is no chance at the moment that that will change. Depending on your use case, tracking which vertex handles really get invalidated may already be enough.

Is this already sufficient? Or do you need a solution that does not invalidate any vertex handle (there are some)?

Let me know if you have any further questions!

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

2 participants