[vtkusers] Display different ImageData Scalar to different Viewport

David Gobbi david.gobbi at gmail.com
Fri Jun 1 12:13:12 EDT 2018


There might be other settings for the mapper that are needed in addition to
SetArrayName().  Take a look at the docs for vtkMapper, it has lots of
methods related to scalars.

On Fri, Jun 1, 2018 at 7:53 AM, Ruben Di Battista <rubendibattista at gmail.com
> wrote:

> Hello David,
>
> thanks for your answer.
>
> I changed my `show` method like this:
>
>     def show(self):
>         # Render Window
>         rw = vtk.vtkRenderWindow()
>         rw.SetSize(800, 800)
>
>         # Defining Bounds of Viewports
>         xmins = [0, 0.5]
>         xmaxs = [0.5, 1]
>         ymins = [0, 0]
>         ymaxs = [1, 1]
>
>         # Curvature Types
>         curv_types = ['Mean_Curvature', 'Gauss_Curvature']
>
>         for i in six.moves.range(2):
>
>             render = vtk.vtkRenderer()
>             rw.AddRenderer(render)
>
>             # Mean Curvature View
>             render.SetViewport(xmins[i], ymins[i], xmaxs[i], ymaxs[i])
>
>             # Create mapper
>             mapper = vtk.vtkPolyDataMapper()
>             mapper.SetInputData(self.surface)
>             mapper.Update()  # Probably useless
>             mapper.SetScalarRange(-1, 1)
>             mapper.SetArrayName(curv_types[0])
>             mapper.Update()
>
>             # ColorBar
>             color_bar = vtk.vtkScalarBarActor()
>             color_bar.SetLookupTable(mapper.GetLookupTable())
>
>             # Surface Actor
>             actor = vtk.vtkActor()
>             actor.SetMapper(mapper)
>             actor.GetProperty().EdgeVisibilityOn()
>
>             render.AddActor(actor)
>             render.AddActor2D(color_bar)
>
>             import ipdb
>             ipdb.set_trace()
>
>         # Render Window Interactor
>         rwi = vtk.vtkRenderWindowInteractor()
>         rwi.SetRenderWindow(rw)
>
>         rwi.Initialize()
>         rwi.Start()
>
> but it's not working.
>
> Actually stopping the execution at the first iteration of the `for` loop,
> and then triggering rwi.Initialize() and rwi.Start() just after the first
> iteration still shows that the Mapper is rendering the last scalar added to
> the `PolyData` and not the one specified by `mapper.SetArrayName`.
>
> In my previous email, at least, if I stopped the execution at the first
> iteration and then manually triggering the rendering, was correctly showing
> the first scalar (i.e. `Mean_Curvatures`).
>
> I'm still attaching the complete example.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180601/58de46db/attachment.html>


More information about the vtkusers mailing list