-
Notifications
You must be signed in to change notification settings - Fork 581
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
subdivide_to_size() does not split shared edges #1731
Comments
Yeah this is true, currently the only way to get a subdivision to maintain nice properties is vanilla |
I have experimented with something like this before; whereby ever time a triangle is subdivided you search all other triangles to see if any have shared edges (i.e. an edge that is now split) and force the shared triangle to be split. It wasn't a particularly quick algorithm though, and certainly wasn't particularly "pythonic" code. |
Here's an implementation using numpy that subdivides the faces with long edges and splits the residual quads into new triangles (along the shortest diagonal) in order to create a consistent mesh (or at least, the consistency is inherited from the inputs). This should also preserve vertex ordering according to the inputted faces (as long as
|
@johannes-lee, could you add a license to this code? Otherwise, it's very hard to use. |
Summary
subdivide_to_size() does not appear to check if an edge being split is shared by another triangle; meaning you can end up with a vertex that, if subsequently moved, will result in tears/holes in a mesh.
This may be related to the "Fix trimesh.remesh.subdivide subdivide_to_size so that if you specify a subset of faces it splits their neighbors in a way to maintain watertightness." comment in #1557
Details
Using Python 3.9.2 and Trimesh 3.15.8 I'm loading a simple STL into a mesh, then subdividing it to make no edge longer than 5 units:
Using the viewer I can check the original mesh (without subdivision) in both shaded and wireframe (the first and second images in the attached jpg). The third image shows the same mesh after the subdivide_to_size() call above, and the fourth is a close up of that mesh.
The circled areas show where triangles have been split, but the formerly shared edge with another triangle hasn't. If these vertices are then moved they will leave a hole in the mesh.
Is there any way to get trimesh to subdivide a mesh and ensure that edges shared with other triangles are also split?
The text was updated successfully, but these errors were encountered: