[Paraview] Opacity transfer function in pvpython

Ross Gardiner ross.gardiner at ultrahaptics.com
Mon Jul 24 11:48:23 EDT 2017


In case anyone finds this useful, I also found a solution to a related problem.

Once I extended the previous code to import multiple VTIs, editing the colour/opacity mapping broke again. I could only get it to affect either one of the imageDatas, or all of them simultaneously.

I eventually discovered that this was due to the default name of the scalar points in imageDatas being hardcoded to “ImagesScalars” in VTK. ParaView apparently assumes that they should all have the same colour/opacity maps as a result. I just added 

imageData->GetPointData()->GetScalars()->SetName(“ImageScalars” + std::to_string(index)).c_str());

to my export code, which seems to have fixed it.

- Ross

On 24/07/2017, 12:01, "Ross Gardiner" <ross.gardiner at ultrahaptics.com> wrote:

    Hi yoshimi,
    
    Thanks – your suggestion helped me find a solution:
    
    
    opacity_map = CreatePiecewiseFunction(Points=[44.0, 0.0, 0.5, 0.0, 132.0, 0.0, 0.5, 0.0, 154.0, 1.0, 0.5, 0.0]) 
    representation.LookupTable.ScalarOpacityFunction = opacity_map
    representation.ScalarOpacityFunction = opacity_map
    
    I believe what’s going on here is that the LookupTable editor in ParaView gets its data from LookupTable.ScalarOpacityFunction, while the renderer gets it from representation.ScalarOpacityFunction. If they’re both initialised separately, updating the opacity mapping in the colour map editor does not cause the rendering to update. If they both reference the same object, it works as expected.
    
    - Ross
    
    On 22/07/2017, 11:12, "kenichiro yoshimi" <rccm.kyoshimi at gmail.com> wrote:
    
        c
    
    



More information about the ParaView mailing list