trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

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

Open bguan opened this issue 1 year ago • 1 comments

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

bguan avatar Aug 17 '24 23:08 bguan

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.

mikedh avatar Aug 22 '24 19:08 mikedh

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

bguan avatar Sep 09 '24 04:09 bguan