[vtkusers] Point rendering : how to filter values with a vtkLookupTable

REGAT-BARREL Aurélien arbvtk at yahoo.fr
Wed Feb 4 18:45:10 EST 2004


Hello David,
I had tried your solution but I failed to use it. I don't understand why it doesn't work :
 
    mapper = vtkDataSetMapper()
    mapper.SetInput( cloud )
    mapper.SetScalarRange( cloud.GetScalarRange() )
    lut = mapper.GetLookupTable()
    lut.Build()
    lut.SetTableValue( 0, 0, 0, 0, 0 )

Black points are still visible... :-(
Do you have a simple example of a vtkStructuredPoints or vtkStructuredGrid build by hand on wich you can choose each point value color. Here is my Python code that doesn't work :
 
from vtk import *
def main():
    math = vtkMath()
    # 20x10x10 points
    nx = 20
    ny = 10
    nz = 10
    
    scalars = vtkUnsignedCharArray()
    for z in range(0, nz):
        for y in range(0, ny):
            for x in range(0, nx):
                if x < 5:
                    scalars.InsertNextTuple1( 0 )
                else:
                    scalars.InsertNextTuple1( math.Random( 0, 255 ) + 1 )
    
    cloud = vtkStructuredPoints()
    cloud.SetDimensions( nx, ny, nz )
    cloud.SetOrigin( 0, 0, 0 )
    cloud.SetSpacing( 1, 1, 1 )
    cloud.GetPointData().SetScalars( scalars )

    mapper = vtkDataSetMapper()
    mapper.SetInput( cloud )
    mapper.SetScalarRange( cloud.GetScalarRange() )
    lut = mapper.GetLookupTable()
    lut.Build()
    lut.SetTableValue( 0, 0, 0, 0, 0 )

    actor = vtkActor()
    actor.SetMapper( mapper )
    
    ren = vtkRenderer()
    ren.AddActor( actor )
    ren.SetBackground( 1, 1, 1 )
    
    renWin = vtkRenderWindow()
    renWin.AddRenderer( ren )
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow( renWin )
    
    renWin.SetSize( 500, 500 )
    renWin.Render()
    iren.Start()
if __name__ == '__main__':
    main()
 
I don't understand what is wrong.
Thanks for your help.


David.Pont at ForestResearch.co.nz wrote:


Hi Aurélien,
The code fragment below constructs a greyscale lookuptable with 5
colors. After the call to Build one color is changed so that alpha is 0.
Data values mapped into this color in the lookuptable will be transparent.

vtkLookupTable *lut1 = vtkLookupTable::New();
lut1->SetRange( 0, 0.5 );
lut1->SetNumberOfColors( 5 );
lut1->SetHueRange( 0, 0 );
lut1->SetSaturationRange( 0, 0 );
lut1->SetValueRange( 0, 1 );
lut1->Build();
lut1->SetTableValue( 1, 0, 0, 0, 0 ); // make one band
disappear, note: rgb values not important

vtkPolyDataMapper *pdm1 = vtkPolyDataMapper::New();
pdm1->SetInput( clpd1->GetOutput() );
pdm1->SetScalarRange( 0, 0.5 );
pdm1->SetLookupTable( lut1 );
pdm1->ScalarVisibilityOn();

You should be able to use appropriate values for SetRange,
SetNumberOfColors, SetTableValue and SetScalarRange to hide parts of your
dataset. This worked for me on polydata surfaces, I am not sure about
rendering points, but I would expect it to work.

bon chance
Dave Pont

		
---------------------------------
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Créez votre Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040205/3910fbb0/attachment.htm>


More information about the vtkusers mailing list