<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> </DIV>
<DIV> 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></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> </DIV>
<DIV>from vtk import *</DIV>
<DIV>def main():<BR> math = vtkMath()</DIV>
<DIV> # 20x10x10 points<BR> nx = 20<BR> ny = 10<BR> nz = 10</DIV>
<DIV> # create the cloud of 20x10x10 points<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 < 5:<BR> scalars.InsertNextTuple1( 0 )<BR> else:<BR> scalars.InsertNextTuple1( math.Random( 0, 255 ) + 1 )</DIV>
<DIV> 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 )</DIV>
<DIV> # create mapper + change black points opacity<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 )</DIV>
<DIV> # render it<BR> actor = vtkActor()<BR> actor.SetMapper( mapper )</DIV>
<DIV> ren = vtkRenderer()<BR> ren.AddActor( actor )<BR> ren.SetBackground( 1, 1, 1 )</DIV>
<DIV> renWin = vtkRenderWindow()<BR> renWin.AddRenderer( ren )<BR> iren = vtkRenderWindowInteractor()<BR> iren.SetRenderWindow( renWin )</DIV>
<DIV> renWin.SetSize( 500, 500 )<BR> renWin.Render()<BR> iren.Start()</DIV>
<DIV>if __name__ == '__main__':<BR> main()</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>vtkStructuredGrid (second screenshot)</DIV>
<DIV> </DIV>
<DIV>from vtk import *</DIV>
<DIV>def main():<BR> math = vtkMath()</DIV>
<DIV> # 20x10x10 points<BR> nx = 20<BR> ny = 10<BR> nz = 10</DIV>
<DIV> # create the cloud of 20x10x10 points<BR> points = vtkPoints()<BR> for z in range(0, nz+1):<BR> for y in range(0, ny+1):<BR> for x in range(0, nx+1):<BR> points.InsertNextPoint( x, y, z )</DIV>
<DIV> cloud = vtkStructuredGrid()<BR> cloud.SetDimensions( nx + 1, ny + 1, nz + 1 )<BR> cloud.SetPoints( points )</DIV>
<DIV> values = 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 < 5:<BR> values.InsertNextValue( 0 )<BR> else:<BR> values.InsertNextValue( math.Random( 0, 255 ) )</DIV>
<DIV> cloud.GetCellData().SetScalars( values );</DIV>
<DIV> # create mapper + change black points opacity<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 )</DIV>
<DIV> # render it<BR> actor = vtkActor()<BR> actor.SetMapper( mapper )</DIV>
<DIV> ren = vtkRenderer()<BR> ren.AddActor( actor )<BR> ren.SetBackground( 1, 1, 1 )</DIV>
<DIV> renWin = vtkRenderWindow()<BR> renWin.AddRenderer( ren )<BR> iren = vtkRenderWindowInteractor()<BR> iren.SetRenderWindow( renWin )</DIV>
<DIV> renWin.SetSize( 500, 500 )<BR> renWin.Render()<BR> iren.Start()</DIV>
<DIV>if __name__ == '__main__':<BR> main()</DIV>
<DIV> </DIV>
<DIV>Thanks for your help.</DIV>
<DIV> </DIV>
<DIV>Aurélien REGAT-BARREL</DIV>
<DIV> </DIV>
<DIV> </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>