<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19394"></HEAD>
<BODY>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>Hello
people,</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>investigating how to
render two scalars into one representation. Natural solution seems to use
array1=Alpha and array2=RGB. This way, I can show two scalars at once.
Works well, if alpha array is i.e. the void fraction, indicating,
how vanishing the values of a field actually are. This way, I can blend a
field out when it is not there, or only fractionally.</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>What I am stumbling
over is how to tell this to the mapper:<BR></FONT></SPAN><SPAN
class=257311712-26022013><FONT size=2 face=Arial>1) internally you most probably
have array1 and array2 as floatarray</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>2) there are
tutorials who basically setup an array of RGBA as the data array to be
rendered.</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>3) this means a
"conversion" of array1 and array2 into array3 (RGBA format, unsigned
char)</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>This approach is
very inflexible since changing the colourmap means a re-setup of this data
array, array3, needed for rendering.</FONT></SPAN></DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=257311712-26022013><FONT size=2 face=Arial>Do different ways
exist?</FONT></SPAN></DIV>
<DIV class=Section1>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>Thanks a
million,</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013></SPAN></FONT></SPAN><SPAN
style="mso-ansi-language: DE" lang=DE><FONT size=2 face=Arial><SPAN
class=257311712-26022013>Martin</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>############# pythoncode,
runnable with vtkpython, looks
nice ############</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>#!/usr/bin/python<BR>import os,
sys<BR>from math import *<BR>import struct<BR>import array<BR>import numpy as
Numeric<BR>import random<BR>import vtk</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>ren =
vtk.vtkRenderer()<BR>renWin = vtk.vtkRenderWindow()<BR>iren =
vtk.vtkRenderWindowInteractor()<BR>iren.SetRenderWindow(renWin)<BR>renWin.AddRenderer(ren)<BR>renWin.SetSize(500,
500)</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>v_lut =
vtk.vtkLookupTable()<BR>v_lut.SetTableRange([-1.0,
1.0])<BR>v_lut.SetRange([-1.0,
1.0])<BR>v_lut.SetHueRange(0.66,0);<BR>v_lut.Build()</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013># build some initial
geometry<BR>pS =
vtk.vtkSphereSource()<BR>pS.SetThetaResolution(100)<BR>pS.SetPhiResolution(100)<BR>pS.Modified()<BR>pS.Update()<BR>pD
= pS.GetOutput()<BR>numP = pD.GetNumberOfPoints()</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>#
##############################################################<BR># initial data
array<BR>arr1 = vtk.vtkFloatArray()<BR>arr2 = vtk.vtkFloatArray()<BR>for i in
range(numP):<BR> arr1.InsertNextTuple([1.0-i/(float(numP))])<BR> #arr1.InsertNextTuple([cos(i/8.0)])<BR> arr2.InsertNextTuple([sin(i/110.0)])</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013># fill the colours
array<BR>arr3 =
vtk.vtkUnsignedCharArray()<BR>arr3.SetName("colors")<BR>arr3.SetNumberOfComponents(4)<BR>for
i in range(numP):<BR> alpha =
arr1.GetValue(i)<BR> rgbindex =
arr2.GetValue(i)<BR> col =
[0,0,0]<BR> v_lut.GetColor(rgbindex,col)<BR> rgba
= [col[0]*255,col[1]*255,col[2]*255,
arr1.GetValue(i)*255]<BR> arr3.InsertNextTuple(rgba)</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013># set the data to the
geometry<BR>pD.GetPointData().SetScalars(arr3)<BR># ---> I would prefer to
set the two arrays to a mapper using it as RGBA
<---<BR>pD.GetPointData().SetActiveScalars("colors")</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013># mapper<BR>pSM =
vtk.vtkPolyDataMapper()<BR>pSM.SetInput(pD)<BR>pSM.ScalarVisibilityOn()<BR>pSM.SetScalarModeToDefault()</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013># actors<BR>pSA =
vtk.vtkActor()<BR>pSA.SetMapper(pSM)<BR>v_scalActor =
vtk.vtkScalarBarActor();<BR>v_scalActor.SetLookupTable(v_lut);<BR>ren.AddActor(v_scalActor)<BR>ren.AddActor(pSA)</SPAN></FONT></SPAN></P>
<P class=MsoNormal align=left><SPAN style="mso-ansi-language: DE" lang=DE><FONT
size=2 face=Arial><SPAN class=257311712-26022013>#
########################<BR>style =
vtk.vtkInteractorStyleTrackballCamera()<BR>iren.SetInteractorStyle(style)<BR>ren.ResetCamera()<BR>ren.GradientBackgroundOn()<BR>ren.SetBackground(0.365,
.365, 0.375)<BR>ren.SetBackground2(0.795, .7995,
0.795)<BR>iren.Initialize()<BR>renWin.Render()<BR>iren.Start()</SPAN></FONT></SPAN></P></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV></BODY></HTML>