mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
3k stars 580 forks source link

trimesh.creation.revolve create non volume if not by 360 degree #2269

Closed bguan closed 2 weeks ago

bguan commented 2 months ago

Using trimesh 4.4.3 and 4.4.6, the following code fails the 2nd assertion.

import trimesh
import math

cross_section = [[0, 0], [10, 0], [10, 10], [0, 10]]

mesh360 = trimesh.creation.revolve(cross_section, 2 * math.pi)
assert mesh360.is_volume, "mesh360 should be a valid volume"

mesh180 = trimesh.creation.revolve(cross_section, math.pi)
assert mesh180.is_volume, "mesh180 should be a valid volume"

Am I missing something? Exporting mesh180 to STL and viewing it seems to indicate it is missing the face covering the cross section. Am I supposed to compute the start and end cap explicitly and somehow concatenate them to mesh180?

image

mikedh commented 2 months ago

Hey, yeah cap: bool is not implemented for non-complete revolves, PR's welcome! cap is supported for sweep which I'd probably look at for reference.

bguan commented 1 month ago

Hi @mikedh, I've attempted a PR for you to review and/or comment. Any feedback is welcome. This is my first attempt peeping into the innards of Trimesh. Somehow my fix feels a little hackish as I am not sure I can follow what is potentially going on in triangulate_polygon(...) and I am worried there might be edge cases that my fix has not covered.

https://github.com/mikedh/trimesh/pull/2283