Some questions about categorical colors

Hi Paraview,
I am trying this categorical colors function in Paraview and I have some questions.
Here is the testcase.vdb I used.

  1. Does it worked with volume representation?
    After I check Interpret Values As Categories, I got something as same as before.


    I expect the color of volume can be changed as in surface representation.

  2. From the document, I saw this function is supported in pvpython. Since the example in the document only set rgb value, I wonder if we can also manipulate the opacity mapping in python.

  3. I noticed there are several applications (e.g. paraview-web, paraview-visualizer and paraview-lite) for using paraview. Is this function also implemented there? I saw for paraview-visualizer is not, how about the other two application?

Thank you!

Volume does not support interpret values as categories I’m afraid

https://gitlab.kitware.com/paraview/paraview/-/issues/22299

Hi @mwestphal,
I am testing categorical colors in python through trame.
And I ran into this error: Uncaught TypeError: t.mapDataIndexed is not a function, here is my code:

from paraview import simple

view = simple.CreateRenderView()
source = simple.OpenVDBReader(FileName=r'testcase.vdb')
arrayName = source.PointData.GetArray(0).Name

displayProps = simple.Show(source, view)
displayProps.Representation = 'Surface'
simple.ColorBy(displayProps, ('POINTS', arrayName), True)
# everything works until here, showing the default color set "Cool to Warm"

categoricalColorMap = simple.GetColorTransferFunction(arrayName, displayProps)
categoricalColorMap.InterpretValuesAsCategories = 1
# error happens when I set this

And also, when I ran displayProps.SetScalarBarVisibility(view, True), a warning came out [paraview] Failed to determine the LookupTable being used and the scalar bar was not shown.

I am affraid trame has issue to choose look up table, or did I miss something?
Thank you for your time!

@jourdain

That issue has nothing to do with trame. Just make sure your script is valid for ParaView.
You can use the “python trace” to get the code from your GUI interaction.

1 Like

Hi @jourdain,
Thank you for the useful suggestion!
I’ll check my script.

Hi @jourdain,
I think my script is fine, it works with the Run Script under python shell in Paraview GUI.
And the same error still exist when I copy & paste the whole code directly from the output of python trace.

So are you saying that all is good since you get the same behavior between ParaView and trame?

I think so. Here is the file cate.py I tested with previous vdb file.
The paraview code part works in paraview python shell (update: also works by using pvpython cate.py by a little modification), but it fails when I launch it through trame.

And here is the file I paste all output from python trace and still failed rendering through trame.
detail.py

Hope the information is clear, thank you for your time.