How can I change the Input Array to Process on a Tube Filter after it's been initialized?

I followed this example here: vtk.js

I am able to get my PolyData to render with the Tube Filter and use setInputArrayToProcess to get the right color map to render during the initial pipeline creation.

However, if I try to modify the array name I want the color map applied to by calling setInputArrayToProcess again with another array name, it doesn’t apply the color map properly. It just changes to a solid color. I then need to refresh so that the entire pipeline is executed again, and the mapper/actor is recreated etc…

I have tried setting the modified properties on the actor, mapper, polydata, and tubefilter.

Is there a way to update this without having to delete/recreate all these objects?


Here is where I am setting the mapper. The only line I change here is 43 arrayName. This works for points and lines representations. It also initializes fine for the tube filter.

When the arrayName changes, I am calling this on the tube filter:

Did you try to calling modified() on the tube filter after calling setInputArrayToProcess() with a new value ?

Yes, I have tried that. I have tried calling modified on all the vtk classes (mapper, actor, colorTransferFunction, and tubeFilter).

Can you place breakpoints in tubefilter requestData function and see if it is called after changin the array name.

Yes, it gets called after changing the array name.

I added some logging here too, and it seems like the right data is coming through this function:

Oh weird. So the range seems to be off??

This is copper range when it is initialized fresh:
Screenshot 2022-11-07 at 2.38.44 PM

But if I have it set to another data array, then switch it back to copper, this is the range that is being printed in the console:
Screenshot 2022-11-07 at 2.39.08 PM

Do you mean it is the range of the vtkDataArray that is wrongly computed (vtkDataArray.getRange()?)

I’m not too sure actually if it’s wrongly computed. I just noticed that the value is different when the input array name is changed after the first pipeline render, vs if it is set during the initial render of all the objects. I was logging that out in the requestData function: inScalars.getRange().