# 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:** 1
**Showing post:** 3

<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

---

_[View the full topic](https://discourse.vtk.org/t/vtktubefilter-with-rounded-corners/11924)._
