<DIV>
<DIV>Hello everybody,</DIV>
<DIV>I am still trying to blank zero-value points in my vtkStrcuturedPoints. I have done it via a vtkThreshold filter but it generate a new DataSet and it is very slow.</DIV>
<DIV>So I have tried to change black points opacity in the lookuptable build by the mapper but it fails.</DIV>
<DIV>Here is the interesting code :</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; mapper = vtkDataSetMapper()<BR>&nbsp;&nbsp;&nbsp; mapper.SetInput( cloud )<BR>&nbsp;&nbsp;&nbsp; mapper.SetScalarRange( cloud.GetScalarRange() )<BR>&nbsp;&nbsp;&nbsp; lut = mapper.GetLookupTable()<BR>&nbsp;&nbsp;&nbsp; lut.Build()<BR>&nbsp;&nbsp;&nbsp; lut.SetTableValue( 0, 0, 0, 0, 0 )<BR></DIV>
<DIV>It does nothing, why ?</DIV>
<DIV>I thought that it was a limitation of vtkStructuredGrid (because a point is used to render more than one cell, see the 2 screenshots to see what I mean) and I changed my code to use a vtkStructuredGrid. It is the same thing... Why ?</DIV>
<DIV>Python examples :</DIV>
<DIV>vtkStructuredPoints (first screenshot)</DIV>
<DIV>&nbsp;</DIV>
<DIV>from vtk import *</DIV>
<DIV>def main():<BR>&nbsp;&nbsp;&nbsp; math = vtkMath()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # 20x10x10 points<BR>&nbsp;&nbsp;&nbsp; nx = 20<BR>&nbsp;&nbsp;&nbsp; ny = 10<BR>&nbsp;&nbsp;&nbsp; nz = 10</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # create the cloud of 20x10x10 points<BR>&nbsp;&nbsp;&nbsp; scalars = vtkUnsignedCharArray()<BR>&nbsp;&nbsp;&nbsp; for z in range(0, nz):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for y in range(0, ny):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in range(0, nx):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x &lt; 5:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scalars.InsertNextTuple1( 0 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scalars.InsertNextTuple1( math.Random( 0, 255 ) + 1 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; cloud = vtkStructuredPoints()<BR>&nbsp;&nbsp;&nbsp; cloud.SetDimensions( nx, ny, nz )<BR>&nbsp;&nbsp;&nbsp; cloud.SetOrigin( 0, 0, 0 )<BR>&nbsp;&nbsp;&nbsp; cloud.SetSpacing( 1, 1, 1 )<BR>&nbsp;&nbsp;&nbsp; cloud.GetPointData().SetScalars( scalars )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # create mapper + change black points opacity<BR>&nbsp;&nbsp;&nbsp; mapper = vtkDataSetMapper()<BR>&nbsp;&nbsp;&nbsp; mapper.SetInput( cloud )<BR>&nbsp;&nbsp;&nbsp; mapper.SetScalarRange( cloud.GetScalarRange() )<BR>&nbsp;&nbsp;&nbsp; lut = mapper.GetLookupTable()<BR>&nbsp;&nbsp;&nbsp; lut.Build()<BR>&nbsp;&nbsp;&nbsp; lut.SetTableValue( 0, 0, 0, 0, 0 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # render it<BR>&nbsp;&nbsp;&nbsp; actor = vtkActor()<BR>&nbsp;&nbsp;&nbsp; actor.SetMapper( mapper )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ren = vtkRenderer()<BR>&nbsp;&nbsp;&nbsp; ren.AddActor( actor )<BR>&nbsp;&nbsp;&nbsp; ren.SetBackground( 1, 1, 1 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; renWin = vtkRenderWindow()<BR>&nbsp;&nbsp;&nbsp; renWin.AddRenderer( ren )<BR>&nbsp;&nbsp;&nbsp; iren = vtkRenderWindowInteractor()<BR>&nbsp;&nbsp;&nbsp; iren.SetRenderWindow( renWin )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; renWin.SetSize( 500, 500 )<BR>&nbsp;&nbsp;&nbsp; renWin.Render()<BR>&nbsp;&nbsp;&nbsp; iren.Start()</DIV>
<DIV>if __name__ == '__main__':<BR>&nbsp;&nbsp;&nbsp; main()</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>vtkStructuredGrid (second screenshot)</DIV>
<DIV>&nbsp;</DIV>
<DIV>from vtk import *</DIV>
<DIV>def main():<BR>&nbsp;&nbsp;&nbsp; math = vtkMath()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # 20x10x10 points<BR>&nbsp;&nbsp;&nbsp; nx = 20<BR>&nbsp;&nbsp;&nbsp; ny = 10<BR>&nbsp;&nbsp;&nbsp; nz = 10</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # create the cloud of 20x10x10 points<BR>&nbsp;&nbsp;&nbsp; points = vtkPoints()<BR>&nbsp;&nbsp;&nbsp; for z in range(0, nz+1):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for y in range(0, ny+1):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in range(0, nx+1):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points.InsertNextPoint( x, y, z )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; cloud = vtkStructuredGrid()<BR>&nbsp;&nbsp;&nbsp; cloud.SetDimensions( nx + 1, ny + 1, nz + 1 )<BR>&nbsp;&nbsp;&nbsp; cloud.SetPoints( points )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; values = vtkUnsignedCharArray()<BR>&nbsp;&nbsp;&nbsp; for z in range(0, nz):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for y in range(0, ny):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in range(0, nx):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x &lt; 5:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; values.InsertNextValue( 0 )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; values.InsertNextValue( math.Random( 0, 255 ) )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; cloud.GetCellData().SetScalars( values );</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # create mapper + change black points opacity<BR>&nbsp;&nbsp;&nbsp; mapper = vtkDataSetMapper()<BR>&nbsp;&nbsp;&nbsp; mapper.SetInput( cloud )<BR>&nbsp;&nbsp;&nbsp; mapper.SetScalarRange( cloud.GetScalarRange() )<BR>&nbsp;&nbsp;&nbsp; lut = mapper.GetLookupTable()<BR>&nbsp;&nbsp;&nbsp; lut.Build()<BR>&nbsp;&nbsp;&nbsp; lut.SetTableValue( 0, 0, 0, 0, 0 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # render it<BR>&nbsp;&nbsp;&nbsp; actor = vtkActor()<BR>&nbsp;&nbsp;&nbsp; actor.SetMapper( mapper )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ren = vtkRenderer()<BR>&nbsp;&nbsp;&nbsp; ren.AddActor( actor )<BR>&nbsp;&nbsp;&nbsp; ren.SetBackground( 1, 1, 1 )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; renWin = vtkRenderWindow()<BR>&nbsp;&nbsp;&nbsp; renWin.AddRenderer( ren )<BR>&nbsp;&nbsp;&nbsp; iren = vtkRenderWindowInteractor()<BR>&nbsp;&nbsp;&nbsp; iren.SetRenderWindow( renWin )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; renWin.SetSize( 500, 500 )<BR>&nbsp;&nbsp;&nbsp; renWin.Render()<BR>&nbsp;&nbsp;&nbsp; iren.Start()</DIV>
<DIV>if __name__ == '__main__':<BR>&nbsp;&nbsp;&nbsp; main()</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks for your help.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Aurélien REGAT-BARREL</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV><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>