[vtkusers] Display different ImageData Scalar to different Viewport
Ruben Di Battista
rubendibattista at gmail.com
Thu May 31 10:57:13 EDT 2018
Hello,
I'm playing a bit with VTK and its Python bindings. I wrote down a simple
case where I generate the distance function of a sphere, I extract the
surface from it using the FlyingEdge3D algorithm, then I calculate the
curvatures using the vtkCurvatures filter, and then I'd like to show the
Mean_Curvature and the Gauss_Curvature in two different viewports.
What I tried to do is to use the `SetActiveScalars` method of the
`PointData` associated to my `ImageData` dataset, but at the end I get two
Viewports showing the same scalar (the last one activated). I also tried to
stop the program execution using a debugger and triggering the render
before the second scalar is made "active", and it correctly shows the first
scalar field. So It's like that the two mappers rendered are "linked".
Do I need to do a ShallowCopy somewhere?
Here below the `Sphere.show` method. The full code is attached.
`self.surface` is an `ImageData` dataset.
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()
self.surface.GetPointData().SetActiveScalars(curv_types[i])
mapper.SetInputData(self.surface)
mapper.SetScalarRange(-1, 1)
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)
# Render Window Interactor
rwi = vtk.vtkRenderWindowInteractor()
rwi.SetRenderWindow(rw)
rwi.Initialize()
rwi.Start()
--
_
-. .´ |∞∞∞∞
', ; |∞∞∞∞∞∞
˜˜ |∞∞∞∞∞∞∞∞∞ RdB
,., |∞∞∞∞∞∞
.' '. |∞∞∞∞
-' `'
http://rdb.is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180531/858d6062/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sphere.py
Type: text/x-python
Size: 6763 bytes
Desc: not available
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180531/858d6062/attachment.py>
More information about the vtkusers
mailing list