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

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Wed Feb 4 22:35:41 EST 2004


Hi Aurélien,
  could you try creating a separate lookuptable as in my example rather
than mapper->GetLookupTable ? and make sure to call SetRange (etc) before
Build?

Otherwise it might be due to a difference between vtkDataSetMapper and
vtkPolyDataMapper?

regards

   Dave P



                                                                                                               
                      REGAT-BARREL                                                                             
                      Aurélien                 To:       David.Pont at forestresearch.co.nz                       
                      <arbvtk at yahoo.fr>        cc:       VTK <vtkusers at vtk.org>, vtkusers-admin at vtk.org        
                      Sent by:                 Subject:  Re: [vtkusers] Point rendering : how to filter values 
                      vtkusers-admin at vt         with a vtkLookupTable                                          
                      k.org                                                                                    
                                                                                                               
                                                                                                               
                      05/02/2004 12:45                                                                         
                                                                                                               
                                                                                                               




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











More information about the vtkusers mailing list