pyvista / pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
https://github.com/pyvista/pyvista/discussions
60 stars 4 forks source link

Merging meshes resulting in gaps #181

Open Eric-R-Liang opened 4 years ago

Eric-R-Liang commented 4 years ago

When I merge multiple triangulated meshes together, the resulting geometry has small gaps between its components. It seems like the gaps occur at the merging points.

Screen Shot 2020-06-10 at 5 05 52 PM

How can I get rid of those gaps without distorting the triangulations? Thanks.

github-actions[bot] commented 4 years ago

Hi and welcome! Thanks for posting your first issue in the PyVista project! Someone from @pyvista/developers will chime in before too long. If your question is support related, it may be automatically transferred to https://github.com/pyvista/pyvista-support

Eric-R-Liang commented 4 years ago

I am using the boolean addition filter to merge the individual meshes

banesullivan commented 4 years ago

Can you share these meshes for us to try?

Eric-R-Liang commented 4 years ago

Yep, there is a total of 8 meshes. Meshes.zip

akaszynski commented 4 years ago

This will get you a little closer. I'm afraid that the meshes are really far apart and it won't be possible to merge them all without corrupting the mesh as increasing tolerance starts to cause the faces to collapse.

import pyvista as pv

block = pv.MultiBlock()
[block.append(pv.read('Component_%d.stl' % i)) for i in range(1, 9)]

combined = block.combine(True).extract_surface()
merged = combined.clean(tolerance=0.6)
merged.plot(show_edges=True, lighting=True, background='w')

image

Eric-R-Liang commented 4 years ago

Thanks a lot for the suggestion. Just as a side note, I have a mesh like this: tunnel_mesh.obj.zip

Screen Shot 2020-06-11 at 7 15 06 PM

I want to systematically split it into individual components (doesn't matter if the 'component' is composed of 1 or multiple segments of the initial geometry, like using a bounding box for example, and within each bounding box there can be multiple segments), and remove 1 or multiple of those components. And I want to essentially, remove 1 or more of those components from the initial geometry (via boolean subtract maybe). Is there a way to do that?

I've tried using the clip_box method but I can't figure out a way to use it to systematically break down the geometry and adjust the number of components that I want split into.

akaszynski commented 4 years ago

This might be a good example for https://github.com/pyvista/pyvista/pull/797.

For the time being, I'd use several clip planes spaced at regular intervals along the XZ and YZ planes. Use mesh.bounds to determine your initial ranges and then generate several planes to clip your mesh.