Hole in a hollow cylinder

Hello everyone,
I have created a disk by cutting a plane source with 2 cylinders. Then created a Hollow cylinder using an Extrusion filter. When I tried to cut a hole in the cylinder using vtkCylinder, it doesn’t work. What is the best way to cut a hole in this case?

When I use cylinder1a.SetCenter(30 , 0 , 0); it creates a semicircle at the border i.e. cut at the border works. But inside it does not work.

Regards,
Anish

HoleInExtendedDisk.txt (2.1 KB)

I think you need to extrude the disc with resolution in z otherwise there won’t be vertices on the cylinder surface. (also, you can use vtkDiskSource you don’t need to cut a plane). E.g.:

from vedo import Disc, Cylinder
disc= Disc(r1=1, r2=1.2, res=25).lineWidth(1)
cut = Cylinder(r=0.4, height=4).rotateX(90).z(2)
disc.extrude(3, res=50).cutWithMesh(cut, invert=1).show(axes=1)

Is the problem that the cylinder walls are “open” where they are cut? So you need the clipper to generate new polygons that seal the cut? That is a feature that vtkClipPolyData does not provide.

Marco, your little example looks very impressive! I’ll have to take a closer look at vedo.

1 Like

Thanks David. What one can achieve with vedo (and pyvista) is to quickly check/debug an idea without having to worry too much about renderers and interactors… then one can go back to the pure vtk to implement it in a more performant way.
E.g. trying to cap the holes:

from vedo import *

disc1= Disc(r1=1, r2=1.2, res=25)
cyl1 = disc1.extrude(3, res=50).lw(1)

disc2= Disc(r1=0.4, r2=0, res=25)
cyl2 = disc2.extrude(4, res=50).rotateX(90).pos(0,2,2)

part1 = cyl1.clone().cutWithMesh(cyl2, invert=1)
part2 = cyl2.clone().cutWithMesh(cyl1, invert=1).c("red4").lw(0)
msh = merge(part1, part2).c("gold").lw(0) # uses vtkAppend

show(part1, part2, msh, N=3, axes=1)

took me 5mins to write it! (yet it’s probably slow and not ideal, but could be close enough to a desired result…)

Thank you @marcomusy for your quick response!

I used vtkLinearExtrusionFilter with extrusion type as VectorExtrusion because I wanted to extrude along a particular vector. Now I will use vtkRotationalExtrusionFilter for the generation of vertices in the extrusion direction and then rotate the cylinder in the required direction.