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

Remove duplicates #139

Open
hypoconulide opened this issue Mar 6, 2023 · 3 comments
Open

Remove duplicates #139

hypoconulide opened this issue Mar 6, 2023 · 3 comments

Comments

@hypoconulide
Copy link

Hello !

I have a simple question: is there any way to remove duplicate vertices in a mesh using this lib ? I didn't find any piece of code that seem to do it.
If not, is this feature planned in the future ?

Thanks !

@dsieger
Copy link
Member

dsieger commented Mar 7, 2023

Assuming your duplicated vertices are not connected to any edges / faces you can detect them with SurfaceMesh::is_isolated(Vertex v).

for (auto v : mesh.vertices())
    if (mesh.is_isolated(v))
        std::cout << "gotcha!" << std::endl;

Hope this helps!

@hypoconulide
Copy link
Author

Thank you for your answer dsieger !

That's not exactly what I'm looking for, I'm talking about merging vertices that belong to two triangles and overlap, typically what can happen when meshes have UV islands.
I guess from your answer that what I'm looking for hasn't been implemented yet.
I see two different ways to achieve this : one would be to make lists of duplicates and recreate the mesh by always referencing the first vertex of the list when adding the faces. The other one would be to update the halfedge connectivity and remove the duplicate vertices that are not referenced anymore, it's probably the best solution but it's a bit more complex to implement than the first one.

Thanks again 🙂 !

@dsieger
Copy link
Member

dsieger commented Mar 12, 2023

Do you mean a mesh with boundaries and the vertices at the boundaries overlap? In that case, no, we currently don't have that. You might have a look at the read_stl() function which deals with merging duplicate vertices from an STL file. Making a round-trip through STL could be a quick-and-dirty workaround to see if that helps.

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