[vtkusers] Display different ImageData Scalar to different Viewport
Ruben Di Battista
rubendibattista at gmail.com
Tue Jun 26 16:34:07 EDT 2018
Hello David,
I reali lurked in the Classes reference and in the documentation and I
cannot find a method to select which data array to plot in a
PolyDataMapper.
So just to resume for other readers: I have a PolyData object that stores
two PointData Double Arrays. I would like to know how, once I set up the
PolyDataMapper, I choose which of the two “scalars” I want to render in the
RenderWindow.
What I tried so far:
- polydata_object.GetPointData().SetActiveScalars(i)
- polydata_mapper_object.SetArrayName(array_names[i])
- polydata_mapper_object.ColorByArrayComponent(array_names[i], 0) # This
seems to be for vector fields
Thanks for your kind help,
_
-. .´ |∞∞∞∞
', ; |∞∞∞∞∞∞
˜˜ |∞∞∞∞∞∞∞∞∞ RdB
,., |∞∞∞∞∞∞
.' '. |∞∞∞∞
-' `’
http://rdb.is
On 1 giugno 2018 a 09:13:33, David Gobbi (david.gobbi at gmail.com) scritto:
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/20180626/2459dcc4/attachment.html>
More information about the vtkusers
mailing list