<DIV>Hello,</DIV>
<DIV>I tested your script without changing the opacity to 0.999 and it worked.</DIV>
<DIV>I have modified it inr order to get a 3x3x3 grid =&gt; 4x2 cells with 1 transparent. It work but it is not the cell but its faces that are invisible (see the screenshot).</DIV>
<DIV>It works only with the vtkDataSetMapper, there is noting with vtkPolyDataMapper.</DIV>
<DIV>My Python code :</DIV>
<DIV>&nbsp;</DIV>
<DIV>from vtk import *</DIV>
<DIV>def main():<BR>&nbsp;&nbsp;&nbsp; # Create the RenderWindow, Renderer and RenderWindowInteractor<BR>&nbsp;&nbsp;&nbsp; ren1 = vtkRenderer()<BR>&nbsp;&nbsp;&nbsp; renWin = vtkRenderWindow()<BR>&nbsp;&nbsp;&nbsp; renWin.AddRenderer( ren1 )<BR>&nbsp;&nbsp;&nbsp; iren = vtkRenderWindowInteractor()<BR>&nbsp;&nbsp;&nbsp; iren.SetRenderWindow( renWin )<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; # create a 2*2 cell/3*3 pt structuredgrid<BR>&nbsp;&nbsp;&nbsp; points = vtkPoints()<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, 1, 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( 0, 1, 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 1,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1,&nbsp; 0,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 0,&nbsp; 0,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 0,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, -1,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp;
 points.InsertNextPoint(&nbsp; 0, -1,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1, -1,&nbsp; 0 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, 1, 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( 0, 1, 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 1,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1,&nbsp; 0,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 0,&nbsp; 0,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 0,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, -1,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 0, -1,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1, -1,&nbsp; 1 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, 1, 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( 0, 1, 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 1,&nbsp; 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1,&nbsp; 0,&nbsp; 2
 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 0,&nbsp; 0,&nbsp; 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1,&nbsp; 0,&nbsp; 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint( -1, -1,&nbsp; 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 0, -1,&nbsp; 2 )<BR>&nbsp;&nbsp;&nbsp; points.InsertNextPoint(&nbsp; 1, -1,&nbsp; 2 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; faceColors = vtkUnsignedCharArray()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; faceColors.SetNumberOfComponents( 4 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetNumberOfTuples( 8 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 0, 0, 0 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 0, 1, 0 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 0, 2, 0 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 0, 3, 0 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 1, 0, 32 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 1, 1, 32 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 1, 2, 32 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 1, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 2, 0, 64 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 2, 1, 64 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 2, 2, 64 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 2, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 3, 0, 96 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 3, 1, 96 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 3, 2, 96 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 3, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 4, 0, 128
 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 4, 1, 128 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 4, 2, 128 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 4, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 5, 0, 160 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 5, 1, 160 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 5, 2, 160 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 5, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 6, 0, 192 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 6, 1, 192 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 6, 2, 192 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 6, 3, 255 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 7, 0, 224 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 7, 1, 224 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 7, 2, 224 )<BR>&nbsp;&nbsp;&nbsp; faceColors.SetComponent( 7, 3, 255 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; sgrid = vtkStructuredGrid()<BR>&nbsp;&nbsp;&nbsp; sgrid.SetDimensions( 3, 3, 3 )<BR>&nbsp;&nbsp;&nbsp; sgrid.SetPoints( points )<BR>&nbsp;&nbsp;&nbsp; sgrid.GetCellData().SetScalars( faceColors )<BR>&nbsp;&nbsp;&nbsp; faceColors.Modified()</DIV>
<DIV>#&nbsp;&nbsp;&nbsp;&nbsp; sggf = vtkStructuredGridGeometryFilter()<BR>#&nbsp;&nbsp;&nbsp;&nbsp; sggf.SetInput( sgrid )<BR>#&nbsp;&nbsp;&nbsp;&nbsp; spdm = vtkPolyDataMapper()<BR>#&nbsp;&nbsp;&nbsp;&nbsp; spdm.SetInput( sggf.GetOutput() )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; mapper = vtkDataSetMapper()<BR>&nbsp;&nbsp;&nbsp; mapper.SetInput( sgrid )<BR>&nbsp;&nbsp;&nbsp; mapper.SetScalarModeToUseCellData()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; actor = vtkActor()<BR>&nbsp;&nbsp;&nbsp; actor.SetMapper( mapper )<BR>#&nbsp;&nbsp;&nbsp; actor.SetMapper( spdm )<BR>#&nbsp;&nbsp;&nbsp; actor.GetProperty().SetOpacity( 0.999 )</DIV>
<DIV><BR>&nbsp;&nbsp;&nbsp; # Add the actors to the renderer, set the background and size<BR>&nbsp;&nbsp;&nbsp; ren1.AddActor( actor )<BR>&nbsp;&nbsp;&nbsp; ren1.SetBackground( 0.5, 0, 1 )<BR>&nbsp;&nbsp;&nbsp; renWin.SetSize( 256, 256 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # render the image<BR>&nbsp;&nbsp;&nbsp; renWin.Render()<BR>&nbsp;&nbsp;&nbsp; iren.Start()<BR>&nbsp;&nbsp;&nbsp; <BR>if __name__ == '__main__':<BR>&nbsp;&nbsp;&nbsp; main()</DIV>
<DIV><BR><B><I>Malcolm Drummond &lt;malcolm@geovision.co.za&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi David, Aurélien<BR><BR>I find that I have to set the actors opacity to something less than 1 for<BR>the scalar opacity values to have any effect, see following script ... not<BR>sure if this is just because I'm colouring direct with unsigned char. Works<BR>with both mappers.<BR><BR># begin ------------------<BR>package require vtk<BR><BR># Create the RenderWindow, Renderer and RenderWindowInteractor<BR>vtkRenderer ren1<BR>vtkRenderWindow renWin<BR>renWin AddRenderer ren1<BR>vtkRenderWindowInteractor iren<BR>iren SetRenderWindow renWin<BR><BR># create a 2*2 cell/3*3 pt structuredgrid<BR>vtkPoints points<BR>points InsertNextPoint -1 1 0<BR>points InsertNextPoint 0 1 0<BR>points InsertNextPoint 1 1 0<BR>points InsertNextPoint -1 0 0<BR>points InsertNextPoint 0 0 0<BR>points InsertNextPoint 1 0 0<BR>points InsertNextPoint -1 -1 0<BR>points InsertNextPoint 0 -1 0<BR>points
 InsertNextPoint 1 -1 0<BR><BR>vtkUnsignedCharArray faceColors<BR><BR>faceColors SetNumberOfComponents 4<BR>faceColors SetNumberOfTuples 4<BR><BR>faceColors SetComponent 0 0 0<BR>faceColors SetComponent 0 1 255<BR>faceColors SetComponent 0 2 0<BR>faceColors SetComponent 0 3 255<BR>faceColors SetComponent 1 0 0<BR>faceColors SetComponent 1 1 255<BR>faceColors SetComponent 1 2 0<BR>faceColors SetComponent 1 3 175<BR>faceColors SetComponent 2 0 0<BR>faceColors SetComponent 2 1 255<BR>faceColors SetComponent 2 2 0<BR>faceColors SetComponent 2 3 100<BR>faceColors SetComponent 3 0 0<BR>faceColors SetComponent 3 1 255<BR>faceColors SetComponent 3 2 0<BR>faceColors SetComponent 3 3 25<BR><BR>vtkStructuredGrid sgrid<BR>sgrid SetDimensions 3 3 1<BR>sgrid SetPoints points<BR>[sgrid GetCellData] SetScalars faceColors<BR>faceColors Modified<BR><BR>vtkStructuredGridGeometryFilter sggf<BR>sggf SetInput sgrid<BR>vtkPolyDataMapper spdm<BR>spdm SetInput [sggf GetOutput]<BR><BR>vtkDataSetMapper
 mapper<BR>mapper SetInput sgrid<BR>#mapper SetScalarModeToUseCellData<BR><BR>vtkActor actor<BR>actor SetMapper mapper<BR>#actor SetMapper mapper spdm<BR>[actor GetProperty] SetOpacity 0.999<BR><BR>vtkCylinderSource cyl<BR>cyl SetResolution 10<BR>vtkPolyDataMapper pdm<BR>pdm SetInput [cyl GetOutput]<BR>vtkActor cylinder<BR>cylinder SetMapper pdm<BR>[cylinder GetProperty] SetColor 0 0 1<BR><BR># Add the actors to the renderer, set the background and size<BR>ren1 AddActor actor<BR>ren1 AddActor cylinder<BR>ren1 SetBackground 1 1 1<BR>renWin SetSize 256 256<BR><BR># render the image<BR>#iren SetUserMethod {wm deiconify .vtkInteract}<BR>iren Initialize<BR>wm withdraw .<BR><BR># end -----------------<BR><BR>Regards<BR>Malcolm<BR><BR>----- Original Message -----<BR>From: <DAVID.PONT@FORESTRESEARCH.CO.NZ><BR>To: "REGAT-BARREL Aurélien" <ARBVTK@YAHOO.FR><BR>Cc: "VTK" <VTKUSERS@VTK.ORG>; <VTKUSERS-ADMIN@VTK.ORG><BR>Sent: Thursday, February 05, 2004 5:35 AM<BR>Subject: Re: [vtkusers] Point
 rendering : how to filter values with a<BR>vtkLookupTable<BR><BR><BR><BR>Hi Aurélien,<BR>could you try creating a separate lookuptable as in my example rather<BR>than mapper-&gt;GetLookupTable ? and make sure to call SetRange (etc) before<BR>Build?<BR><BR>Otherwise it might be due to a difference between vtkDataSetMapper and<BR>vtkPolyDataMapper?<BR><BR>regards<BR><BR>Dave P<BR><BR><BR><BR><BR>REGAT-BARREL<BR>Aurélien To:<BR>David.Pont@forestresearch.co.nz<BR><ARBVTK@YAHOO.FR>cc: VTK<BR><VTKUSERS@VTK.ORG>, vtkusers-admin@vtk.org<BR>Sent by: Subject: Re: [vtkusers]<BR>Point rendering : how to filter values<BR>vtkusers-admin@vt with a vtkLookupTable<BR>k.org<BR><BR><BR>05/02/2004 12:45<BR><BR><BR><BR><BR><BR><BR>Hello David,<BR>I had tried your solution but I failed to use it. I don't understand why it<BR>doesn't work :<BR><BR>mapper = vtkDataSetMapper()<BR>mapper.SetInput( cloud )<BR>mapper.SetScalarRange( cloud.GetScalarRange() )<BR>lut =
 mapper.GetLookupTable()<BR>lut.Build()<BR>lut.SetTableValue( 0, 0, 0, 0, 0 )<BR>Black points are still visible... :-(<BR>Do you have a simple example of a vtkStructuredPoints or vtkStructuredGrid<BR>build by hand on wich you can choose each point value color. Here is my<BR>Python code that doesn't work :<BR><BR>from vtk import *<BR>def main():<BR>math = vtkMath()<BR># 20x10x10 points<BR>nx = 20<BR>ny = 10<BR>nz = 10<BR><BR>scalars = vtkUnsignedCharArray()<BR>for z in range(0, nz):<BR>for y in range(0, ny):<BR>for x in range(0, nx):<BR>if x &lt; 5:<BR>scalars.InsertNextTuple1( 0 )<BR>else:<BR>scalars.InsertNextTuple1( math.Random( 0, 255 ) + 1 )<BR><BR>cloud = vtkStructuredPoints()<BR>cloud.SetDimensions( nx, ny, nz )<BR>cloud.SetOrigin( 0, 0, 0 )<BR>cloud.SetSpacing( 1, 1, 1 )<BR>cloud.GetPointData().SetScalars( scalars )<BR>mapper = vtkDataSetMapper()<BR>mapper.SetInput( cloud )<BR>mapper.SetScalarRange( cloud.GetScalarRange() )<BR>lut =
 mapper.GetLookupTable()<BR>lut.Build()<BR>lut.SetTableValue( 0, 0, 0, 0, 0 )<BR>actor = vtkActor()<BR>actor.SetMapper( mapper )<BR><BR>ren = vtkRenderer()<BR>ren.AddActor( actor )<BR>ren.SetBackground( 1, 1, 1 )<BR><BR>renWin = vtkRenderWindow()<BR>renWin.AddRenderer( ren )<BR>iren = vtkRenderWindowInteractor()<BR>iren.SetRenderWindow( renWin )<BR><BR>renWin.SetSize( 500, 500 )<BR>renWin.Render()<BR>iren.Start()<BR>if __name__ == '__main__':<BR>main()<BR><BR>I don't understand what is wrong.<BR>Thanks for your help.<BR><BR><BR>David.Pont@ForestResearch.co.nz wrote:<BR><BR></BLOCKQUOTE><p>
                <hr size=1>
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
<br><a href="http://fr.rd.yahoo.com/mail/taglines/*http://fr.benefits.yahoo.com/">Créez votre Yahoo! Mail</a>