-
Notifications
You must be signed in to change notification settings - Fork 267
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
Close an extruded mesh with a cover #1155
Comments
Or you can try with
then import vedo # 2024.5.2
import time
import pymeshfix
def close_with_cover_reply(mesh, value_z):
extrude_mesh = mesh.extrude(zshift=value_z, cap=False, res=10)
cut_mesh = extrude_mesh.cut_with_plane(origin=(0, 0, value_z), normal=(0, 0, 1))
extrude_cut_mesh = vedo.merge(mesh, cut_mesh)
extrude_cut_mesh.clean()
cover_mesh = extrude_cut_mesh.copy()
cover_mesh.vertices[:, 2:] = value_z
closed_mesh = vedo.merge(extrude_cut_mesh, cover_mesh)
closed_mesh.clean()
meshfix = pymeshfix.MeshFix(closed_mesh.vertices, closed_mesh.cells)
meshfix.repair()
return vedo.Mesh(meshfix.mesh)
name_mesh = "data/example_lower.stl"
mesh = vedo.Mesh(name_mesh)
value_z: int = -20
st_time = time.time()
closed_mesh = close_with_cover_reply(mesh, value_z)
print(time.time() - st_time, closed_mesh.is_closed(), closed_mesh.is_manifold())
vedo.show(closed_mesh, axes=1) |
Thank you very much for your answers. Unfortunately I can't use pymeshfix because it takes too long. I need to solve the problem in a very small amount of time. Indeed the type of meshes present many difficulties. But my idea would be to make smooth to the edge or to take a subsampling of the edge to lose a little its morphology. The problem would be that with the subsampling I would not be able to use the to_strips function because the number of lines is different. Perhaps in this way I could clean the edge that apparently is the biggest impediment. Would it be an option? |
Sorry I overlooked your question.. |
I am working with a kind of mesh that is a bit complicated. At the edges they might have intersections. Therefore, when it comes to extruding and putting a cover, I have problems. For example, I can't generate the cover with "Delaney". Or if I paste a slice the mesh is not closed (I use the is_closed method and it returns False).
example_lower.stl.zip
I have extruded the mesh and then cut the extrusion to have a plane surface.
My problem comes to generate the cover.
Option 1. Function "close_with_cover_reply".
I have tried to replicate the mesh at the desired Z coordinate. This way I get a closed mesh, but at the cost of obtaining a mesh with twice the number of points, which is not very elegant.
Option 2. Function "close_with_delaney".
I tried to get the boundary of the extracted mesh. Then I generate the cover with Delaney, but, apart from the fact that it generates triangles where it does not correspond, the mesh would not be closed.
I wouldn't mind modifying the morphology of the edge, so I could make a smooth of the edge and join it as it is done in @#1019 and then extrude to simplify it, but it is not enough.
I have used the "cap" parameter of the extrude function but it generates a copy of the mesh points, which I am trying to avoid.
My goal would be to have something similar to this and also, the is_closed function would return True:
Thanks for the help and congratulations for the work, I love vedo.
The text was updated successfully, but these errors were encountered: