- Home /
Mesh adaption
Hey guys, I'm currently working on a project where I import a mesh through code (C#) into my application. The triangles on the mesh are all in different sizes, meaning the edges and the area of the triangles are quite different. See the image below. Does anyone know a way to shape the triangles uniformly, while approximately keeping the shape of the whole mesh? Appreciate your answers!
Answer by sh_code · Jan 22, 2019 at 11:29 AM
the solution depends heavily on some other things:
is the mesh just 2D? it kinda seems so from the screenshot, but i can't be sure.
does it have uv mapping which you need to keep, or in general, do you need to keep the original (number and connections) of inside vertices, or can you just scrap them and make your own?
what is the mesh (supposed to represent), and how is it going to be used? (terrain? close-sliced sprite? part of a rigged object? just a static model?)
Hey @sh_code, the mesh is a 3D representation of a tooth. Each tooth is unique. I initially load it from a binary STL file. The user then adds some information to the tooth and saves everything as a PLY file. The mesh has no UVs attached to it and the number of vertices and with it triangles has to stay same. Hope that answered all your questions.
In that case... why do you want to equalize/modify the mesh? Because I think you should be aware that ANYTHING you will do with the mesh, even if number of vertices and triangles will stay the same, will change the shape. And seeing it's a scan of a tooth, I'd assume that to keep the detailed shape is important. Oh, I see you mention this in the question, that the shape needs to stay "approximately" the same... Then the question is, what exactly "approximately" means in your case.
I can think of an algorithm that would be relatively straightforward to implement, using a gravity-like principle: Put a centerpoint into each triangle, which will exert repulsive force to the vertices belonging to the triangle, and think of each edge between vertices as a line representing attractive force. Now run several (tens or hundreds of) thousands of simulation iterations, where the centerpoint repulses the relevant vertices, and then the vertices attract each other. Assu$$anonymous$$g you find the correct values for the repulsive and attractive forces (basically the attractive forces need to be equal for all edges, and the repulsive force you will need to calculate from the original size of the triangle, and then modify/lower/increase it it depending on how much that specific triangle is allowed to shrink or grow, and that will give you the final repulsive value to work with for each separate triangle)... Assu$$anonymous$$g you find the correct values for the forces, several thousands of iterations through the whole mesh should result in reorganizing them to make them more uniform.
Your problem is basically a "graph/network visualization problem" (search for this term on google, there's lots of papers written on it), but I don't think there's any ready-made, or actually straightforward solution for you to implement, this will require a lot of thinking, reading existing stuff, heavily adjusting the solutions in there for your specific case, and lots and lots of experimentation...
$$anonymous$$ay I ask WHY do you need to modify the mesh like this?
First of all, thank you for your detailed answer! I imagined that there wouldn't be a straightforward solution to my problem. The only reason why this should be implemented is because my client wants it (as a nice to have feature). As you mentioned, the level of detail (amount of vertices) of the tooth should stay same to be able to mark each tooth as detailed as possible.