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

extrude_polygon not creating watertight mesh #2266

Closed
kgulmer opened this issue Aug 15, 2024 · 3 comments · Fixed by #2265
Closed

extrude_polygon not creating watertight mesh #2266

kgulmer opened this issue Aug 15, 2024 · 3 comments · Fixed by #2265

Comments

@kgulmer
Copy link

kgulmer commented Aug 15, 2024

I am trying to create a watertight mesh from a series of points to be used in the boolean module functions, which fail when the body does not meet the criteria for is_volume.

extrude_polygon is not returning the mesh as a watertight body as it should.

import trimesh
import shapely

coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
polygon = shapely.geometry.Polygon(coords)

extrude = trimesh.creation.extrude_polygon(polygon,1)

print('is_watertight',extrude.is_watertight)
print('is_volume',extrude.is_volume)
@mikedh
Copy link
Owner

mikedh commented Aug 15, 2024

Hey, yeah results depends a lot on which triangulation backend it's using, after pip install manifold3d triangle mapbox-earcut:

In [1]: import shapely, trimesh

In [2]: coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
   ...: polygon = shapely.geometry.Polygon(coords)

In [3]: trimesh.creation.extrude_polygon(polygon,1, engine='triangle').is_volume
Out[3]: True

In [4]: trimesh.creation.extrude_polygon(polygon,1, engine='manifold').is_volume
Out[4]: False

In [5]: trimesh.creation.extrude_polygon(polygon,1, engine='earcut').is_volume
Out[5]: True


mikedh added a commit that referenced this issue Aug 15, 2024
@mikedh
Copy link
Owner

mikedh commented Aug 15, 2024

It looks like manifold doesn't like the duplicated first-and-last vertex, and produces a watertight result when we clip it off. Thanks for the report!

@kgulmer
Copy link
Author

kgulmer commented Aug 15, 2024

Thanks! Yes, I am using manifold.

I also found just now that you can re-process the mesh with the validate flag and it resolves the issue.

extrude.process(validate=True)

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

Successfully merging a pull request may close this issue.

2 participants