# vtkTubeFilter with rounded corners

**URL:** https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924
**Category:** Support
**Created:** [July 11, 2023, 6:18am UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924 "2023-07-11T06:18:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![liuzhongshu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liuzhongshu/32/6921_2.png) [@liuzhongshu](https://discourse.vtk.org/u/liuzhongshu)
#### Post date: [July 11, 2023, 6:18am UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/1 "2023-07-11T06:18:02Z")

</div>

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 ‘)’

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.vtk.org/user_avatar/discourse.vtk.org/stephen_aylward/32/106_2.png) [@Stephen\_Aylward](https://discourse.vtk.org/u/Stephen_Aylward)
#### Post date: [July 11, 2023, 1:48pm UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/2 "2023-07-11T13:48:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [July 11, 2023, 10:23pm UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/3 "2023-07-11T22:23:14Z")

</div>

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](https://stackoverflow.com/questions/10162864/how-to-soften-the-edges-of-a-polyline)) 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](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:

```python
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](https://discourse.vtk.org/t/how-to-show-a-polyline-with-arbitrary-width-and-nice-joins-between-the-nodes)

I hope this helps,

PC

---

<div class="post-metadata">

### Author: ![liuzhongshu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liuzhongshu/32/6921_2.png) [@liuzhongshu](https://discourse.vtk.org/u/liuzhongshu)
#### Post date: [August 16, 2023, 5:31am UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/4 "2023-08-16T05:31:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.vtk.org/user_avatar/discourse.vtk.org/stephen_aylward/32/106_2.png) [@Stephen\_Aylward](https://discourse.vtk.org/u/Stephen_Aylward)
#### Post date: [August 16, 2023, 3:27pm UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/5 "2023-08-16T15:27:38Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![liuzhongshu](https://discourse.vtk.org/user_avatar/discourse.vtk.org/liuzhongshu/32/6921_2.png) [@liuzhongshu](https://discourse.vtk.org/u/liuzhongshu)
#### Post date: [August 17, 2023, 5:14am UTC](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924/6 "2023-08-17T05:14:58Z")

</div>

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