vtkTubeFilter with rounded corners

Currently, I have a tube with vtkTubeFilter that has a 90 degree angle at the ends of the tube. Can I change the end with a rounded corner.

In other words, I’d like to change the endpoint of the tube from ‘]’ to ‘)’

Hi,

I do not believe that it is possible to do that via the vtkTubeFilter, but I have approximated this in the past by also rendering a sphere at the coordinates of the end points of the tube.

Hope that works for you as well.

Stephen

Hello,

I believe you’re better off if you round the corners of the input polyline (see graphics - How to "soften" the edges of a polyline? - Stack Overflow) before processing it with the tube filter. This way you’ll likely get tubes with round elbows. Here (https://public.kitware.com/pipermail/vtkusers/2014-May/083921.html) you can find an algorithm in Python to produce rounded corners given an input 3D path/polyline.

Alternativelly, you can use the following pipeline: edges → implicit modeler → distance field → compute isosurface (e.g. for 1") → a smooth tube around the edges with 1" radius. Here’s a Python code illustrating that:

def polylineToTube(edges, radius, resolution=10, sampling=400):
    modeller = vtk.vtkImplicitModeller()
    modeller.SetSampleDimensions(sampling, sampling, sampling)
    modeller.SetInputData(edges)
    contours = vtk.vtkContourFilter()
    contours.SetInputConnection(modeller.GetOutputPort())
    contours.SetValue(0, radius) # generate iso-surface at radius
    contours.Update()
    return contours

source: https://discourse.vtk.org/t/how-to-show-a-polyline-with-arbitrary-width-and-nice-joins-between-the-nodes

I hope this helps,

PC

Thanks @Stephen_Aylward @Paulo_Carvalho

I just want a round corner at the end of the tube, I tried add a sphere at the end, but the effect didn’t satisfy me, because my tube is translucent, maybe hemisphere would be better, but I don’t know how to add a hemisphere.

Perhaps another option is to specify the final tube endpoints to have decreasing radii so as to approximate a rounded end cap?

Otherwise, it might be a good option to add to the TubeFilter directly, rather than trying to piece together different actors. We’d welcome that contribution to VTK!

Good idea, I tried it and it works. Thanks.