Custom colormap and `vtkTubeFilter`

I’m having a very hard time convincing VTK to color my data according to the supplied custom lookup table, and I would really appreciate some hints. The problem occurs when using the vtkTubeFilter: it seems that the tube colors between the points with defined scalar values are not interpolated from the lookup table, but rather some other interpolation method is used.

Consider this simple case: I have two points connected with a segment, I assign scalars to those points. I then build a vtkTubeFilter on top of that PolyData, and I set a custom 3-color lookup table on the mapper. The tube is colored, but the color space is wrong: it only spans from the first to the last color in the lookup table, and completely disregards the third color in the middle (see attached picture_2points). The correct coloring can be seen when I make a 3-point model, with 2 lines, and I color it with the same colormap (see the second picture_3points).

IMO, those two figures should be colored the same way, but you see that the middle part of the colormap is missing in the first 2-point case. I have attached the python code that generates those figures. Could someone help me to understand what am I doing wrong?


picture_3points (3.5 KB)


You’re using a four-component vtkUnsignedCharArray (array.SetNumberOfComponents(4)) to configure your LUT. So, your 12-element array should have 16 elements (red green blue alpha x 4) for a four-point LUT. Either that or set a three-element (red green blue) vtkUnsignedCharArray (array.SetNumberOfComponents(3)) instead.



Hi, @Paulo_Carvalho,

Why do I want a 4 point LUT? I wrote explicitly that I use a 3-point LUT (for simplicity), so 4x3=12. The LUT works as expected for geometry with 3 points / 2 lines, but does not work when I only have 2 points / 1 line.



The solution was to use InterpolateScalarsBeforeMapping: