vedo icon indicating copy to clipboard operation
vedo copied to clipboard

Extrude until contact/overlap

Open JeffreyWardman opened this issue 1 year ago • 3 comments

I'd like a way to run mesh.extrude() where it extrudes until contact with the previous mesh (and then stops on a point by point basis). Is there a way to do this? At the moment some parts exceed through the mesh.

JeffreyWardman avatar Mar 20 '24 03:03 JeffreyWardman

Yes - I will try implementing it now.

marcomusy avatar Mar 21 '24 12:03 marcomusy

I implemented this but i'm not sure if it works the intended way (i may not understand the vtk filter...): https://vedo.embl.es/autodocs/content/vedo/vedo/mesh.html#Mesh.extrude_and_trim_with

Also there is another possibility by "sweeping" a Line along a spline:

from vedo import *

sphere = Sphere([-1,0,4]).rotate_x(25).wireframe().color('r')
circle = Circle([0,0,0], r=2, res=100).color('b6')

extruded_circle = circle.extrude_and_trim_with(
    sphere, 
    direction=[0,-0.2,1],
    strategy="bound",
    cap=True,
    cap_strategy="intersection",
)

circle.lw(3).c("tomato").shift(dz=-0.1)

show(circle, sphere, extruded_circle, axes=1).close()

and:



from vedo import *

aline = Line(Circle().coordinates)
spline = Spline([(0,0,0), (1,1,1), (2,3,3), (1,1,4), (0,1,5)]).lw(5)
pts = spline.coordinates

surfs = []
for i in range(1, len(pts)-1):
    p0, p1 = pts[i-1:i+1]
    surf = aline.sweep(p1 - p0)
    surfs.append(surf)
surface = merge(surfs, flag=True)
surface.c("gold").lw(0.1).pickable(True)

show(spline, surface, aline, axes=1).close()

Screenshot from 2024-03-22 10-51-49

marcomusy avatar Mar 22 '24 09:03 marcomusy

Oh I forgot the other option is to use Ribbon() and then merge the pieces the same way.

marcomusy avatar Mar 22 '24 10:03 marcomusy