trimesh
trimesh copied to clipboard
Added method for planar intersection remeshing
this method allows to remesh at the intersection with a plane. This is useful for deformation and segmentation algorithms, i.e. morphing a mesh bound to a spline
Awesome thanks for the PR and test! The logic seems pretty similar to trimesh.intersections.slice_faces_plane, I was wondering if it would be possible to use the outputs of that to simplify this function, or split out the logic common to the two functions? Then we get the benefits of testing slice_faces_plane in this function as well.
Hi thanks for your response. Yes, it is a modified version of this method. I first tried to insert this as a flag like "keep_both", but since the sequence is rather different, it was merely two methods with a switch. If you want to, I could give it a second try, now that it seems to be functional.
Awesome yeah if you wouldn't mind factoring it use slice_plane (maybe pulling some of the internals into a simpler function that returns only numpy arrays or something?). From a maintenance perspective people find bugs in slice_plane all the time hahah and it would be really great to have the fiddly logic in one place.
As a cheesy implementation this works on a simple test data:
m = trimesh.load('models/machinist.3DXML', force='mesh')
m.process(merge_tex=True, merge_norm=True)
assert m.is_volume
# random vector
vector = np.array([-0.88284, 0.42343, -0.20321])
origin = m.center_mass
r = trimesh.util.concatenate([
m.slice_plane(origin, vector), m.slice_plane(origin, -vector)])
# this is necessary because we're running slice twice independently and indexes
# aren't preserved
r.process(merge_norm=True, merge_tex=True)
assert r.is_volume